Class representing a byte quantity.
A byte quantity has both a quantity and a byte-related unit. Units are
maintained using the constants from util.py.
The quantity is maintained internally as a string so that issues of
precision can be avoided. It really isn't possible to store a floating
point number here while being able to losslessly translate back and forth
between XML and object representations. (Perhaps the Python 2.4 Decimal
class would have been an option, but I want to stay compatible with
Python 2.3.)
Even though the quantity is maintained as a string, the string must be
in a valid floating point positive number. Technically, any floating
point string format supported by Python is allowble. However, it does not
make sense to have a negative quantity of bytes in this context.
Method Summary |
|
__init__ (self,
quantity,
units)
Constructor for the ByteQuantity class. |
|
__repr__ (self)
Official string representation for class instance. |
|
__str__ (self)
Informal string representation for class instance. |
|
__cmp__ (self,
other)
Definition of equals operator for this class. |
|
_getQuantity (self)
Property target used to get the quantity. |
|
_getUnits (self)
Property target used to get the units value. |
|
_setQuantity (self,
value)
Property target used to set the quantity The value must be a non-empty
string if it is not None . |
|
_setUnits (self,
value)
Property target used to set the units value. |
Inherited from object |
|
__delattr__ (...)
x.__delattr__('name') <==> del x.name |
|
__getattribute__ (...)
x.__getattribute__('name') <==> x.name |
|
__hash__ (x)
x.__hash__() <==> hash(x) |
|
__new__ (T,
S,
...)
T.__new__(S, ...) -> a new object with type S, a subtype of T |
|
__reduce__ (...)
helper for pickle |
|
__reduce_ex__ (...)
helper for pickle |
|
__setattr__ (...)
x.__setattr__('name', value) <==> x.name = value |