{ "info": { "author": "Dan Snider", "author_email": "dan.snider.cu@outlook.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries", "Topic :: Utilities" ], "description": "=========\nPublicize\n=========\nSet of utilities to help manage how modules are imported or exported\n\nWorks with both of the current major CPython versions, 2.7 and 3.7.\n\nDetailed error messages make finding name conflicts easy.\n\nSignificantly reduce boilerplate, especially using ``star_export``, ``star_import``, ``public_constants``, and ``import_from_object``.\n\nSimplifies dynamically reloading modules when source code has changed but restarting the interpreter is impossible or undesirable\n\n============\nInstallation\n============\n\n``$ pip install publicize``\n\n=========\nFunctions\n=========\n\n- ``import_as_copy(mod_or_name:[str, object]) -> module:``\n Import a shallow copy of `mod_or_name`\n\n- ``import_from_object(obj, overwrite=False) -> dict``\n Pretends `obj` is a module and imports its public attributes\n\n- ``public(*objects:[str, object], overwrite=False) -> objects[0]``\n Mark objects (or names) as public and automatically append them to ``__all__``.\n Can be used as a decorator with or without closing parentheses.\n\n There are 2 different ways to use it\\:\n \n - ``@public(overwrite=False) <- (with or without parentheses)``\n Simple decorator for functions/classes. Adds the wrapped object's \n ``__name__`` attribute to ``__all__``\n\n - ``public(name_or_object, *names_or_objects)``\n If an object is passed as an argument, all names that refer to that\n object will be added to ``__all__``. If a string is passed, the name \n will be added assuming the reference actually exists.\n \n- ``public constants(**constants) -> constants:``\n Define public global variables, adding their names to ``__all__``.\n\n- ``public_from_import(module:[str, ModuleType], *names, overwrite=False) -> {**imported}:``\n ``from module import names`` and add the imported names to ``__all__``.\n\n- ``publish_module(module:[str, ModuleType], overwrite=False) -> module:``\n Publish everything that would be gotten with ``from module import *``\n\n- ``reimport_module(module:[str, ModuleType]) -> module:``\n Clear a module's dict and reimport it.\n\n- ``reverse_star_import(module) -> None:``\n Removes what would be imported with ``from module import *``\n \n- ``safe_star_import(module) -> {**imported}:``\n ``from module import *`` that will not overwrite existing names\n\n- ``star_export(*private_modules, ignore_list=None, export_private=True, export_metadata=False, caller=None):``\n Force `exporter` (caller by default) to export almost everything\n \n- ``star_import(module:[str, ModuleType], overwrite=False, module=False, prefix=None, id_mod=None, ignore_private=False, import_metadata=False) -> [dict, {**imported}]:``\n Ignore default ``* import`` mechanics to import almost everything.\n\n If ``prefix`` is True, it will be prepended to imported names.\n \n If ``overwrite`` is False, an error is raised instead of overwriting.\n\n If ``ignore_private`` is True then _private names prepended with an\n underscore are ignored.\n\n If ``import_metadata`` is True, then module metadata attributes such as\n ``__author__`` and ``__version__`` are imported.\n\n If ``module`` is True, return the module itself, otherwise a dict\n mapping of imported:object names.\n \n Special attributes of modules such as ``__path__``, ``__file__``, and\n ``__all__`` are never imported.\n\n\n=============\nExample usage\n=============\n::\n\n # in colors.py\n from publicize import *\n public_from_import('enum', 'Enum')\n @public\n class Colors(Enum):\n RED = red = 'red'\n BLUE = blue = 'blue'\n GREEN = green = 'green'\n COLOR_LIST = [*Colors]\n COLOR_DICT=public_constants(**Colors.__members__)\n CHARTREUSE = GREEN\n CYAN = BLUE\n CARMINE = RED\n public(CHARTREUSE, CYAN, CARMINE)\n random = star_import('random', prefix='random_', module=True)\n\n def random_color():\n return random_choice(COLOR_LIST)\n \n def _get_valid_colors():\n return {k for k, v in globals().items() if isinstance(v, Colors)}\n\n``>>> from publicize import *``\n\n``>>> import colors``\n\n``>>> colors_namespace = star_import('colors')``\n\n``>>> colors.__all__``\n\n``['BLUE', 'CARMINE', 'CHARTREUSE', 'CYAN', 'Colors', 'Enum', 'GREEN', 'RED', 'blue', 'green', 'red']``\n\n``>>> CHARTREUSE``\n\n````\n\n``>>> COLOR_DICT['blue']``\n\n````\n\n``>>> old = CARMINE``\n\n``>>> reverse_star_import('colors')``\n\n``>>> reimport_module('colors').CARMINE is not old``\n\n``True``\n\n``>>> random_color()``\n\n````\n\n``>>> _get_colors()``\n\n``>>> {'BLUE', 'CHARTREUSE', 'GREEN', 'CARMINE', 'red', 'CYAN', 'green', 'blue', 'RED'}``", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/publicize/", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "publicize", "package_url": "https://pypi.org/project/publicize/", "platform": "", "project_url": "https://pypi.org/project/publicize/", "project_urls": { "Homepage": "http://pypi.python.org/pypi/publicize/" }, "release_url": "https://pypi.org/project/publicize/1.6.0/", "requires_dist": null, "requires_python": "", "summary": "Utilities to manage the way a module is exported", "version": "1.6.0" }, "last_serial": 4134869, "releases": { "1.3.0": [ { "comment_text": "", "digests": { "md5": "b08815780a6e98d318b4ae8cedc94444", "sha256": "32c52878011758d43dc8ea1ef8cc23fff8d1eece1b20b72944222a435400a55f" }, "downloads": -1, "filename": "publicize-1.3.0.tar.gz", "has_sig": false, "md5_digest": "b08815780a6e98d318b4ae8cedc94444", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8891, "upload_time": "2017-10-08T17:57:55", "url": "https://files.pythonhosted.org/packages/46/af/27103f8cd073e12d6eb2f30e71677a5297be2759e56e58d9999487e3a77e/publicize-1.3.0.tar.gz" } ], "1.5.0": [ { "comment_text": "", "digests": { "md5": "8af064357be8f263502a762b9264853f", "sha256": "57f2ab6b9ec60060b023a39ae3415d22d872b66ef10c2e3f20f6ed762145c15f" }, "downloads": -1, "filename": "publicize-1.5.0.tar.gz", "has_sig": false, "md5_digest": "8af064357be8f263502a762b9264853f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16255, "upload_time": "2018-07-31T00:28:08", "url": "https://files.pythonhosted.org/packages/6b/64/bec7916513319f14dc938e2b629d167b79e5e0c89705f5e2ac43e8fce034/publicize-1.5.0.tar.gz" } ], "1.6.0": [ { "comment_text": "", "digests": { "md5": "2195beee4024e89fe73d79a5c6745b52", "sha256": "514726c33c53fa92726402a231fe1485c8d7ce88e1a80fbbac3cd0cef3d7585d" }, "downloads": -1, "filename": "publicize-1.6.0.tar.gz", "has_sig": false, "md5_digest": "2195beee4024e89fe73d79a5c6745b52", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18322, "upload_time": "2018-08-04T04:56:19", "url": "https://files.pythonhosted.org/packages/89/83/1213255bacc00659e2cfc0faaf31bfc427cf99b608e6bfbfaabbfe344626/publicize-1.6.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2195beee4024e89fe73d79a5c6745b52", "sha256": "514726c33c53fa92726402a231fe1485c8d7ce88e1a80fbbac3cd0cef3d7585d" }, "downloads": -1, "filename": "publicize-1.6.0.tar.gz", "has_sig": false, "md5_digest": "2195beee4024e89fe73d79a5c6745b52", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18322, "upload_time": "2018-08-04T04:56:19", "url": "https://files.pythonhosted.org/packages/89/83/1213255bacc00659e2cfc0faaf31bfc427cf99b608e6bfbfaabbfe344626/publicize-1.6.0.tar.gz" } ] }