r"""
    Effectively import * statements

    The dynamic_import must happen before any * imports otherwise it wont catch
    anything.

    Ignore:
        ignore_startswith = []
        ignore_endswith = []
        check_not_imported = False
        verbose = True
        veryverbose = True

def __execute_fromimport_star(module, modname, import_tuples, ignore_list=[],
                              ignore_startswith=[], ignore_endswith=[],
                              check_not_imported=True, verbose=False,
                              veryverbose=False):
    r"""
    Effectively import * statements

    The dynamic_import must happen before any * imports otherwise it wont catch
    anything.

    Ignore:
        ignore_startswith = []
        ignore_endswith = []
        check_not_imported = False
        verbose = True
        veryverbose = True
    """
    if verbose:
        print('[UTIL_IMPORT] EXECUTE %d FROMIMPORT STAR TUPLES.' % (len(import_tuples),))
    from_imports = []
    # Explicitly ignore these special functions (usually stdlib functions)
    ignoreset = set(['print', 'print_', 'printDBG', 'rrr', 'profile',
                     'print_function', 'absolute_import', 'division', 'zip',
                     'map', 'range', 'list', 'zip_longest', 'filter', 'filterfalse',
                     'dirname', 'realpath', 'join', 'exists', 'normpath',
                     'splitext', 'expanduser', 'relpath', 'isabs',
                     'commonprefix', 'basename', 'input', 'reduce',
                     #'OrderedDict',
                     #'product',
                     ] + ignore_list)
                     #'isdir', 'isfile', '

    #def is_defined_by_module2(item, module):
    #    belongs = False
    #    if hasattr(item, '__module__'):
    #        belongs = item.__module__ == module.__name__
    #    elif hasattr(item, 'func_globals'):
    #        belongs = item.func_globals['__name__'] == module.__name__
    #    return belongs

    for name, fromlist in import_tuples:
        #absname = modname + '.' + name
        child_module = sys.modules[modname + '.' + name]
        # Check if the variable already belongs to the module
        varset = set(vars(module)) if check_not_imported else set()
        fromset = set(fromlist) if fromlist is not None else set()
        def valid_attrname(attrname):
            """
            Guess if the attrname is valid based on its name
            """
            is_forced  = attrname in fromset
            is_private = attrname.startswith('_')
            is_conflit = attrname in varset
            is_module  = attrname in sys.modules  # Isn't fool proof (next step is)
            is_ignore1 = attrname in ignoreset
            is_ignore2 = any([attrname.startswith(prefix) for prefix in ignore_startswith])
            is_ignore3 = any([attrname.endswith(suffix) for suffix in ignore_endswith])
            is_ignore  = any((is_ignore1, is_ignore2, is_ignore3))
            is_valid = not any((is_ignore, is_private, is_conflit, is_module))
            #is_valid = is_valid and is_defined_by_module2(getattr(child_module, attrname), child_module)
            return (is_forced or is_valid)
        allattrs = dir(child_module)
        fromlist_ = [attrname for attrname in allattrs if valid_attrname(attrname)]
        #if verbose:
        #    print('[UTIL_IMPORT]     name=%r, len(allattrs)=%d' % (name, len(allattrs)))
        #if verbose:
        #    print('[UTIL_IMPORT]     name=%r, len(fromlist_)=%d' % (name, len(fromlist_)))
        valid_fromlist_ = []
        for attrname in fromlist_:
            attrval = getattr(child_module, attrname)
            try:
                # Disallow fromimport modules
                forced = attrname in fromset
                if not forced and getattr(attrval, '__name__') in sys.modules:
                    if veryverbose:
                        print('[UTIL_IMPORT] not importing: %r' % attrname)
                    continue
            except AttributeError:
                pass
            if veryverbose:
                print('[UTIL_IMPORT] %s is importing: %r' % (modname, attrname))
            valid_fromlist_.append(attrname)
            setattr(module, attrname, attrval)
        if verbose:
            print('[UTIL_IMPORT]     name=%r, len(valid_fromlist_)=%d' % (name, len(valid_fromlist_)))
        from_imports.append((name, valid_fromlist_))
    return from_imports