Exemplo n.º 1
0
def loadFromDir(section, command, commandsDir):
    result = {}
    if section:
        section = utils.lcfirst(section)
    if command:
        command = utils.lcfirst(command)
    for f in os.listdir(commandsDir):
        if f[0] == '_' or f.split('.')[-1:][0] != 'py':
            continue
        f = f.split('.')[:1][0]
        if f == 'Help':
            continue
        tmp = utils.caseSplit(f, firstOnly=True)
        _section = tmp[0]
        _command = tmp[1]
        if section and section != _section:
            continue
        if command and command != _command:
            continue
        if not result.has_key(_section):
            result[_section] = {}
        result[_section][_command] = utils.newObject(
            pkgName = f,
            className = 'Command%s' % f,
            path = commandsDir + '/' + f + '.py'
        )
    return result
Exemplo n.º 2
0
def loadFromDir(section, command, commandsDir):
    result = {}
    if section:
        section = utils.lcfirst(section)
    if command:
        command = utils.lcfirst(command)
    for f in os.listdir(commandsDir):
        if f[0] == '_' or f.split('.')[-1:][0] != 'py':
            continue
        f = f.split('.')[:1][0]
        if f == 'Help':
            continue
        tmp = utils.caseSplit(f, firstOnly=True)
        _section = tmp[0]
        _command = tmp[1]
        if section and section != _section:
            continue
        if command and command != _command:
            continue
        if not result.has_key(_section):
            result[_section] = {}
        result[_section][_command] = utils.newObject(pkgName=f,
                                                     className='Command%s' % f,
                                                     path=commandsDir + '/' +
                                                     f + '.py')
    return result
Exemplo n.º 3
0
def factory(conf):
    if not conf.get('class'):
        raise Exception('Missing main.class in config')
    obj = utils.newObject(
        "chains.services.%s" % conf.get('class').lower(),
        "%sService" % conf.get('class'),
        args=[conf]
    )
    return obj
Exemplo n.º 4
0
def factory(conf):
    if not conf.get('class'):
        raise Exception('Missing main.class in config')
    obj = utils.newObject(
        "chains.services.%s" % conf.get('class').lower(),
        "%sService" % conf.get('class'),
        args=[conf]
    )
    return obj
Exemplo n.º 5
0
def load(formatterName):
    formatterName = utils.ucfirst(formatterName)
    for dir in getFormatterDirs():
        path = '%s/%s.py' % (dir, formatterName)
        if os.path.exists(path):
            try:
                return utils.newObject(
                    pkgName   = formatterName, #'chains.commandline.formatter.%s' % formatterName, 
                    className = 'Formatter%s' % formatterName,
                    path = '%s/%s.py' % (dir, formatterName)
                )
            except ImportError:
                pass
    raise Exception('Formatter not found: %s' % formatterName)