blob: 0a0eb4256f81c8fc32c7c9804983b9673283dfca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import os, sys
from subprocess import Popen, PIPE
class ValidateFo():
def __init__(self):
valid_home = os.environ.get('VALIDATE_HOME')
if not valid_home:
raise OSError('You must set the "VALIDATE_HOME" variable')
xsl_stylesheet = os.path.join(valid_home, 'xslt', 'folint.xsl')
if not os.path.isfile(xsl_stylesheet):
raise OSError('Cannot find xsl_stylesheet')
self.xsl_stylesheet = xsl_stylesheet
def validate_fo(self, in_file):
command_list = ['xsltproc', self.xsl_stylesheet, in_file]
p = Popen(command_list, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
if len(stderr) != 0:
sys.stderr.write(stderr)
return False
return True
if __name__ == '__main__':
validate_obj = ValidateFo()
validate_obj.validate_fo(sys.argv[1])
|