Slight cleanup in gitinspector.py.

Renamed all "local" declarations in main().
This commit is contained in:
Adam Waldenberg 2015-10-30 03:41:09 +01:00
parent c01a59430c
commit d88ff2c5b9
1 changed files with 32 additions and 33 deletions

View File

@ -97,25 +97,24 @@ def main():
terminal.check_terminal_encoding() terminal.check_terminal_encoding()
terminal.set_stdin_encoding() terminal.set_stdin_encoding()
argv = terminal.convert_command_line_to_utf8() argv = terminal.convert_command_line_to_utf8()
__run__ = Runner() run = Runner()
try: try:
__opts__, __args__ = optval.gnu_getopt(argv[1:], "f:F:hHlLmrTwx:", ["exclude=", "file-types=", "format=", opts, args = optval.gnu_getopt(argv[1:], "f:F:hHlLmrTwx:", ["exclude=", "file-types=", "format=",
"hard:true", "help", "list-file-types:true", "hard:true", "help", "list-file-types:true", "localize-output:true",
"localize-output:true", "metrics:true", "responsibilities:true", "metrics:true", "responsibilities:true", "since=", "grading:true",
"since=", "grading:true", "timeline:true", "until=", "version", "timeline:true", "until=", "version", "weeks:true"])
"weeks:true"]) if len(args) > 0:
if len(__args__) > 0: run.repo = args[-1]
__run__.repo = __args__[-1]
#Try to clone the repo or return the same directory and bail out. #Try to clone the repo or return the same directory and bail out.
__run__.repo = clone.create(__run__.repo) run.repo = clone.create(run.repo)
#We need the repo above to be set before we read the git config. #We need the repo above to be set before we read the git config.
GitConfig(__run__).read() GitConfig(run, len(args) > 1).read()
clear_x_on_next_pass = True clear_x_on_next_pass = True
for o, a in __opts__: for o, a in opts:
if o in("-h", "--help"): if o in("-h", "--help"):
help.output() help.output()
sys.exit(0) sys.exit(0)
@ -125,25 +124,25 @@ def main():
if not format.select(a): if not format.select(a):
raise format.InvalidFormatError(_("specified output format not supported.")) raise format.InvalidFormatError(_("specified output format not supported."))
elif o == "-H": elif o == "-H":
__run__.hard = True run.hard = True
elif o == "--hard": elif o == "--hard":
__run__.hard = optval.get_boolean_argument(a) run.hard = optval.get_boolean_argument(a)
elif o == "-l": elif o == "-l":
__run__.list_file_types = True run.list_file_types = True
elif o == "--list-file-types": elif o == "--list-file-types":
__run__.list_file_types = optval.get_boolean_argument(a) run.list_file_types = optval.get_boolean_argument(a)
elif o == "-L": elif o == "-L":
__run__.localize_output = True run.localize_output = True
elif o == "--localize-output": elif o == "--localize-output":
__run__.localize_output = optval.get_boolean_argument(a) run.localize_output = optval.get_boolean_argument(a)
elif o == "-m": elif o == "-m":
__run__.include_metrics = True run.include_metrics = True
elif o == "--metrics": elif o == "--metrics":
__run__.include_metrics = optval.get_boolean_argument(a) run.include_metrics = optval.get_boolean_argument(a)
elif o == "-r": elif o == "-r":
__run__.responsibilities = True run.responsibilities = True
elif o == "--responsibilities": elif o == "--responsibilities":
__run__.responsibilities = optval.get_boolean_argument(a) run.responsibilities = optval.get_boolean_argument(a)
elif o == "--since": elif o == "--since":
interval.set_since(a) interval.set_since(a)
elif o == "--version": elif o == "--version":
@ -151,23 +150,23 @@ def main():
sys.exit(0) sys.exit(0)
elif o == "--grading": elif o == "--grading":
grading = optval.get_boolean_argument(a) grading = optval.get_boolean_argument(a)
__run__.include_metrics = grading run.include_metrics = grading
__run__.list_file_types = grading run.list_file_types = grading
__run__.responsibilities = grading run.responsibilities = grading
__run__.grading = grading run.grading = grading
__run__.hard = grading run.hard = grading
__run__.timeline = grading run.timeline = grading
__run__.useweeks = grading run.useweeks = grading
elif o == "-T": elif o == "-T":
__run__.timeline = True run.timeline = True
elif o == "--timeline": elif o == "--timeline":
__run__.timeline = optval.get_boolean_argument(a) run.timeline = optval.get_boolean_argument(a)
elif o == "--until": elif o == "--until":
interval.set_until(a) interval.set_until(a)
elif o == "-w": elif o == "-w":
__run__.useweeks = True run.useweeks = True
elif o == "--weeks": elif o == "--weeks":
__run__.useweeks = optval.get_boolean_argument(a) run.useweeks = optval.get_boolean_argument(a)
elif o in("-x", "--exclude"): elif o in("-x", "--exclude"):
if clear_x_on_next_pass: if clear_x_on_next_pass:
clear_x_on_next_pass = False clear_x_on_next_pass = False
@ -175,7 +174,7 @@ def main():
filtering.add(a) filtering.add(a)
__check_python_version__() __check_python_version__()
__run__.output() run.output()
except (filtering.InvalidRegExpError, format.InvalidFormatError, optval.InvalidOptionArgument, getopt.error) as exception: except (filtering.InvalidRegExpError, format.InvalidFormatError, optval.InvalidOptionArgument, getopt.error) as exception:
print(sys.argv[0], "\b:", exception.msg, file=sys.stderr) print(sys.argv[0], "\b:", exception.msg, file=sys.stderr)