Adjusted diff.Subscription.__init__() to guess type_root if required.
authorW. Trevor King <wking@drexel.edu>
Sat, 5 Dec 2009 08:32:06 +0000 (03:32 -0500)
committerW. Trevor King <wking@drexel.edu>
Sat, 5 Dec 2009 08:32:06 +0000 (03:32 -0500)
libbe/diff.py

index b5384a8eaeef0341c4fcade6fa1680c62f8b9679..73db13db1a61088f54965e18abe26b20b67832f2 100644 (file)
@@ -75,13 +75,18 @@ def type_from_name(name, type_root, default=None, default_ok=False):
 
 class Subscription (object):
     """
-    >>> subscriptions = [Subscription('XYZ', 'all', type_root=BUG_TYPE_ALL),
-    ...                  Subscription('DIR', 'new', type_root=BUGDIR_TYPE_ALL),
+    >>> subscriptions = [Subscription('XYZ', 'all'),
+    ...                  Subscription('DIR', 'new'),
     ...                  Subscription('ABC', BUG_TYPE_ALL),]
     >>> print sorted(subscriptions)
     [<Subscription: DIR (new)>, <Subscription: ABC (all)>, <Subscription: XYZ (all)>]
     """
     def __init__(self, id, subscription_type, **kwargs):
+        if 'type_root' not in kwargs:
+            if id == BUGDIR_ID:
+                kwargs['type_root'] = BUGDIR_TYPE_ALL 
+            else:
+                kwargs['type_root'] = BUG_TYPE_ALL 
         if type(subscription_type) in types.StringTypes:
             subscription_type = type_from_name(subscription_type, **kwargs)
         self.id = id