コード例 #1
0
ファイル: conf.py プロジェクト: openology/imapfw
class ImapfwConfig(object):
    def __init__(self):
        self.parser = Parser

        self.concurrency = None
        self.rascal = None
        self.ui = None

    def getAction(self):
        return self.parser.getAction()

    def getLogger(self):
        return logging

    def setupConcurrency(self):
        self.concurrency = Concurrency(self.parser.get('concurrency'))
        set_module('concurrency', self.concurrency) # Export concurrency module.

    def loadRascal(self):
        rascalFile = self.parser.get('rascalfile')
        if rascalFile is not None:
            self.rascal = Rascal()
            self.rascal.load(rascalFile)
        set_module('rascal', self.rascal) # Export the rascal.

    def parseCLI(self):
        self.parser.parse()

    def setupUI(self):
        ui = TTY(self.concurrency.createLock())
        ui.configure()

        # Let ui prefix log lines with the worker name.
        ui.setCurrentWorkerNameFunction(self.concurrency.getCurrentWorkerNameFunction())
        # Apply CLI options.
        ui.enableDebugCategories(self.parser.get('debug'))
        ui.setInfoLevel(self.parser.get('info'))

        self.ui = ui
        set_module('ui', ui) # Export ui module.
コード例 #2
0
class ImapfwConfig(object):
    def __init__(self):
        self._cli = None
        self._concurrency = None
        self._rascal = None
        self._ui = None

    def getAction(self):
        return self._cli.get('action')

    def getActionOptions(self):
        actionName = self.getAction()
        mapping = {
            'devel': [],
            'examine': ['repositories'],
            'noop': [],
            'shell': ['shell_name'],
            'syncAccounts': ['accounts', 'engine'],
            'testRascal': [],
            'unitTests': [],
        }
        options = {}

        for option in mapping[actionName]:
            options[option] = self._cli.get(option)
        options['action'] = actionName
        return options

    def getConcurrency(self):
        return self._concurrency

    def getLogger(self):
        return logging

    def getRascal(self):
        return self._rascal

    def getUI(self):
        return self._ui

    def listActions(self):
        return self._cli.get('listActions')

    def setupConcurrency(self):
        self._concurrency = Concurrency(self._cli.get('concurrency'))
        set_module('concurrency',
                   self._concurrency)  # Export concurrency module.

    def loadRascal(self):
        rascalFile = self._cli.get('rascalfile')
        if rascalFile is not None:
            self._rascal = Rascal()
            self._rascal.load(rascalFile)
        set_module('rascal', self._rascal)  # Export the rascal.

    def parseCLI(self):
        if self._cli is None:
            self._cli = CLIOptions()
            self._cli.parse()

    def setupUI(self):
        ui = TTY(self._concurrency.createLock())
        ui.configure()

        # Let ui prefix log lines with the worker name.
        ui.setCurrentWorkerNameFunction(
            self._concurrency.getCurrentWorkerNameFunction())
        # Apply CLI options.
        ui.enableDebugCategories(self._cli.get('debug'))
        ui.setInfoLevel(self._cli.get('info'))

        self._ui = ui
        set_module('ui', ui)  # Export ui module.