Пример #1
0
    def run_completer(self, parser, command, point=None, completer=autocomplete, **kwargs):
        command = ensure_str(command)

        if point is None:
            point = str(len(command))
        with TemporaryFile() as t:
            os.environ["COMP_LINE"] = ensure_bytes(command) if USING_PYTHON2 else command
            os.environ["COMP_POINT"] = point
            self.assertRaises(SystemExit, completer, parser, output_stream=t,
                              exit_method=sys.exit, **kwargs)
            t.seek(0)
            return t.read().decode(sys_encoding).split(IFS)
Пример #2
0
 def run_completer(self, parser, command, point=None, **kwargs):
     command = ensure_str(command)
     if point is None:
         # Adjust point for wide chars
         point = str(len(command.encode(sys_encoding)))
     with TemporaryFile() as t:
         os.environ["COMP_LINE"] = ensure_bytes(command) if USING_PYTHON2 else command
         os.environ["COMP_POINT"] = point
         os.environ["_ARGCOMPLETE_COMP_WORDBREAKS"] = '"\'@><=;|&(:'
         self.assertRaises(SystemExit, autocomplete, parser, output_stream=t,
                           exit_method=sys.exit, **kwargs)
         t.seek(0)
         return t.read().decode(sys_encoding).split(IFS)
Пример #3
0
 def run_completer(self, parser, command, point=None, **kwargs):
     command = ensure_str(command)
     if point is None:
         # Adjust point for wide chars
         point = str(len(command.encode(sys_encoding)))
     with TemporaryFile() as t:
         os.environ["COMP_LINE"] = ensure_bytes(command) if USING_PYTHON2 else command
         os.environ["COMP_POINT"] = point
         os.environ["_ARGCOMPLETE_COMP_WORDBREAKS"] = '"\'@><=;|&(:'
         self.assertRaises(SystemExit, autocomplete, parser, output_stream=t,
                           exit_method=sys.exit, **kwargs)
         t.seek(0)
         return t.read().decode(sys_encoding).split(IFS)