root/galaxy-central/eggs/sqlalchemy_migrate-0.5.4-py2.6.egg/migrate/versioning/script/base.py @ 3

リビジョン 3, 1.3 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4from migrate.versioning.base import log,operations
5from migrate.versioning import pathed,exceptions
6
7
8class BaseScript(pathed.Pathed):
9    """Base class for other types of scripts
10    All scripts have the following properties:
11
12    source (script.source())
13      The source code of the script
14    version (script.version())
15      The version number of the script
16    operations (script.operations())
17      The operations defined by the script: upgrade(), downgrade() or both.
18      Returns a tuple of operations.
19      Can also check for an operation with ex. script.operation(Script.ops.up)
20    """
21
22    def __init__(self,path):
23        log.info('Loading script %s...' % path)
24        self.verify(path)
25        super(BaseScript, self).__init__(path)
26        log.info('Script %s loaded successfully' % path)
27   
28    @classmethod
29    def verify(cls,path):
30        """Ensure this is a valid script, or raise InvalidScriptError
31        This version simply ensures the script file's existence
32        """
33        try:
34            cls.require_found(path)
35        except:
36            raise exceptions.InvalidScriptError(path)
37
38    def source(self):
39        fd = open(self.path)
40        ret = fd.read()
41        fd.close()
42        return ret
43
44    def run(self, engine):
45        raise NotImplementedError()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。