[Merge] ~hyask/ubuntu-dev-tools:skia/i-b-f-d_multipart into ubuntu-dev-tools:main
Benjamin Drung
mp+468091 at code.launchpad.net
Thu Jul 18 15:08:58 UTC 2024
Diff comments:
> diff --git a/import-bug-from-debian b/import-bug-from-debian
> index 5d0fd7f..a675a2a 100755
> --- a/import-bug-from-debian
> +++ b/import-bug-from-debian
> @@ -118,7 +118,45 @@ def main():
> bug_num = bug.bug_num
> subject = bug.subject
> log = debianbts.get_bug_log(bug_num)
> - summary = log[0]["message"].get_payload()
> + message = log[0]["message"]
> + attachments = []
> + if message.is_multipart():
> + summary = ""
> + i = 1
> + for part in message.walk():
How about we having this new loop code in a separate function?
> + content_type = part.get_content_type()
> + if content_type.startswith("multipart/"):
> + # we're already iterating on multipart items, let's just skip the multipart extra metadata
> + continue
> + elif content_type == "application/pgp-signature":
> + continue
> + elif part.is_attachment():
> + attachments.append((i, part))
> + elif content_type.startswith("image/"):
> + # images here are not attachment, they are inline, but Launchpad can't handle that,
> + # so let's add them as attachments
> + summary += f"Message part #{i}\n"
> + summary += f"[inline image '{part.get_filename()}']\n\n"
> + attachments.append((i, part))
> + elif content_type.startswith("text/html"):
> + summary += f"Message part #{i}\n"
> + summary += "[inline html]\n\n"
> + attachments.append((i, part))
> + elif content_type == "text/plain":
> + summary += f"Message part #{i}\n"
> + summary += part.get_content() + "\n"
> + else:
> + raise RuntimeError(
> + f"""Unknown message part
> +Your Debian bug is too weird to be imported in Launchpad, sorry.
> +You can fix that by patching this script in ubuntu-dev-tools.
> +Faulty message part:
> +{part}"""
> + )
> + i += 1
> + else:
> + summary = log[0]["message"].get_payload()
> +
> target = ubuntu.getSourcePackage(name=ubupackage)
> if target is None:
> Logger.error(
--
https://code.launchpad.net/~hyask/ubuntu-dev-tools/+git/ubuntu-dev-tools/+merge/468091
Your team Ubuntu Development Team is subscribed to branch ubuntu-dev-tools:main.
More information about the Ubuntu-reviews
mailing list