示例#1
0
文件: base.py 项目: cenk/inbox
def register_backends():
    """
    Finds the monitor modules for the different providers
    (in the backends directory) and imports them.

    Creates a mapping of provider:monitor for each backend found.
    """
    monitor_cls_for = {}

    # Find and import
    backend_dir = os.path.dirname(os.path.realpath(__file__))

    modules = load_modules(backend_dir)

    path = lambda x: os.path.join(backend_dir, x)
    backend_subdirs = [path(e) for e in os.listdir(backend_dir) if
        os.path.isdir(path(e))]

    for d in backend_subdirs:
        modules += load_modules(d)

    # Create mapping
    for module in modules:
        if getattr(module, 'PROVIDER', None) is not None:
            provider = module.PROVIDER

            assert getattr(module, 'SYNC_MONITOR_CLS', None) is not None
            monitor_cls = getattr(module, module.SYNC_MONITOR_CLS, None)

            assert monitor_cls is not None

            monitor_cls_for[provider] = monitor_cls

    return monitor_cls_for
示例#2
0
文件: base.py 项目: aceofspades/inbox
def register_backends():
    """
    Finds the monitor modules for the different providers
    (in the backends directory) and imports them.

    Creates a mapping of provider:monitor for each backend found.
    """
    monitor_cls_for = {}

    # Find and import
    modules = load_modules(inbox.mailsync.backends)

    # Create mapping
    for module in modules:
        if hasattr(module, 'PROVIDER'):
            provider = module.PROVIDER

            assert hasattr(module, 'SYNC_MONITOR_CLS')
            monitor_cls = getattr(module, module.SYNC_MONITOR_CLS, None)

            assert monitor_cls is not None

            monitor_cls_for[provider] = (monitor_cls, module)

    return monitor_cls_for
示例#3
0
文件: base.py 项目: caitp/inbox
def register_backends():
    """
    Finds the monitor modules for the different providers
    (in the backends directory) and imports them.

    Creates a mapping of provider:monitor for each backend found.
    """
    monitor_cls_for = {}

    # Find and import
    modules = load_modules(inbox.server.mailsync.backends)

    # Create mapping
    for module in modules:
        if hasattr(module, 'PROVIDER'):
            provider = module.PROVIDER

            assert hasattr(module, 'SYNC_MONITOR_CLS')
            monitor_cls = getattr(module, module.SYNC_MONITOR_CLS, None)

            assert monitor_cls is not None

            monitor_cls_for[provider] = monitor_cls

    return monitor_cls_for
示例#4
0
文件: base.py 项目: jre21/inbox
def register_backends():
    """
    Finds the sendmail modules for the different providers
    (in the sendmail/ directory) and imports them.

    Creates a mapping of provider:sendmail for each backend found.
    """
    import inbox.server.sendmail

    # Find and import
    modules = load_modules(inbox.server.sendmail)

    # Create mapping
    sendmail_cls_for = {}
    for module in modules:
        if hasattr(module, 'PROVIDER'):
            provider = module.PROVIDER

            assert hasattr(module, 'SENDMAIL_CLS')
            sendmail_cls = getattr(module, module.SENDMAIL_CLS, None)

            assert sendmail_cls is not None

            sendmail_cls_for[provider] = sendmail_cls

    return sendmail_cls_for
示例#5
0
文件: base.py 项目: jre21/inbox
def register_backends():
    import inbox.server.models.tables

    # Find and import
    modules = load_modules(inbox.server.models.tables)

    # Create mapping
    table_mod_for = {}
    for module in modules:
        if hasattr(module, 'PROVIDER'):
            provider = module.PROVIDER
            table_mod_for[provider] = module

    return table_mod_for
示例#6
0
文件: base.py 项目: caitp/inbox
def register_backends():
    """
    Finds the action modules for the different providers
    (in the actions/ directory) and imports them.

    Creates a mapping of provider:actions_mod for each backend found.
    """
    # Find and import
    modules = load_modules(inbox.server.actions)

    # Create mapping
    for module in modules:
        if hasattr(module, 'PROVIDER'):
            provider = module.PROVIDER
            ACTION_MODULES[provider] = module
示例#7
0
def register_backends():
    """
    Finds the action modules for the different providers
    (in the actions/ directory) and imports them.

    Creates a mapping of provider:actions_mod for each backend found.
    """
    # Find and import
    modules = load_modules(inbox.server.actions)

    # Create mapping
    for module in modules:
        if hasattr(module, 'PROVIDER'):
            provider = module.PROVIDER
            ACTION_MODULES[provider] = module
示例#8
0
文件: base.py 项目: jre21/inbox
def register_backends():
    """
    Finds the auth modules for the different providers
    (in the backends directory) and imports them.

    Creates a mapping of provider:auth_cls for each backend found.
    """
    # Find and import
    modules = load_modules(inbox.server.auth)

    # Create mapping
    for module in modules:
        if hasattr(module, 'PROVIDER'):
            provider = module.PROVIDER
            AUTH_MOD_FOR[provider] = module
示例#9
0
文件: base.py 项目: caitp/inbox
def register_backends():
    """
    Finds the auth modules for the different providers
    (in the backends directory) and imports them.

    Creates a mapping of provider:auth_cls for each backend found.
    """
    # Find and import
    modules = load_modules(inbox.server.auth)

    # Create mapping
    for module in modules:
        if hasattr(module, 'PROVIDER'):
            provider = module.PROVIDER
            AUTH_MOD_FOR[provider] = module
示例#10
0
文件: base.py 项目: cenk/inbox
def register_backends():
    """
    Finds the auth modules for the different providers
    (in the backends directory) and imports them.

    Creates a mapping of provider:auth_cls for each backend found.
    """
    # Find and import
    backend_dir = os.path.dirname(os.path.realpath(__file__))
    modules = load_modules(backend_dir)

    # Create mapping
    for module in modules:
        if getattr(module, 'PROVIDER', None) is not None:
            provider = module.PROVIDER
            AUTH_MOD_FOR[provider] = module
示例#11
0
def register_backends():
    """
    Finds the sendmail modules for the different providers
    (in the sendmail/ directory) and imports them.

    Creates a mapping of provider:sendmail_mod for each backend found.

    """
    import inbox.server.sendmail

    # Find and import
    modules = load_modules(inbox.server.sendmail)

    # Create mapping
    sendmail_mod_for = {}
    for module in modules:
        if hasattr(module, 'PROVIDER'):
            provider = module.PROVIDER

            assert hasattr(module, 'SENDMAIL_CLS')

            sendmail_mod_for[provider] = module

    return sendmail_mod_for