zope.size API

Interfaces

Interfaces that give the size of an object.

interface zope.size.interfaces.ISized[source]

An object that is sized in some unit.

Basic units:

  • ‘byte’
  • ‘item’ for example, number of subobjects for a folder
  • None for unsized things
  • ‘line’ for source-code like things
sizeForDisplay()

Returns a string giving the size. The output string may be a zope.i18nmessageid.message.Message with an embedded mapping, so it should be translated with zope.i18n.translate()

sizeForSorting()

Returns a tuple (basic_unit, amount)

Used for sorting among different kinds of sized objects. ‘amount’ need only be sortable among things that share the same basic unit.

Implementations

Adapters that give the size of an object.

class zope.size.DefaultSized(obj)[source]

Bases: object

A default zope.size.interfaces.ISized adapter producing bytes for any object that has a getSize method and (None, None) for all other objects.

sizeForDisplay()[source]

See ISized

sizeForSorting()[source]

See ISized

zope.size.byteDisplay(size)[source]

Returns a size with the correct unit (KB, MB), given the size in bytes. The output should be given to zope.i18n.translate()