aboutsummaryrefslogtreecommitdiffstats
path: root/libbe
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-12-05 04:11:39 -0500
committerW. Trevor King <wking@drexel.edu>2009-12-05 04:11:39 -0500
commitfbb8504a6c0438e90b046e44a60608159f4e3f63 (patch)
tree23358fae96603fd1a92ead1256f40456c7c02512 /libbe
parente95de5d97dc05ce5dbb9a553d5e42e437ceccbbf (diff)
downloadbugseverywhere-fbb8504a6c0438e90b046e44a60608159f4e3f63.tar.gz
Created diff.subscriptions_from_string()
Diffstat (limited to 'libbe')
-rw-r--r--libbe/diff.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/libbe/diff.py b/libbe/diff.py
index 3122fe8..e947021 100644
--- a/libbe/diff.py
+++ b/libbe/diff.py
@@ -108,6 +108,29 @@ class Subscription (object):
def __repr__(self):
return "<Subscription: %s (%s)>" % (self.id, self.type)
+def subscriptions_from_string(string=None, subscription_sep=',', id_sep=':'):
+ """
+ >>> 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
+ """
+ if string == None:
+ return [Subscription(BUGDIR_ID, BUGDIR_TYPE_ALL)]
+ subscriptions = []
+ for subscription in string.split(','):
+ fields = subscription.split(':')
+ if len(fields) != 2:
+ raise ValueError('Invalid subscription "%s", should be ID:TYPE'
+ % subscription)
+ id,type = fields
+ subscriptions.append(Subscription(id, type))
+ return subscriptions
+
class DiffTree (tree.Tree):
"""
A tree holding difference data for easy report generation.