On 27 mai 15:32, David Jackson wrote: > Hi, guys, Hi, > I'm trying to build a code-intelligence tool for myself on top of astroid, > and I'm confused about the way that astroid decides how to name modules, > and when to include __init__ files in the project. I've been creating my > astroid projects like this: > > AstroidManager().project_from_files([project_path]) > > where project_path is an absolute filesystem path to the root of my project. > > In some cases, the module names in the resulting project are the absolute > path to the file. In other cases, they're the 'dot-notation' path with my > project name prepended (e.g. 'my_project.some_root_level_module'), and in > still others, they're the dot-notation path without the project name (e.g. > 'some_root_level_module'). I've also noticed that only some of the > __init__.py files in my project get added as modules. > > As far as I can tell, this has something to do with whether or not the > project source is contained within the current Python path. Even then, I'm > still getting inconsistent behavior. Could someone explain to me how the > names are supposed to work, and when __init__ files are registered with the > project?
Huuum, astroid's Project class is only used by pyreverse and as such is not the more active part of astroid... Pylint does such job by itself, take a look at the pylint.utils.expand_modules function. If there is some interest for external use, we could backport it to astroid, and even use it for Project. -- Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (05.62.17.16.42) Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations Développement logiciel sur mesure: http://www.logilab.fr/services CubicWeb, the semantic web framework: http://www.cubicweb.org _______________________________________________ code-quality mailing list code-quality@python.org https://mail.python.org/mailman/listinfo/code-quality