Tools for comparing two libbe.bug.BugDirs.
Difference tree generator for BugDirs.
Examples
>>> import copy
>>> bd = libbe.bugdir.SimpleBugDir(memory=True)
>>> bd_new = copy.deepcopy(bd)
>>> bd_new.target = '1.0'
>>> a = bd_new.bug_from_uuid('a')
>>> rep = a.comment_root.new_reply("I'm closing this bug")
>>> rep.uuid = 'acom'
>>> rep.author = 'John Doe <j@doe.com>'
>>> rep.date = 'Thu, 01 Jan 1970 00:00:00 +0000'
>>> a.status = 'closed'
>>> b = bd_new.bug_from_uuid('b')
>>> bd_new.remove_bug(b)
>>> c = bd_new.new_bug('Bug C', _uuid='c')
>>> d = Diff(bd, bd_new)
>>> r = d.report_tree()
>>> print '\n'.join(r.paths())
bugdir
bugdir/settings
bugdir/bugs
bugdir/bugs/new
bugdir/bugs/new/c
bugdir/bugs/rem
bugdir/bugs/rem/b
bugdir/bugs/mod
bugdir/bugs/mod/a
bugdir/bugs/mod/a/settings
bugdir/bugs/mod/a/comments
bugdir/bugs/mod/a/comments/new
bugdir/bugs/mod/a/comments/new/acom
bugdir/bugs/mod/a/comments/rem
bugdir/bugs/mod/a/comments/mod
>>> print r.report_string()
Changed bug directory settings:
target: None -> 1.0
New bugs:
abc/c:om: Bug C
Removed bugs:
abc/b:cm: Bug B
Modified bugs:
abc/a:cm: Bug A
Changed bug settings:
status: open -> closed
New comments:
from John Doe <j@doe.com> on Thu, 01 Jan 1970 00:00:00 +0000
I'm closing this bug...
You can also limit the report generation by providing a list of subscriptions.
>>> subscriptions = [Subscription('DIR', BUGDIR_TYPE_NEW),
... Subscription('b', BUG_TYPE_ALL)]
>>> r = d.report_tree(subscriptions)
>>> print r.report_string()
New bugs:
abc/c:om: Bug C
Removed bugs:
abc/b:cm: Bug B
While sending subscriptions to report_tree() makes the report generation more efficient (because you may not need to compare _all_ the bugs, etc.), sometimes you will have several sets of subscriptions. In that case, it’s better to run full_report() first, and then use report_tree() to avoid redundant comparisons.
>>> d.full_report()
>>> print d.report_tree([subscriptions[0]]).report_string()
New bugs:
abc/c:om: Bug C
>>> print d.report_tree([subscriptions[1]]).report_string()
Removed bugs:
abc/b:cm: Bug B
>>> bd.cleanup()
Methods
Generate a full report for efficiency if you’ll be using .report_tree() with several sets of subscriptions.
Pretty bare to make it easy to adjust to specific cases. You can pass in a DiffTree subclass via diff_tree to override the default report assembly process.
A tree holding difference data for easy report generation.
Examples
>>> bugdir = DiffTree('bugdir')
>>> bdsettings = DiffTree('settings', data='target: None -> 1.0')
>>> bugdir.append(bdsettings)
>>> bugs = DiffTree('bugs', 'bug-count: 5 -> 6')
>>> bugdir.append(bugs)
>>> new = DiffTree('new', 'new bugs: ABC, DEF')
>>> bugs.append(new)
>>> rem = DiffTree('rem', 'removed bugs: RST, UVW')
>>> bugs.append(rem)
>>> print bugdir.report_string()
target: None -> 1.0
bug-count: 5 -> 6
new bugs: ABC, DEF
removed bugs: RST, UVW
>>> print '\n'.join(bugdir.paths())
bugdir
bugdir/settings
bugdir/bugs
bugdir/bugs/new
bugdir/bugs/rem
>>> bugdir.child_by_path('/') == bugdir
True
>>> bugdir.child_by_path('/bugs') == bugs
True
>>> bugdir.child_by_path('/bugs/rem') == rem
True
>>> bugdir.child_by_path('bugdir') == bugdir
True
>>> bugdir.child_by_path('bugdir/') == bugdir
True
>>> bugdir.child_by_path('bugdir/bugs') == bugs
True
>>> bugdir.child_by_path('/bugs').masked = True
>>> print bugdir.report_string()
target: None -> 1.0
Methods
append | |
branch_len | |
child_by_path | |
count | |
data_part | |
extend | |
has_descendant | |
index | |
insert | |
join | |
make_root | |
paths | |
pop | |
remove | |
report | |
report_string | |
reverse | |
sort | |
thread | This module provides primitive operations to write multi-threaded programs. |
traverse |
A user subscription.
Examples
>>> subscriptions = [Subscription('XYZ', 'all'),
... Subscription('DIR', 'new'),
... Subscription('ABC', BUG_TYPE_ALL),]
>>> print sorted(subscriptions)
[<Subscription: DIR (new)>, <Subscription: ABC (all)>, <Subscription: XYZ (all)>]
Trees of subscription types to allow users to select exactly what notifications they want to subscribe to.
Methods
append | |
branch_len | |
count | |
extend | |
has_descendant | |
index | |
insert | |
pop | |
remove | |
reverse | |
sort | |
string_tree | |
thread | This module provides primitive operations to write multi-threaded programs. |
traverse |
Provide a simple way for non-Python interfaces to read in subscriptions.
Examples
>>> subscriptions_from_string(None)
[<Subscription: DIR (all)>]
>>> subscriptions_from_string('DIR:new,DIR:rem,ABC:all,XYZ:all')
[<Subscription: DIR (new)>, <Subscription: DIR (rem)>, <Subscription: ABC (all)>, <Subscription: XYZ (all)>]
>>> subscriptions_from_string('DIR::new')
Traceback (most recent call last):
...
ValueError: Invalid subscription "DIR::new", should be ID:TYPE