Esempio n. 1
0
 def preprocess_body(self, body: EntityDefinition) -> EntityDefinition:
     body = super().preprocess_body(body)
     version = body.pop("version", None)
     if version is not None:
         repository_href = body.pop("repository")
         body["repository_version"] = f"{repository_href}versions/{version}/"
     return body
Esempio n. 2
0
 def preprocess_body(self, body: EntityDefinition) -> EntityDefinition:
     body = super().preprocess_body(body)
     fields = self.APT_ONLY.intersection(body.keys())
     if fields:
         raise click.ClickException(
             _("{} can't be used when creating VerbatimPublications").format(fields)
         )
     version = body.pop("version", None)
     if version is not None:
         repository_href = body.pop("repository")
         body["repository_version"] = f"{repository_href}versions/{version}/"
     return body
Esempio n. 3
0
 def preprocess_body(self, body: EntityDefinition) -> EntityDefinition:
     body = super().preprocess_body(body)
     if self.pulp_ctx.has_plugin(
             PluginRequirement("core", min="3.17.dev", inverted=True)):
         if "creation_hooks" in body:
             body["permissions_assignment"] = body.pop("creation_hooks")
     return body
Esempio n. 4
0
 def preprocess_body(self, body: EntityDefinition) -> EntityDefinition:
     body = super().preprocess_body(body)
     if "requirements" in body.keys():
         body["requirements_file"] = body.pop("requirements")
     for nullable in remote_nullables + self.collection_nullable:
         if body.get(nullable) == "":
             body[nullable] = None
     return body
Esempio n. 5
0
 def tuple_to_whitespace_separated_string(field_name: str, body: EntityDefinition) -> None:
     """
     Safely turns a tuple contained in body[field_name] into a whitespace separated string.
     If body[field_name] contains None or (), then field_name is dropped from body.
     If we end up with an empty string, we use None instead.
     All conversions happen in place.
     If body[field_name] does not contain a tuple, the behaviour is undefined.
     """
     field = body.pop(field_name, None)
     if field is not None and field != ():
         string_field = " ".join(field).strip()
         body[field_name] = string_field if string_field else None
Esempio n. 6
0
 def preprocess_body(self, body: EntityDefinition) -> EntityDefinition:
     body = super().preprocess_body(body)
     if "requirements" in body.keys():
         body["requirements_file"] = body.pop("requirements")
     return body