summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Lint/Validate.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-07-24 11:32:56 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-07-24 11:33:10 -0400
commitdcf8fddddfa98f39549b57c89c5f79275b0c6b1c (patch)
treec46152862cb1cf0666c7bd531e0f008829cf04ea /src/lib/Bcfg2/Server/Lint/Validate.py
parent73ac82182e4cdf2d6371f24455ff7bda71afae81 (diff)
downloadbcfg2-dcf8fddddfa98f39549b57c89c5f79275b0c6b1c.tar.gz
bcfg2-dcf8fddddfa98f39549b57c89c5f79275b0c6b1c.tar.bz2
bcfg2-dcf8fddddfa98f39549b57c89c5f79275b0c6b1c.zip
allow xinclude files to be missing if xi:fallback is provided
Diffstat (limited to 'src/lib/Bcfg2/Server/Lint/Validate.py')
-rw-r--r--src/lib/Bcfg2/Server/Lint/Validate.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/lib/Bcfg2/Server/Lint/Validate.py b/src/lib/Bcfg2/Server/Lint/Validate.py
index aa5cfe62c..5499e75c2 100644
--- a/src/lib/Bcfg2/Server/Lint/Validate.py
+++ b/src/lib/Bcfg2/Server/Lint/Validate.py
@@ -1,10 +1,10 @@
-import fnmatch
+import os
+import sys
import glob
+import fnmatch
import lxml.etree
-import os
from subprocess import Popen, PIPE, STDOUT
-import sys
-
+from Bcfg2.Server import XI, XI_NAMESPACE
import Bcfg2.Server.Lint
class Validate(Bcfg2.Server.Lint.ServerlessPlugin):
@@ -174,23 +174,29 @@ class Validate(Bcfg2.Server.Lint.ServerlessPlugin):
def follow_xinclude(self, xfile):
""" follow xincludes in the given file """
xdata = lxml.etree.parse(xfile)
- included = set([ent.get('href') for ent in
- xdata.findall('./{http://www.w3.org/2001/XInclude}include')])
+ included = set([el
+ for el in xdata.findall('./%sinclude' % XI_NAMESPACE)])
rv = []
while included:
try:
- filename = included.pop()
+ el = included.pop()
except KeyError:
continue
+ filename = el.get("href")
path = os.path.join(os.path.dirname(xfile), filename)
- if self.HandlesFile(path):
+ if not os.path.exists(path):
+ if not el.findall('./%sfallback' % XI_NAMESPACE):
+ self.LintError("broken-xinclude-chain",
+ "XInclude %s does not exist in %s: %s" %
+ (filename, xfile, self.RenderXML(el)))
+ elif self.HandlesFile(path):
rv.append(path)
groupdata = lxml.etree.parse(path)
[included.add(el.get('href'))
for el in
- groupdata.findall('./{http://www.w3.org/2001/XInclude}include')]
+ groupdata.findall('./%sinclude' % XI_NAMESPACE)]
included.discard(filename)
return rv