mirror of
https://github.com/openSUSE/osc.git
synced 2025-09-06 21:28:42 +02:00
Merge _private.project.ProjectMeta into obs_api.Project
This commit is contained in:
@@ -120,3 +120,32 @@ class Project(XmlModel):
|
||||
url_query = {}
|
||||
response = self.xml_request("PUT", apiurl, url_path, url_query, data=self.to_string())
|
||||
return Status.from_file(response)
|
||||
|
||||
def resolve_repository_flags(self, package_obj=None):
|
||||
"""
|
||||
Resolve the `build`, `debuginfo`, `publish` and `useforbuild` flags
|
||||
and return their values for each repository and build arch.
|
||||
|
||||
:returns: {(repo_name, repo_buildarch): {flag_name: bool} for all available repos
|
||||
"""
|
||||
result = {}
|
||||
flag_names = ("build", "debuginfo", "publish", "useforbuild")
|
||||
|
||||
# populate the result matrix: {(repo, arch): {"build": None, "debuginfo": None, "publish": None, "useforbuild": None}}
|
||||
for repo_obj in self.repository_list or []:
|
||||
for arch in repo_obj.arch_list or []:
|
||||
result[(repo_obj.name, arch)] = dict([(flag_name, None) for flag_name in flag_names])
|
||||
|
||||
for flag_name in flag_names:
|
||||
flag_objects = getattr(self, f"{flag_name}_list") or []
|
||||
if package_obj is not None:
|
||||
flag_objects += getattr(package_obj, f"{flag_name}_list") or []
|
||||
|
||||
for flag_obj in flag_objects:
|
||||
# look up entries matching the current flag and change their values according to the flag's tag
|
||||
for (entry_repo, entry_arch), entry_data in result.items():
|
||||
match = flag_obj.repository in (entry_repo, None) and flag_obj.arch in (entry_arch, None)
|
||||
if match:
|
||||
entry_data[flag_name] = True if flag_obj.flag == "enable" else False
|
||||
|
||||
return result
|
||||
|
Reference in New Issue
Block a user