mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 14:34:31 +08:00
changed module name checking (should only be in one place)
This commit is contained in:
@@ -5,8 +5,6 @@ interesting information about completion and goto operations.
|
|||||||
"""
|
"""
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
|
||||||
import re
|
|
||||||
import os
|
|
||||||
import warnings
|
import warnings
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
@@ -81,8 +79,7 @@ class BaseDefinition(object):
|
|||||||
|
|
||||||
# generate a path to the definition
|
# generate a path to the definition
|
||||||
self._module = definition.get_parent_until()
|
self._module = definition.get_parent_until()
|
||||||
p = self._module.path
|
self.module_path = self._module.path
|
||||||
self.module_path = p if p is None else unicode(p)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def type(self):
|
def type(self):
|
||||||
@@ -164,12 +161,8 @@ class BaseDefinition(object):
|
|||||||
>>> d = script.definition()[0]
|
>>> d = script.definition()[0]
|
||||||
>>> print(d.module_name) # doctest: +ELLIPSIS
|
>>> print(d.module_name) # doctest: +ELLIPSIS
|
||||||
datetime
|
datetime
|
||||||
|
|
||||||
"""
|
"""
|
||||||
path = self.module_path
|
return str(self._module.name)
|
||||||
sep = os.path.sep
|
|
||||||
p = re.sub(r'^.*?([\w\d]+)(%s__init__)?.(py|so)$' % sep, r'\1', path)
|
|
||||||
return p
|
|
||||||
|
|
||||||
def in_builtin_module(self):
|
def in_builtin_module(self):
|
||||||
"""Whether this is a builtin module."""
|
"""Whether this is a builtin module."""
|
||||||
|
|||||||
Reference in New Issue
Block a user