Пример #1
0
    def get_completions(self, info):
        """Return a list of (completion, type) tuples

        Simple completion based on python-like identifiers and whitespace
        """
        items = []
        line = info.line.strip()
        is_from = line.startswith('from')
        if ((line.startswith('import') or is_from and ' import' not in line)
                and info.is_python_like):
            items += module_completion(info.line, [info.filename])
            return [(i, 'module') for i in sorted(items)]
        elif is_from and info.is_python_like:
            items += module_completion(info.line, [info.filename])
            return [(i, '') for i in sorted(items)]
        elif info.obj:
            base = info.obj
            tokens = set(info.split_words(-1))
            items = [item for item in tokens if
                     item.startswith(base) and len(item) > len(base)]
            if '.' in base:
                start = base.rfind('.') + 1
            else:
                start = 0

            items = [i[start:len(base)] + i[len(base):].split('.')[0]
                     for i in items]
            # get path completions
            # get last word back to a space or a quote character
            match = re.search('''[ "\']([\w\.\\\\/]+)\Z''', info.line)
            if match:
                items += _complete_path(match.groups()[0])
            return [(i, '') for i in sorted(items)]
Пример #2
0
 def getmodcomplist(self, name, path):
     """Return module completion list for object named *name*"""
     return module_completion(name, path)
Пример #3
0
 def getmodcomplist(self, name, path):
     """Return module completion list for object named *name*"""
     return module_completion(name, path)