Function for invoking the lldptool utility.
513812
def run_lldptool(self, args):
        
        full_args = ['lldptool'] + args
        try:
            return utils.execute(full_args, root_helper=self.root_helper)
        except Exception as exc:
            LOG.error("Unable to execute %(cmd)s. "
                      "Exception: %(exception)s",
                      {'cmd': full_args, 'exception': str(exc)})
1164486
def debug(s, *args):
    """"""
    # Get the path name and line number of the function which called us.
    previous_frame = inspect.currentframe().f_back
    try:
        pathname, lineno, _, _, _ = inspect.getframeinfo(previous_frame)
        # if path is in cwd, simplify it
        cwd = os.path.abspath(os.getcwd())
        pathname = os.path.abspath(pathname)
        if os.path.commonprefix([cwd, pathname]) == cwd:
            pathname = os.path.relpath(pathname, cwd)
    except Exception:  # pylint: disable=broad-except
        pathname = '<UNKNOWN-FILE>.py'
        lineno = 0
    if _FORMATTER: # log could have not been initialized.
        _FORMATTER.pathname = pathname
        _FORMATTER.lineno = lineno
    logger = logging.getLogger(__package__)
    logger.debug(s.format(*args))
910930
def run_pylint(self):
        """"""
        if (self.get_option('save_before', True)
                and not self.main.editor.save()):
            return
        self.switch_to_plugin()
        self.analyze(self.main.editor.get_current_filename())
577269
def run_vdptool(self, args, oui_args=None):
        
        if oui_args is None:
            oui_args = []
        full_args = ['vdptool'] + args + oui_args
        try:
            return utils.execute(full_args, root_helper=self.root_helper)
        except Exception as e:
            LOG.error("Unable to execute %(cmd)s. "
                      "Exception: %(exception)s",
                      {'cmd': full_args, 'exception': e})
16481
def trace_dispatch(self, frame, event, arg):
        """"""
        if hasattr(self, 'pdb'):
            return self.pdb.trace_dispatch(frame, event, arg)
        else:
            return Pdb.trace_dispatch(self, frame, event, arg)
1270865
def function_parser(function, parser):
    """"""

    # Store the function pointer on the parser for later use
    parser.set_defaults(func=function)

    # Get the help text and parse it for params
    help_text = inspect.getdoc(function)
    main_text, params_help = parser_help_text(help_text)

    # Get the function information
    args, varargs, keywords, defaults = inspect.getargspec(function)
    if args is None:
        args = []

    if defaults is None:
        defaults = []

    # If the function is a class method, it will have a self that needs to be removed
    if len(args) and args[0] == 'self':
        args.pop(0)

    # Work out whether the argument has a default by subtracting the length
    # of the default args from the number of arguments
    num_required_args = len(args) - len(defaults)
    for idx, arg in enumerate(args):
        if idx < num_required_args:
            arg_name, arg_params = calculate_default_type(arg, False, None, params_help)
        else:
            default_value = defaults[idx - num_required_args]
            arg_name, arg_params = calculate_default_type(arg, True, default_value, params_help)

        parser.add_argument(arg_name, **arg_params)
968969
def _compile_fdpf(self):
        
        string = '"""\n'
        string += 'system.dae.init_g()\n'
        for pflow, gcall, call in zip(self.pflow, self.gcall, self.gcalls):
            if pflow and gcall:
                string += call
        string += 'system.dae.reset_small_g()\n'
        string += '\n'
        string += '"""'
        self.fdpf = compile(eval(string), '', 'exec')
1251226
def dispatch_hook(cls, _pkt=None, *args, **kargs):
        '''
          
        '''
        if _pkt and len(_pkt) >= 2:
            version = orb(_pkt[0])
            pdu_type = orb(_pkt[1])
            if version == 0:
                return PDU_CLASS_VERSION_0[pdu_type]
            elif version == 1:
                return PDU_CLASS_VERSION_1[pdu_type]
        return Raw
160774
def _call_lset(self, command, index, value, *args, **kwargs):
        
        if self.indexable:
            old_value = self.lindex(index)
            self.deindex([old_value])
        result = self._traverse_command(command, index, value, *args, **kwargs)
        if self.indexable:
            self.index([value])
        return result
848627
def _invoke(self, arguments, autoescape):
        """"""
        rv = self._func(*arguments)
        if autoescape:
            rv = Markup(rv)
        return rv
353534
def main() -> None:
    """""""
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--outdir", help="output directory", default=os.path.dirname(__file__))
    args = parser.parse_args()

    outdir = pathlib.Path(args.outdir)
    if not outdir.exists():
        raise FileNotFoundError("Output directory is missing: {}".format(outdir))

    for contracts in [0, 1, 5, 10]:
        if contracts == 0:
            pth = outdir / "functions_100_with_no_contract.py"
        elif contracts == 1:
            pth = outdir / "functions_100_with_1_contract.py"
        else:
            pth = outdir / "functions_100_with_{}_contracts.py".format(contracts)

        text = generate_functions(functions=100, contracts=contracts, disabled=False)
        pth.write_text(text)

    for contracts in [1, 5, 10]:
        if contracts == 1:
            pth = outdir / "functions_100_with_1_disabled_contract.py"
        else:
            pth = outdir / "functions_100_with_{}_disabled_contracts.py".format(contracts)

        text = generate_functions(functions=100, contracts=contracts, disabled=True)
        pth.write_text(text)

    for invariants in [0, 1, 5, 10]:
        if invariants == 0:
            pth = outdir / "classes_100_with_no_invariant.py"
        elif invariants == 1:
            pth = outdir / "classes_100_with_1_invariant.py"
        else:
            pth = outdir / "classes_100_with_{}_invariants.py".format(invariants)

        text = generate_classes(classes=100, invariants=invariants, disabled=False)
        pth.write_text(text)

    for invariants in [1, 5, 10]:
        if invariants == 1:
            pth = outdir / "classes_100_with_1_disabled_invariant.py"
        else:
            pth = outdir / "classes_100_with_{}_disabled_invariants.py".format(invariants)

        text = generate_classes(classes=100, invariants=invariants, disabled=True)
        pth.write_text(text)
589856
def _function_handler(function, args, kwargs, pipe):
    """"""
    signal.signal(signal.SIGINT, signal.SIG_IGN)

    result = process_execute(function, *args, **kwargs)

    send_result(pipe, result)
260656
def on_functiondef(self, node):
        """"""
        # ('name', 'args', 'body', 'decorator_list')
        if node.decorator_list:
            raise Warning("decorated procedures not supported!")
        kwargs = []

        if not valid_symbol_name(node.name) or node.name in self.readonly_symbols:
            errmsg = "invalid function name (reserved word?) %s" % node.name
            self.raise_exception(node, exc=NameError, msg=errmsg)

        offset = len(node.args.args) - len(node.args.defaults)
        for idef, defnode in enumerate(node.args.defaults):
            defval = self.run(defnode)
            keyval = self.run(node.args.args[idef+offset])
            kwargs.append((keyval, defval))

        if version_info[0] == 3:
            args = [tnode.arg for tnode in node.args.args[:offset]]
        else:
            args = [tnode.id for tnode in node.args.args[:offset]]

        doc = None
        nb0 = node.body[0]
        if isinstance(nb0, ast.Expr) and isinstance(nb0.value, ast.Str):
            doc = nb0.value.s

        varkws = node.args.kwarg
        vararg = node.args.vararg
        if version_info[0] == 3:
            if isinstance(vararg, ast.arg):
                vararg = vararg.arg
            if isinstance(varkws, ast.arg):
                varkws = varkws.arg

        self.symtable[node.name] = Procedure(node.name, self, doc=doc,
                                             lineno=self.lineno,
                                             body=node.body,
                                             args=args, kwargs=kwargs,
                                             vararg=vararg, varkws=varkws)
        if node.name in self.no_deepcopy:
            self.no_deepcopy.remove(node.name)
843971
def dispatch_hook(cls, _pkt=b"", *args, **kargs):
        """"""  # noqa: E501
        if _pkt and len(_pkt) >= 1:
            if orb(_pkt[0]) == 0x41:
                return LoWPANUncompressedIPv6
            if orb(_pkt[0]) == 0x42:
                return LoWPAN_HC1
            if orb(_pkt[0]) >> 3 == 0x18:
                return LoWPANFragmentationFirst
            elif orb(_pkt[0]) >> 3 == 0x1C:
                return LoWPANFragmentationSubsequent
            elif orb(_pkt[0]) >> 6 == 0x02:
                return LoWPANMesh
            elif orb(_pkt[0]) >> 6 == 0x01:
                return LoWPAN_IPHC
        return cls
1209781
def lpop(self, key, *, encoding=_NOTSET):
        """"""
        return self.execute(b'LPOP', key, encoding=encoding)
1350827
def log_decl_method(func):
    """"""
    from functools import wraps

    @wraps(func)
    def with_logging(*args, **kwargs):
        self = args[0]
        decl = args[2]
        log(DEBUG, u"    {}: {} {}".format(
            self.state['current_step'], decl.name,
            serialize(decl.value).strip()).encode('utf-8'))
        return func(*args, **kwargs)
    return with_logging
588180
def invoke(config, name, input):
    
    # options should override config if it is there
    myname = name or config.name

    click.echo('Invoking ' + myname)
    output = lambder.invoke_function(myname, input)
    click.echo(output)