This commit is contained in:
Waylon Walker 2022-03-31 20:20:07 -05:00
commit 38355d2442
No known key found for this signature in database
GPG key ID: 66E2BF2B4190EFE4
9083 changed files with 1225834 additions and 0 deletions

48
.venv/bin/transform-imports Executable file
View file

@ -0,0 +1,48 @@
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
"""
transform-imports --transform aa.bb=xx.yy *.py
transform-imports --transform aa.bb=xx.yy < foo.py
Transforms::
from aa.bb.cc import dd, ee
from aa import bb
to::
from xx.yy.cc import dd, ee
from xx import yy as bb
If filenames are given on the command line, rewrites them. Otherwise, if
stdin is not a tty, read from stdin and write to stdout.
"""
# pyflyby/transform-imports
# Copyright (C) 2014 Karl Chen.
# License: MIT http://opensource.org/licenses/MIT
from __future__ import absolute_import, division, with_statement
from pyflyby._cmdline import hfmt, parse_args, process_actions
from pyflyby._imports2s import transform_imports
def main():
transformations = {}
def addopts(parser):
def callback(option, opt_str, value, group):
k, v = value.split("=", 1)
transformations[k] = v
parser.add_option("--transform", action='callback',
type="string", callback=callback,
metavar="OLD=NEW",
help=hfmt('''
Replace OLD with NEW in imports.
May be specified multiple times.'''))
options, args = parse_args(
addopts, import_format_params=True, modify_action_params=True)
def modify(x):
return transform_imports(x, transformations, params=options.params)
process_actions(args, options.actions, modify)
if __name__ == '__main__':
main()