##// END OF EJS Templates
deps: bumped python3-saml lib
deps: bumped python3-saml lib

File last commit:

r5042:4c5af799 default
r5503:767e3b26 default
Show More
base.py
56 lines | 1.7 KiB | text/x-python | PythonLexer
project: added all source files and assets
r1 #!/usr/bin/env python
dbmigrate: python3 changes...
r5042
project: added all source files and assets
r1 import logging
from rhodecode.lib.dbmigrate.migrate import exceptions
from rhodecode.lib.dbmigrate.migrate.versioning.config import operations
from rhodecode.lib.dbmigrate.migrate.versioning import pathed
log = logging.getLogger(__name__)
class BaseScript(pathed.Pathed):
"""Base class for other types of scripts.
All scripts have the following properties:
source (script.source())
The source code of the script
version (script.version())
The version number of the script
operations (script.operations())
The operations defined by the script: upgrade(), downgrade() or both.
Returns a tuple of operations.
Can also check for an operation with ex. script.operation(Script.ops.up)
""" # TODO: sphinxfy this and implement it correctly
def __init__(self, path):
logging: use lazy parameter evaluation in log calls.
r3061 log.debug('Loading script %s...', path)
project: added all source files and assets
r1 self.verify(path)
super(BaseScript, self).__init__(path)
logging: use lazy parameter evaluation in log calls.
r3061 log.debug('Script %s loaded successfully', path)
project: added all source files and assets
r1
@classmethod
def verify(cls, path):
"""Ensure this is a valid script
This version simply ensures the script file's existence
:raises: :exc:`InvalidScriptError <migrate.exceptions.InvalidScriptError>`
"""
try:
cls.require_found(path)
except:
raise exceptions.InvalidScriptError(path)
def source(self):
""":returns: source code of the script.
:rtype: string
"""
with open(self.path) as fd:
ret = fd.read()
return ret
def run(self, engine):
"""Core of each BaseScript subclass.
This method executes the script.
"""
raise NotImplementedError()