Fix #338: re.sub() flag argument at wrong position.
[docutils.git] / sandbox / docbook / scripts / validate_fo.py
blob0a0eb4256f81c8fc32c7c9804983b9673283dfca
1 import os, sys
2 from subprocess import Popen, PIPE
4 class ValidateFo():
6 def __init__(self):
7 valid_home = os.environ.get('VALIDATE_HOME')
8 if not valid_home:
9 raise OSError('You must set the "VALIDATE_HOME" variable')
10 xsl_stylesheet = os.path.join(valid_home, 'xslt', 'folint.xsl')
11 if not os.path.isfile(xsl_stylesheet):
12 raise OSError('Cannot find xsl_stylesheet')
13 self.xsl_stylesheet = xsl_stylesheet
15 def validate_fo(self, in_file):
16 command_list = ['xsltproc', self.xsl_stylesheet, in_file]
17 p = Popen(command_list, stdout=PIPE, stderr=PIPE)
18 stdout, stderr = p.communicate()
19 if len(stderr) != 0:
20 sys.stderr.write(stderr)
21 return False
22 return True
24 if __name__ == '__main__':
25 validate_obj = ValidateFo()
26 validate_obj.validate_fo(sys.argv[1])