{ "info": { "author": "Tommy Yu", "author_email": "y@metatoaster.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Introduction\n============\n\nF3U1 - Factories and Functions for Fiddling with Units.\n\nBackstory\n---------\n\nOnce upon a time, the quest for a method to format seconds into a human\nreadable string was given to a hero. Braving through the nets of Inter,\nour hero stumbled upon place after places, such as State of Active, the\nExchange of Stacks, and even some other Hubs of Gits. Some giants were\nfound, like Tens of Tens Lines Long of Repetition, others were touching\nstrange, unrelated things and looking complicated. Those that spoke in\nother unworldly incantations were of no use. In the end, our hero gave\nup, and constructed this monstrosity from the corpses of fairies::\n\n def format_timedelta(delta_t):\n hours = delta_t.seconds / 3600\n days = delta_t.days\n seconds = delta_t.seconds\n\n # Don't ask. Read the test; be happy you don't have to write this.\n # (WTB something simple like str(delta_t) with more control.)\n # (Maybe I should just do this in javascript?)\n return '%(day)s%(hour)s' % {\n 'day': days and '%(days)d day%(dayp)s%(comma)s' % {\n 'days': days,\n 'dayp': days != 1 and 's' or '',\n 'comma': seconds > 3599 and ', ' or '',\n } or '',\n 'hour': (hours > 0 or days == 0 and hours == 0)\n and '%(hours)d hour%(hourp)s' % {\n 'hours': hours,\n 'hourp': hours != 1 and 's' or '',\n } or '',\n }\n\n(OOC: It was actually tested; see earliest commits).\n\nThen the realization hit our hero: sometimes a dworf want to micromanage\nthe resolution in minutes, and then the middle management dino will come\nback and stamp on all the things and make the resolution to be no lesser\nthan a weeks in the name of opsec. These arbitrary changes to this tiny\nsimple thing resulted in many gnashing of teeth and also many nightmares\nthat never seem to end. Many cries of F7U12 was thrown about.\n\nAfter countless nanoseconds of meditation, our hero destroyed 4 of those\nF's and 11 of those U's towards the direction of the unseen horizon, the\nsolution was discovered, and it is one that transcends beyond time.\n\nWhat?\n=====\n\nThis resulted in the creation of original F3U1 - Factory For Formatting\nUnits. Other descriptions used to fit, including Factory of Functions\nfor Formatting Units or Formatting Functions from Functions for Units.\nHowever, over time as this module matured, it really became Factories\nand Functions for Fiddling with Units.\n\nWhile this started as a module for formatting time into a human friendly\nstring, this got generalized to be able to format arbitrary units, such\nas non-metric measurements units, into a human readable string. Then\nthis got further generalized into being callable objects that can be\nused to construct an object representing some value and then be casted\ninto the same human readable string.\n\nHow?\n====\n\nJust install with pip in your virtualenv setup.\n\nAlternatively you may clone this repository for running the tests, which\nwill require some other dependencies which are specified inside the\nrequirements.txt::\n\n $ git clone git://github.com/metatoaster/mtj.f3u1.git\n $ cd mtj.f3u1\n $ pip install -r requirements.txt\n $ python setup.py develop\n\nExamples\n--------\n\nUsing a predefined unit::\n\n >>> from mtj.f3u1.units import Time\n >>> value = Time(second=90210)\n >>> print value\n 1 day, 1 hour, 3 minutes, 30 seconds\n\nOr create your own group of units::\n\n >>> from mtj.f3u1.factory import UnitGroup\n >>> Custom = UnitGroup(base_unit='one', ratios={\n ... 'thousand': 1000,\n ... 'hundred': 100,\n ... 'ten': 10,\n ... })\n >>> custom = Custom(thousand=2, hundred=5, one=621)\n >>> print custom\n 3 thousand, 1 hundred, 2 ten, 1 one\n\nResolution limitation can be done also::\n\n >>> value = Time('hour', second=99999)\n >>> print value\n 1 day, 3 hours\n\nConstruction of the value can use any key as part of the defined set of\nunits::\n\n >>> value = Time(hour=1, minute=99999)\n >>> print value\n 69 days, 11 hours, 39 minutes\n\nAny unit definitions can be respecified, along with their associated\nplural form::\n\n >>> TimeWithWeek = Time.respecify({'week': 604800},\n ... plurals={'week': 'weeks'})\n >>> value = TimeWithWeek(hour=1, minute=99999)\n >>> print value\n 9 weeks, 6 days, 11 hours, 39 minutes\n\nNote: currently the values are all limited to positive integers. This\nmay change to be more inclusive in the future. Maybe if I go insane I\nmight add a full blown units conversion and mathematics into here.\n\nChangelog\n=========\n\n0.2 - 2014-11-07\n----------------\n\n* Python 3 compatibility.\n* Allow specification of the divider between elements.\n\n0.1 - 2013-04-10\n----------------\n\n* Core functionality of formatting time into a human readable string is\n provided.\n* Other units are also provided, and new units can be constructed from\n a definition of ratios.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/metatoaster/mtj.f3u1", "keywords": "", "license": "GPL", "maintainer": null, "maintainer_email": null, "name": "mtj.f3u1", "package_url": "https://pypi.org/project/mtj.f3u1/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/mtj.f3u1/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/metatoaster/mtj.f3u1" }, "release_url": "https://pypi.org/project/mtj.f3u1/0.2/", "requires_dist": null, "requires_python": null, "summary": "Factories and Functions for Fiddling with Units", "version": "0.2" }, "last_serial": 1298184, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "bfa3b37572346b2493435654f7291fd2", "sha256": "757ccb79188312011c192622f14a843252ea1c7c380493a42c806008bf352c71" }, "downloads": -1, "filename": "mtj.f3u1-0.1.tar.gz", "has_sig": false, "md5_digest": "bfa3b37572346b2493435654f7291fd2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8674, "upload_time": "2013-04-10T14:33:21", "url": "https://files.pythonhosted.org/packages/6b/7e/6c61450d49a42d524f31eb8a3fe42823a1d97f395bf4b780ed5adb3f81f5/mtj.f3u1-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "e95c3d70e21ba32c5f455bc8db3e0402", "sha256": "5c951464ad9423c736cf6be7f1b73dc307245ec3157e4dfcbba1a5d47368f632" }, "downloads": -1, "filename": "mtj.f3u1-0.2.tar.gz", "has_sig": false, "md5_digest": "e95c3d70e21ba32c5f455bc8db3e0402", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9885, "upload_time": "2014-11-07T11:39:03", "url": "https://files.pythonhosted.org/packages/56/16/2ec2b87c8ce97eabc95f9b1d15580f775a7dccd00fbf14f4039abb1b9c01/mtj.f3u1-0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e95c3d70e21ba32c5f455bc8db3e0402", "sha256": "5c951464ad9423c736cf6be7f1b73dc307245ec3157e4dfcbba1a5d47368f632" }, "downloads": -1, "filename": "mtj.f3u1-0.2.tar.gz", "has_sig": false, "md5_digest": "e95c3d70e21ba32c5f455bc8db3e0402", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9885, "upload_time": "2014-11-07T11:39:03", "url": "https://files.pythonhosted.org/packages/56/16/2ec2b87c8ce97eabc95f9b1d15580f775a7dccd00fbf14f4039abb1b9c01/mtj.f3u1-0.2.tar.gz" } ] }