justbytes._constants module

Constants used by the justbytes package.

Categories of constants:
  • Rounding methods
  • Size units, e.g., Ki, Mi
justbytes._constants.B = B

The universal unit, bytes.

class justbytes._constants.BinaryUnits

Bases: justbytes._constants.Units

Class to store binary unit constants.

EiB = EiB
FACTOR = 1024
GiB = GiB
KiB = KiB
MiB = MiB
PiB = PiB
TiB = TiB
YiB = YiB
ZiB = ZiB
class justbytes._constants.DecimalUnits

Bases: justbytes._constants.Units

Class to store decimal unit constants.

EB = EB
FACTOR = 1000
GB = GB
KB = kB
MB = MB
PB = PB
TB = TB
YB = YB
ZB = ZB
justbytes._constants.UNITS()

All unit constants.

class justbytes._constants.Unit(factor, prefix, abbr)

Bases: object

Class to encapsulate unit information.

abbr

abbreviation for unit, precedes ‘B’

factor

numeric multiple of bytes

prefix

prefix for ‘bytes’

class justbytes._constants.Units

Bases: object

Generic class for units.

FACTOR

A decorator indicating abstract properties.

Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract properties are overridden. The abstract properties can be called using any of the normal ‘super’ call mechanisms.

Usage:

class C:

__metaclass__ = ABCMeta @abstractproperty def my_abstract_property(self):

...

This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:

class C:
__metaclass__ = ABCMeta def getx(self): ... def setx(self, value): ... x = abstractproperty(getx, setx)
classmethod UNITS()

Units of this class.

classmethod max_exponent()

The maximum exponent for which there is a unit.

Returns:the maximum exponent
Return type:int
classmethod unit_for_exp(exponent)

Get the unit for the given exponent.

Parameters:exponent (int) – the exponent, 0 <= exponent < len(UNITS())

Previous topic

justbytes._config module

Next topic

justbytes._errors module

This Page