当前位置: 首页>>代码示例>>Python>>正文


Python readline.set_completer_delims函数代码示例

本文整理汇总了Python中readline.set_completer_delims函数的典型用法代码示例。如果您正苦于以下问题:Python set_completer_delims函数的具体用法?Python set_completer_delims怎么用?Python set_completer_delims使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了set_completer_delims函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: launch_ui

def launch_ui(args):
    # Setup tab completion
    try:
        import readline
    except ImportError:
        print('%s[!] Module \'readline\' not available. Tab complete disabled.%s' % (Colors.R, Colors.N))
    else:
        import rlcompleter
        if 'libedit' in readline.__doc__:
            readline.parse_and_bind('bind ^I rl_complete')
        else:
            readline.parse_and_bind('tab: complete')
            readline.set_completer_delims(re.sub('[/-]', '', readline.get_completer_delims()))
    # Instantiate the UI object
    x = cli.CLI(cli.Mode.CONSOLE)
    # check for and run version check
    if args.check:
        if not x.version_check(): return
    # Check for and run script session
    if args.script_file:
        x.do_resource(args.script_file)
    # Run the UI
    try: 
        x.cmdloop()
    except KeyboardInterrupt: 
        print('')
开发者ID:mwrlabs,项目名称:needle,代码行数:26,代码来源:needle.py

示例2: h5py_attr_completer

def h5py_attr_completer(context, command):
    """Compute possible attr matches for nested dict-like objects"""

    base, attr = re_attr_match.split(command)[1:3]
    base = base.strip()

    try:
        assert '(' not in base
    except AssertionError:
        raise ValueError()

    try:
        obj = eval(base, context.shell.user_ns)
    except:
        return []

    attrs = dir(obj)
    try:
        attrs = generics.complete_object(obj, attrs)
    except TryNext:
        pass

    try:
        omit__names = ipget().readline_omit__names
    except AttributeError:
        # support <ipython-0.11
        omit__names = ipget().options.readline_omit__names
    if omit__names == 1:
        attrs = [a for a in attrs if not a.startswith('__')]
    elif omit__names == 2:
        attrs = [a for a in attrs if not a.startswith('_')]

    readline.set_completer_delims(' =')

    return ["%s.%s" % (base, a) for a in attrs if a[:len(attr)] == attr]
开发者ID:Juxi,项目名称:OpenSignals,代码行数:35,代码来源:ipy_completer.py

示例3: main

    def main(self, argv):
        cmd_args = argv[1:]
        if cmd_args:
            cmd_line = u' '.join(cmd_args)
            cmds = cmd_line.split(';')
            for cmd in cmds:
                ret = self.onecmd(cmd)
                if ret:
                    return ret
        elif self.DISABLE_REPL:
            self._parser.print_help()
            self._parser.exit()
        else:
            try:
                import readline
            except ImportError:
                pass
            else:
                # Remove '-' from delims
                readline.set_completer_delims(readline.get_completer_delims().replace('-', ''))

                history_filepath = os.path.join(self.weboob.workdir, '%s_history' % self.APPNAME)
                try:
                    readline.read_history_file(history_filepath)
                except IOError:
                    pass

                def savehist():
                    readline.write_history_file(history_filepath)
                atexit.register(savehist)

            self.intro += '\nLoaded backends: %s\n' % ', '.join(sorted(backend.name for backend in self.weboob.iter_backends()))
            self._interactive = True
            self.cmdloop()
开发者ID:blckshrk,项目名称:Weboob,代码行数:34,代码来源:repl.py

示例4: main

def main(files=[]):
    printtty(colorize('> ', PROMPT_COLOR) + "; Type HELP to get the HELP")
    printtty(colorize('> ', PROMPT_COLOR) +
           "; Completion is activated using the tab (if supported by the terminal)")

    for i in files:
        load_relation(i)

    readline.set_completer(completer.complete)

    readline.parse_and_bind('tab: complete')
    readline.parse_and_bind('set editing-mode emacs')
    readline.set_completer_delims(" ")

    while True:
        try:

            line = input(colorize('> ' if TTY else '', PROMPT_COLOR))
            if isinstance(line, str) and len(line) > 0:
                exec_line(line)
        except KeyboardInterrupt:
            if TTY:
                print ('^C\n')
                continue
            else:
                break
        except EOFError:
            printtty()
            sys.exit(0)
开发者ID:chippography,项目名称:relational,代码行数:29,代码来源:linegui.py

示例5: file_chooser

def file_chooser(prompt_text = "Enter File: ", default=None, filearg=[], filekwarg={}):
    """A simple tool to get a file from the user. Takes keyworded arguemnts
    and passes them to open().
    
    If the user enters nothing the function will return the ``default`` value.
    Otherwise it continues to prompt the user until it get's a decent response.
    
    filekwarg may contain arguements passed on to ``open()``.
    """
    try:
        import readline, rlcomplete
        completer = rlcomplete.PathCompleter()
        readline.set_completer_delims(completer.delims)
        readline.parse_and_bind("tab: complete")
        readline.set_completer(completer.complete)
    except ImportError:
        pass
    while True:
        f = raw_input(prompt_text)
        if f == '': return default
        f = os.path.expanduser(f)
        if len(f) != 0 and f[0] == os.path.sep:
            f = os.path.abspath(f)
        try:
            return open(f, *filearg, **filekwarg)
        except IOError, e:
            stderr.write(ERROR_MESSAGE % ("unable to open %s : %s" % (f, e)))
开发者ID:Heldroe,项目名称:fabulous,代码行数:27,代码来源:prompt.py

示例6: sshcheck

def sshcheck():
  attacks = {}
  users = {}
  try:
    import readline, rlcompleter
    readline.set_completer_delims(' \t\n;')
    readline.parse_and_bind("tab: complete")
    readline.set_completer(complete)
  except ImportError:
    print 'No Tab Completion'
  LOGs = raw_input('Enter the path to the log file: ')
  for LOG in LOGs.split(' '):
    if LOG.endswith('.gz'):
      auth_logs = gzip.GzipFile(LOG, 'r')
    else:
      auth_logs = open(LOG, 'r')
    if len(LOGs) is '1':
      print "Parsing log file"
    else:
      print "Parsing log files"
    for log in auth_logs:
      l = {"raw": log }
      normalizer.normalize(l)
      if l.get('action') == 'fail' and l.get('program') == 'sshd':
        u = l['user']
        p = l['source_ip']
        o1, o2, o3, o4 = [int(i) for i in p.split('.')]
        if o1 == 192 and o2 == 168 or o1 == 172 and o2 in range(16, 32) or o1 == 10:
          print "Private IP, %s No geolocation data" %str(p)
        attacks[p] = attacks.get(p, 0) + 1
  getip()
  dojson(attacks, IP)
开发者ID:radman404,项目名称:Who-s-attacking-me-now--,代码行数:32,代码来源:wamnclient.py

示例7: exec_cmdloop

    def exec_cmdloop(self, args, options):
        try:
            import readline
            delims = readline.get_completer_delims()
            delims = delims.replace(':', '')  # "group:process" as one word
            delims = delims.replace('*', '')  # "group:*" as one word
            delims = delims.replace('-', '')  # names with "-" as one word
            readline.set_completer_delims(delims)

            if options.history_file:
                try:
                    readline.read_history_file(options.history_file)
                except IOError:
                    pass

                def save():
                    try:
                        readline.write_history_file(options.history_file)
                    except IOError:
                        pass

                import atexit
                atexit.register(save)
        except ImportError:
            pass
        try:
            self.cmdqueue.append('status')
            self.cmdloop()
        except KeyboardInterrupt:
            self.output('')
            pass
开发者ID:maoshuyu,项目名称:supervisor,代码行数:31,代码来源:supervisorctl.py

示例8: set_completer

def set_completer(options=None):
    if options:
        completer = InputCompleter(options)
        readline.set_completer(completer.complete)
        readline.set_completer_delims('')
    else:
        readline.set_completer(None)
开发者ID:flywire,项目名称:qifqif,代码行数:7,代码来源:ui.py

示例9: __init__

    def __init__(self, command_line):
        self.status = {}
        self.status['log_started'] = False
        self.status['resource_found'] = False
        self.status['command_line'] = command_line
        self.status['file_found'] = False

        self.global_config = {}
        self.tools = []
        self.assessments = []
        self.job_queue = []

        self.arguments = ddict_options = defaultdict(lambda : '')

        self.instance = {}
        self.instance['tool'] = []
        self.instance['config'] = {}

        self.load("tools")
        self.load("assessments")
        self.load("global_config")

        # Remove / from completer delim so tab completion works
        # with tool/nmap, for example
        old_delims = readline.get_completer_delims()
        readline.set_completer_delims(old_delims.replace('/', ''))
开发者ID:rubicondimitri,项目名称:autopwn,代码行数:26,代码来源:__init__.py

示例10: run_shell

    def run_shell(self):
        '''Run shell.'''

        run = 1

        self.load_shell_history()

        readline.parse_and_bind('tab: complete')
        readline.set_completer(self.shell_completer2)
        readline.set_completer_delims(
            ' \t\n`[email protected]#$%^&*()=+[{]}\\|;:\'",<>/?')

        while run:
            try:

                comm = raw_input("# ")
            
            except EOFError:

                print('')
                sys.exit(0)

            self.simple_parse(comm)

            if comm == 'quit':

                run = 0

        return
开发者ID:dvoraka,项目名称:pyvirsh,代码行数:29,代码来源:pyvirsh.py

示例11: run

    def run(self, script_file=None):
        """Run the python interpreter.

        The namespace of this function is the namespace seen inside the interpreter.  All user
        accessible functions, classes, etc, should be placed in this namespace.


        @param script_file: The script file to be executed.  For the interpreter mode, this
                            should be left as None.
        @type script_file:  None or str
        """

        # Add the interpreter objects to the local run namespace.
        for name in self._locals.keys():
            locals()[name] = self._locals[name]

        # Setup tab completion.
        if dep_check.readline_module:
            readline.set_completer(Tab_completion(name_space=locals()).finish)
            readline.set_completer_delims(' \t\n`[email protected]#$%^&*()=+{}\\|;:",<>/?')
            readline.parse_and_bind("tab: complete")

        # Execute the script file if given.
        if script_file:
            # Turn on the user function intro flag.
            status.uf_intro = True

            # Run the script.
            return run_script(intro=self.__intro_string, local=locals(), script_file=script_file, quit=self.__quit_flag, show_script=self.__show_script, raise_relax_error=self.__raise_relax_error)

        # Go to the prompt.
        else:
            prompt(intro=self.__intro_string, local=locals())
开发者ID:belisario21,项目名称:relax_trunk,代码行数:33,代码来源:interpreter.py

示例12: __init__

    def __init__(self, admin_cli):
        # remove stdout stream encoding while in 'shell' mode, becuase this breaks readline
        # (autocompletion and shell history). In 'shell' mode the stdout
        # is encoded just for time necessary for command execution see precmd a postcmd

        sys.stdout = stdout_origin
        self.stdout_with_codec = encode_stream(sys.stdout, "utf-8")

        self.completion_matches = None
        Cmd.__init__(self)
        self.admin_cli = admin_cli
        self.completion = Completion(self.admin_cli)
        try:
            Config()
            self.prompt = Config.parser.get('shell', 'prompt') + ' '
        except (ConfigFileError, ConfigParser.Error):
            self.prompt = 'katello> '

        try:
            # don't split on hyphens during tab completion (important for completing parameters)
            newdelims = readline.get_completer_delims()
            newdelims = re.sub('-', '', newdelims)
            readline.set_completer_delims(newdelims)

            if (Config.parser.get('shell', 'nohistory').lower() != 'true'):
                self.__init_history()
        except ConfigParser.Error:
            pass
        self.__init_commands()
开发者ID:bcrochet,项目名称:katello,代码行数:29,代码来源:shell.py

示例13: interactive

 def interactive(self):
     print "Command list: " + ", ".join(self.cmd_list)
     try:
         readline.set_completer(SuricataCompleter(self.cmd_list))
         readline.set_completer_delims(";")
         readline.parse_and_bind('tab: complete')
         while True:
             command = raw_input(">>> ").strip()
             if command == "quit":
                 break;
             try:
                 (cmd, arguments) = self.parse_command(command)
             except SuricataCommandException, err:
                 print err
                 continue
             cmdret = self.send_command(cmd, arguments)
             #decode json message
             if cmdret["return"] == "NOK":
                 print "Error:"
                 print json.dumps(cmdret["message"], sort_keys=True, indent=4, separators=(',', ': '))
             else:
                 print "Success:"
                 print json.dumps(cmdret["message"], sort_keys=True, indent=4, separators=(',', ': '))
     except KeyboardInterrupt:
         print "[!] Interrupted"
开发者ID:BreakingTheory,项目名称:suricata,代码行数:25,代码来源:suricatasc.py

示例14: __init__

    def __init__(self):
        main = sys.modules.pop('__main__')
        try:
            self.dummy_main = new.module('__main__')
            sys.modules['__main__'] = self.dummy_main
            from rlcompleter import Completer as RlCompleter
            self.python_completer = RlCompleter()
        finally:
            sys.modules['__main__'] = main

        readline.set_completer_delims(' \t\n;`\"()')
        readline.parse_and_bind('tab: complete')
        readline.set_completer(self.complete)
        base_dir = os.path.expanduser('~/.dq')
        if not os.path.exists(base_dir):
            try:
                os.mkdir(base_dir)
            except IOError:
                pass

        hist_file = os.path.join(base_dir, 'hist')
        try:
            readline.read_history_file(hist_file)
        except IOError:
            pass
        
        atexit.register(readline.write_history_file, hist_file)

        init_file = os.path.join(base_dir, 'init')
        if os.path.exists(init_file):
            with open(init_file, 'r') as f:
                self.run_script(f.read())

        self.sql = ''
开发者ID:eclipselu,项目名称:dpark,代码行数:34,代码来源:dquery.py

示例15: setup

    def setup(self):
        """ Initialization of third-party libraries

        Setting interpreter history.
        Setting appropriate completer function.

        :return:
        """
        if not os.path.exists(self.history_file):
            with open(self.history_file, 'a+') as history:
                if is_libedit():
                    history.write("_HiStOrY_V2_\n\n")

        readline.read_history_file(self.history_file)
        readline.set_history_length(self.history_length)
        atexit.register(readline.write_history_file, self.history_file)

        readline.parse_and_bind('set enable-keypad on')

        readline.set_completer(self.complete)
        readline.set_completer_delims(' \t\n;')
        if is_libedit():
            readline.parse_and_bind("bind ^I rl_complete")
        else:
            readline.parse_and_bind("tab: complete")
开发者ID:zongdeiqianxing,项目名称:routersploit,代码行数:25,代码来源:interpreter.py


注:本文中的readline.set_completer_delims函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。