コード例 #1
0
ファイル: __init__.py プロジェクト: pombredanne/unuk
def get_runner(name, **kwargs):
    name = name.lower()
    mname = REACTOR_TYPES.get(name,None)
    if mname:
        bmodule = 'unuk.internet.%s' % mname
    else:
        bmodule = name
    module = import_module(bmodule)
    for attr_name in dir(module):
        attr = getattr(module,attr_name)
        if inspect.isclass(attr) and issubclass(attr,Runner):
            return attr(name, **kwargs)
    raise ValueError('Could not find a reactor class in module %s' % bmodule)
コード例 #2
0
ファイル: runtests.py プロジェクト: pombredanne/unuk
def import_tests(tags):
    apptests = []
    for loc,app in get_tests():
        if tags and app not in tags:
            logger.debug("Skipping tests for %s" % app)
            continue
        logger.debug("Try to import tests for %s" % app)
        test_module = '{0}.{1}.tests'.format(loc,app)
        if loc == 'contrib':
            test_module = 'unuk.{0}'.format(test_module)
            
        try:
            mod = import_module(test_module)
        except ImportError, e:
            logger.debug("Could not import tests for %s: %s" % (test_module,e))
            continue
        
        logger.debug("Adding tests for %s" % app)
        apptests.append(mod)
コード例 #3
0
ファイル: static.py プロジェクト: pombredanne/unuk
def application_map(applications):
    '''Very very useful function for finding static media directories.
It looks for the ``media`` directory in each installed application.'''
    map = {}
    for app in applications:
        sapp = app.split('.')
        name = sapp[-1]
        if app.startswith('django.'):
            if app == 'django.contrib.admin':
                handler = djangoAdminHandler
            else:
                # we skip any other django contrib application
                continue
        else:
            handler = pathHandler
            
        try:
            module = import_module(app)
        except:
            continue

        path   = module.__path__[0]
        map[name] = handler(name,path)
    return map