[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: improvement for trunk/src/en/tools/find-xsl.p

From: Toralf Förster <toralf.foerster_at_gmx.de>
Date: 2005-03-17 15:05:27 CET

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

This is an archived mail posted to the Subversion Users mailing list.