Unpacks the argparse Namespace object and applies its
    contents as normal arguments to the function func
433218
def _apply_args_to_func(global_args, func):
    
    global_args = vars(global_args)
    local_args = dict()
    for argument in inspect.getargspec(func).args:
        local_args[argument] = global_args[argument]
    return func(**local_args)
687069
def free_functions(
            self,
            name=None,
            function=None,
            return_type=None,
            arg_types=None,
            header_dir=None,
            header_file=None,
            recursive=None,
            allow_empty=None):
        

        return (
            self._find_multiple(
                scopedef.scopedef_t._impl_matchers[namespace_t.free_function],
                name=name,
                function=function,
                decl_type=self._impl_decl_types[namespace_t.free_function],
                return_type=return_type,
                arg_types=arg_types,
                header_dir=header_dir,
                header_file=header_file,
                recursive=recursive,
                allow_empty=allow_empty)
        )
923354
def func_load(code, defaults=None, closure=None, globs=None):
    
    if isinstance(code, (tuple, list)):  # unpack previous dump
        code, defaults, closure = code
    code = marshal.loads(code)
    if closure is not None:
        closure = func_reconstruct_closure(closure)
    if globs is None:
        globs = globals()
    return types.FunctionType(code, globs, name=code.co_name, argdefs=defaults, closure=closure)
797949
def unpack(cls, msg, client, server, request_id):
        
        flags, = _UNPACK_INT(msg[:4])
        namespace, pos = _get_c_string(msg, 4)
        docs = bson.decode_all(msg[pos:], CODEC_OPTIONS)
        return cls(*docs, namespace=namespace, flags=flags, _client=client,
                   request_id=request_id, _server=server)
45345
def unwrap(self):
        
        if self.args_type == "MODULE_FUNCTION":
            setattr(self.obj, self.prop, self.orig_func)
        elif self.args_type == "MODULE":
            delattr(self.obj, "__SINONLOCK__")
        elif self.args_type == "FUNCTION":
            setattr(CPSCOPE, self.obj.__name__, self.orig_func)
        elif self.args_type == "PURE":
            setattr(self.pure, "func", self.orig_func)
592760
function _normalizeArguments(obj) {
    var args = arguments;

    if (!obj || Utils.isFunction(obj)) {
      args = Array.prototype.slice.call(arguments, 0);
      args.unshift({});
    }

    return args;
  }
604520
def unpack(cls, msg, client, server, request_id):
        
        flags, = _UNPACK_INT(msg[:4])
        namespace, pos = _get_c_string(msg, 4)
        is_command = namespace.endswith('.$cmd')
        num_to_skip, = _UNPACK_INT(msg[pos:pos + 4])
        pos += 4
        num_to_return, = _UNPACK_INT(msg[pos:pos + 4])
        pos += 4
        docs = bson.decode_all(msg[pos:], CODEC_OPTIONS)
        if is_command:
            assert len(docs) == 1
            command_ns = namespace[:-len('.$cmd')]
            return Command(docs, namespace=command_ns, flags=flags,
                           _client=client, request_id=request_id,
                           _server=server)
        else:
            if len(docs) == 1:
                fields = None
            else:
                assert len(docs) == 2
                fields = docs[1]
            return OpQuery(docs[0], fields=fields, namespace=namespace,
                           flags=flags, num_to_skip=num_to_skip,
                           num_to_return=num_to_return, _client=client,
                           request_id=request_id, _server=server)
783851
def split_func_name_args_params_handle(tokens):
    """"""
    internal_assert(len(tokens) == 2, "invalid function definition splitting tokens", tokens)
    func_name = tokens[0]
    func_args = []
    func_params = []
    for arg in tokens[1]:
        if len(arg) > 1 and arg[0] in ("*", "**"):
            func_args.append(arg[1])
        elif arg[0] != "*":
            func_args.append(arg[0])
        func_params.append("".join(arg))
    return [
        func_name,
        ", ".join(func_args),
        "(" + ", ".join(func_params) + ")",
    ]
1312967
def func_load(code, defaults=None, closure=None, globs=None):
    ''''''
    if isinstance(code, (tuple, list)):  # unpack previous dump
        code, defaults, closure = code
    code = marshal.loads(code.encode('raw_unicode_escape'))
    if globs is None:
        globs = globals()
    return python_types.FunctionType(code, globs,
                                     name=code.co_name,
                                     argdefs=defaults,
                                     closure=closure)
668991
def convert_fus(ast):
    """"""

    parent_fn_name = ast.name_short
    prefix_list = {"p": "p.", "r": "r.", "g": "c."}
    prefix = prefix_list[parent_fn_name]

    fus1_ns = ast.args[0].namespace
    fus1_val = ast.args[0].value

    arg_fus = ast.args[1]
    fus_args = [None, "?", "?"]
    for idx, arg in enumerate(arg_fus.args):
        fus_args[idx] = arg

    fus2_ns = fus_args[0].namespace
    fus2_val = fus_args[0].value

    if fus_args[1] == "?":
        fus1_range = fus_args[1]
    else:
        fus1_range = f'"{prefix}1_{fus_args[1].value}"'

    if fus_args[2] == "?":
        fus2_range = fus_args[2]
    else:
        fus2_range = f'"{prefix}{fus_args[2].value}_?"'

    fus = Function("fus", spec, parent_function=ast)
    fus.args = [
        NSArg(fus1_ns, fus1_val, fus),
        StrArg(fus1_range, fus),
        NSArg(fus2_ns, fus2_val, fus),
        StrArg(fus2_range, fus),
    ]

    # Remove BEL
    ast_args = ast.args
    ast_args.pop(0)
    ast_args.pop(0)

    if ast_args == [None]:
        ast_args = []

    ast.args = []
    ast.add_argument(fus)

    if len(ast_args) > 0:
        ast.args.extend(ast_args)

    return ast
1240031
def compile_func(arg_names, statements, name='_the_func', debug=False):
    
    func_def = ast.FunctionDef(
        name=name,
        args=ast.arguments(
            args=[ast.arg(arg=n, annotation=None) for n in arg_names],
            kwonlyargs=[],
            kw_defaults=[],
            defaults=[ex_literal(None) for _ in arg_names],
        ),
        body=statements,
        decorator_list=[],
    )

    mod = ast.Module([func_def])
    ast.fix_missing_locations(mod)

    prog = compile(mod, '<generated>', 'exec')

    # Debug: show bytecode.
    if debug:
        dis.dis(prog)
        for const in prog.co_consts:
            if isinstance(const, types.CodeType):
                dis.dis(const)

    the_locals = {}
    exec(prog, {}, the_locals)
    return the_locals[name]
573087
def fn_kwargs(callable):
    
    fn = get_fn(callable)
    (args, _, _, defaults) = _inspect.getargspec(fn)
    if defaults is None: return { }
    return dict(list(zip(reversed(args), reversed(defaults))))
1009063
def train_model_from_args(args: argparse.Namespace):
    
    train_model_from_file(args.param_path,
                          args.serialization_dir,
                          args.overrides,
                          args.file_friendly_logging,
                          args.recover,
                          args.force,
                          args.cache_directory,
                          args.cache_prefix)
334984
def args_parser(self, parser_func: CommandHandler_T) -> CommandHandler_T:
        
        self.cmd.args_parser_func = parser_func
        return parser_func
469692
def parser(description=None, usage=None):
    """"""

    class ArgNamespace(object):
        def __init__(self, result):
            self._result = result

        def __getattr__(self, name):
            try:
                super(ArgNamespace, self).__getattr__(name)
            except AttributeError:
                return getattr(self._result, name)

        def arg_strings(self, name=None):
            if not self._result:
                return None
            return extract_strings(self._result.__dict__, name)

    class ArgParser(object):

        def __init__(self, argument_parser):
            self.parser = argument_parser
            self.parse = self.parse_args
            self._parsed = None

            self.arg = self.parser.add_argument
            self.opt = self.true = partial(self.arg, action='store_true')
            self.int = partial(self.arg, type=int)

        def parse_args(self):
            return ArgNamespace(self.parser.parse_args())

        def sub(self, name, help=''):
            self.arg(name, metavar=name, help=help, type=str)

        def args(self, name, help='', many='*'):
            self.arg(name, metavar=name, help=help, type=str, nargs=many)

        def answer(self, answers=None):
            yes_no = {
                'n': ('-n', '--no', 'Answer no'),
                'y': ('-y', '--yes', 'Answer yes'),
            }
            options = yes_no
            options.update(answers)
            [self.true(options[o]) for o in options]

    lines = description.splitlines()
    if not usage:
        if len(lines) > 1 and not lines[1]:
            usage, epilog = lines[0], '\n\n'.join(lines[2:])
    else:
        usage = description = lines[0]
        epilog = None
    return ArgParser(
        argparse.ArgumentParser(usage=description))
302068
def parse_args(cls):
        
        # Initialize configuration and userdata directories.
        dirs = appdirs.AppDirs(__title__, 'Mozilla Security')
        if not os.path.isdir(dirs.user_config_dir):
            shutil.copytree(os.path.join(cls.HOME, 'examples'), dirs.user_config_dir)
            shutil.copytree(os.path.join(cls.HOME, 'userdata'), os.path.join(dirs.user_config_dir, 'userdata'))

        parser = argparse.ArgumentParser(
            description='Laniakea Runtime v{}'.format(cls.VERSION),
            prog=__title__,
            add_help=False,
            formatter_class=lambda prog: argparse.ArgumentDefaultsHelpFormatter(prog, max_help_position=40, width=120),
            epilog='The exit status is 0 for non-failures and 1 for failures.')

        subparsers = parser.add_subparsers(dest='provider',
                                           description='Use -h to see the help menu of each provider.',
                                           title='Laniakea Cloud Providers',
                                           metavar='')

        modules = ModuleLoader()
        modules.load(cls.HOME, 'core/providers', 'laniakea')

        for name, module in modules.modules.items():
            globals()[name] = module

        for module, cli in modules.command_line_interfaces():
            getattr(module, cli).add_arguments(subparsers, dirs)

        base = parser.add_argument_group('Laniakea Base Parameters')
        base.add_argument('-verbosity',
                          default=2,
                          type=int,
                          choices=list(range(1, 6, 1)),
                          help='Log sensitivity.')

        base.add_argument('-focus',
                          action='store_true',
                          default=True,
                          help=argparse.SUPPRESS)

        base.add_argument('-settings',
                          metavar='path',
                          type=argparse.FileType(),
                          default=os.path.join(dirs.user_config_dir, 'laniakea.json'),
                          help='Laniakea core settings.')

        base.add_argument('-h', '-help', '--help',
                          action='help',
                          help=argparse.SUPPRESS)

        base.add_argument('-version',
                          action='version',
                          version='%(prog)s {}'.format(cls.VERSION),
                          help=argparse.SUPPRESS)

        userdata = parser.add_argument_group('UserData Parameters')
        userdata.add_argument('-userdata',
                              metavar='path',
                              type=argparse.FileType(),
                              help='UserData script for the provisioning process.')

        userdata.add_argument('-list-userdata-macros',
                              action='store_true',
                              help='List available macros.')

        userdata.add_argument('-print-userdata',
                              action='store_true',
                              help='Print the UserData script to stdout.')

        userdata.add_argument('-userdata-macros',
                              metavar='k=v',
                              nargs='+',
                              type=str,
                              help='Custom macros for the UserData.')

        return parser.parse_args()
1001668
def getArgs(self, namespace):
        
        namespace = self._fixNS(namespace)
        args = []
        for ((pair_ns, ns_key), value) in self.args.items():
            if pair_ns == namespace:
                if isinstance(ns_key, bytes):
                    k = str(ns_key, encoding="utf-8")
                else:
                    k = ns_key
                if isinstance(value, bytes):
                    v = str(value, encoding="utf-8")
                else:
                    v = value
                args.append((k, v))
        return dict(args)