Ah, thanks! That makes more sense.
I have no problem pulling pylint into my project and using expand_modules to build out my tree of modules/packages, but it does seem like a useful thing to have in astroid. Wherever that specific function belongs, it'd be nice to have a little documentation for astroid to help guide newbies like myself to the right functionality.
Tangentially, has anybody looked at my ticket about line info for the end of list/bracket elements ( https://bitbucket.org/logilab/astroid/issue/31/astroid-sometimes-reports-the... If it matters to anybody else, I'd be happy to take a stab at fixing it -- if not, I might handle it on my end in my own project.
On Tue, May 27, 2014 at 11:33 PM, Sylvain Thénault < sylvain.thenault@logilab.fr> wrote:
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