Bug
|
Size: 643
Comment: started this tutorial
|
Size: 4247
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 9: | Line 9: |
| >>> bug = Bug(126927) | >>> bug = Bug(120593) |
| Line 15: | Line 15: |
| >>> bug = Bug("https://bugs.launchpad.net/buglog-data/+bug/126927") | >>> bug = Bug(url="https://bugs.launchpad.net/buglog-data/+bug/120593") |
| Line 27: | Line 27: |
||'''Attribute'''||'''Description'''||'''Example'''|| ||.assignee||Person assigned to a bugreport (type: user)|| [#user] || ||.attachments||List of attachments|| [#attachments] || ||.bugnumber||Number of a bugreport (type: int)|| || ||.changed||List of local changes to a bugreport|| [#changed] || ||.comments||List of comments|| [#comments] || ||.date|| || || ||.description|| || || ||.duplicate_of|| || || ||.duplicates||List of duplicates of a bug|| || ||.importance|| || || ||.info|| || || ||.infotable|| || || ||.milestone|| || || ||.nickname|| || || ||.private|| || || ||.reporter|| || || ||.security|| || || ||.sourcepackage|| || || ||.status|| || || ||.subscribtions|| || || ||.summary|| || || ||.tags|| || || ||.target|| || || ||.text|| || || ||.title|| || || ||.url|| || || === Attachments === [[Anchor(attachments)]] Get a list of attachments: {{{#!python start=5 >>> for a in bug.attachments: ... print a ... <Attachment (up: 8554243), (down: <path-to-file>/120593/8554243/79140.patch)> <Attachment (up: 8558770)> <Attachment (up: 8554203)> <Attachment (up: 8541039)> }}} As you can see there are four files attached to the bug and the first attachment has already been downloaded. You can for example filter the list of attachments by the filename: {{{#!python start=12 >>> def test_filter(a): ... import re ... return re.match("assignee.*", a.lp_filename) ... >>> [i for i in bug.attachments.filter(test_filter)] [<Attachment (up: 8541039)>] >>> bug.attachments[8541039].lp_filename 'assignee.patch' }}} These filtered attachments can be easily removed: {{{#!python start=20 >>> bug.attachments.remove(test_filter) True }}} To add an attachment you have to create an new attachment-object: {{{#!python start=22 >>> attachment = Bug.NewAttachment(localfilename="<path-to-file>/79140.patch") >>> attachment.description = "example patch" >>> attachment.is_patch = True >>> attachment <Attachment (down: <path-to-file>/79140.patch)> }}} Now you have to add this attachment to the bugreport: {{{#!python start=27 >>> bug.attachments.add(attachment) >>> for a in bug.attachments: ... print a ... <Attachment (up: 8554243), (down: <path-to-file>/120593/8554243/79140.patch)> <Attachment (up: 8558770)> <Attachment (up: 8554203)> <Attachment (down: <path-to-file>/79140.patch)> }}} === Comments === [[Anchor(comments)]] Get a list of comments: {{{#!python start=35 >>> [c for c in bug.comments][0:2] [<Comment 1 by thekorn on 2007-07-20>, <Comment 2 by thekorn on 2007-07-20>] }}} Create a new comment and add this comment to the bugreport: {{{#!python start=37 >>> comment = Bug.NewComment(text="this is a test comment") >>> bug.comments.add(comment) >>> [c for c in bug.comments] [<Comment 1 by thekorn on 2007-07-20>, <Comment 2 by thekorn on 2007-07-20>, ... , <Comment 'unknown'>] }}} === User === [[Anchor(user)]] User are String-like objects with an additional attribute `.realname`.[[BR]] {{{#!python >>> str(bug.assignee) 'thekorn' >>> repr(bug.assignee) '<user thekorn (Markus Korn)>' >>> bug.assignee.realname 'Markus Korn' }}} == Commit changes == === get a list of changes === [[Anchor(changed)]] {{{#!python start=41 >>> for i in bug.changed: ... print i ... (<Attachmentlist> changed: (<Attachment (up: 8541039)> deleted), (<Attachment (down: <path-to-file>/79140.patch)> added)) (<Commentslist> changed: (<Comment 'unknown'> added)) }}} === commit changes === {{{#!python start=46 >>> bug.commit() }}} |
Bug - tutorial
General workflow
That is the way to use python-launchpad-bugs to get information on a bugreport or to edit a bugreport:
It is also possible to get a bugreport by its url:
3 >>> bug = Bug(url="https://bugs.launchpad.net/buglog-data/+bug/120593")
If you want to change the bugreport or view private bugs you have to set Bug.authentication:
4 >>> Bug.authentication="cookie.txt"
Attributes of a bugreport
Overview
Attribute |
Description |
Example |
.assignee |
Person assigned to a bugreport (type: user) |
[#user] |
.attachments |
List of attachments |
[#attachments] |
.bugnumber |
Number of a bugreport (type: int) |
|
.changed |
List of local changes to a bugreport |
[#changed] |
.comments |
List of comments |
[#comments] |
.date |
|
|
.description |
|
|
.duplicate_of |
|
|
.duplicates |
List of duplicates of a bug |
|
.importance |
|
|
.info |
|
|
.infotable |
|
|
.milestone |
|
|
.nickname |
|
|
.private |
|
|
.reporter |
|
|
.security |
|
|
.sourcepackage |
|
|
.status |
|
|
.subscribtions |
|
|
.summary |
|
|
.tags |
|
|
.target |
|
|
.text |
|
|
.title |
|
|
.url |
|
|
Attachments
Anchor(attachments) Get a list of attachments:
As you can see there are four files attached to the bug and the first attachment has already been downloaded.
You can for example filter the list of attachments by the filename:
These filtered attachments can be easily removed:
To add an attachment you have to create an new attachment-object:
Now you have to add this attachment to the bugreport:
Comments
Anchor(comments) Get a list of comments:
Create a new comment and add this comment to the bugreport:
User
Anchor(user) User are String-like objects with an additional attribute .realname.BR
Commit changes
get a list of changes
commit changes
46 >>> bug.commit()
BugHelper/Dev/python-launchpad-bugs/Bug (last edited 2008-08-12 22:24:51 by c-24-21-234-111)