Commit 4426de1b authored by Julien Muchembled's avatar Julien Muchembled

pylint: various fixups

- start supporting newer astroid (untested)
- lxml so files can be installed with names like
  'builder.x86_64-linux-gnu.so'
parent 1a6f0c0e
...@@ -291,7 +291,10 @@ register_module_extender(MANAGER, 'AccessControl.PermissionRole', ...@@ -291,7 +291,10 @@ register_module_extender(MANAGER, 'AccessControl.PermissionRole',
## Package dynamically extending the namespace of their modules with C ## Package dynamically extending the namespace of their modules with C
## extension symbols ## extension symbols
# astroid/brain/ added dynamically to sys.path by astroid __init__ # astroid/brain/ added dynamically to sys.path by astroid __init__
from py2gi import _gi_build_stub as build_stub try:
from brain_gi import _gi_build_stub as build_stub
except ImportError: # BBB: old version of astroid
from py2gi import _gi_build_stub as build_stub
def _register_module_extender_from_live_module(module_name, module): def _register_module_extender_from_live_module(module_name, module):
def transform(): def transform():
return AstroidBuilder(MANAGER).string_build(build_stub(module)) return AstroidBuilder(MANAGER).string_build(build_stub(module))
...@@ -322,7 +325,7 @@ import lxml ...@@ -322,7 +325,7 @@ import lxml
import os import os
for filename in os.listdir(os.path.dirname(lxml.__file__)): for filename in os.listdir(os.path.dirname(lxml.__file__)):
if filename.endswith('.so'): if filename.endswith('.so'):
module_name = 'lxml.' + filename[:-3] module_name = 'lxml.' + filename.split('.', 1)[0]
_register_module_extender_from_live_module( _register_module_extender_from_live_module(
module_name, module_name,
__import__(module_name, fromlist=[module_name], level=0)) __import__(module_name, fromlist=[module_name], level=0))
...@@ -344,8 +347,12 @@ MANAGER.register_transform(Module, wendelin_transform, lambda node: node.name == ...@@ -344,8 +347,12 @@ MANAGER.register_transform(Module, wendelin_transform, lambda node: node.name ==
# Products.ZSQLMethods; Shared and Shared.DC being a namespace package defined # Products.ZSQLMethods; Shared and Shared.DC being a namespace package defined
# in Zope2) as Shared (rather than Shared.DC) is considered... # in Zope2) as Shared (rather than Shared.DC) is considered...
from astroid import modutils from astroid import modutils
modutils__module_file = modutils._module_file try: # BBB
def _module_file(modpath, path=None): modutils__module_file = modutils._module_file
except AttributeError:
pass # recent astroid, anything to do ?
else:
def _module_file(modpath, path=None):
if modutils.pkg_resources is not None: if modutils.pkg_resources is not None:
i = len(modpath) - 1 i = len(modpath) - 1
while i > 0: while i > 0:
...@@ -355,11 +362,9 @@ def _module_file(modpath, path=None): ...@@ -355,11 +362,9 @@ def _module_file(modpath, path=None):
modpath = modpath[i:] modpath = modpath[i:]
path = sys.modules[package].__path__ path = sys.modules[package].__path__
break break
i -= 1 i -= 1
return modutils__module_file(modpath, path) return modutils__module_file(modpath, path)
modutils._module_file = _module_file modutils._module_file = _module_file
if sys.modules['isort'] is None: if sys.modules['isort'] is None:
del sys.modules['isort'] del sys.modules['isort']
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