Bugs that are filed by or appended to by apport have key:value pairs
inserted into their descriptions. The patch below enables arsenal to
parse this data out and provides it in a dictionary structure.
Posting to the list for comment before I merge it.
Also, attaching an example script for testing purposes, which outputs
the bug properties in JSON format.
Comments welcomed.
Bryce
=== modified file 'lpltk/bug.py'
--- a/lpltk/bug.py 2010-07-17 18:19:25 +0000
+++ b/lpltk/bug.py 2010-12-07 08:09:09 +0000
@@ -1,5 +1,6 @@
#!/usr/bin/python
+import re
from utils import o2str
from tags import BugTags
from attachments import Attachments
@@ -27,6 +28,7 @@
self.__tags = None
self.__attachments = None
self.__owner = None
+ self.__properties = None
#--------------------------------------------------------------------------
# title
@@ -89,4 +91,42 @@
def attachments(self):
return Attachments(self)
+ def _parse_properties(self, text):
+ return props
+
+ #--------------------------------------------------------------------------
+ # properties
+ #
+ @property
+ def properties(self):
+ '''Returns dict of key: value pairs found in the bug description
+
+ This parses the bug report description into a more
+ programmatically digestable dictionary form.
+ '''
+ if self.__properties is None:
+ re_kvp = re.compile("^(\s*)([\.\-\w]+):\s*(.*)$")
+ re_error = re.compile("^Error:\s*(.*)$")
+ self.__properties = {}
+ last_key = {'': 'bar'}
+ for line in self.description.split("\n"):
+ m = re_kvp.match(line)
+ if not m:
+ continue
+
+ level = m.group(1)
+ item = m.group(2)
+ value = m.group(3)
+ key = item
+
+ if len(level)> 0:
+ key = "%s.%s" %(last_key[''], item)
+ last_key[level] = item
+
+ m = re_error.match(value)
+ if not m:
+ self.__properties[key] = value
+
+ return self.__properties
+
# vi:set ts=4 sw=4 expandtab:
_______________________________________________
Mailing list: https://launchpad.net/~arsenal-devel
Post to : arsenal-devel@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~arsenal-devel
More help : https://help.launchpad.net/ListHelp