hurry.filesize-0.9/0000755000175000017500000000000011156034006014162 5ustar faassenfaassenhurry.filesize-0.9/src/0000755000175000017500000000000011156034006014751 5ustar faassenfaassenhurry.filesize-0.9/src/hurry/0000755000175000017500000000000011156034006016122 5ustar faassenfaassenhurry.filesize-0.9/src/hurry/filesize/0000755000175000017500000000000011156034006017734 5ustar faassenfaassenhurry.filesize-0.9/src/hurry/filesize/README.txt0000644000175000017500000000213111156033711021431 0ustar faassenfaassenhurry.filesize ============== hurry.filesize a simple Python library that can take a number of bytes and returns a human-readable string with the size in it, in kilobytes (K), megabytes (M), etc. The default system it uses is "traditional", where multipliers of 1024 increase the unit size:: >>> from hurry.filesize import size >>> size(1024) '1K' An alternative, slightly more verbose system:: >>> from hurry.filesize import alternative >>> size(1, system=alternative) '1 byte' >>> size(10, system=alternative) '10 bytes' >>> size(1024, system=alternative) '1 KB' A verbose system:: >>> from hurry.filesize import verbose >>> size(10, system=verbose) '10 bytes' >>> size(1024, system=verbose) '1 kilobyte' >>> size(2000, system=verbose) '1 kilobyte' >>> size(3000, system=verbose) '2 kilobytes' >>> size(1024 * 1024, system=verbose) '1 megabyte' >>> size(1024 * 1024 * 3, system=verbose) '3 megabytes' You can also use the SI system, where multipliers of 1000 increase the unit size:: >>> from hurry.filesize import si >>> size(1000, system=si) '1K' hurry.filesize-0.9/src/hurry/filesize/__init__.py0000644000175000017500000000017211156033711022047 0ustar faassenfaassenfrom hurry.filesize.filesize import size from hurry.filesize.filesize import traditional, alternative, verbose, iec, si hurry.filesize-0.9/src/hurry/filesize/filesize.py0000644000175000017500000000416611156033711022131 0ustar faassenfaassen traditional = [ (1024 ** 5, 'P'), (1024 ** 4, 'T'), (1024 ** 3, 'G'), (1024 ** 2, 'M'), (1024 ** 1, 'K'), (1024 ** 0, 'B'), ] alternative = [ (1024 ** 5, ' PB'), (1024 ** 4, ' TB'), (1024 ** 3, ' GB'), (1024 ** 2, ' MB'), (1024 ** 1, ' KB'), (1024 ** 0, (' byte', ' bytes')), ] verbose = [ (1024 ** 5, (' petabyte', ' petabytes')), (1024 ** 4, (' terabyte', ' terabytes')), (1024 ** 3, (' gigabyte', ' gigabytes')), (1024 ** 2, (' megabyte', ' megabytes')), (1024 ** 1, (' kilobyte', ' kilobytes')), (1024 ** 0, (' byte', ' bytes')), ] iec = [ (1024 ** 5, 'Pi'), (1024 ** 4, 'Ti'), (1024 ** 3, 'Gi'), (1024 ** 2, 'Mi'), (1024 ** 1, 'Ki'), (1024 ** 0, ''), ] si = [ (1000 ** 5, 'P'), (1000 ** 4, 'T'), (1000 ** 3, 'G'), (1000 ** 2, 'M'), (1000 ** 1, 'K'), (1000 ** 0, 'B'), ] def size(bytes, system=traditional): """Human-readable file size. Using the traditional system, where a factor of 1024 is used:: >>> size(10) '10B' >>> size(100) '100B' >>> size(1000) '1000B' >>> size(2000) '1K' >>> size(10000) '9K' >>> size(20000) '19K' >>> size(100000) '97K' >>> size(200000) '195K' >>> size(1000000) '976K' >>> size(2000000) '1M' Using the SI system, with a factor 1000:: >>> size(10, system=si) '10B' >>> size(100, system=si) '100B' >>> size(1000, system=si) '1K' >>> size(2000, system=si) '2K' >>> size(10000, system=si) '10K' >>> size(20000, system=si) '20K' >>> size(100000, system=si) '100K' >>> size(200000, system=si) '200K' >>> size(1000000, system=si) '1M' >>> size(2000000, system=si) '2M' """ for factor, suffix in system: if bytes >= factor: break amount = int(bytes/factor) if isinstance(suffix, tuple): singular, multiple = suffix if amount == 1: suffix = singular else: suffix = multiple return str(amount) + suffix hurry.filesize-0.9/src/hurry/filesize/tests.py0000644000175000017500000000030411156033711021447 0ustar faassenfaassenimport unittest, doctest def test_suite(): return unittest.TestSuite(( doctest.DocFileSuite('README.txt'), doctest.DocTestSuite('hurry.filesize.filesize'), )) hurry.filesize-0.9/src/hurry/__init__.py0000644000175000017500000000031011156033711020227 0ustar faassenfaassen# this is a namespace package try: import pkg_resources pkg_resources.declare_namespace(__name__) except ImportError: import pkgutil __path__ = pkgutil.extend_path(__path__, __name__) hurry.filesize-0.9/src/hurry.filesize.egg-info/0000755000175000017500000000000011156034006021425 5ustar faassenfaassenhurry.filesize-0.9/src/hurry.filesize.egg-info/PKG-INFO0000644000175000017500000000400711156034005022522 0ustar faassenfaassenMetadata-Version: 1.0 Name: hurry.filesize Version: 0.9 Summary: A simple Python library for human readable file sizes (or anything sized in bytes). Home-page: UNKNOWN Author: Martijn Faassen, Startifact Author-email: faassen@startifact.com License: ZPL 2.1 Description: hurry.filesize ============== hurry.filesize a simple Python library that can take a number of bytes and returns a human-readable string with the size in it, in kilobytes (K), megabytes (M), etc. The default system it uses is "traditional", where multipliers of 1024 increase the unit size:: >>> from hurry.filesize import size >>> size(1024) '1K' An alternative, slightly more verbose system:: >>> from hurry.filesize import alternative >>> size(1, system=alternative) '1 byte' >>> size(10, system=alternative) '10 bytes' >>> size(1024, system=alternative) '1 KB' A verbose system:: >>> from hurry.filesize import verbose >>> size(10, system=verbose) '10 bytes' >>> size(1024, system=verbose) '1 kilobyte' >>> size(2000, system=verbose) '1 kilobyte' >>> size(3000, system=verbose) '2 kilobytes' >>> size(1024 * 1024, system=verbose) '1 megabyte' >>> size(1024 * 1024 * 3, system=verbose) '3 megabytes' You can also use the SI system, where multipliers of 1000 increase the unit size:: >>> from hurry.filesize import si >>> size(1000, system=si) '1K' Changes ======= 0.9 (2009-03-11) ---------------- * Initial public release. Download ======== Keywords: file size bytes Platform: UNKNOWN Classifier: Programming Language :: Python Classifier: Topic :: Software Development :: Libraries :: Python Modules hurry.filesize-0.9/src/hurry.filesize.egg-info/SOURCES.txt0000644000175000017500000000073411156034005023314 0ustar faassenfaassenCHANGES.txt buildout.cfg setup.py src/hurry/__init__.py src/hurry.filesize.egg-info/PKG-INFO src/hurry.filesize.egg-info/SOURCES.txt src/hurry.filesize.egg-info/dependency_links.txt src/hurry.filesize.egg-info/namespace_packages.txt src/hurry.filesize.egg-info/not-zip-safe src/hurry.filesize.egg-info/requires.txt src/hurry.filesize.egg-info/top_level.txt src/hurry/filesize/README.txt src/hurry/filesize/__init__.py src/hurry/filesize/filesize.py src/hurry/filesize/tests.pyhurry.filesize-0.9/src/hurry.filesize.egg-info/dependency_links.txt0000644000175000017500000000000111156034005025472 0ustar faassenfaassen hurry.filesize-0.9/src/hurry.filesize.egg-info/namespace_packages.txt0000644000175000017500000000000611156034005025753 0ustar faassenfaassenhurry hurry.filesize-0.9/src/hurry.filesize.egg-info/not-zip-safe0000644000175000017500000000000111156034005023652 0ustar faassenfaassen hurry.filesize-0.9/src/hurry.filesize.egg-info/requires.txt0000644000175000017500000000001211156034005024015 0ustar faassenfaassensetuptoolshurry.filesize-0.9/src/hurry.filesize.egg-info/top_level.txt0000644000175000017500000000000611156034005024152 0ustar faassenfaassenhurry hurry.filesize-0.9/CHANGES.txt0000644000175000017500000000011611156033727016002 0ustar faassenfaassenChanges ======= 0.9 (2009-03-11) ---------------- * Initial public release. hurry.filesize-0.9/buildout.cfg0000644000175000017500000000024211156033711016472 0ustar faassenfaassen[buildout] develop = . parts = test newest = false [test] recipe = zc.recipe.testrunner eggs = hurry.filesize defaults = ['--tests-pattern', '^f?tests$', '-v'] hurry.filesize-0.9/setup.py0000644000175000017500000000176611156033767015723 0ustar faassenfaassenfrom setuptools import setup, find_packages import os def read(*rnames): return open(os.path.join(os.path.dirname(__file__), *rnames)).read() long_description = ( read('src', 'hurry', 'filesize', 'README.txt') + '\n' + read('CHANGES.txt') + '\n' + 'Download\n' '========\n' ) setup( name="hurry.filesize", version="0.9", description="A simple Python library for human readable file sizes (or anything sized in bytes).", long_description=long_description, classifiers=[ "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules", ], keywords='file size bytes', author='Martijn Faassen, Startifact', author_email='faassen@startifact.com', url='', license='ZPL 2.1', packages=find_packages('src'), package_dir= {'':'src'}, namespace_packages=['hurry'], include_package_data=True, zip_safe=False, install_requires=[ 'setuptools', ], ) hurry.filesize-0.9/PKG-INFO0000644000175000017500000000400711156034006015260 0ustar faassenfaassenMetadata-Version: 1.0 Name: hurry.filesize Version: 0.9 Summary: A simple Python library for human readable file sizes (or anything sized in bytes). Home-page: UNKNOWN Author: Martijn Faassen, Startifact Author-email: faassen@startifact.com License: ZPL 2.1 Description: hurry.filesize ============== hurry.filesize a simple Python library that can take a number of bytes and returns a human-readable string with the size in it, in kilobytes (K), megabytes (M), etc. The default system it uses is "traditional", where multipliers of 1024 increase the unit size:: >>> from hurry.filesize import size >>> size(1024) '1K' An alternative, slightly more verbose system:: >>> from hurry.filesize import alternative >>> size(1, system=alternative) '1 byte' >>> size(10, system=alternative) '10 bytes' >>> size(1024, system=alternative) '1 KB' A verbose system:: >>> from hurry.filesize import verbose >>> size(10, system=verbose) '10 bytes' >>> size(1024, system=verbose) '1 kilobyte' >>> size(2000, system=verbose) '1 kilobyte' >>> size(3000, system=verbose) '2 kilobytes' >>> size(1024 * 1024, system=verbose) '1 megabyte' >>> size(1024 * 1024 * 3, system=verbose) '3 megabytes' You can also use the SI system, where multipliers of 1000 increase the unit size:: >>> from hurry.filesize import si >>> size(1000, system=si) '1K' Changes ======= 0.9 (2009-03-11) ---------------- * Initial public release. Download ======== Keywords: file size bytes Platform: UNKNOWN Classifier: Programming Language :: Python Classifier: Topic :: Software Development :: Libraries :: Python Modules hurry.filesize-0.9/setup.cfg0000644000175000017500000000007311156034006016003 0ustar faassenfaassen[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0