diff options
| author | Emile Anclin <emile.anclin@logilab.fr> | 2010-09-02 19:01:42 +0200 |
|---|---|---|
| committer | Emile Anclin <emile.anclin@logilab.fr> | 2010-09-02 19:01:42 +0200 |
| commit | 1fbb30774758b0e4056f3617cc0d7a51ac1247fa (patch) | |
| tree | 3808b4626e1abf3dd1e9245a0ff89481243d123a | |
| parent | dc0cc3fe184a03c3f4e1828635949f3663b64767 (diff) | |
| download | astroid-git-1fbb30774758b0e4056f3617cc0d7a51ac1247fa.tar.gz | |
remove sys.path.insert from project_from_files
This method is only used by Pyrevevers and we have to insert the
cwd to the PYTHONPATH there.
| -rw-r--r-- | manager.py | 60 |
1 files changed, 27 insertions, 33 deletions
@@ -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 |
