creeper-adventure/.venv/bin/find-import
2022-03-31 20:20:07 -05:00

40 lines
1 KiB
Python
Executable file

#!/home/walkers/git/creeper-adventure/.venv/bin/python3
"""
Usage: find-import names...
Prints how to import given name(s).
"""
# pyflyby/find-import
# Copyright (C) 2011, 2014 Karl Chen.
# License: MIT http://opensource.org/licenses/MIT
from __future__ import absolute_import, division, with_statement
from __future__ import print_function
from pyflyby._cmdline import parse_args, syntax
from pyflyby._importdb import ImportDB
from pyflyby._log import logger
def main():
options, args = parse_args(import_format_params=True)
if not args:
syntax()
db = ImportDB.get_default(".")
known = db.known_imports.by_import_as
errors = 0
for arg in args:
try:
imports = known[arg]
except KeyError:
errors += 1
logger.error("Can't find import for %r", arg)
else:
for imp in imports:
print(imp.pretty_print(params=options.params), end=' ')
if errors:
raise SystemExit(1)
if __name__ == '__main__':
main()