| OLD | NEW |
| 1 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. | 1 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
| 2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr | 2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
| 3 # | 3 # |
| 4 # This file is part of astroid. | 4 # This file is part of astroid. |
| 5 # | 5 # |
| 6 # astroid is free software: you can redistribute it and/or modify it | 6 # astroid is free software: you can redistribute it and/or modify it |
| 7 # under the terms of the GNU Lesser General Public License as published by the | 7 # under the terms of the GNU Lesser General Public License as published by the |
| 8 # Free Software Foundation, either version 2.1 of the License, or (at your | 8 # Free Software Foundation, either version 2.1 of the License, or (at your |
| 9 # option) any later version. | 9 # option) any later version. |
| 10 # | 10 # |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 else: | 325 else: |
| 326 attach_import_node(node, modname, name) | 326 attach_import_node(node, modname, name) |
| 327 return True | 327 return True |
| 328 return False | 328 return False |
| 329 | 329 |
| 330 | 330 |
| 331 ### astroid bootstrapping ###################################################### | 331 ### astroid bootstrapping ###################################################### |
| 332 Astroid_BUILDER = InspectBuilder() | 332 Astroid_BUILDER = InspectBuilder() |
| 333 | 333 |
| 334 _CONST_PROXY = {} | 334 _CONST_PROXY = {} |
| 335 def astroid_bootstrapping(): | 335 def _astroid_bootstrapping(astroid_builtin=None): |
| 336 """astroid boot strapping the builtins module""" | 336 """astroid boot strapping the builtins module""" |
| 337 # this boot strapping is necessary since we need the Const nodes to | 337 # this boot strapping is necessary since we need the Const nodes to |
| 338 # inspect_build builtins, and then we can proxy Const | 338 # inspect_build builtins, and then we can proxy Const |
| 339 from logilab.common.compat import builtins | 339 if astroid_builtin is None: |
| 340 astroid_builtin = Astroid_BUILDER.inspect_build(builtins) | 340 from logilab.common.compat import builtins |
| 341 astroid_builtin = Astroid_BUILDER.inspect_build(builtins) |
| 342 |
| 341 for cls, node_cls in CONST_CLS.items(): | 343 for cls, node_cls in CONST_CLS.items(): |
| 342 if cls is type(None): | 344 if cls is type(None): |
| 343 proxy = build_class('NoneType') | 345 proxy = build_class('NoneType') |
| 344 proxy.parent = astroid_builtin | 346 proxy.parent = astroid_builtin |
| 345 else: | 347 else: |
| 346 proxy = astroid_builtin.getattr(cls.__name__)[0] | 348 proxy = astroid_builtin.getattr(cls.__name__)[0] |
| 347 if cls in (dict, list, set, tuple): | 349 if cls in (dict, list, set, tuple): |
| 348 node_cls._proxied = proxy | 350 node_cls._proxied = proxy |
| 349 else: | 351 else: |
| 350 _CONST_PROXY[cls] = proxy | 352 _CONST_PROXY[cls] = proxy |
| 351 | 353 |
| 352 astroid_bootstrapping() | 354 _astroid_bootstrapping() |
| 353 | 355 |
| 354 # TODO : find a nicer way to handle this situation; | 356 # TODO : find a nicer way to handle this situation; |
| 355 # However __proxied introduced an | 357 # However __proxied introduced an |
| 356 # infinite recursion (see https://bugs.launchpad.net/pylint/+bug/456870) | 358 # infinite recursion (see https://bugs.launchpad.net/pylint/+bug/456870) |
| 357 def _set_proxied(const): | 359 def _set_proxied(const): |
| 358 return _CONST_PROXY[const.value.__class__] | 360 return _CONST_PROXY[const.value.__class__] |
| 359 Const._proxied = property(_set_proxied) | 361 Const._proxied = property(_set_proxied) |
| 360 | 362 |
| 361 from types import GeneratorType | 363 from types import GeneratorType |
| 362 Generator._proxied = Class(GeneratorType.__name__, GeneratorType.__doc__) | 364 Generator._proxied = Class(GeneratorType.__name__, GeneratorType.__doc__) |
| 363 Astroid_BUILDER.object_build(Generator._proxied, GeneratorType) | 365 Astroid_BUILDER.object_build(Generator._proxied, GeneratorType) |
| 364 | 366 |
| OLD | NEW |