Return a parser action property.
359285
def action(toktype):
    """"""
    def outer(func):
        """Return a function that pushes a token onto the token queue."""
        def inner(lexer, text):
            """Push a token onto the token queue."""
            value = func(lexer, text)
            lexer.tokens.append(toktype(value, lexer.lineno, lexer.offset))
        return inner
    return outer
1003853
def register_action(*args, **kwarg):
    '''
    
    '''
    def decorator(fun):
        KeywordArgumentParser._action_dict[frozenset(args)] = fun
        return fun
    return decorator
130188
def register_custom_actions(parser: argparse.ArgumentParser) -> None:
    """"""
    parser.register('action', None, _StoreRangeAction)
    parser.register('action', 'store', _StoreRangeAction)
    parser.register('action', 'append', _AppendRangeAction)
207709
def get_parser():
    """"""
    from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
    parser = ArgumentParser(description=__doc__,
                            formatter_class=ArgumentDefaultsHelpFormatter)
    parser.add_argument("-n",
                        dest="n", default=10, type=int,
                        help="Show TOP-N results")
    parser.add_argument("--port",
                        dest="port", default=5000, type=int,
                        help="where should the webserver run")
    parser.add_argument("--use_segmenter",
                        dest="use_segmenter",
                        default=False,
                        action='store_true',
                        help=("try to segment the input for multiple symbol "
                              "recognition"))
    return parser
1281015
def _handle_actionif(self, _):
        """"""
        obj = _make_object("ActionIf")
        obj.BranchOffset = unpack_si16(self._src)
        yield obj
61709
def read_actions():
    """"""
    while True:
        key = get_key()

        # Handle arrows, j/k (qwerty), and n/e (colemak)
        if key in (const.KEY_UP, const.KEY_CTRL_N, 'k', 'e'):
            yield const.ACTION_PREVIOUS
        elif key in (const.KEY_DOWN, const.KEY_CTRL_P, 'j', 'n'):
            yield const.ACTION_NEXT
        elif key in (const.KEY_CTRL_C, 'q'):
            yield const.ACTION_ABORT
        elif key in ('\n', '\r'):
            yield const.ACTION_SELECT
1334959
def get_parser():
    """"""
    from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
    parser = ArgumentParser(description=__doc__,
                            formatter_class=ArgumentDefaultsHelpFormatter)
    parser.add_argument('--version',
                        action='version',
                        version='mpu {}'.format(mpu.__version__))
    subparsers = parser.add_subparsers(help='Python package commands')
    package_parser = subparsers.add_parser('package')
    mpu.package.cli.get_parser(package_parser)
    return parser
634121
def action_getattr():
    

    def action_getattr(_value, context, **_params):
        value = getattr(context["action"], context["key"])
        return _attr(value)

    return action_getattr
312181
def _parse_file_usage(cls, action_class, args):
        """"""

        fixed_files = {}
        variable_files = []

        if not hasattr(action_class, 'FILES'):
            return fixed_files, variable_files

        for file_arg in action_class.FILES:
            arg_value = args.get(file_arg)
            if arg_value is None:
                raise RecipeFileInvalid("Action lists a file argument but none was given", declared_argument=file_arg, passed_arguments=args)

            variables = _extract_variables(arg_value)
            if len(variables) == 0:
                fixed_files[file_arg] = arg_value
            else:
                variable_files.append(arg_value)

        return fixed_files, variable_files
637743
def _parse(self, source, name, filename):
        """"""
        return Parser(self, source, name, _encode_filename(filename)).parse()
774680
def get_event_action(cls) -> Optional[str]:
        
        if not cls.actor:
            return None
        return event_context.get_event_action(cls.event_type)
897763
def activate(ctx):
        """"""
        if hasattr(ctx, '_on_context_exit'):
            raise ContextError(
                'Context actions registered outside this '
                'parse context are active')

        try:
            ParseContext._active.append(ctx)
            ctx._on_context_exit = []
            yield
        finally:
            for func, args, kwargs in ctx._on_context_exit:
                func(*args, **kwargs)
            del ctx._on_context_exit
            ParseContext._active.pop()
1228097
function (model, data, action, options) {
                var processor = this.$dataSource.getProcessorForModel(model);
                return processor.parse(model, data, action, options);
            }
104395
def find_actions(namespace, action_prefix):
    """"""
    actions = {}
    for key, value in iteritems(namespace):
        if key.startswith(action_prefix):
            actions[key[len(action_prefix):]] = analyse_action(value)
    return actions
1126505
def getPoseActionData(self, action, eOrigin, fPredictedSecondsFromNow, unActionDataSize, ulRestrictToDevice):
        """"""

        fn = self.function_table.getPoseActionData
        pActionData = InputPoseActionData_t()
        result = fn(action, eOrigin, fPredictedSecondsFromNow, byref(pActionData), unActionDataSize, ulRestrictToDevice)
        return result, pActionData
1173249
def run(action: str, args: dict) -> int:
    
    if args.get('show_version_info'):
        return run_version(args)

    actions = dict(
        shell=run_shell,
        kernel=run_kernel,
        serve=run_kernel,
        version=run_version
    )

    if action not in actions:
        print('[ERROR]: Unrecognized sub command "{}"'.format(action))
        parser = args['parser']  # type: ArgumentParser
        parser.print_help()
        return 1

    return actions.get(action)(args)
226874
def _handle_actionconstantpool(self, _):
        """"""
        obj = _make_object("ActionConstantPool")
        obj.Count = count = unpack_ui16(self._src)
        obj.ConstantPool = pool = []
        for _ in range(count):
            pool.append(self._get_struct_string())
        yield obj