Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

This module manages sizes as they are reported by various UNIX commands.

Project Description

This module manages sizes of devices like files, block devices or system memory, as they are reported by various UNIX commands. It can be useful for people who often parse command outputs, log file, etc, looking for sizes in various units and formats to compare and compute them, then print results in a homogeneous way.

>>> from Size import mkSize
>>> a = mkSize('20 Gb')         # Default unit is 'm'
>>> b = mkSize('0.1T', 'k')     # Size in kilobytes from string in Tera
>>> a, b
(20480.0, 107374182.40000001)   # a and b are float
>>> a(), b()                    # sizes are callable
('20480 Mb', '107374182 Kb')    # Results in human readable string
>>> c = b - a                   # Sizes may be added or substracted
>>> d = a * 3                   # or divided or multiplied
>>> d.g('%dMBytes')             # Sizes may be converted in differents units
'60GBytes'                      # and printed with differents formats
>>> b.smartprint(6)             # Size may be printed with the smallest unit
'102 Gb'                        # that fills a given length
>>> b.smartprint(10)            #
'104857 Mb'
Release History

Release History

This version
History Node

0.1

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting