How to use the productmd.composeinfo.VariantPaths function in productmd

To help you get started, we’ve selected a few productmd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github product-definition-center / product-definition-center / pdc / apps / compose / lib.py View on Github external
def _store_relative_path_for_compose(compose_obj, variants_info, variant, variant_obj, add_to_changelog):
    vp = productmd.composeinfo.VariantPaths(variant)
    common_hacks.deserialize_wrapper(vp.deserialize, variants_info.get(variant.name, {}).get('paths', {}))
    for path_type in vp._fields:
        path_type_obj, created = models.PathType.objects.get_or_create(name=path_type)
        if created:
            add_to_changelog.append(path_type_obj)
        for arch in variant.arches:
            field_value = getattr(vp, path_type)
            if field_value and field_value.get(arch, None):
                arch_obj = common_models.Arch.objects.get(name=arch)
                crp_obj, created = models.ComposeRelPath.objects.get_or_create(arch=arch_obj, variant=variant_obj,
                                                                               compose=compose_obj, type=path_type_obj,
                                                                               path=field_value[arch])
                if created:
                    add_to_changelog.append(crp_obj)