# 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
        """visit a stmt.Global node -> add declared names to locals
        """
        self.visit_default(node)
        if not self._global_names: # global at the module level, no effect
            return
        for name in node.names:
            self._global_names[-1].setdefault(name, []).append(node)
#             node.parent.set_local(name, node)
#         module = node.root()
#         if module is not node.frame():
#             for name in node.names:
#                 module.set_local(name, node)
            
    def visit_import(self, node):
        """visit a stmt.Import node -> add imported names to locals
        """
        self.visit_default(node)
        for (name, asname) in node.names:
            name = asname or name
            node.parent.set_local(name.split('.')[0], node)
            
    def visit_from(self, node):
        """visit a stmt.From node -> add imported names to locals
        """
        self.visit_default(node)
        # add names imported by the import to locals
        for (name, asname) in node.names:
            if name == '*':
                try:
                    imported = node.root().import_module(node.modname)

# 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

        """visit a stmt.Global node -> add declared names to locals
        """
        self.visit_default(node)
        if not self._global_names: # global at the module level, no effect
            return
        for name in node.names:
            self._global_names[-1].setdefault(name, []).append(node)
#             node.parent.set_local(name, node)
#         module = node.root()
#         if module is not node.frame():
#             for name in node.names:
#                 module.set_local(name, node)
            
    def visit_import(self, node):
        """visit a stmt.Import node -> add imported names to locals
        """
        self.visit_default(node)
        for (name, asname) in node.names:
            name = asname or name
            node.parent.set_local(name.split('.')[0], node)
            
    def visit_from(self, node):
        """visit a stmt.From node -> add imported names to locals
        """
        self.visit_default(node)
        # add names imported by the import to locals
        for (name, asname) in node.names:
            if name == '*':
                try:
                    imported = node.root().import_module(node.modname)

                except ASTNGBuildingException: