~svn/ubuntu/oneiric/subversion/ppa

« back to all changes in this revision

Viewing changes to doc/tools/bin/find-xsl.py

  • Committer: Max Bowsher
  • Date: 2012-06-27 12:25:12 UTC
  • mfrom: (44.1.46 precise)
  • Revision ID: _@maxb.eu-20120627122512-kmo8fj0lr7mlkppj
Make tree identical to precise branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
 
3
 
import sys
4
 
import os
5
 
import glob
6
 
 
7
 
#######################################################
8
 
candidate_xsldirs = (
9
 
    # Fedora
10
 
    '/usr/share/sgml/docbook/xsl-stylesheets',
11
 
    # Cygwin
12
 
    '/usr/share/docbook-xsl',
13
 
    # Debian
14
 
    '/usr/share/xml/docbook/stylesheet/nwalsh',
15
 
    # SUSE
16
 
    '/usr/share/xml/docbook/stylesheet/nwalsh/current',
17
 
    # FreeBSD
18
 
    '/usr/local/share/xsl/docbook',
19
 
    # Gentoo
20
 
    '/usr/share/sgml/docbook/xsl-stylesheets-*',
21
 
    # Please add your OS's location here if not listed!
22
 
    )
23
 
#######################################################
24
 
 
25
 
tools_bin_dir = os.path.dirname(sys.argv[0])
26
 
xsl_dir = os.path.join(tools_bin_dir, '..', 'xsl')
27
 
 
28
 
if os.path.exists(xsl_dir):
29
 
  print "XSL directory %s already exists" % (xsl_dir,)
30
 
  sys.exit(0)
31
 
 
32
 
for i in candidate_xsldirs:
33
 
  # Crude method of preferring the highest version, when multiple exist
34
 
  globs = sorted(glob.glob(i))
35
 
  globs.reverse()
36
 
  for j in globs:
37
 
    if os.path.exists(os.path.join(j, 'html', 'docbook.xsl')):
38
 
      os.symlink(j, xsl_dir)
39
 
      print "Found and linked %s" % (j,)
40
 
      sys.exit(0)
41
 
 
42
 
sys.stderr.write('ERROR: Failed to find a DocBook XSL directory\n')
43
 
sys.exit(1)