[PATCH 06/21] Fix subtraction for Size.
David Lehman
dlehman at redhat.com
Thu Aug 9 19:28:25 UTC 2012
---
pyanaconda/storage/size.py | 24 +++++++++++++-----------
1 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/pyanaconda/storage/size.py b/pyanaconda/storage/size.py
index eb3e2e4..75ea933 100644
--- a/pyanaconda/storage/size.py
+++ b/pyanaconda/storage/size.py
@@ -139,27 +139,29 @@ class Size(Decimal):
return self
- def __str__(self):
+ def __str__(self, context=None):
return self.humanReadable()
def __repr__(self):
return "Size('%s')" % self
- def __add__(self, other):
- return Size(bytes=Decimal.__add__(self, other))
+ def __add__(self, other, context=None):
+ return Size(bytes=Decimal.__add__(self, other, context=context))
# needed to make sum() work with Size arguments
- def __radd__(self, other):
- return Size(bytes=Decimal.__radd__(self, other))
+ def __radd__(self, other, context=None):
+ return Size(bytes=Decimal.__radd__(self, other, context=context))
- def __sub__(self, other):
- return Size(bytes=Decimal.__sub__(self, other))
+ def __sub__(self, other, context=None):
+ # subtraction is implemented using __add__ and negation, so we'll
+ # be getting passed a Size
+ return Decimal.__sub__(self, other, context=context)
- def __mul__(self, other):
- return Size(bytes=Decimal.__mul__(self, other))
+ def __mul__(self, other, context=None):
+ return Size(bytes=Decimal.__mul__(self, other, context=context))
- def __div__(self, other):
- return Size(bytes=Decimal.__div__(self, other))
+ def __div__(self, other, context=None):
+ return Size(bytes=Decimal.__div__(self, other, context=context))
def _trimEnd(self, val):
""" Internal method to trim trailing zeros. """
--
1.7.7.6
More information about the anaconda-patches
mailing list