Exemplo n.º 1
0
 def matches(self, cursor_offset, line, locals_, **kwargs):
     r = self.locate(cursor_offset, line)
     if r is None:
         return None
     start, end, orig = r
     _, _, dexpr = lineparts.current_dict(cursor_offset, line)
     try:
         obj = safe_eval(dexpr, locals_)
     except EvaluationError:
         return set()
     if isinstance(obj, dict) and obj.keys():
         return set("{0!r}]".format(k) for k in obj.keys()
                    if repr(k).startswith(orig))
     else:
         return set()
Exemplo n.º 2
0
    def matches(self, cursor_offset, line, **kwargs):
        if 'locals_' not in kwargs:
            return None
        locals_ = kwargs['locals_']

        r = self.locate(cursor_offset, line)
        if r is None:
            return None
        _, _, dexpr = lineparts.current_dict(cursor_offset, line)
        try:
            obj = safe_eval(dexpr, locals_)
        except EvaluationError:
            return set()
        if isinstance(obj, dict) and obj.keys():
            return set("{0!r}]".format(k) for k in obj.keys()
                       if repr(k).startswith(r.word))
        else:
            return set()
Exemplo n.º 3
0
    def matches(self, cursor_offset, line, **kwargs):
        if 'locals_' not in kwargs:
            return None
        locals_ = kwargs['locals_']

        r = self.locate(cursor_offset, line)
        if r is None:
            return None
        _, _, dexpr = lineparts.current_dict(cursor_offset, line)
        try:
            obj = safe_eval(dexpr, locals_)
        except EvaluationError:
            return set()
        if isinstance(obj, dict) and obj.keys():
            return set("{0!r}]".format(k) for k in obj.keys()
                       if repr(k).startswith(r.word))
        else:
            return set()