Class ByteQuantity
source code
object --+
|
ByteQuantity
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 originally wanted 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.
|
|
|
|
|
|
|
|
|
_setQuantity(self,
value)
Property target used to set the quantity The value must be
interpretable as a float if it is not None |
source code
|
|
|
_getQuantity(self)
Property target used to get the quantity. |
source code
|
|
|
|
|
_getUnits(self)
Property target used to get the units value. |
source code
|
|
|
_getBytes(self)
Property target used to return the byte quantity as a floating point
number. |
source code
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__setattr__ ,
__sizeof__ ,
__subclasshook__
|
|
quantity
Byte quantity, as a string
|
|
units
Units for byte quantity, for instance UNIT_BYTES
|
|
bytes
Byte quantity, as a floating point number.
|
Inherited from object :
__class__
|
__init__(self,
quantity=None,
units=None)
(Constructor)
| source code
|
Constructor for the ByteQuantity class.
- Parameters:
quantity - Quantity of bytes, something interpretable as a float
units - Unit of bytes, one of VALID_BYTE_UNITS
- Raises:
ValueError - If one of the values is invalid.
- Overrides:
object.__init__
|
Official string representation for class instance.
- Overrides:
object.__repr__
|
__str__(self)
(Informal representation operator)
| source code
|
Informal string representation for class instance.
- Overrides:
object.__str__
|
Definition of equals operator for this class. Lists within this class
are "unordered" for equality comparisons.
- Parameters:
other - Other object to compare to.
- Returns:
- -1/0/1 depending on whether self is
< ,
= or > other.
|
Property target used to set the quantity The value must be
interpretable as a float if it is not None
- Raises:
ValueError - If the value is an empty string.
ValueError - If the value is not a valid floating point number
ValueError - If the value is less than zero
|
Property target used to set the units value. If not None ,
the units value must be one of the values in VALID_BYTE_UNITS.
- Raises:
ValueError - If the value is not valid.
|
Property target used to return the byte quantity as a floating point
number. If there is no quantity set, then a value of 0.0 is returned.
|
quantity
Byte quantity, as a string
- Get Method:
- _getQuantity(self)
- Property target used to get the quantity.
- Set Method:
- _setQuantity(self,
value)
- Property target used to set the quantity The value must be
interpretable as a float if it is not None
|
units
Units for byte quantity, for instance UNIT_BYTES
- Get Method:
- _getUnits(self)
- Property target used to get the units value.
- Set Method:
- _setUnits(self,
value)
- Property target used to set the units value.
|
bytes
Byte quantity, as a floating point number.
- Get Method:
- _getBytes(self)
- Property target used to return the byte quantity as a floating point
number.
|