Allow zero+ paths in migration script

and run the self-tests on Windows, too.
main
Dan Buch 8 years ago
parent 6d59b40b68
commit 462217f9fc
No known key found for this signature in database
GPG Key ID: FAEF12936DD3E3EC

@ -23,3 +23,4 @@ build_script:
- python runtests vet - python runtests vet
- python runtests test - python runtests test
- python runtests gfmxr - python runtests gfmxr
- python cli-v1-to-v2 --selftest

@ -36,7 +36,7 @@ def main(sysargs=sys.argv[:]):
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description=_DESCRIPTION, description=_DESCRIPTION,
formatter_class=argparse.ArgumentDefaultsHelpFormatter) formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('path', nargs='+', parser.add_argument('path', nargs='*',
type=os.path.abspath, default=os.getcwd()) type=os.path.abspath, default=os.getcwd())
parser.add_argument('-w', '--write', help='write changes back to file', parser.add_argument('-w', '--write', help='write changes back to file',
action='store_true', default=False) action='store_true', default=False)
@ -60,7 +60,11 @@ def main(sysargs=sys.argv[:]):
format='%(message)s' format='%(message)s'
) )
for filepath in _find_candidate_files(args.path): paths = args.path
if len(paths) == 0:
paths = ['.']
for filepath in _find_candidate_files(paths):
updated_source = _update_filepath(filepath) updated_source = _update_filepath(filepath)
if args.write: if args.write:
logging.info('Updating %s', filepath) logging.info('Updating %s', filepath)
@ -86,7 +90,7 @@ def _find_candidate_files(paths):
dirs.pop(i) dirs.pop(i)
for filename in files: for filename in files:
if not filename.endswith('.go'): if not filename.decode('utf-8').endswith('.go'):
continue continue
filepath = os.path.join(curdir, filename) filepath = os.path.join(curdir, filename)

Loading…
Cancel
Save