Skip to content
Snippets Groups Projects
Commit ed3c5e18 authored by Pierre-Yves David's avatar Pierre-Yves David
Browse files

bundle2: add reply awareness to unbundlerecords

We need an efficient way to handle bundle replies. The unbundle records class is
extended to carry such data.
parent e995d104
No related branches found
No related tags found
No related merge requests found
......@@ -205,4 +205,5 @@
def __init__(self):
self._categories = {}
self._sequences = []
self._replies = {}
......@@ -208,8 +209,8 @@
def add(self, category, entry):
def add(self, category, entry, inreplyto=None):
"""add a new record of a given category.
The entry can then be retrieved in the list returned by
self['category']."""
self._categories.setdefault(category, []).append(entry)
self._sequences.append((category, entry))
......@@ -210,9 +211,15 @@
"""add a new record of a given category.
The entry can then be retrieved in the list returned by
self['category']."""
self._categories.setdefault(category, []).append(entry)
self._sequences.append((category, entry))
if inreplyto is not None:
self.getreplies(inreplyto).add(category, entry)
def getreplies(self, partid):
"""get the subrecords that replies to a specific part"""
return self._replies.setdefault(partid, unbundlerecords())
def __getitem__(self, cat):
return tuple(self._categories.get(cat, ()))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment