# Path: clonedigger/logilab/common/fileutils.py
# def norm_read(path):
#     """return the content of the file with normalized line feeds
# 
#     :type path: str
#     :param path: path to the file to read
# 
#     :rtype: str
#     :return: the content of the file with normalized line feeds
#     """
#     if _HAS_UNIV_OPEN:
#         return open(path, 'U').read()
#     return _LINE_RGX.sub('\n', open(path).read())
# 
# Path: clonedigger/logilab/common/modutils.py
# def modpath_from_file(filename):
#     """given a file path return the corresponding splitted module's name
#     (i.e name of a module or package splitted on '.')
# 
#     :type filename: str
#     :param filename: file's path for which we want the module's name
# 
# 
#     :raise ImportError:
#       if the corresponding module's name has not been found
# 
#     :rtype: list(str)
#     :return: the corresponding splitted module's name
#     """
#     base = splitext(abspath(filename))[0]
#     for path in sys.path:
#         path = abspath(path)
#         if path and base[:len(path)] == path:
#             if filename.find('site-packages') != -1 and \
#                    path.find('site-packages') == -1:
#                 continue
#             mod_path = [module for module in base[len(path):].split(os.sep)
#                         if module]
#             for part in mod_path[:-1]:
#                 path = join(path, part)
#                 if not _has_init(path):
#                     break
#             else:
#                 break
#     else:
#         raise ImportError('Unable to find module for %s in %s' % (
#             filename, ', \n'.join(sys.path)))
#     return mod_path
# 
# Path: clonedigger/logilab/astng/_exceptions.py
# class ASTNGBuildingException(ASTNGError):
#     """exception class when we are not able to build an astng representation"""
# 
# class InferenceError(ResolveError):
#     """raised when we are unabled to infer a node"""
# 
# Path: clonedigger/logilab/astng/astutils.py
# def cvrtr(tuple):
#     """debug method returning an ast string in a readable fashion"""
#     if type(tuple) is TupleType:
#         try:
#             try:
#                 txt = 'token.'+token.tok_name[tuple[0]]
#             except:
#                 txt = 'symbol.'+symbol.sym_name[tuple[0]]
#         except:
#             txt =  'Unknown token/symbol'
#         return [txt] + list(map(cvrtr, tuple[1:]))
#     else:
#         return tuple


from future import standard_library
from builtins import *
from builtins import object
from os.path import splitext, basename, dirname, exists, abspath
from parser import ParserError
from compiler import parse
from inspect import isfunction, ismethod, ismethoddescriptor, isclass, \
     isbuiltin
from inspect import isdatadescriptor
from clonedigger.logilab.common.fileutils import norm_read
from clonedigger.logilab.common.modutils import modpath_from_file
from clonedigger.logilab.astng import nodes, YES, Instance
from clonedigger.logilab.astng.utils import ASTWalker
from clonedigger.logilab.astng._exceptions import ASTNGBuildingException, InferenceError
from clonedigger.logilab.astng.raw_building import *
from clonedigger.logilab.astng.astutils import cvrtr
from compiler import transformer, consts
from types import TupleType
            from clonedigger.logilab.astng import MANAGER as manager
import sys
import token
            if ext in ('.py', '.pyc', '.pyo') and exists(path_ + '.py'):
                node = self.file_build(path_ + '.py', modname)
        if node is None:
            # this is a built-in module
            # get a partial representation by introspection
            node = self.inspect_build(module, modname=modname, path=path)
        return node

    def inspect_build(self, module, modname=None, path=None):
        """build astng from a living module (i.e. using inspect)
        this is used when there is no python source code available (either
        because it's a built-in module or because the .py is not available)
        """
        self._module = module
        node = build_module(modname or module.__name__, module.__doc__)
        node.file = node.path = path and abspath(path) or path
        if self._manager is not None:
            self._manager._cache[node.file] = self._manager._cache[node.name] = node
        node.package = hasattr(module, '__path__')
        attach___dict__(node)
        self._done = {}
        self.object_build(node, module)
        return node
    
    def file_build(self, path, modname=None):
        """build astng from a source code file (i.e. from an ast)

        path is expected to be a python source file
        """
        try:

# Path: clonedigger/logilab/common/fileutils.py
# def norm_read(path):
#     """return the content of the file with normalized line feeds
# 
#     :type path: str
#     :param path: path to the file to read
# 
#     :rtype: str
#     :return: the content of the file with normalized line feeds
#     """
#     if _HAS_UNIV_OPEN:
#         return open(path, 'U').read()
#     return _LINE_RGX.sub('\n', open(path).read())
# 
# Path: clonedigger/logilab/common/modutils.py
# def modpath_from_file(filename):
#     """given a file path return the corresponding splitted module's name
#     (i.e name of a module or package splitted on '.')
# 
#     :type filename: str
#     :param filename: file's path for which we want the module's name
# 
# 
#     :raise ImportError:
#       if the corresponding module's name has not been found
# 
#     :rtype: list(str)
#     :return: the corresponding splitted module's name
#     """
#     base = splitext(abspath(filename))[0]
#     for path in sys.path:
#         path = abspath(path)
#         if path and base[:len(path)] == path:
#             if filename.find('site-packages') != -1 and \
#                    path.find('site-packages') == -1:
#                 continue
#             mod_path = [module for module in base[len(path):].split(os.sep)
#                         if module]
#             for part in mod_path[:-1]:
#                 path = join(path, part)
#                 if not _has_init(path):
#                     break
#             else:
#                 break
#     else:
#         raise ImportError('Unable to find module for %s in %s' % (
#             filename, ', \n'.join(sys.path)))
#     return mod_path
# 
# Path: clonedigger/logilab/astng/_exceptions.py
# class ASTNGBuildingException(ASTNGError):
#     """exception class when we are not able to build an astng representation"""
# 
# class InferenceError(ResolveError):
#     """raised when we are unabled to infer a node"""
# 
# Path: clonedigger/logilab/astng/astutils.py
# def cvrtr(tuple):
#     """debug method returning an ast string in a readable fashion"""
#     if type(tuple) is TupleType:
#         try:
#             try:
#                 txt = 'token.'+token.tok_name[tuple[0]]
#             except:
#                 txt = 'symbol.'+symbol.sym_name[tuple[0]]
#         except:
#             txt =  'Unknown token/symbol'
#         return [txt] + list(map(cvrtr, tuple[1:]))
#     else:
#         return tuple


# Path: clonedigger/logilab/astng/builder.py
from future import standard_library
from builtins import *
from builtins import object
from os.path import splitext, basename, dirname, exists, abspath
from parser import ParserError
from compiler import parse
from inspect import isfunction, ismethod, ismethoddescriptor, isclass, \
     isbuiltin
from inspect import isdatadescriptor
from clonedigger.logilab.common.fileutils import norm_read
from clonedigger.logilab.common.modutils import modpath_from_file
from clonedigger.logilab.astng import nodes, YES, Instance
from clonedigger.logilab.astng.utils import ASTWalker
from clonedigger.logilab.astng._exceptions import ASTNGBuildingException, InferenceError
from clonedigger.logilab.astng.raw_building import *
from clonedigger.logilab.astng.astutils import cvrtr
from compiler import transformer, consts
from types import TupleType
            from clonedigger.logilab.astng import MANAGER as manager
import sys
import token

            if ext in ('.py', '.pyc', '.pyo') and exists(path_ + '.py'):
                node = self.file_build(path_ + '.py', modname)
        if node is None:
            # this is a built-in module
            # get a partial representation by introspection
            node = self.inspect_build(module, modname=modname, path=path)
        return node

    def inspect_build(self, module, modname=None, path=None):
        """build astng from a living module (i.e. using inspect)
        this is used when there is no python source code available (either
        because it's a built-in module or because the .py is not available)
        """
        self._module = module
        node = build_module(modname or module.__name__, module.__doc__)
        node.file = node.path = path and abspath(path) or path
        if self._manager is not None:
            self._manager._cache[node.file] = self._manager._cache[node.name] = node
        node.package = hasattr(module, '__path__')
        attach___dict__(node)
        self._done = {}
        self.object_build(node, module)
        return node
    
    def file_build(self, path, modname=None):
        """build astng from a source code file (i.e. from an ast)

        path is expected to be a python source file
        """
        try:

            data = norm_read(path)