Function for invoking the lldptool utility.
777644
def run_lldptool(self, args):
        
        full_args = ['lldptool'] + args
        try:
            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})
1347136
def main(arguments=None):   # suppress(unused-function)
    """"""
    result = _parse_arguments(arguments)
    linter_funcs = _ordered(linter_functions_from_filters,
                            result.whitelist,
                            result.blacklist)
    global_options = vars(result)
    tool_options = tool_options_from_global(global_options, len(result.files))
    any_would_run = _any_would_run(_run_lint_on_file_exceptions,
                                   result.files,
                                   result.stamp_file_path,
                                   result.log_technical_terms_to,
                                   linter_funcs,
                                   tool_options,
                                   result.fix_what_you_can)

    if any_would_run:
        for linter_function in linter_funcs.values():
            if linter_function.before_all:
                linter_function.before_all(global_options, tool_options)

        use_multiprocessing = _should_use_multiprocessing(len(result.files))
    else:
        use_multiprocessing = False

    if use_multiprocessing:
        mapper = parmap.map
    else:
        # suppress(E731)
        mapper = lambda f, i, *a: [f(*((x, ) + a)) for x in i]

    errors = list(itertools.chain(*mapper(_run_lint_on_file_stamped,
                                          result.files,
                                          result.stamp_file_path,
                                          result.log_technical_terms_to,
                                          linter_funcs,
                                          tool_options,
                                          result.fix_what_you_can)))

    for error in sorted(errors):
        _report_lint_error(error.failure, os.path.relpath(error.absolute_path))

    if any_would_run:
        for linter_funcs in linter_funcs.values():
            if linter_funcs.after_all:
                linter_funcs.after_all(global_options, tool_options)

    return len(errors)
949868
def function_end_action(self, text, loc, fun):
        """"""
        if DEBUG > 0:
            print("FUN_END:",fun)
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
        #set function's attribute to number of function parameters
        self.symtab.set_attribute(self.shared.function_index, self.shared.function_params)
        #clear local function symbols (but leave function name)
        self.symtab.clear_symbols(self.shared.function_index + 1)
        self.codegen.function_end()
825128
def docopt_cmd(func):
    
    def helper_fn(self, arg):
        '''helper function for docopt'''
        try:
            opt = docopt(helper_fn.__doc__, arg)
        except DocoptExit as exception:
            # The DocoptExit is thrown when the args do not match.
            # We print a message to the user and the usage block.
            print 'Invalid Command!'
            print exception
            return
        except SystemExit:
            # The SystemExit exception prints the usage for --help
            # We do not need to do the print here.
            return
        return func(self, opt)
    helper_fn.__name__ = func.__name__
    helper_fn.__doc__ = func.__doc__
    helper_fn.__dict__.update(func.__dict__)
    return helper_fn
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)
312450
def _call_with_selection(func):
    """"""
    wrapped_kwonly_params = [
        param for param in inspect.signature(func).parameters.values()
        if param.kind == param.KEYWORD_ONLY]
    sel_sig = inspect.signature(Selection)
    default_sel_sig = sel_sig.replace(
        parameters=[param.replace(default=None) if param.default is param.empty
                    else param
                    for param in sel_sig.parameters.values()])

    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        extra_kw = {param.name: kwargs.pop(param.name)
                    for param in wrapped_kwonly_params if param.name in kwargs}
        ba = default_sel_sig.bind(*args, **kwargs)
        # apply_defaults
        ba.arguments = ChainMap(
            ba.arguments,
            {name: param.default
             for name, param in default_sel_sig.parameters.items()
             if param.default is not param.empty})
        sel = Selection(*ba.args, **ba.kwargs)
        return func(sel, **extra_kw)

    wrapper.__signature__ = Signature(
        list(sel_sig.parameters.values()) + wrapped_kwonly_params)
    return wrapper
279138
def function_call_action(self, text, loc, fun):
        """"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print("FUN_CALL:",fun)
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
        #check number of arguments
        if len(self.function_arguments) != self.symtab.get_attribute(self.function_call_index):
            raise SemanticException("Wrong number of arguments for function '%s'" % fun.name)
        #arguments should be pushed to stack in reverse order
        self.function_arguments.reverse()
        self.codegen.function_call(self.function_call_index, self.function_arguments)
        self.codegen.restore_used_registers()
        return_type = self.symtab.get_type(self.function_call_index)
        #restore previous function call data
        self.function_call_index = self.function_call_stack.pop()
        self.function_arguments = self.function_arguments_stack.pop()
        register = self.codegen.take_register(return_type)
        #move result to a new free register, to allow the next function call
        self.codegen.move(self.codegen.take_function_register(return_type), register)
        return register
10948
def do_library(self, args):
        """"""
        func = getattr(args, 'func', None)
        if func is not None:
            # Call whatever subcommand function was selected
            func(self, args)
        else:
            # No subcommand was provided, so call help
            self.do_help('library')
1138895
def main(ctx, opts, version):
    """"""
    # pylint: disable=unused-argument
    if version:
        print_version()
    elif ctx.invoked_subcommand is None:
        click.echo(ctx.get_help())
1026307
def main():
    """"""
    description = ('PATH can be either the path to a scratch file, or a '
                   'directory containing scratch files. Multiple PATH '
                   'arguments can be provided.')
    parser = OptionParser(usage='%prog -p PLUGIN_NAME [options] PATH...',
                          description=description,
                          version='%prog {}'.format(__version__))
    parser.add_option('-d', '--plugin-dir', metavar='DIR',
                      help=('Specify the path to a directory containing '
                            'plugins. Plugins in this directory take '
                            'precedence over similarly named plugins '
                            'included with Hairball.'))
    parser.add_option('-p', '--plugin', action='append',
                      help=('Use the named plugin to perform analysis. '
                            'This option can be provided multiple times.'))
    parser.add_option('-k', '--kurt-plugin', action='append',
                      help=('Provide either a python import path (e.g, '
                            'kelp.octopi) to a package/module, or the path'
                            ' to a python file, which will be loaded as a '
                            'Kurt plugin. This option can be provided '
                            'multiple times.'))
    parser.add_option('-q', '--quiet', action='store_true',
                      help=('Prevent output from Hairball. Plugins may still '
                            'produce output.'))
    parser.add_option('-C', '--no-cache', action='store_true',
                      help='Do not use Hairball\'s cache.', default=False)
    options, args = parser.parse_args(sys.argv[1:])

    if not options.plugin:
        parser.error('At least one plugin must be specified via -p.')
    if not args:
        parser.error('At least one PATH must be provided.')

    if options.plugin_dir:
        if os.path.isdir(options.plugin_dir):
            sys.path.append(options.plugin_dir)
        else:
            parser.error('{} is not a directory'.format(options.plugin_dir))

    hairball = Hairball(options, args, cache=not options.no_cache)
    hairball.initialize_plugins()
    hairball.process()
    hairball.finalize()
16845
def enable_lldp(self):
        
        if self.is_ncb:
            self.run_lldptool(["-L", "-i", self.port_name, "-g", "ncb",
                               "adminStatus=rxtx"])
        if self.is_nb:
            self.run_lldptool(["-L", "-i", self.port_name, "-g", "nb",
                               "adminStatus=rxtx"])
342950
def _check(self):
        
        if conf.contribs['LLDP'].strict_mode() and self._length != 2:
            raise LLDPInvalidLengthField('length must be 2 - got '
                                         '{}'.format(self._length))
866798
def make_open_functions():
    """"""
    # Create shortcut open methods
    if hasattr(str, 'isidentifier'):
        def isidentifier(x):
            return x.isidentifier()
    else:
        IDENTIFIER_REGEX = re.compile(r'[a-zA-Z_][a-zA-Z0-9_]*$')
        isidentifier = IDENTIFIER_REGEX.match
    for plugin_name, plugin in registry.items():
        func_name = 'open_' + plugin_name
        if not isidentifier(func_name):
            # primitive name normalization
            func_name = re.sub('[-=~^&|@+]', '_', func_name)
        if isidentifier(func_name):
            globals()[func_name] = plugin
        else:
            warnings.warn('Invalid Intake plugin name "%s" found.' %
                          plugin_name)
640854
def p_functioncall(self, p):
        ''
        p[0] = FunctionCall(p[1], p[3], lineno=p.lineno(1))
        p.set_lineno(0, p.lineno(1))
1305122
def inject_print_functions(module_name=None, module_prefix='[???]',
                           DEBUG=False, module=None):
    
    module = _get_module(module_name, module)
    if SILENT:
        def print(*args):
            """ silent builtins.print """
            pass
        def printDBG(*args):
            """ silent debug print """
            pass
        def print_(*args):
            """ silent stdout.write """
            pass
    else:
        if DEBUG_PRINT:
            # Turns on printing where a message came from
            def print(*args):
                """ debugging logging builtins.print """
                from utool._internal.meta_util_dbg import get_caller_name
                calltag = ''.join(('[caller:', get_caller_name(N=DEBUG_PRINT_N), ']' ))
                util_logging._utool_print()(calltag, *args)
        else:
            def print(*args):
                """ logging builtins.print """
                util_logging._utool_print()(*args)

        if __AGGROFLUSH__:
            def print_(*args):
                """ aggressive logging stdout.write """
                util_logging._utool_write()(*args)
                util_logging._utool_flush()()
        else:
            def print_(*args):
                """ logging stdout.write """
                util_logging._utool_write()(*args)

        # turn on module debugging with command line flags
        dotpos = module.__name__.rfind('.')
        if dotpos == -1:
            module_name = module.__name__
        else:
            module_name = module.__name__[dotpos + 1:]
        def _replchars(str_):
            return str_.replace('_', '-').replace(']', '').replace('[', '')
        flag1 = '--debug-%s' % _replchars(module_name)
        flag2 = '--debug-%s' % _replchars(module_prefix)
        DEBUG_FLAG = any([flag in sys.argv for flag in [flag1, flag2]])
        for curflag in ARGV_DEBUG_FLAGS:
            if curflag in module_prefix:
                DEBUG_FLAG = True
        if __DEBUG_ALL__ or DEBUG or DEBUG_FLAG:
            print('INJECT_PRINT: %r == %r' % (module_name, module_prefix))
            def printDBG(*args):
                """ debug logging print """
                msg = ', '.join(map(str, args))
                util_logging.__UTOOL_PRINTDBG__(module_prefix + ' DEBUG ' + msg)
        else:
            def printDBG(*args):
                """ silent debug logging print """
                pass
    #_inject_funcs(module, print, print_, printDBG)
    print_funcs = (print, print_, printDBG)
    return print_funcs
576306
def extern_call(self, context_handle, func, args_ptr, args_len):
    """"""
    c = self._ffi.from_handle(context_handle)
    runnable = c.from_value(func[0])
    args = tuple(c.from_value(arg[0]) for arg in self._ffi.unpack(args_ptr, args_len))
    return self.call(c, runnable, args)
103414
def _pulse_method_call(pulse_op, func=None, index_arg=True):
		''''''
		def _wrapper(self, *args, **kws):
			if index_arg:
				if 'index' in kws: index = kws.pop('index')
				else: index, args = args[0], args[1:]
			pulse_args = func(*args, **kws) if func else list()
			if not is_list(pulse_args): pulse_args = [pulse_args]
			if index_arg: pulse_args = [index] + list(pulse_args)
			with self._pulse_op_cb() as cb:
				try: pulse_op(self._ctx, *(list(pulse_args) + [cb, None]))
				except c.ArgumentError as err: raise TypeError(err.args)
				except c.pa.CallError as err: raise PulseOperationInvalid(err.args[-1])
		func_args = list(inspect.getargspec(func or (lambda: None)))
		func_args[0] = list(func_args[0])
		if index_arg: func_args[0] = ['index'] + func_args[0]
		_wrapper.__name__ = '...'
		_wrapper.__doc__ = 'Signature: func' + inspect.formatargspec(*func_args)
		if func.__doc__: _wrapper.__doc__ += '\n\n' + func.__doc__
		return _wrapper