[Oval-commits] r44 - trunk/tools/oval/parser

Pavel Vinogradov blaze-guest at alioth.debian.org
Tue Jun 12 13:12:24 UTC 2007


Author: blaze-guest
Date: 2007-06-12 13:12:24 +0000 (Tue, 12 Jun 2007)
New Revision: 44

Modified:
   trunk/tools/oval/parser/wml.py
Log:
WML file parsing 


Modified: trunk/tools/oval/parser/wml.py
===================================================================
--- trunk/tools/oval/parser/wml.py	2007-06-10 18:15:14 UTC (rev 43)
+++ trunk/tools/oval/parser/wml.py	2007-06-12 13:12:24 UTC (rev 44)
@@ -8,23 +8,51 @@
 #<define-tag moreinfo>Multiline information</define-tag>
 
 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
+	
+	data = {}
+	moreinfo = False
+	
+	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))
+	
+	try:
+		wmlFile = open(path)
+		
+		for line in wmlFile:
+			
+			
+			descrpatern = re.compile (r'description>(.*?)</define-tag>')
+			result = descrpatern.search (line)
+			if result:
+				data["description"] = result.groups()[0]
+				continue
+				
+			sinfopatern = re.compile (r'<define-tag moreinfo>(.*?)')
+			result = sinfopatern.search (line)
+			if result:
+				moreinfo = True
+				data["moreinfo"] = result.groups()[0] 
+				continue
+			
+			einfopatern = re.compile (r'</define-tag>')
+			if moreinfo and einfopatern.search (line):
+				moreinfo = False
+				continue
+			
+			if moreinfo:
+				data["moreinfo"] += line
+				continue
+			
+	except IOError:
+		logging.log (logging.ERROR, "Can't work with file %s" % path)
+	
+	return ({dsa : data})
\ No newline at end of file




More information about the Oval-commits mailing list