aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/util/id.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-12-10 19:31:47 -0500
committerW. Trevor King <wking@drexel.edu>2009-12-10 19:31:47 -0500
commita153347564e4c6baa0388fda05530f5548d16ac5 (patch)
treeb45fa56249efa1ac9308f73a6d53dffc098ae98b /libbe/util/id.py
parentf52fc3a243edf5ccef2dcdfd0c4b4cded4357e13 (diff)
downloadbugseverywhere-a153347564e4c6baa0388fda05530f5548d16ac5.tar.gz
Moved bugdir, bug, and comment over to new id implementation.
Diffstat (limited to 'libbe/util/id.py')
-rw-r--r--libbe/util/id.py28
1 files changed, 23 insertions, 5 deletions
diff --git a/libbe/util/id.py b/libbe/util/id.py
index d443706..ab62359 100644
--- a/libbe/util/id.py
+++ b/libbe/util/id.py
@@ -137,7 +137,7 @@ class ID (object):
referenced object. It would be hard to find bug 'XYZ' if
that's all you knew. Much easier with 'ABC/XYZ', where ABC
is the bugdir. Each project can publish a list of bugdir-id
-x - to - location mappings, e.g.
+ - to - location mappings, e.g.
ABC...(full uuid)...DEF https://server.com/projectX/be/
which is easier than publishing all-object-ids-to-location
mappings.
@@ -169,9 +169,9 @@ x - to - location mappings, e.g.
self._object = object
self._type = type
assert self._type in HIERARCHY, self._type
- self.uuid = self._object.uuid
def storage(self, *args):
+ import libbe.comment
return _assemble(self._object.uuid, *args)
def _ancestors(self):
@@ -182,7 +182,7 @@ x - to - location mappings, e.g.
o = self._object
for i in range(index, 0, -1):
parent_name = HIERARCHY[i-1]
- o = getattr(o, parent_name)
+ o = getattr(o, parent_name, None)
ret.insert(0, o)
return ret
@@ -190,8 +190,26 @@ x - to - location mappings, e.g.
return _assemble(*[o.uuid for o in self._ancestors()])
def user(self):
- return _assemble(*[_truncate(o.uuid, o.sibling_uuids())
- for o in self._ancestors()])
+ ids = []
+ for o in self._ancestors():
+ if o == None:
+ ids.append(None)
+ else:
+ ids.append(_truncate(o.uuid, o.sibling_uuids()))
+ return _assemble(*ids)
+
+def child_uuids(child_storage_ids):
+ """
+ Extract uuid children from other children generated by the
+ ID.storage() method.
+ >>> list(child_uuids(['abc123/values', '123abc', '123def']))
+ ['123abc', '123def']
+ """
+ for id in child_storage_ids:
+ fields = libbe.util.id._split(id)
+ if len(fields) == 1:
+ yield fields[0]
+
def parse_user(id):
"""