From 9e59ce842876023c75d483166ac08aa1da3c6df0 Mon Sep 17 00:00:00 2001 From: studioj <22102283+studioj@users.noreply.github.com> Date: Sat, 25 Jun 2022 23:20:14 +0200 Subject: [PATCH] extend the examples with a more thorough example for getting attachments from a specific comment --- docs/examples.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/examples.rst b/docs/examples.rst index 5c68b153a..69277343b 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -336,6 +336,16 @@ Adding, editing and deleting comments is similarly straightforward:: comment.update(body='updated comment body but no mail notification', notify=False) comment.delete() +Get all images from a comment:: + + issue = jira.issue('JRA-1330') + regex_for_png = re.compile(r'\!(\S+?\.(jpg|png|bmp))\|?\S*?\!') + pngs_used_in_comment = regex_for_png.findall(issue.fields.comment.comments[0].body) + for attachment in issue.fields.attachment: + if attachment.filename in pngs_used_in_comment: + with open(attachment.filename, 'wb') as f: + f.write(attachment.get()) + Transitions -----------