Comments
Patch
@@ -420,5 +420,33 @@
"date": datefunc,
}
# tell hggettext to extract docstrings from these functions:
i18nfunctions = filters.values()
+
+# should this be a class?
+def _islabel(thing):
+ return isinstance(thing, dict) and 'data' in thing and 'label' in thing
+
+def labelify(thing, label=''):
+ if thing is None:
+ return None
+
+ if label is None:
+ label = ''
+
+ if _islabel(thing):
+ if thing['label'] not in label:
+ label += ' ' + thing['label']
+ thing = thing['data']
+
+ label = label.strip()
+
+ return {'data':thing, 'label':label}
+
+def delabelify(thing, label=''):
+ thing = labelify(thing, label)
+ if _islabel(thing):
+ label = thing['label']
+ thing = thing['data']
+
+ return thing, label