Esempio n. 1
0
def __read_git_config_bool__(repo, variable):
    try:
        variable = __read_git_config__(repo, variable)
        return optval.get_boolean_argument(False if variable ==
                                           "" else variable)
    except optval.InvalidOptionArgument:
        return False
def main():
	terminal.check_terminal_encoding()
	terminal.set_stdin_encoding()
	argv = terminal.convert_command_line_to_utf8()
	__run__ = Runner()

	try:
		__opts__, __args__ = optval.gnu_getopt(argv[1:], "f:F:hHlLmrTwx:", ["exclude=", "file-types=", "format=",
		                                                 "hard:true", "help", "list-file-types:true",
		                                                 "localize-output:true", "metrics:true", "responsibilities:true",
		                                                 "since=", "grading:true", "timeline:true", "until=", "version",
		                                                 "weeks:true"])
		for arg in __args__:
			__run__.repo = arg

		#We need the repo above to be set before we read the git config.
		config.init(__run__)
		clear_x_on_next_pass = True

		for o, a in __opts__:
			if o in("-h", "--help"):
				help.output()
				sys.exit(0)
			elif o in("-f", "--file-types"):
				extensions.define(a)
			elif o in("-F", "--format"):
				if not format.select(a):
					raise format.InvalidFormatError(_("specified output format not supported."))
			elif o == "-H":
				__run__.hard = True
			elif o == "--hard":
				__run__.hard = optval.get_boolean_argument(a)
			elif o == "-l":
				__run__.list_file_types = True
			elif o == "--list-file-types":
				__run__.list_file_types = optval.get_boolean_argument(a)
			elif o == "-L":
				__run__.localize_output = True
			elif o == "--localize-output":
				__run__.localize_output = optval.get_boolean_argument(a)
			elif o == "-m":
				__run__.include_metrics = True
			elif o == "--metrics":
				__run__.include_metrics = optval.get_boolean_argument(a)
			elif o == "-r":
				__run__.responsibilities = True
			elif o == "--responsibilities":
				__run__.responsibilities = optval.get_boolean_argument(a)
			elif o == "--since":
				interval.set_since(a)
			elif o == "--version":
				version.output()
				sys.exit(0)
			elif o == "--grading":
				grading = optval.get_boolean_argument(a)
				__run__.include_metrics = grading
				__run__.list_file_types = grading
				__run__.responsibilities = grading
				__run__.grading = grading
				__run__.hard = grading
				__run__.timeline = grading
				__run__.useweeks = grading
			elif o == "-T":
				__run__.timeline = True
			elif o == "--timeline":
				__run__.timeline = optval.get_boolean_argument(a)
			elif o == "--until":
				interval.set_until(a)
			elif o == "-w":
				__run__.useweeks = True
			elif o == "--weeks":
				__run__.useweeks = optval.get_boolean_argument(a)
			elif o in("-x", "--exclude"):
				if clear_x_on_next_pass:
					clear_x_on_next_pass = False
					filtering.clear()
				filtering.add(a)

		__check_python_version__()
		__run__.output()

	except (filtering.InvalidRegExpError, format.InvalidFormatError, optval.InvalidOptionArgument, getopt.error) as exception:
		print(sys.argv[0], "\b:", exception.msg, file=sys.stderr)
		print(_("Try `{0} --help' for more information.").format(sys.argv[0]), file=sys.stderr)
		sys.exit(2)
Esempio n. 3
0
def __read_git_config_bool__(repo, variable):
	try:
		variable = __read_git_config__(repo, variable)
		return optval.get_boolean_argument(False if variable == "" else variable)
	except optval.InvalidOptionArgument:
		return False
Esempio n. 4
0
def main():
    terminal.check_terminal_encoding()
    terminal.set_stdin_encoding()
    argv = terminal.convert_command_line_to_utf8()
    __run__ = Runner()

    try:
        __opts__, __args__ = optval.gnu_getopt(argv[1:], "f:F:hHlLmrTwx:", [
            "exclude=", "file-types=", "format=", "hard:true", "help",
            "list-file-types:true", "localize-output:true", "metrics:true",
            "responsibilities:true", "since=", "grading:true", "timeline:true",
            "until=", "version", "weeks:true"
        ])
        for arg in __args__:
            __run__.repo = arg

        #Try to clone the repo or return the same directory and bail out.
        __run__.repo = clone.create(__run__.repo)

        #We need the repo above to be set before we read the git config.
        config.init(__run__)
        clear_x_on_next_pass = True

        for o, a in __opts__:
            if o in ("-h", "--help"):
                help.output()
                sys.exit(0)
            elif o in ("-f", "--file-types"):
                extensions.define(a)
            elif o in ("-F", "--format"):
                if not format.select(a):
                    raise format.InvalidFormatError(
                        _("specified output format not supported."))
            elif o == "-H":
                __run__.hard = True
            elif o == "--hard":
                __run__.hard = optval.get_boolean_argument(a)
            elif o == "-l":
                __run__.list_file_types = True
            elif o == "--list-file-types":
                __run__.list_file_types = optval.get_boolean_argument(a)
            elif o == "-L":
                __run__.localize_output = True
            elif o == "--localize-output":
                __run__.localize_output = optval.get_boolean_argument(a)
            elif o == "-m":
                __run__.include_metrics = True
            elif o == "--metrics":
                __run__.include_metrics = optval.get_boolean_argument(a)
            elif o == "-r":
                __run__.responsibilities = True
            elif o == "--responsibilities":
                __run__.responsibilities = optval.get_boolean_argument(a)
            elif o == "--since":
                interval.set_since(a)
            elif o == "--version":
                version.output()
                sys.exit(0)
            elif o == "--grading":
                grading = optval.get_boolean_argument(a)
                __run__.include_metrics = grading
                __run__.list_file_types = grading
                __run__.responsibilities = grading
                __run__.grading = grading
                __run__.hard = grading
                __run__.timeline = grading
                __run__.useweeks = grading
            elif o == "-T":
                __run__.timeline = True
            elif o == "--timeline":
                __run__.timeline = optval.get_boolean_argument(a)
            elif o == "--until":
                interval.set_until(a)
            elif o == "-w":
                __run__.useweeks = True
            elif o == "--weeks":
                __run__.useweeks = optval.get_boolean_argument(a)
            elif o in ("-x", "--exclude"):
                if clear_x_on_next_pass:
                    clear_x_on_next_pass = False
                    filtering.clear()
                filtering.add(a)

        __check_python_version__()
        __run__.output()

    except (filtering.InvalidRegExpError, format.InvalidFormatError,
            optval.InvalidOptionArgument, getopt.error) as exception:
        print(sys.argv[0], "\b:", exception.msg, file=sys.stderr)
        print(_("Try `{0} --help' for more information.").format(sys.argv[0]),
              file=sys.stderr)
        sys.exit(2)