diff options
Diffstat (limited to 'libbe/util/id.py')
-rw-r--r-- | libbe/util/id.py | 28 |
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): """ |