creeper-adventure/.venv/bin/replace-star-imports
2022-03-31 20:20:07 -05:00

38 lines
1,011 B
Python
Executable file

#!/home/walkers/git/creeper-adventure/.venv/bin/python3
"""
replace-star-imports *.py
replace-star-imports < foo.py
Replaces::
from foo.bar import *
with::
from foo.bar import (f1, f2, ...)
Note: This actually executes imports.
If filenames are given on the command line, rewrites them. Otherwise, if
stdin is not a tty, read from stdin and write to stdout.
Only top-level import statements are touched.
"""
# pyflyby/replace-star-imports
# Copyright (C) 2012, 2014 Karl Chen.
# License: MIT http://opensource.org/licenses/MIT
from __future__ import absolute_import, division, with_statement
from pyflyby._cmdline import parse_args, process_actions
from pyflyby._imports2s import replace_star_imports
def main():
options, args = parse_args(
import_format_params=True, modify_action_params=True)
def modify(x):
return replace_star_imports(x, params=options.params)
process_actions(args, options.actions, modify)
if __name__ == '__main__':
main()