Commit b27d23e3 authored by Jérome Perrin's avatar Jérome Perrin

patches/pylint: update register_xpkg for python3

parent 7dd644ec
...@@ -524,12 +524,20 @@ def register_xpkg(pkgname): ...@@ -524,12 +524,20 @@ def register_xpkg(pkgname):
except ImportError: except ImportError:
pass pass
else: else:
def xpkg_transform(node): if six.PY2:
m = AstroidBuilder(MANAGER).string_build('__path__ = %r' % pkg.__path__) def xpkg_transform(node):
m.package = True m = AstroidBuilder(MANAGER).string_build('__path__ = %r' % pkg.__path__)
m.name = pkgname m.package = True
return m m.name = pkgname
MANAGER.register_transform(Module, xpkg_transform, lambda node: node.name == pkgname) return m
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