[Oval-commits] r52 - in trunk/tools: . oval/parser

Pavel Vinogradov blaze-guest at alioth.debian.org
Sat Jun 16 14:03:30 UTC 2007


Author: blaze-guest
Date: 2007-06-16 14:03:29 +0000 (Sat, 16 Jun 2007)
New Revision: 52

Modified:
   trunk/tools/TODO
   trunk/tools/oval/parser/wml.py
Log:
Intellegent parsing of WML files 


Modified: trunk/tools/TODO
===================================================================
--- trunk/tools/TODO	2007-06-15 17:34:11 UTC (rev 51)
+++ trunk/tools/TODO	2007-06-16 14:03:29 UTC (rev 52)
@@ -4,4 +4,7 @@
 		
 oval/definition/generator.py:
 	Rewrite tests generation conform to linux-definition-schema
-	 
\ No newline at end of file
+	 
+Future:
+oval/parser/wml.py
+	Save html tags instead of omit them 
\ No newline at end of file

Modified: trunk/tools/oval/parser/wml.py
===================================================================
--- trunk/tools/oval/parser/wml.py	2007-06-15 17:34:11 UTC (rev 51)
+++ trunk/tools/oval/parser/wml.py	2007-06-16 14:03:29 UTC (rev 52)
@@ -46,7 +46,8 @@
 			
 			einfopatern = re.compile (r'</define-tag>')
 			if moreinfo and einfopatern.search (line):
-				moreinfo = False
+				data["moreinfo"] = parseMoreinfo(data["moreinfo"])
+ 				moreinfo = False
 				continue
 			
 			if moreinfo:
@@ -56,4 +57,24 @@
 	except IOError:
 		logging.log (logging.ERROR, "Can't work with file %s" % path)
 	
-	return (dsa, data)
\ No newline at end of file
+	return (dsa, data)
+
+def parseMoreinfo (info):
+	
+	from xml.sax import saxutils
+	
+	p = re.compile ("<p>(.*?)</p>", re.DOTALL)
+	paragraphs = [m.groups()[0]  for m in re.finditer(p, info, re.DOTALL)]
+	result = ""
+
+	for par in paragraphs:
+		if re.match(re.compile("For the .* distribution"), par):
+			break
+		result += "\n" + par
+	
+	return result
+
+if __name__ == "__main__":
+	(dsa, info) = parseFile ("/home/blaze/opt/testdata/simple/dsa-1282.wml")
+	print dsa
+	print info["moreinfo"]
\ No newline at end of file




More information about the Oval-commits mailing list