예제 #1
0
    def _check_impl_args(self, namespace):
        assert hasattr(namespace, 'build_script_impl_args')

        try:
            migration.check_impl_args(BUILD_SCRIPT_IMPL,
                                      namespace.build_script_impl_args)
        except (SystemExit, ValueError) as e:
            raise ParserError('failed to parse impl arguments: ' +
                              str(namespace.build_script_impl_args), e)
예제 #2
0
    def _check_impl_args(self, namespace):
        assert hasattr(namespace, 'build_script_impl_args')

        try:
            migration.check_impl_args(BUILD_SCRIPT_IMPL,
                                      namespace.build_script_impl_args)
        except (SystemExit, ValueError) as e:
            raise ParserError('failed to parse impl arguments: ' +
                              str(namespace.build_script_impl_args), e)
예제 #3
0
    def parse_args(self, args, error_message=None, check_impl_args=False):
        if error_message is None:
            error_message = 'failed to parse arguments: ' + str(args)

        with open(os.devnull, 'w') as devnull:
            try:
                with redirect_stderr(devnull), redirect_stdout(devnull):
                    namespace = migration.parse_args(self.parser, args)
            except (SystemExit, ValueError) as e:
                raise ParserError(error_message, e)

            if not namespace.build_script_impl_args and not check_impl_args:
                return namespace

            try:
                with redirect_stderr(devnull), redirect_stdout(devnull):
                    migration.check_impl_args(BUILD_SCRIPT_IMPL,
                                              namespace.build_script_impl_args)
            except (SystemExit, ValueError) as e:
                raise ParserError(error_message, e)

        return namespace
예제 #4
0
    def parse_args(self, args, error_message=None, check_impl_args=False):
        if error_message is None:
            error_message = 'failed to parse arguments: ' + str(args)

        with open(os.devnull, 'w') as devnull:
            try:
                with redirect_stderr(devnull), redirect_stdout(devnull):
                    namespace = migration.parse_args(self.parser, args)
            except (SystemExit, ValueError) as e:
                raise ParserError(error_message, e)

            if not namespace.build_script_impl_args and not check_impl_args:
                return namespace

            try:
                with redirect_stderr(devnull), redirect_stdout(devnull):
                    migration.check_impl_args(BUILD_SCRIPT_IMPL,
                                              namespace.build_script_impl_args)
            except (SystemExit, ValueError) as e:
                raise ParserError(error_message, e)

        return namespace