[Swift-commit] r4307 - trunk/bin
skenny at ci.uchicago.edu
skenny at ci.uchicago.edu
Thu Apr 7 21:06:25 CDT 2011
Author: skenny
Date: 2011-04-07 21:06:25 -0500 (Thu, 07 Apr 2011)
New Revision: 4307
Added:
trunk/bin/chxml
Log:
sanity check for sites.xml
Added: trunk/bin/chxml
===================================================================
--- trunk/bin/chxml (rev 0)
+++ trunk/bin/chxml 2011-04-08 02:06:25 UTC (rev 4307)
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+
+# given a filename chxml will ensure it is well-formed xml and
+# contains essential swift attributes
+
+import xml.parsers.expat,sys
+from glob import glob
+
+def parsefile(file):
+ parser = xml.parsers.expat.ParserCreate()
+ parser.ParseFile(open(file, "r"))
+
+startTags= []
+endTags=[]
+
+def start_element(name, attrs):
+ startTags.append(name)
+def end_element(name):
+ print 'End element:', name
+ endTags.append(name)
+
+for arg in sys.argv[1:]:
+ for filename in glob(arg):
+ try:
+ parsefile(filename)
+ print "%s is well-formed" % filename
+ except Exception, e:
+ print "Error: there is a problem with your sites file"
+ print "%s is %s" % (filename, e)
+ sys.exit()
+
+ p = xml.parsers.expat.ParserCreate()
+ p.StartElementHandler = start_element
+ p.EndElementHandler = end_element
+ p.ParseFile(open(filename,"r"))
+
+config = 0
+pool = 0
+
+for tag in startTags:
+ if tag=="config":
+ config = 1
+ else:
+ if tag=="pool":
+ pool= 1
+
+if (pool and config):
+ pass
+else:
+ print "Error: there is a problem with your sites file "+sys.argv[1]
+
+
Property changes on: trunk/bin/chxml
___________________________________________________________________
Name: svn:executable
+ *
More information about the Swift-commit
mailing list