Exemple #1
0
 def complete(self, prefix):
     names = [sig for sig in signal.__dict__.keys() if
              sig.startswith('SIG')]
     nums  = [str(eval("signal."+name)) for name in names]
     lnames = [sig.lower() for sig in names]
     completions = lnames + nums + ['unconditional']
     return Mcomplete.complete_token(completions, prefix.lower())
Exemple #2
0
def complete_identifier(cmd, prefix):
    """Complete an arbitrary expression."""
    if not cmd.proc.curframe:
        return [None]
    # Collect globals and locals.  It is usually not really sensible to also
    # complete builtins, and they clutter the namespace quite heavily, so we
    # leave them out.
    ns = cmd.proc.curframe.f_globals.copy()
    ns.update(cmd.proc.curframe.f_locals)
    if "." in prefix:
        # Walk an attribute chain up to the last part, similar to what
        # rlcompleter does.  This will bail if any of the parts are not
        # simple attribute access, which is what we want.
        dotted = prefix.split(".")
        try:
            obj = ns[dotted[0]]
            for part in dotted[1:-1]:
                obj = getattr(obj, part)
        except (KeyError, AttributeError):
            return []
        pre_prefix = ".".join(dotted[:-1]) + "."
        return [pre_prefix + n for n in dir(obj) if n.startswith(dotted[-1])]
    else:
        # Complete a simple name.
        return Mcomplete.complete_token(ns.keys(), prefix)
Exemple #3
0
 def complete(self, prefix):
     names = [sig for sig in signal.__dict__.keys() if
              sig.startswith('SIG')]
     nums  = [str(eval("signal."+name)) for name in names]
     lnames = [sig.lower() for sig in names]
     completions = lnames + nums + ['unconditionally']
     return Mcomplete.complete_token(completions, prefix.lower())
Exemple #4
0
def complete_identifier(cmd, prefix):
    '''Complete an arbitrary expression.'''
    if not cmd.proc.curframe: return [None]
    # Collect globals and locals.  It is usually not really sensible to also
    # complete builtins, and they clutter the namespace quite heavily, so we
    # leave them out.
    ns = cmd.proc.curframe.f_globals.copy()
    ns.update(cmd.proc.curframe.f_locals)
    if '.' in prefix:
        # Walk an attribute chain up to the last part, similar to what
        # rlcompleter does.  This will bail if any of the parts are not
        # simple attribute access, which is what we want.
        dotted = prefix.split('.')
        try:
            obj = ns[dotted[0]]
            for part in dotted[1:-1]:
                obj = getattr(obj, part)
        except (KeyError, AttributeError):
            return []
        pre_prefix = '.'.join(dotted[:-1]) + '.'
        return [pre_prefix + n for n in dir(obj) if
                n.startswith(dotted[-1])]
    else:
        # Complete a simple name.
        return Mcomplete.complete_token(ns.keys(), prefix)
Exemple #5
0
 def complete(self, prefix):
     proc_obj = self.proc
     matches = Mcomplete.complete_token(
         list(categories.keys()) + ['*', 'all'] +
         list(proc_obj.commands.keys()), prefix)
     aliases = Mcomplete.complete_token_filtered(proc_obj.aliases, prefix,
                                                 matches)
     return sorted(matches + aliases)
Exemple #6
0
 def complete(self, prefix):
     proc_obj = self.proc
     matches = Mcomplete.complete_token(list(categories.keys())
                                        + ['*', 'all'] +
                                        list(proc_obj.commands.keys()),
                                        prefix)
     aliases = Mcomplete.complete_token_filtered(proc_obj.aliases, prefix,
                                                 matches)
     return sorted(matches + aliases)
Exemple #7
0
    def test_complete(self):

        hash = {'ab': 1, 'aac': 2, 'aa': 3, 'a': 4}
        ary = sorted(hash.keys())
        for result, prefix in [[[], 'b'], [ary, 'a'], [['aa', 'aac'], 'aa'],
                               [ary, ''], [['ab'], 'ab'], [[], 'abc']]:
            self.assertEqual(result, Mcomplete.complete_token(ary, prefix),
                             "Trouble matching %s on %s" % (repr(ary), prefix))
            pass
        for result_keys, prefix in [[ary, 'a'], [['aa', 'aac'], 'aa'],
                                    [['ab'], 'ab'], [[], 'abc']]:
            result = [[key, hash[key]] for key in result_keys]
            self.assertEqual(
                result, Mcomplete.complete_token_with_next(hash, prefix),
                "Trouble matching %s on %s" % (repr(hash), prefix))
            pass
        return
    def test_complete(self):

        hash = {'ab': 1, 'aac': 2, 'aa': 3, 'a':  4}
        ary = sorted(hash.keys())
        for result, prefix in [
                [[], 'b'], [ary, 'a'],
                [['aa', 'aac'], 'aa'],
                [ary, ''], [['ab'], 'ab'], [[], 'abc']]:
            self.assertEqual(result, Mcomplete.complete_token(ary, prefix),
                             "Trouble matching %s on %s" %
                              (repr(ary), prefix))
            pass
        for result_keys, prefix in [
            [ary, 'a'],
            [['aa', 'aac'], 'aa'],
            [['ab'], 'ab'], [[], 'abc']]:
            result = [[key, hash[key]] for key in result_keys]
            self.assertEqual(result,
                             Mcomplete.complete_token_with_next(hash, prefix),
                             "Trouble matching %s on %s" %
                             (repr(hash), prefix))
            pass
        return
Exemple #9
0
 def complete(self, prefix):
     completions = sorted(['*'] + self.debugger.sigmgr.siglist)
     return Mcomplete.complete_token(completions, prefix)
 def complete(self, prefix):
     return Mcomplete.complete_token(self.subcmds.subcmds.keys(), prefix)
Exemple #11
0
 def complete(self, prefix):
     m = sorted(list(self.proc.macros.keys()) + ["*"])
     return Mcomplete.complete_token(m, prefix)
Exemple #12
0
 def complete(self, prefix):
     result = Mcomplete.complete_token(("on", "off"), prefix)
     return result
Exemple #13
0
 def complete(self, prefix):
     completions = sorted(["."] + file_list())
     return Mcomplete.complete_token(completions, prefix)
Exemple #14
0
 def complete(self, prefix):
     completions = sorted(['*'] +
                           self.proc.curframe.f_locals.keys())
     return Mcomplete.complete_token(completions, prefix)
Exemple #15
0
def complete_break_linenumber(self, prefix):
    canonic_name = self.proc.curframe.f_code.co_filename
    completions = pyficache.trace_line_numbers(canonic_name)
    return Mcomplete.complete_token([str(i) for i in completions],
                                    prefix)
 def complete(self, prefix):
     result = Mcomplete.complete_token(('on', 'off'), prefix)
     return result
Exemple #17
0
 def complete(self, prefix):
     m = sorted(list(self.proc.macros.keys()) + ['*'])
     return Mcomplete.complete_token(m, prefix)
 def complete(self, prefix):
     return Mcomplete.complete_token(self.proc.aliases.keys(), prefix)
Exemple #19
0
def complete_id_and_builtins(cmd, prefix):
    if not cmd.proc.curframe: return [None]
    items = (list(cmd.proc.curframe.f_builtins.keys()) +
             complete_identifier(cmd, prefix))
    return Mcomplete.complete_token(items, prefix)
 def complete(self, prefix):
     completions = sorted(['*'] + self.debugger.sigmgr.siglist)
     return Mcomplete.complete_token(completions, prefix)
Exemple #21
0
 def complete(self, prefix):
     result = Mcomplete.complete_token(('on', 'off'), prefix)
     return result
Exemple #22
0
 def complete(self, prefix):
     proc_obj = self.proc
     low, high = Mframe.frame_low_high(proc_obj, None)
     ary = [str(low+i) for i in range(high-low+1)]
     # FIXME: add in Thread names
     return Mcomplete.complete_token(ary, prefix)
Exemple #23
0
def frame_complete(proc_obj, prefix, direction):
    low, high = frame_low_high(proc_obj, direction)
    ary = [str(low+i) for i in range(high-low+1)]
    return Mcomplete.complete_token(ary, prefix)
Exemple #24
0
 def complete(self, prefix):
     completions = [str(disp.number) for disp in self.proc.display_mgr.list]
     return Mcomplete.complete_token(completions, prefix)
Exemple #25
0
 def complete(self, prefix):
     proc_obj = self.proc
     low, high = Mframe.frame_low_high(proc_obj, None)
     ary = [str(low + i) for i in range(high - low + 1)]
     # FIXME: add in Thread names
     return Mcomplete.complete_token(ary, prefix)
Exemple #26
0
 def complete(self, prefix):
     return Mcomplete.complete_token(style_names, prefix)
 def complete(self, prefix):
     return Mcomplete.complete_token(SetHighlight.highlight_choices, prefix)
Exemple #28
0
 def complete(self, prefix):
     completions = [str(disp.number) for disp in self.proc.display_mgr.list]
     return Mcomplete.complete_token(completions, prefix)
Exemple #29
0
 def complete(self, prefix):
     return Mcomplete.complete_token(style_names, prefix)
Exemple #30
0
 def complete(self, prefix):
     return complete_token(SetLogLevel.logger_choices, prefix)
Exemple #31
0
def complete_break_linenumber(self, prefix):
    canonic_name = self.proc.curframe.f_code.co_filename
    completions = pyficache.trace_line_numbers(canonic_name)
    return Mcomplete.complete_token([str(i) for i in completions], prefix)
Exemple #32
0
 def complete(self, prefix):
     completions = sorted(['.'] + file_list())
     return Mcomplete.complete_token(completions, prefix)
Exemple #33
0
def complete_id_and_builtins(cmd, prefix):
    if not cmd.proc.curframe:
        return [None]
    items = list(cmd.proc.curframe.f_builtins.keys()) + complete_identifier(cmd, prefix)
    return Mcomplete.complete_token(items, prefix)
Exemple #34
0
 def complete(self, prefix):
     # files = Readline::FILENAME_COMPLETION_PROC.call(prefix) || []
     opts = ["-v", "-Y", "-N", "-c"]  # + files
     return complete_token(opts, prefix)
Exemple #35
0
 def complete(self, prefix):
     return Mcomplete.complete_token(self.subcmds.subcmds.keys(), prefix)
Exemple #36
0
 def complete(self, prefix):
     return Mcomplete.complete_token(SetHighlight.highlight_choices,
                                     prefix)
Exemple #37
0
 def complete(self, prefix):
     # files = Readline::FILENAME_COMPLETION_PROC.call(prefix) || []
     opts = ['-v', '-Y', '-N', '-c']  # + files
     return Mcomplete.complete_token(opts, prefix)
Exemple #38
0
 def complete(self, prefix):
     return complete_token(choices, prefix)
Exemple #39
0
 def complete(self, prefix):
     completions = sorted(['*'] + self.proc.curframe.f_locals.keys())
     return Mcomplete.complete_token(completions, prefix)
Exemple #40
0
 def complete(self, prefix):
     return Mcomplete.complete_token(self.proc.aliases.keys(), prefix)
 def complete(self, prefix):
     # files = Readline::FILENAME_COMPLETION_PROC.call(prefix) || []
     opts = ['-v', '-Y', '-N', '-c']  # + files
     return Mcomplete.complete_token(opts, prefix)
Exemple #42
0
def frame_complete(proc_obj, prefix, direction):
    low, high = frame_low_high(proc_obj, direction)
    ary = [str(low + i) for i in range(high - low + 1)]
    return Mcomplete.complete_token(ary, prefix)