On Thu, 2005-03-17 at 10:31 +0000, Max Bowsher wrote:
> Toralf Förster wrote:
> > Under gentoo the xsl is not located under the
> > dir /usr/share/sgml/docbook/xsl-stylesheets, it is stored under the dir
> > under /usr/share/sgml/docbook/xsl-stylesheets-<version>
> > eg /usr/share/sgml/docbook/xsl-stylesheets-1.66.1/.
>
> Patches welcome.
>
> Max.
>
My first Python experiences, don't cry, please :-)
#!/usr/bin/env python
import sys
import os
import glob
#######################################################
candidate_xsldirs = (
'/usr/share/sgml/docbook/xsl-stylesheets',
'/usr/share/docbook-xsl',
# Please add your OS's location here if not listed!
# Gentoo: '/usr/share/sgml/docbook/xsl-stylesheets-<version>',
)
#######################################################
tools_dir = os.path.dirname(sys.argv[0])
xsl_dir = os.path.join(tools_dir, 'xsl')
if os.path.exists(xsl_dir):
print "XSL directory %s already exists" % (xsl_dir,)
sys.exit(0)
for i in candidate_xsldirs:
if os.path.exists(os.path.join(i, 'html', 'docbook.xsl')):
os.symlink(i, xsl_dir)
print "Found and linked %s" % (i,)
break
else:
for j in glob.glob(i + '-*'):
if os.path.exists(os.path.join(j, 'html', 'docbook.xsl')):
os.symlink(j, xsl_dir)
print "Found and linked %s" % (j,)
break
if os.path.exists(xsl_dir):
sys.exit(0)
else:
sys.stderr.write('ERROR: Failed to find a DocBook XSL directory\n')
sys.exit(1)
--
Mit freundlichen Grüßen / Sincerely yours
Toralf Förster
_____________________________________________
Warning: potentially contains traces of nuts.
Received on Thu Mar 17 15:08:21 2005