{ "info": { "author": "Jon Parise", "author_email": "jon@indelible.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "Python Module Reloader\n======================\n\n.. image:: https://secure.travis-ci.org/jparise/python-reloader.png?branch=master\n :target: http://travis-ci.org/jparise/python-reloader\n\nThis library implements a dependency-based module reloader for Python. Unlike\nthe builtin `reload()`_ function, this reloader will reload the requested\nmodule *and all other modules that are dependent on that module*.\n\nA detailed discussion of the reloader's implementation is available here:\n\n http://www.indelible.org/ink/python-reloading/\n\nUsage\n-----\n\nThe reloader works by tracking dependencies between imported modules. It must\nfirst be enabled in order to track those dependencies. The reloader has no\ndependency information for modules that were imported before it was enabled or\nafter it is disabled, so you'll probably want to enable the reloader early in\nyour application's startup process.\n\n::\n\n import reloader\n reloader.enable()\n\n # Import additional modules\n import module1\n import module2\n\nTo manually reload an imported module, pass it to the reloader's ``reload()``\nmethod::\n\n import example\n reloader.reload(example)\n\nNote that you must pass the module object itself and not a string containing\nthe module's name. If you only have the module's name, you can fetch the\nmodule object from the global ``sys.modules`` dictionary::\n\n reloader.reload(sys.modules['example'])\n\nYou can also query a module's dependencies for informational or debugging\npurposes::\n\n reloader.get_dependencies(example)\n\nYou can disable the reloader's dependency tracking at any time::\n\n reloader.disable()\n\nBlacklisting Modules\n--------------------\n\nThere may be times when you don't want a module and its dependency hierarchy\nto be reloaded. The module might rarely change and be expensive to import.\nTo support these cases, you can explicitly \"blacklist\" modules from the\nreloading process using the ``blacklist`` argument to ``enable()``.\n\n::\n\n reloader.enable(blacklist=['os', 'ConfigParser'])\n\nThe blacklist can be any iterable listing the fully-qualified names of modules\nthat should be ignored. Note that blacklisted modules will still appear in\nthe dependency graph for completeness; they will just not be reloaded.\n\nAn Interactive Example\n----------------------\n\nThis example demonstrates how easily the reloader can be used from the\ninteractive Python interpretter. Imagine you have the module ``example.py``\nopen in a text editor, and it contains the following::\n\n print \"I am example.py\"\n\nOur interactive session starts like this::\n\n >>> import reloader\n >>> reloader.enable()\n >>> import example\n I am example.py\n\nNow modify ``example.py`` in your text editor. You can then reload the\n``example`` in your interactive session::\n\n >>> reloader.reload(example)\n I am the modified example.py\n\nThis is a simplistic example that doesn't fully demonstrate the power of the\nreloader's dependency-based module tracking, but it hopefully illustrates the\nbasic usage and utility of the system.\n\nThe __reload__() Callback\n-------------------------\n\nIf a module has a ``__reload__()`` function, it will be called with a copy of\nthe original module's dictionary after it has been reloaded. This provides a\nconvenient mechanism for preserving state between reloads.\n\nConsider a module named ``counts`` that contains the following code::\n\n COUNTER = 0\n\nThe module's ``COUNTER`` variable will be reset to 0 when the module is\nreloaded::\n\n >>> import counts\n >>> counts.COUNTER += 1\n >>> counts.COUNTER\n 1\n >>> reloader.reload(counts)\n >>> counts.COUNTER += 1\n 1\n\nWe can preserve the value of ``COUNTER`` across reloads by adding a\n``__reload__()`` function to the ``counts`` module::\n\n def __reload__(state):\n global COUNTER\n COUNTER = state['COUNTER']\n\nNow when we reload ``counts``::\n\n >>> import counts\n >>> counts.COUNTER += 1\n >>> counts.COUNTER\n 1\n >>> reloader.reload(counts)\n >>> counts.COUNTER += 1\n >>> counts.COUNTER\n 2\n\n.. _`reload()`: http://docs.python.org/library/functions.html#reload\n", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/jparise/python-reloader/tarball/0.6", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jparise/python-reloader", "keywords": null, "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "reloader", "package_url": "https://pypi.org/project/reloader/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/reloader/", "project_urls": { "Download": "https://github.com/jparise/python-reloader/tarball/0.6", "Homepage": "https://github.com/jparise/python-reloader" }, "release_url": "https://pypi.org/project/reloader/0.6/", "requires_dist": null, "requires_python": null, "summary": "Dependency-based Python module reloader", "version": "0.6" }, "last_serial": 1395257, "releases": { "0.2": [ { "comment_text": "", "digests": { "md5": "21d35fe384107e3db4a588b1c7b1ac6d", "sha256": "9d128dc7a0f252019bba5deaba9e79564cd7e2f4883efd5509f24d8678017563" }, "downloads": -1, "filename": "reloader-0.2.tar.gz", "has_sig": false, "md5_digest": "21d35fe384107e3db4a588b1c7b1ac6d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2881, "upload_time": "2011-11-22T22:41:27", "url": "https://files.pythonhosted.org/packages/b7/d5/71174b7697fd65055b4b3a0251ed09b8983c5e7f4d3e67ffec272c6d3855/reloader-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "1424d69bb04f3fc335596efdabc75a85", "sha256": "c2b6e9201ac3cef2dce603473b3f1a07c0882aa670bf96c80b6a5f2fbdc01126" }, "downloads": -1, "filename": "reloader-0.3.tar.gz", "has_sig": false, "md5_digest": "1424d69bb04f3fc335596efdabc75a85", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2882, "upload_time": "2012-05-01T07:31:42", "url": "https://files.pythonhosted.org/packages/69/04/e10faf7c023c6d33ae2d0138ebf5ef25864e5ef9d834ba9eb7d70619f639/reloader-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "1f721fc0de1b7d49ecc20a7258717a15", "sha256": "ed90ea316505010f5c59df49a775f581dab33d03586aad4c9d7ef2d2e650221b" }, "downloads": -1, "filename": "reloader-0.4.tar.gz", "has_sig": false, "md5_digest": "1f721fc0de1b7d49ecc20a7258717a15", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5072, "upload_time": "2014-01-09T05:01:23", "url": "https://files.pythonhosted.org/packages/d7/7e/76094258f561b8dc50bbb4c6ca880ba01724d8dd38bd7948315358574cb8/reloader-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "be3a2d3a913274b4baa97a721f70dafe", "sha256": "012b1308132dbaa79a12fdbaf5c278478a66a6c4738e0a0c4be1d35ec57fd899" }, "downloads": -1, "filename": "reloader-0.5.tar.gz", "has_sig": false, "md5_digest": "be3a2d3a913274b4baa97a721f70dafe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5099, "upload_time": "2014-01-12T17:42:11", "url": "https://files.pythonhosted.org/packages/7f/09/3f5f743ca871254746f2251e7a9ffad74197934b1b43276d34be489119e1/reloader-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "6709441b2dd9a4d22ef13b21d17a72fa", "sha256": "2bca19c2450bcac75110ae2b0d8c5f7bb2c11dd05e163fb8e121f6c1130fd922" }, "downloads": -1, "filename": "reloader-0.6.tar.gz", "has_sig": false, "md5_digest": "6709441b2dd9a4d22ef13b21d17a72fa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5202, "upload_time": "2015-01-25T00:49:12", "url": "https://files.pythonhosted.org/packages/64/19/12089757f2f50f3aa81e05cf07089e3e82f260260362d4d9da6c8cf43f90/reloader-0.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6709441b2dd9a4d22ef13b21d17a72fa", "sha256": "2bca19c2450bcac75110ae2b0d8c5f7bb2c11dd05e163fb8e121f6c1130fd922" }, "downloads": -1, "filename": "reloader-0.6.tar.gz", "has_sig": false, "md5_digest": "6709441b2dd9a4d22ef13b21d17a72fa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5202, "upload_time": "2015-01-25T00:49:12", "url": "https://files.pythonhosted.org/packages/64/19/12089757f2f50f3aa81e05cf07089e3e82f260260362d4d9da6c8cf43f90/reloader-0.6.tar.gz" } ] }