コード例 #1
0
ファイル: v2.py プロジェクト: kernelci/kcidb-io
        dict(revisions=dict(id=('origin', 'origin_id')),
             builds=dict(id=('origin', 'origin_id'),
                         revision_id=('revision_origin',
                                      'revision_origin_id')),
             tests=dict(id=('origin', 'origin_id'),
                        build_id=('build_origin',
                                  'build_origin_id'))).items():
        for id, pair in id_pair_map.items():
            for obj in data.get(collection, []):
                obj[id] = obj[pair[0]] + ':' + obj[pair[1]]
                del obj[pair[0]]
                del obj[pair[1]]

    # Replace slashes with underscores in resource names
    for collection, prop_list in \
        dict(revisions=["patch_mboxes"],
             builds=["input_files", "output_files"],
             tests=["output_files"]).items():
        for obj in data.get(collection, []):
            for prop in prop_list:
                for resource in obj.get(prop, []):
                    resource["name"] = resource["name"].replace("/", "_")

    # Update version
    data['version'] = dict(major=JSON_VERSION_MAJOR, minor=JSON_VERSION_MINOR)
    return data


VERSION = Version(JSON_VERSION_MAJOR, JSON_VERSION_MINOR, JSON,
                  v1.VERSION.tree, get_version, v1.VERSION, inherit)
コード例 #2
0
}


def inherit(data):
    """
    Inherit data, i.e. convert data adhering to the previous version of
    the schema to satisfy this version of the schema.

    Args:
        data:   The data to inherit.
                Will be modified in place.

    Returns:
        The inherited data.
    """
    # Update version
    data['version'] = dict(major=JSON_VERSION_MAJOR, minor=JSON_VERSION_MINOR)
    return data


# The parent-child relationship tree
TREE = {
    "": ["checkouts"],
    "checkouts": ["builds"],
    "builds": ["tests"],
    "tests": []
}

VERSION = Version(JSON_VERSION_MAJOR, JSON_VERSION_MINOR, JSON, TREE,
                  v4.VERSION.get_version, v4.VERSION, inherit)
コード例 #3
0
            "items": JSON_REVISION,
        },
        "builds": {
            "description": "List of builds",
            "type": "array",
            "items": JSON_BUILD,
        },
        "tests": {
            "description": "List of test runs",
            "type": "array",
            "items": JSON_TEST,
        },
    },
    "additionalProperties": False,
    "required": [
        "version",
    ]
}

# The parent-child relationship tree
TREE = {
    "": ["revisions"],
    "revisions": ["builds"],
    "builds": ["tests"],
    "tests": []
}

VERSION = Version(JSON_VERSION_MAJOR, JSON_VERSION_MINOR, JSON, TREE)

__all__ = ["VERSION"]
コード例 #4
0
ファイル: v3.py プロジェクト: spbnick/kcidb-io
    for revision in data.get("revisions", []):
        revision["id"] = remove_origin(revision["id"])
    for build in data.get("builds", []):
        build["revision_id"] = remove_origin(build["revision_id"])

    # Rename git_repository_commit* to git_commit* in revisions
    for revision in data.get("revisions", []):
        for old, new in (("git_repository_commit_hash", "git_commit_hash"),
                         ("git_repository_commit_name", "git_commit_name")):
            if old in revision:
                revision[new] = revision.pop(old)

    # Update version
    data['version'] = dict(major=JSON_VERSION_MAJOR, minor=JSON_VERSION_MINOR)
    return data


# The parent-child relationship tree
TREE = {
    "": ["revisions"],
    "revisions": ["builds"],
    "builds": ["tests"],
    "tests": []
}

VERSION = Version(JSON_VERSION_MAJOR, JSON_VERSION_MINOR, JSON, TREE,
                  v2.VERSION, inherit)

__all__ = ["VERSION"]
コード例 #5
0
    try:
        version = data["version"]
        if isinstance(version, str):
            match = re.match("^([0-9]+)(\\.([0-9]+))?$", version)
            if match:
                return int(match.group(1)), int(match.group(3) or "0")
        else:
            major = version["major"]
            try:
                minor = version["minor"]
            except KeyError:
                minor = 0
            if isinstance(major, int) and isinstance(minor, int) and \
               major >= 0 and minor >= 0:
                return major, minor
    except (TypeError, KeyError, ValueError):
        pass
    return None, None


# The parent-child relationship tree
TREE = {
    "": ["revisions"],
    "revisions": ["builds"],
    "builds": ["tests"],
    "tests": []
}

VERSION = Version(JSON_VERSION_MAJOR, JSON_VERSION_MINOR, JSON, TREE,
                  get_version)