Skip to content

Commit 9e59ce8

Browse files
committed
extend the examples with a more thorough example for getting attachments from a specific comment
1 parent c6d59a1 commit 9e59ce8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

docs/examples.rst

+10
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,16 @@ Adding, editing and deleting comments is similarly straightforward::
336336
comment.update(body='updated comment body but no mail notification', notify=False)
337337
comment.delete()
338338

339+
Get all images from a comment::
340+
341+
issue = jira.issue('JRA-1330')
342+
regex_for_png = re.compile(r'\!(\S+?\.(jpg|png|bmp))\|?\S*?\!')
343+
pngs_used_in_comment = regex_for_png.findall(issue.fields.comment.comments[0].body)
344+
for attachment in issue.fields.attachment:
345+
if attachment.filename in pngs_used_in_comment:
346+
with open(attachment.filename, 'wb') as f:
347+
f.write(attachment.get())
348+
339349
Transitions
340350
-----------
341351

0 commit comments

Comments
 (0)