Blame SOURCES/journaling-fixes.patch

e965a0
diff -u b/src/python/journalling.py b/src/python/journalling.py
e965a0
--- b/src/python/journalling.py
e965a0
+++ b/src/python/journalling.py
e965a0
@@ -27,7 +27,6 @@
e965a0
 import re
e965a0
 from optparse import OptionParser
e965a0
 from lxml import etree
e965a0
-import shlex
e965a0
 import base64
e965a0
 
e965a0
 # TODO fix xml pretty print
e965a0
@@ -100,8 +99,8 @@
e965a0
     # Count number of leading spaces
e965a0
     indent = len(line) - len(line.lstrip())
e965a0
 
e965a0
-    # using shlex to get rid of the quotes
e965a0
-    splitted = shlex.split(line)
e965a0
+    # splitting the line into list
e965a0
+    splitted = line.split()
e965a0
 
e965a0
     # if the line is not empty
e965a0
     if splitted:
e965a0
@@ -118,7 +117,9 @@
e965a0
     for part in splitted:
e965a0
         # if flag is set, string is an elements content
e965a0
         if CONTENT_FLAG == 1:
e965a0
-            content = base64.b64decode(part)
e965a0
+            # First and last characters(quotes) stripped and
e965a0
+            # string is decoded from base64
e965a0
+            content = base64.b64decode(part[1:-1])
e965a0
             # end parsing after content is stored
e965a0
             break
e965a0
         # test if string is an elements content indicator
e965a0
@@ -128,13 +129,15 @@
e965a0
         # test if string is an elements time attribute
e965a0
         if re.match(r'^--timestamp=', part):
e965a0
             attribute_name = "timestamp"
e965a0
-            attribute_value = part.split('=', 1)[1]
e965a0
+            # Value is string after '=' sign and without first abd last char(quotes)
e965a0
+            attribute_value = part.split('=', 1)[1][1:-1]
e965a0
             attributes[attribute_name] = time.strftime(TIME_FORMAT, time.localtime(int(attribute_value)))
e965a0
             continue
e965a0
         # test if string is an elements regular attribute
e965a0
         if re.match(r'^--[a-zA-Z0-9]+=', part):
e965a0
             attribute_name = part.split('=', 1)[0][2:]
e965a0
-            attribute_value = part.split('=', 1)[1]
e965a0
+            # Value is string after '=' sign and without first abd last char(quotes)
e965a0
+            attribute_value = part.split('=', 1)[1][1:-1]
e965a0
             attributes[attribute_name] = base64.b64decode(attribute_value)
e965a0
             continue
e965a0
 
e965a0
@@ -145,7 +148,11 @@
e965a0
 # information given as parameters
e965a0
 def createElement(element, attributes, content):
e965a0
     element = unicode(element, 'utf-8', errors='replace').translate(xmlTrans)
e965a0
-    new_el = etree.Element(element)
e965a0
+    try:
e965a0
+        new_el = etree.Element(element)
e965a0
+    except ValueError, e:
e965a0
+        sys.stderr.write('Failed to create element with name %s\nError: %s\nExiting unsuccessfully.\n' % (element, e))
e965a0
+        exit(1)
e965a0
 
e965a0
     content = unicode(content, 'utf-8', errors='replace').translate(xmlTrans)
e965a0
     new_el.text = content