Beispiel #1
0
def get_frameworks(type_=None):
    frameworks = _lookup_frameworks()

    if type_ is None:
        return frameworks
    else:
        if type_ not in frameworks:
            raise exception.UnknownFramework(type_)
        return frameworks[type_]

    return frameworks
Beispiel #2
0
def get_frameworks(type_=None):
    frameworks = {}

    try:
        frameworks = get_frameworks._cache  # pylint: disable=W0212
    except AttributeError:
        frameworks_path = join(get_source_dir(), "builder", "scripts",
                               "frameworks")

        frameworks_list = [
            f[:-3] for f in os.listdir(frameworks_path)
            if not f.startswith("__") and f.endswith(".py")
        ]
        for _type in frameworks_list:
            script_path = join(frameworks_path, "%s.py" % _type)
            with open(script_path) as f:
                fcontent = f.read()
                assert '"""' in fcontent
                _doc_start = fcontent.index('"""') + 3
                fdoc = fcontent[_doc_start:fcontent.index('"""', _doc_start
                                                          )].strip()
                doclines = [l.strip() for l in fdoc.splitlines() if l.strip()]
                frameworks[_type] = {
                    "name": doclines[0],
                    "description": " ".join(doclines[1:-1]),
                    "url": doclines[-1],
                    "script": script_path
                }
        get_frameworks._cache = frameworks  # pylint: disable=W0212

    if type_ is None:
        return frameworks
    else:
        if type_ not in frameworks:
            raise exception.UnknownFramework(type_)
        return frameworks[type_]

    return frameworks