Commit 6524eaea authored by Jérome Perrin's avatar Jérome Perrin

patches/pylint: update register_xpkg for python3

parent 735c66af
...@@ -534,12 +534,20 @@ def register_xpkg(pkgname): ...@@ -534,12 +534,20 @@ def register_xpkg(pkgname):
except ImportError: except ImportError:
pass pass
else: else:
if six.PY2:
def xpkg_transform(node): def xpkg_transform(node):
m = AstroidBuilder(MANAGER).string_build('__path__ = %r' % pkg.__path__) m = AstroidBuilder(MANAGER).string_build('__path__ = %r' % pkg.__path__)
m.package = True m.package = True
m.name = pkgname m.name = pkgname
return m return m
MANAGER.register_transform(Module, xpkg_transform, lambda node: node.name == pkgname) MANAGER.register_transform(Module, xpkg_transform, lambda node: node.name == pkgname)
else:
import importlib
def fail_hook_xpkg(modname):
if modname.split('.')[0] == pkgname:
return MANAGER.ast_from_module(importlib.import_module(modname))
raise AstroidBuildingError()
MANAGER.register_failed_import_hook(fail_hook_xpkg)
register_xpkg('wendelin') register_xpkg('wendelin')
register_xpkg('xlte') register_xpkg('xlte')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment