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

Pavel Vinogradov blaze-guest at alioth.debian.org
Sun Jun 10 18:15:14 UTC 2007


Author: blaze-guest
Date: 2007-06-10 18:15:14 +0000 (Sun, 10 Jun 2007)
New Revision: 43

Modified:
   trunk/tools/oval/parser/dsa.py
   trunk/tools/oval/parser/wml.py
   trunk/tools/parse-dsa-oval.py
Log:
Use new parser module

Modified: trunk/tools/oval/parser/dsa.py
===================================================================
--- trunk/tools/oval/parser/dsa.py	2007-06-10 17:01:57 UTC (rev 42)
+++ trunk/tools/oval/parser/dsa.py	2007-06-10 18:15:14 UTC (rev 43)
@@ -10,7 +10,7 @@
 #<define-tag isvulnerable>yes|no</define-tag>                                                                                                  
 #<define-tag fixed>yes|no</define-tag>  
 
-def parseDSAFile (path):
+def parseFile (path):
 
 	data = {}
 	deb_ver = None

Modified: trunk/tools/oval/parser/wml.py
===================================================================
--- trunk/tools/oval/parser/wml.py	2007-06-10 17:01:57 UTC (rev 42)
+++ trunk/tools/oval/parser/wml.py	2007-06-10 18:15:14 UTC (rev 43)
@@ -1,10 +1,30 @@
 import re
 import os
+import sys
 import logging
 
 # Format of wml files is:
 #<define-tag description>DESCRIPTION</define-tag>
 #<define-tag moreinfo>Multiline information</define-tag>
 
-def parseWMLFile (path):
-    pass
\ No newline at end of file
+def parseFile (path):
+    
+    data = {}
+    deb_ver = None
+    
+    filename = os.path.basename (path)
+
+    patern = re.compile(r'dsa-(\d+)')
+    result = patern.search(filename)
+    if result:
+        dsa = result.groups()[0]
+    else:
+        logging.log(logging.WARNING, "File %s does not look like a proper DSA wml description, not checking" % filename)
+        return (None)
+
+    logging.log (logging.DEBUG, "Parsing information for DSA %s from wml file %s" % (dsa, filename))
+
+    wmlFile = open(path)
+    
+    for line in wmlFile:
+        sys.stderr.write(line)
\ No newline at end of file

Modified: trunk/tools/parse-dsa-oval.py
===================================================================
--- trunk/tools/parse-dsa-oval.py	2007-06-10 17:01:57 UTC (rev 42)
+++ trunk/tools/parse-dsa-oval.py	2007-06-10 18:15:14 UTC (rev 43)
@@ -13,7 +13,7 @@
 import logging
 
 import oval.definition.generator
-import oval.dsa.parser
+from oval.parser import dsa
 
 dsaref = []
 
@@ -36,7 +36,7 @@
 def parsedirs (directory, postfix, depth):
 	""" Recursive search directory for DSA files contain postfix in their names.
 
-		For this files called oval.dsa.parser.parseDSAFile() for extracting DSA information.
+		For this files called oval.parser.dsa.parseFile() for extracting DSA information.
 	"""
 
 	if depth == 0:
@@ -54,7 +54,7 @@
 			parsedirs (path, postfix, depth-1)
 
 		if os.access(path, os.R_OK) and file.endswith(postfix) and file[0] != '.' and file[0] != '#':
-			result = oval.dsa.parser.parseDSAFile (path)
+			result = dsa.parseFile (path)
 			if result:
 				dsaref.append (result)
 	return 0




More information about the Oval-commits mailing list