Commit e4626e29 authored by Lorenz Huedepohl's avatar Lorenz Huedepohl
Browse files

Specialed Exception class for unset attribute

parent 1af833c9
......@@ -33,6 +33,10 @@ def project_meta(api_url, project):
return ElementTree.fromstringlist(osc.core.show_project_meta(api_url, project))
class UnsetAttributeException(Exception):
pass
def get_attribute(api_url, project, package, attribute, with_project=False):
attribute_meta = osc.core.show_attribute_meta(api_url, project, package, None, attribute, False, with_project)
if attribute_meta is None:
......@@ -43,7 +47,7 @@ def get_attribute(api_url, project, package, attribute, with_project=False):
if attribute is not None:
return root
else:
raise Exception("Attribute not set")
raise UnsetAttributeException("Attribute not set")
def get_attribute_values(api_url, project, package, attribute, with_project=False):
......
......@@ -76,7 +76,9 @@ def do_mpcdf_sync_projects(self, subcmd, opts, *args):
for attribute in package_attributes:
try:
attr = mpcdf_common.get_attribute(api_url, from_project, orig_package, attribute)
except Exception:
except mpcdf_common.UnsetAttributeException:
if mpcdf_common.has_attribute(api_url, to_project, orig_package, attribute):
mpcdf_common.remove_attribute(api_url, to_project, orig_package, attribute)
continue
mpcdf_common.set_attribute(api_url, to_project, orig_package, attr)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment