summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bases.py2
-rw-r--r--manager.py60
-rw-r--r--scoped_nodes.py2
3 files changed, 29 insertions, 35 deletions
diff --git a/bases.py b/bases.py
index af988445..ea3c9c6c 100644
--- a/bases.py
+++ b/bases.py
@@ -168,7 +168,7 @@ class Instance(Proxy):
if lookupclass:
# class attributes not available through the instance
# unless they are explicitly defined
- if name in ('__name__', '__bases__', '__mro__'):
+ if name in ('__name__', '__bases__', '__mro__', '__subclasses__'):
return self._proxied.local_attr(name)
return self._proxied.getattr(name, context)
raise NotFoundError(name)
diff --git a/manager.py b/manager.py
index 376c686e..746dd73a 100644
--- a/manager.py
+++ b/manager.py
@@ -263,39 +263,33 @@ class ASTNGManager(OptionsProviderMixIn):
def project_from_files(self, files, func_wrapper=astng_wrapper,
project_name=None, black_list=None):
"""return a Project from a list of files or modules"""
- # insert current working directory to the python path to have a correct
- # behaviour
- sys.path.insert(0, os.getcwd())
- try:
- # build the project representation
- project_name = project_name or self.config.project
- black_list = black_list or self.config.black_list
- project = Project(project_name)
- for something in files:
- if not exists(something):
- fpath = file_from_modpath(something.split('.'))
- elif isdir(something):
- fpath = join(something, '__init__.py')
- else:
- fpath = something
- astng = func_wrapper(self.astng_from_file, fpath)
- if astng is None:
- continue
- project.path = project.path or astng.file
- project.add_module(astng)
- base_name = astng.name
- # recurse in package except if __init__ was explicitly given
- if astng.package and something.find('__init__') == -1:
- # recurse on others packages / modules if this is a package
- for fpath in get_module_files(dirname(astng.file),
- black_list):
- astng = func_wrapper(self.astng_from_file, fpath)
- if astng is None or astng.name == base_name:
- continue
- project.add_module(astng)
- return project
- finally:
- sys.path.pop(0)
+ # build the project representation
+ project_name = project_name or self.config.project
+ black_list = black_list or self.config.black_list
+ project = Project(project_name)
+ for something in files:
+ if not exists(something):
+ fpath = file_from_modpath(something.split('.'))
+ elif isdir(something):
+ fpath = join(something, '__init__.py')
+ else:
+ fpath = something
+ astng = func_wrapper(self.astng_from_file, fpath)
+ if astng is None:
+ continue
+ project.path = project.path or astng.file
+ project.add_module(astng)
+ base_name = astng.name
+ # recurse in package except if __init__ was explicitly given
+ if astng.package and something.find('__init__') == -1:
+ # recurse on others packages / modules if this is a package
+ for fpath in get_module_files(dirname(astng.file),
+ black_list):
+ astng = func_wrapper(self.astng_from_file, fpath)
+ if astng is None or astng.name == base_name:
+ continue
+ project.add_module(astng)
+ return project
diff --git a/scoped_nodes.py b/scoped_nodes.py
index b53ec4e5..c890661f 100644
--- a/scoped_nodes.py
+++ b/scoped_nodes.py
@@ -651,7 +651,7 @@ class Class(StmtMixIn, LocalsDictNodeNG, FilterStmtsMixin):
instance_attrs = None
special_attributes = set(('__name__', '__doc__', '__dict__', '__module__',
- '__bases__', '__mro__'))
+ '__bases__', '__mro__', '__subclasses__'))
blockstart_tolineno = None