def import_validator(validator):
    try:
        import_name, function_name = validator.rsplit('.', 1)
    except __HOLE__:
        # no dot; treat it as a global
        func = globals().get(validator, None)
        if not func:
            # we use ImportError to keep error handling for callers simple
            raise ImportError
        return validator
    else:
        # The below __import__() call is from python docs, and is equivalent to:
        #
        #   from import_name import function_name
        #
        import_module = __import__(import_name, globals(), locals(), [function_name])

        return getattr(import_module, function_name)
dataset/ETHPy150Open dokterbob/satchmo/satchmo/apps/product/utils.py/import_validator