{ "info": { "author": "Quentin Stafford-Fraser", "author_email": "quentin@pobox.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python :: 2" ], "description": "# Dewildcard\n\nA not-very-sophisticated script to replace Python wildcard import statements.\n\n## Background\n\nIn Python, wildcard import statements, such as:\n\n from foo import *\n from bar import *\n\ncan be very convenient, but are now usually considered bad practice. If, later in your code, you encounter a symbol you don't recognise, how do you know whether it came from *foo* or *bar*? And if you install an updated version of *bar*, it may define a new name that clashes with one in *foo* that you were using in your code.\n\nIt's much better, therefore, to say:\n\n from foo import item1, item2\n from bar import item3, item4, item5\n\neven though it's more verbose. \n\nTools like *pylint* of *pyflakes* can also let you know if you can safely delete, say, 'item5', because it isn't used in your code. If you have a good text editor, it may have a plugin which can highlight this fact.\n\nThis little script reads some python code on stdin and, when it finds a wildcard import statement, does the import and replaces the line with a full multi-line import statement:\n\n from bar import (item3,\n item4,\n item5,\n item6)\n\nYou can then easily go through and delete any items that pylint tells you aren't needed.\n\nIf you prefer a single (possibly long) import line, you can use the `--single-line` option.\nOne advantage is that some tools such as autoflake and autopep8 handle this format better.\n\nThe parentheses are there to allow it to span multiple lines, but it shouldn't be too difficult to change the code to make it a single line or to use backslashes for line continuation if you prefer that.\n\nNOTE: This has many limitations, the main one being that dewildcard must actually *perform* the imports in order to extract the symbol names, so you must run this in an environment where the appropriate modules exist, are on the Python path, and can be imported without unfortunate side-effects.\n\n\n## Installation\n\n pip install dewildcard\n\nNote that dewildcard makes use of importlib, so Python 2.7 or later will be needed.\n\n## Example usage\n\n dewildcard my_code.py\n\nThis outputs the modified file to stdout. If you wish to modify it in place, add a `-w` option:\n\n dewildcard -w my_code.py\n\n## Acknowledgements\n\nDewildcard is based on an initial idea from Alexandre Fayolle - thanks, Alexandre!\n\nOther contributors include Jan Biero\u0144 and Jakub Wilk - thanks!\n\n## To Do\n\nLots of room for improvements here, including:\n\n* Options to change the output format\n\n## Licence\n\nSuch a simple script is barely worth a licence, but, for what it's worth, it's released under GNU General Public Licence v2. Use at your own risk, etc.\n\n(c) 2015 Quentin Stafford-Fraser\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/quentinsf/dewildcard/tarball/0.2", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/quentinsf/dewildcard", "keywords": "pylint", "license": "", "maintainer": "", "maintainer_email": "", "name": "dewildcard", "package_url": "https://pypi.org/project/dewildcard/", "platform": "", "project_url": "https://pypi.org/project/dewildcard/", "project_urls": { "Download": "https://github.com/quentinsf/dewildcard/tarball/0.2", "Homepage": "http://github.com/quentinsf/dewildcard" }, "release_url": "https://pypi.org/project/dewildcard/0.2.1/", "requires_dist": null, "requires_python": "", "summary": "Expand wildcard imports in Python code", "version": "0.2.1" }, "last_serial": 4222165, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "b6a9b0e1aec3429e9d727c5b28333937", "sha256": "e2031395c3980768503ae8fc25f77ddbccaccc123d0947ca27d9ff0995e0fcfa" }, "downloads": -1, "filename": "dewildcard-0.1.tar.gz", "has_sig": false, "md5_digest": "b6a9b0e1aec3429e9d727c5b28333937", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1390, "upload_time": "2015-08-26T16:11:02", "url": "https://files.pythonhosted.org/packages/30/7c/e3e4aa2a2a29d1cd87958be8432aad7a7c2294a0cffb90319b7691960f4b/dewildcard-0.1.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "2093bef1043545534a6eb93f0c12f864", "sha256": "ea4bb9a7a186c7ff11a4de972afb92920c6fbd8918de0165b1a4d32382997c0d" }, "downloads": -1, "filename": "dewildcard-0.2.1-py2-none-any.whl", "has_sig": false, "md5_digest": "2093bef1043545534a6eb93f0c12f864", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 3745, "upload_time": "2018-08-30T11:03:18", "url": "https://files.pythonhosted.org/packages/e1/b8/2f3fbef31359f8fd68b0e22ad64c4c289118c4b59a65d9ce18d4708cc571/dewildcard-0.2.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cc24b23a444ee718a7553f813c2bd904", "sha256": "ec74af9121fe8dd5a17ac1a61104c1f351fcd0c77a7ff3c3512b290a2c9b43de" }, "downloads": -1, "filename": "dewildcard-0.2.1.tar.gz", "has_sig": false, "md5_digest": "cc24b23a444ee718a7553f813c2bd904", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3385, "upload_time": "2018-08-30T11:03:19", "url": "https://files.pythonhosted.org/packages/0d/0a/21255d0477cfc9f885941484c041cd1b9d98e1763773dee72afab354991b/dewildcard-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2093bef1043545534a6eb93f0c12f864", "sha256": "ea4bb9a7a186c7ff11a4de972afb92920c6fbd8918de0165b1a4d32382997c0d" }, "downloads": -1, "filename": "dewildcard-0.2.1-py2-none-any.whl", "has_sig": false, "md5_digest": "2093bef1043545534a6eb93f0c12f864", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 3745, "upload_time": "2018-08-30T11:03:18", "url": "https://files.pythonhosted.org/packages/e1/b8/2f3fbef31359f8fd68b0e22ad64c4c289118c4b59a65d9ce18d4708cc571/dewildcard-0.2.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cc24b23a444ee718a7553f813c2bd904", "sha256": "ec74af9121fe8dd5a17ac1a61104c1f351fcd0c77a7ff3c3512b290a2c9b43de" }, "downloads": -1, "filename": "dewildcard-0.2.1.tar.gz", "has_sig": false, "md5_digest": "cc24b23a444ee718a7553f813c2bd904", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3385, "upload_time": "2018-08-30T11:03:19", "url": "https://files.pythonhosted.org/packages/0d/0a/21255d0477cfc9f885941484c041cd1b9d98e1763773dee72afab354991b/dewildcard-0.2.1.tar.gz" } ] }