Package CedarBackup2 :: Package extend :: Module split :: Class ByteQuantity
[show private | hide private]
[frames | no frames]

Type ByteQuantity

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 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

Property Summary
  quantity: Byte quantity, as a string
  units: Units for byte quantity, for instance UNIT_BYTES

Method Details

__init__(self, quantity=None, units=None)
(Constructor)

Constructor for the ByteQuantity class.
Parameters:
quantity - Quantity of bytes, as string ("1.25")
units - Unit of bytes, one of VALID_BYTE_UNITS
Raises:
ValueError - If one of the values is invalid.
Overrides:
__builtin__.object.__init__

__repr__(self)
(Representation operator)

Official string representation for class instance.
Overrides:
__builtin__.object.__repr__

__str__(self)
(Informal representation operator)

Informal string representation for class instance.
Overrides:
__builtin__.object.__str__

__cmp__(self, other)
(Comparison operator)

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.

_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.
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

_setUnits(self, value)

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 Details

quantity

Byte quantity, as a string
Get Method:
_getQuantity(self)
Set Method:
_setQuantity(self, value)

units

Units for byte quantity, for instance UNIT_BYTES
Get Method:
_getUnits(self)
Set Method:
_setUnits(self, value)

Generated by Epydoc 2.1 on Thu Mar 29 20:58:28 2007 http://epydoc.sf.net