def _get_modules(request):
    """Returns set of current modules and active module
    :param WSGIRequest request:
    """

    perspective = request.user.profile.get_perspective()

    modules = perspective.modules.filter(display=True).order_by('title')
    if not modules:
        modules = Module.objects.filter(display=True).order_by('title')
    active = None

    for module in modules:
        module.type = 'minor'
        try:
            import_name = module.name + "." + \
                settings.HARDTREE_MODULE_IDENTIFIER
            hmodule = __import__(import_name, fromlist=[str(module.name)])
            urls = hmodule.URL_PATTERNS
            for regexp in urls:
                if re.match(regexp, request.path):
                    active = module
            module.type = hmodule.PROPERTIES['type']
        except ImportError:
            pass
        except __HOLE__:
            pass
        except KeyError:
            pass

    return modules, active
dataset/ETHPy150Open treeio/treeio/treeio/core/templatetags/modules.py/_get_modules