def import_(module, objects=None, via=None):
    """
    :param module: py3 compatiable module path
    :param objects: objects want to imported, it should be a list
    :param via: for some py2 module, you should give the import path according the
        objects which you want to imported
    :return: object or module
    """
    if PY3:
        mod = __import__(module, fromlist=['*'])
    else:
        path = modules_mapping.get(module)
        if not path:
            raise Exception("Can't find the module %s in mappings." % module)
        if isinstance(path, list):
            if not via:
                raise Exception("You should give a via parameter to enable import from py2.")
            path = via
        mod = __import__(path, fromlist=['*'])

    if objects:
        if not isinstance(objects, (list, tuple)):
            raise Exception("objects parameter should be a list or tuple.")
        r = []
        for x in objects:
            r.append(getattr(mod, x))
        if len(r) > 1:
            return tuple(r)
        else:
            return r[0]
    else:
        return mod
def import_ ( module , objects = None , via = None ) : if PY3 : mod = __import__ ( module , fromlist = [ '*' ] ) else : path = modules_mapping . get ( module ) if not path : raise Exception ( "Can't find the module %s in mappings." % module ) if isinstance ( path , list ) : if not via : raise Exception ( "You should give a via parameter to enable import from py2." ) path = via mod = __import__ ( path , fromlist = [ '*' ] ) if objects : if not isinstance ( objects , ( list , tuple ) ) : raise Exception ( "objects parameter should be a list or tuple." ) r = [ ] for x in objects : r . append ( getattr ( mod , x ) ) if len ( r ) > 1 : return tuple ( r ) else : return r [ 0 ] else : return mod
:param module: py3 compatiable module path
    :param objects: objects want to imported, it should be a list
    :param via: for some py2 module, you should give the import path according the
        objects which you want to imported
    :return: object or module