Hi Bryan, I just stepped over a curious problem: While `import pygments.lexers` works fine, `hookutils.collect_submodules()` fails with an AtrributeError in /usr/lib/python2.7/site-packages/pygments/lexers/__init__.py.
I tracked this down to hookutils.get_module_file_attribute() using
`__import__('pygments.lexers', fromlist=_fromlist)` which fails (the
real code is a bit different, but this does not matter).
Why did you choose __import__ instead of using code like this (or even
use the imptracker)?
import sys, imp
parts = package.split('.')
path = sys.path
for i, name in enumerate(parts):
print
print name, path
try:
m = imp.find_module(name, path)
except ImportError:
raise ImportError('xNo module named %s' % '.'.join(parts[:i+1]))
if m[-1][-1] == imp.PKG_DIRECTORY:
path = [m[1]]
else:
print 'result:', m[1]
get_package_paths() then could be adopted, too.
What do you think? Bryan: Are you willed implementing this? (Or should
we wait until we switched to modulegraph?)
--
Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP
Information Security Management, Security Governance, Secure Software
Development
Goebel Consult, Landshut
http://www.goebel-consult.de
Blog:
http://www.goebel-consult.de/blog/alternative-zu-small-business-server-in-der-ct
Kolumne:
http://www.cissp-gefluester.de/2012-04-compliance-bringt-keine-sicherheit
Goebel Consult ist Mitglied bei http://www.7-it.de/
smime.p7s
Description: S/MIME Cryptographic Signature
