scons_gd/scons/test/Docbook/basedir/slideshtml/image/xsltver.py

21 lines
660 B
Python
Raw Permalink Normal View History

2022-10-15 16:06:26 +02:00
import os
import re
def detectXsltVersion(fpath):
""" Return a tuple with the version of the Docbook XSLT stylesheets,
or (0, 0, 0) if no stylesheets are installed or the VERSION
file couldn't be found/parsed correctly.
"""
with open(os.path.join(fpath, 'VERSION'), 'rb') as fin:
re_version = re.compile("<fm:Version>([^<]+)</fm:Version>".encode('utf-8'))
m = re_version.search(fin.read())
if m:
try:
return tuple(map(int, m.group(1).split(b'.')))
except Exception:
return (0, 0, 0)
return (0, 0, 0)
return (0, 0, 0)