{ "info": { "author": "Tucker Beck", "author_email": "tucker.beck@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": ".. image:: https://badge.fury.io/py/report-on-interval.svg\n :target: https://badge.fury.io/py/report-on-interval\n :alt: Latest Published Version\n\n.. image:: https://travis-ci.org/dusktreader/report-on-interval.svg?branch=master\n :target: https://travis-ci.org/dusktreader/report-on-interval\n :alt: Build Status\n\n********************\n report-on-interval\n********************\n\n---------------------------------------------------------\nPrint out regular status reports while looping over items\n---------------------------------------------------------\n\nThis package provides a function that simply prints out information about the\nprogress of a loop that iterates over an iterable. So, say you have a 10k\nelements that you are iterating over and each one takes a second. Wouldn't it\nbe nice to get a little output after every 1% of the items are processed?\n\nWith report-on-interval, it's as easy as this:\n\n.. code-block:: python:\n\n from report_on_interval import report_on_interval\n\n for item in report_on_interval(lots_of_items):\n do_something_with_item(item)\n\nOutput would look like this::\n\n processed 100 of 10000 items\n processed 200 of 10000 items\n processed 300 of 10000 items\n processed 400 of 10000 items\n ...\n processed 10000 of 10000 items\n\n\nSuper-quick Start\n-----------------\n - requirements: `python` versions 3.4+\n - install through pip: `$ pip install report-on-interval`\n\nAdditional Options\n------------------\n\nThe ``report_on_interval`` function has some additional arguments that may be\nuseful:\n\n* ``message``\n\n Supply your own message for the report:\n\n .. code-block:: python:\n\n for bug in report_on_interval(\n bug_generator,\n message='{i}/{n} little buggers squished',\n ):\n squash_bug(bug)\n\n* ``item_count``\n\n If you are looping over an iterator that produces items programatically, you\n absolutely should provide this if you know the total number of items.\n Otherwise, ``report_on_interval`` will convert the iterable to a list, and,\n poof!, the benefits of programatically producing items disapears. A great\n example of this is iterating over the results from a SQLAlchemy query:\n\n .. code-block:: python:\n\n query = session.query(MyModel).filter(MyModel.column > 0)\n for row in report_on_interval(\n query,\n item_count=query.count(),\n ):\n process_row(row)\n\n* ``printer``\n\n Supply a different printer than the default of printing to standard out. This\n is often an application logger:\n\n .. code-block:: python:\n\n from my_app.logging import logger\n for cheese in report_on_interval(cheese_shop, printer=logger):\n request_cheese(cheese)\n\n* ``get_deltas``\n\n Provide your own method for computing the reporting interval. By default,\n the ``compute_reporting_interval`` method is used. This method prints\n after every 1% is processed for iterables with over 100k items, after every\n 10% for iterables over 30 items, and after every item for anything else\n\n .. code-block:: python:\n\n def deltafier(n):\n return n // 7\n for marble in report_on_interval(bag, get_deltas=deltafier):\n shoot(marble)\n\n* ``report_at_end``\n\n Print the progress report after the last item is processed. Maybe you want\n a report when your loop is done because you don't report it yourself. There's\n no accounting for tastes...\n\n* ``extra_actions``\n\n Provide a list of additional tasks to perform on each reporting interval.\n One use for this is to regularly flush updates out to your database on the\n interval as well as reporting progress\n\n .. code-block:: python:\n\n for new_thingie in report_on_interval(\n produce_new_thingies,\n item_count=thingie_total,\n extra_actions=[lambda: session.flush()],\n ):\n thingie.update(doodad=None)\n\n* ``extras_at_end``\n\n Also perform the extra actions after finishing the loop. Note that like the\n ``report_at_end`` argument, if the count of items in the iterable is an exact\n multiple of the reporting interval, this will not result in an extra report\n and running the extras a second time. The logic in ``report_on_interval``\n makes sure of that\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/dusktreader/report-on-interval", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "report-on-interval", "package_url": "https://pypi.org/project/report-on-interval/", "platform": "", "project_url": "https://pypi.org/project/report-on-interval/", "project_urls": { "Homepage": "https://github.com/dusktreader/report-on-interval" }, "release_url": "https://pypi.org/project/report-on-interval/0.1.0/", "requires_dist": null, "requires_python": "", "summary": "Print out regular status reports while looping over items", "version": "0.1.0" }, "last_serial": 4047856, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "7cf151abd8e0f0db45cc302aa4d8ae62", "sha256": "cc3a8a61b1714ef1feabd36f572004a37c12f1bb6a44c01ac228e3c195ccfb9f" }, "downloads": -1, "filename": "report_on_interval-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "7cf151abd8e0f0db45cc302aa4d8ae62", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 4917, "upload_time": "2018-07-10T16:29:38", "url": "https://files.pythonhosted.org/packages/67/e6/9cef8c8dacd2edc9e3f0c11bafb8c0db88f824ef65c5390d97450f45b232/report_on_interval-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ebe5430b1baa24e54a99aa976f53b1d9", "sha256": "32885e1dc7fef832e40a7d7410d4ca4b0639ec06e236a95bec7516596eb17130" }, "downloads": -1, "filename": "report-on-interval-0.1.0.tar.gz", "has_sig": false, "md5_digest": "ebe5430b1baa24e54a99aa976f53b1d9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4821, "upload_time": "2018-07-10T16:29:37", "url": "https://files.pythonhosted.org/packages/99/cf/9b5fcd9928e6242df5c0e3d324b22f6e9355ba749d8dfc8df67e9719e70a/report-on-interval-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7cf151abd8e0f0db45cc302aa4d8ae62", "sha256": "cc3a8a61b1714ef1feabd36f572004a37c12f1bb6a44c01ac228e3c195ccfb9f" }, "downloads": -1, "filename": "report_on_interval-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "7cf151abd8e0f0db45cc302aa4d8ae62", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 4917, "upload_time": "2018-07-10T16:29:38", "url": "https://files.pythonhosted.org/packages/67/e6/9cef8c8dacd2edc9e3f0c11bafb8c0db88f824ef65c5390d97450f45b232/report_on_interval-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ebe5430b1baa24e54a99aa976f53b1d9", "sha256": "32885e1dc7fef832e40a7d7410d4ca4b0639ec06e236a95bec7516596eb17130" }, "downloads": -1, "filename": "report-on-interval-0.1.0.tar.gz", "has_sig": false, "md5_digest": "ebe5430b1baa24e54a99aa976f53b1d9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4821, "upload_time": "2018-07-10T16:29:37", "url": "https://files.pythonhosted.org/packages/99/cf/9b5fcd9928e6242df5c0e3d324b22f6e9355ba749d8dfc8df67e9719e70a/report-on-interval-0.1.0.tar.gz" } ] }