Readability for completion parts.

This commit is contained in:
Dave Halter
2016-05-19 11:33:17 +02:00
parent 323581e253
commit 055ff8be23
3 changed files with 24 additions and 20 deletions

View File

@@ -2,18 +2,22 @@
Helpers for the API
"""
import re
from collections import namedtuple
from jedi.parser import tree as pt
from jedi.evaluate import imports
def completion_parts(path_until_cursor):
CompletionParts = namedtuple('CompletionParts', ['path', 'has_dot', 'name'])
def get_completion_parts(path_until_cursor):
"""
Returns the parts for the completion
:return: tuple - (path, dot, like)
"""
match = re.match(r'^(.*?)(\.|)(\w?[\w\d]*)$', path_until_cursor, flags=re.S)
return match.groups()
path, dot, name = match.groups()
return CompletionParts(path, bool(dot), name)
def sorted_definitions(defs):