Update of /cvsroot/eas-dev/eas-dev/tools/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv14691
Added Files:
docassistant.py
Log Message:
Initial commit. Work in progress.
--- NEW FILE: docassistant.py ---
#!/usr/bin/python
# /*******************************************************/
# /* */
# /* Copyright (c) 2003. */
# /* E/AS Software Foundation */
# /* */
# /* Author(s): */
# /* Egor Cheshkov <eg...@ip...> */
# /* */
# /* */
# /* This program is free software; you can redistribute */
# /* it and/or modify it under the terms of the GNU */
# /* Lesser General Public License as published by the */
# /* Free Software Foundation; version 2 of the License. */
# /* */
# /*******************************************************/
# $Id: docassistant.py,v 1.1 2003/01/27 19:59:23 egor Exp $
"""Usage:
%s <arguments> <ducument descriptor>
Arguments:
--check Check all modules for all languages are present,
main files for all languages are present
--fix Fix missing modules and files
--html Regenerate html document presentation
--pdf Regenerate pdf document presentation
--stylesheet=file Use alternative stylesheet
--help Print this message and exit
"""
import getopt
import sys
from xml.dom.minidom import parse
import os.path
def usage():
print __doc__ % sys.argv[0]
sys.exit(2)
def die(msg):
print "%s: %s" % (sys.argv[0], msg)
print
print "Try %s --help to get clue how to use it." % sys.argv[0]
type,value,traceback = sys.exc_info()
if type != None:
import traceback
print
traceback.print_exc()
sys.exit(1)
class DocumentDescriptor:
def __init__(self, file):
self._doc = parse(file)
def getLangs(self):
return map(lambda x: x.firstChild.data,
self._doc.getElementsByTagName('lang'))
def getModules(self):
modulesElem = self._doc.getElementsByTagName('modules')[0]
modules = []
for child in modulesElem.childNodes:
if child.nodeType == child.ELEMENT_NODE and \
child.nodeName == "module":
modules.append(child.getAttribute("id"))
return modules
def getId(self):
return self._doc.documentElement.getAttribute("id")
def main():
try:
optlist, args = getopt.getopt(sys.argv[1:], "",
["help", "check", "fix"])
except getopt.GetoptError:
usage()
if len(args) != 1:
usage()
else:
docDescrName = args[0]
try:
docDescrFile = open(docDescrName)
except:
die("Can't open document descriptor")
docPath = os.path.dirname(os.path.realpath('docDescrName'))
try:
docDescr = DocumentDescriptor(docDescrFile)
except:
die("Can't parse document descriptor. Check syntax")
altStylesheet = None
for o,a in optlist:
if o == "stylesheet":
altStylesheet = a
for o,a in optlist:
if o == "--help":
usage()
if o == "--check":
pass
if o == "--fix":
pass
if o == "--html":
pass
if o == "--pdf":
pass
if __name__ == "__main__":
main()
|