summaryrefslogtreecommitdiffstats
path: root/setup.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-12-10 17:19:54 -0600
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-12-10 17:22:38 -0600
commit9d6e6241954d001a5b49e4ea9a48c10e2a792958 (patch)
tree270309c0e04eacf2ce1e0d6cc6d61f1485899c0a /setup.py
parent7dcb468f09781bacf79823748ef12bfbd1faeb21 (diff)
downloadbcfg2-9d6e6241954d001a5b49e4ea9a48c10e2a792958.tar.gz
bcfg2-9d6e6241954d001a5b49e4ea9a48c10e2a792958.tar.bz2
bcfg2-9d6e6241954d001a5b49e4ea9a48c10e2a792958.zip
generate XML schema docs from XML schemas themselves
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py109
1 files changed, 1 insertions, 108 deletions
diff --git a/setup.py b/setup.py
index e486afb5f..3fb42e585 100755
--- a/setup.py
+++ b/setup.py
@@ -1,11 +1,7 @@
#!/usr/bin/env python
from setuptools import setup
-from setuptools import Command
-from fnmatch import fnmatch
from glob import glob
-import os
-import os.path
import sys
vfile = 'src/lib/Bcfg2/version.py'
@@ -22,114 +18,11 @@ version = sys.version_info[:2]
if version < (2, 6):
need_m2crypto = True
-
-class BuildDTDDoc (Command):
- """Build DTD documentation"""
-
- description = "Build DTD documentation"
-
- # List of option tuples: long name, short name (None if no short
- # name), and help string.
- user_options = [
- ('links-file=', 'l', 'Links file'),
- ('source-dir=', 's', 'Source directory'),
- ('build-dir=', None, 'Build directory'),
- ('xslt=', None, 'XSLT file'),
- ]
-
- def initialize_options(self):
- """Set default values for all the options that this command
- supports."""
-
- self.build_links = False
- self.links_file = None
- self.source_dir = None
- self.build_dir = None
- self.xslt = None
-
- def finalize_options(self):
- """Set final values for all the options that this command
- supports."""
- if self.source_dir is None:
- if os.path.isdir('schemas'):
- for root, dirnames, filenames in os.walk('schemas'):
- for filename in filenames:
- if fnmatch(filename, '*.xsd'):
- self.source_dir = root
- self.announce('Using source directory %s' % root)
- break
- self.ensure_dirname('source_dir')
- self.source_dir = os.path.abspath(self.source_dir)
-
- if self.build_dir is None:
- build = self.get_finalized_command('build')
- self.build_dir = os.path.join(build.build_base, 'dtd')
- self.mkpath(self.build_dir)
-
- if self.links_file is None:
- self.links_file = "links.xml"
- if os.path.isfile(os.path.join(self.source_dir, "links.xml")):
- self.announce("Using linksFile links.xml")
- else:
- self.build_links = True
-
- if self.xslt is None:
- xsl_files = glob(os.path.join(self.source_dir, '*.xsl'))
- if xsl_files:
- self.xslt = xsl_files[0]
- self.announce("Using XSLT file %s" % self.xslt)
- self.ensure_filename('xslt')
-
- def run(self):
- """Perform XSLT transforms, writing output to self.build_dir"""
-
- xslt = lxml.etree.parse(self.xslt).getroot()
- transform = lxml.etree.XSLT(xslt)
-
- if self.build_links:
- self.announce("Building linksFile %s" % self.links_file)
- links_xml = \
- lxml.etree.Element('links',
- attrib={'xmlns': "http://titanium.dstc.edu.au/xml/xs3p"})
- for filename in glob(os.path.join(self.source_dir, '*.xsd')):
- attrib = {'file-location': os.path.basename(filename),
- 'docfile-location': os.path.splitext(os.path.basename(filename))[0] + ".html"}
- links_xml.append(lxml.etree.Element('schema', attrib=attrib))
- open(os.path.join(self.source_dir, self.links_file),
- "w").write(lxml.etree.tostring(links_xml))
-
- # build parameter dict
- params = {'printLegend': "'false'",
- 'printGlossary': "'false'",
- 'sortByComponent': "'false'"}
- if self.links_file is not None:
- params['linksFile'] = "'%s'" % self.links_file
- params['searchIncludedSchemas'] = "'true'"
-
- for filename in glob(os.path.join(self.source_dir, '*.xsd')):
- outfile = \
- os.path.join(self.build_dir,
- os.path.splitext(os.path.basename(filename))[0] +
- ".html")
- self.announce("Transforming %s to %s" % (filename, outfile))
- xml = lxml.etree.parse(filename).getroot()
- xhtml = str(transform(xml, **params))
- open(outfile, 'w').write(xhtml)
-
-cmdclass = {}
-
-try:
- import lxml.etree
- cmdclass['build_dtddoc'] = BuildDTDDoc
-except ImportError:
- pass
-
inst_reqs = ['lxml']
if need_m2crypto:
inst_reqs.append('M2Crypto')
-setup(cmdclass=cmdclass,
- name="Bcfg2",
+setup(name="Bcfg2",
version="1.3.0pre2",
description="Bcfg2 Server",
author="Narayan Desai",