def verify_module(cls,path): """Ensure this is a valid script, or raise InvalidScriptError""" # Try to import and get the upgrade() func try: module=import_path(path) except: # If the script itself has errors, that's not our problem raise try: assert callable(module.upgrade) except Exception,e: raise exceptions.InvalidScriptError(path+': %s'%str(e))
def verify_module(cls, path): """Ensure this is a valid script, or raise InvalidScriptError""" # Try to import and get the upgrade() func try: module = import_path(path) except: # If the script itself has errors, that's not our problem raise try: assert callable(module.upgrade) except Exception, e: raise exceptions.InvalidScriptError(path + ': %s' % str(e))
def verify_module(cls, path): """Ensure path is a valid script :param path: Script location :type path: string :raises: :exc:`InvalidScriptError <migrate.exceptions.InvalidScriptError>` :returns: Python module """ # Try to import and get the upgrade() func module = import_path(path) try: assert callable(module.upgrade) except Exception, e: raise InvalidScriptError(path + ': %s' % str(e))