Example #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
Example #2
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
Example #3
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
Example #4
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
Example #5
0
 def preprocess_body(self, body: EntityDefinition) -> EntityDefinition:
     body = super().preprocess_body(body)
     for nullable in [
             "publication",
     ]:
         if body.get(nullable) == "":
             body[nullable] = None
     return body
Example #6
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
Example #7
0
 def preprocess_body(self, body: EntityDefinition) -> EntityDefinition:
     body = super().preprocess_body(body)
     for nullable in [
             "ca_cert",
             "client_cert",
             "client_key",
             "password",
             "proxy_url",
             "username",
     ]:
         if body.get(nullable) == "":
             body[nullable] = None
     return body
Example #8
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
Example #9
0
 def preprocess_body(self, body: EntityDefinition) -> EntityDefinition:
     body = super().preprocess_body(body)
     if body.get("description") == "":
         body["description"] = None
     return body
Example #10
0
 def preprocess_body(self, body: EntityDefinition) -> EntityDefinition:
     body = super().preprocess_body(body)
     for nullable in remote_nullables:
         if body.get(nullable) == "":
             body[nullable] = None
     return body