changed module name checking (should only be in one place)

This commit is contained in:
David Halter
2013-05-03 14:09:46 +04:30
parent da067c5c38
commit cc520530c0

View File

@@ -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."""