Exemplo n.º 1
0
def _get():
    '''
    Gets channels defined in the settings.
    '''
    channels = []
    modules = iter(utils.packageModules(_package()))
    for name in settings.get(CONFIG_NAME, force=True):
        if name in _cache:
            # A name of the channel conflicts with some predefined channel
            continue
        params = {}
        section = settings.get(CONFIG_NAME, name, force=True)
        for option in section:
            params[option.name().lower()] = option
        clsname = params.pop("class", None)
        if clsname is None:
            continue
        clsname = clsname.get()
        while clsname not in _registry:
            try:
                while not utils.importModule(modules.next()):
                    pass
            except StopIteration:
                break
        if clsname in _registry:
            channels.append(_registry[clsname](name, **params))
    return channels
Exemplo n.º 2
0
def _get():
    '''
    Gets channels defined in the settings.
    '''
    channels = []
    modules = iter(utils.packageModules(_package()))
    for name in settings.get(CONFIG_NAME, force=True):
        if name in _cache:
            # A name of the channel conflicts with some predefined channel
            continue
        params = {}
        section = settings.get(CONFIG_NAME, name, force=True)
        for option in section:
            params[option.name().lower()] = option
        clsname = params.pop("class", None)
        if clsname is None:
            continue
        clsname = clsname.get()
        while clsname not in _registry:
            try:
                while not utils.importModule(modules.next()):
                    pass
            except StopIteration:
                break
        if clsname in _registry:
            channels.append(_registry[clsname](name, **params))
    return channels
Exemplo n.º 3
0
def _loadExtensions():
    '''
    Loads all modules with protocol extensions.
    '''
    global _loaded
    _loaded = True
    name = __name__.rsplit('.', 1)[0]
    package = sys.modules[name]
    userdir = utils.ensureUserDir(name.rsplit('.', 1)[1])
    if userdir and userdir not in package.__path__:
        package.__path__.append(userdir)
    for module in utils.packageModules(package):
        if not utils.importModule(module):
            # TODO: Log the import error?
            pass