[Python-checkins] python/dist/src/Doc/tools prechm.py,1.8,1.9

tim_one@sourceforge.net tim_one@sourceforge.net
2002年4月19日 20:25:04 -0700


Update of /cvsroot/python/python/dist/src/Doc/tools
In directory usw-pr-cvs1:/tmp/cvs-serv14735
Modified Files:
	prechm.py 
Log Message:
Replaced the fiddly 5-tuples with a new Book convenience class, allowing
to reference fields via names instead of meaningless little integers.
This turned up one case where the wrong little integer was being used,
in informative progress output. Fixed that too.
Index: prechm.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/tools/prechm.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** prechm.py	20 Apr 2002 02:56:20 -0000	1.8
--- prechm.py	20 Apr 2002 03:25:02 -0000	1.9
***************
*** 98,146 ****
 '''
 
! # Library Doc list of tuples:
 # each 'book' : (Dir, Title, First page, Content page, Index page)
- #
 supported_libraries = {
 '2.2': ### Beta!!! fix for actual release
 [
! ('.', 'Global Module Index', 'modindex.html', None, None),
! ('whatsnew', "What's New", 'index.html', 'contents.html', None),
! ('tut','Tutorial','tut.html','node2.html',None),
! ('lib','Library Reference','lib.html','contents.html','genindex.html'),
! ('ref','Language Reference','ref.html','contents.html','genindex.html'),
! ('mac','Macintosh Reference','mac.html','contents.html','genindex.html'),
! ('ext','Extending and Embedding','ext.html','contents.html',None),
! ('api','Python/C API','api.html','contents.html','genindex.html'),
! ('doc','Documenting Python','doc.html','contents.html',None),
! ('inst','Installing Python Modules', 'inst.html', 'index.html', None),
! ('dist','Distributing Python Modules', 'dist.html', 'index.html', None),
 ],
 
 '2.1.1':
 [
! ('.', 'Global Module Index', 'modindex.html', None, None),
! ('tut','Tutorial','tut.html','node2.html',None),
! ('lib','Library Reference','lib.html','contents.html','genindex.html'),
! ('ref','Language Reference','ref.html','contents.html','genindex.html'),
! ('mac','Macintosh Reference','mac.html','contents.html','genindex.html'),
! ('ext','Extending and Embedding','ext.html','contents.html',None),
! ('api','Python/C API','api.html','contents.html','genindex.html'),
! ('doc','Documenting Python','doc.html','contents.html',None),
! ('inst','Installing Python Modules', 'inst.html', 'index.html', None),
! ('dist','Distributing Python Modules', 'dist.html', 'index.html', None),
 ],
 
 '2.0.0':
 [
! ('.', 'Global Module Index', 'modindex.html', None, None),
! ('tut','Tutorial','tut.html','node2.html',None),
! ('lib','Library Reference','lib.html','contents.html','genindex.html'),
! ('ref','Language Reference','ref.html','contents.html','genindex.html'),
! ('mac','Macintosh Reference','mac.html','contents.html','genindex.html'),
! ('ext','Extending and Embedding','ext.html','contents.html',None),
! ('api','Python/C API','api.html','contents.html','genindex.html'),
! ('doc','Documenting Python','doc.html','contents.html',None),
! ('inst','Installing Python Modules', 'inst.html', 'contents.html', None),
! ('dist','Distributing Python Modules', 'dist.html', 'contents.html', None),
 ],
 
--- 98,164 ----
 '''
 
! # s is a string or None. If None or empty, return None. Else tack '.html'
! # on to the end, unless it's already there.
! def addhtml(s):
! if s:
! if not s.endswith('.html'):
! s += '.html'
! return s
! 
! # Convenience class to hold info about "a book" in HTMLHelp terms == a doc
! # directory in Python terms.
! class Book:
! def __init__(self, directory, title, firstpage,
! contentpage=None, indexpage=None):
! self.directory = directory
! self.title = title
! self.firstpage = addhtml(firstpage)
! self.contentpage = addhtml(contentpage)
! self.indexpage = addhtml(indexpage)
! 
! # Library Doc list of books:
 # each 'book' : (Dir, Title, First page, Content page, Index page)
 supported_libraries = {
 '2.2': ### Beta!!! fix for actual release
 [
! Book('.', 'Global Module Index', 'modindex'),
! Book('whatsnew', "What's New", 'index', 'contents'),
! Book('tut','Tutorial','tut','node2'),
! Book('lib','Library Reference','lib','contents','genindex'),
! Book('ref','Language Reference','ref','contents','genindex'),
! Book('mac','Macintosh Reference','mac','contents','genindex'),
! Book('ext','Extending and Embedding','ext','contents'),
! Book('api','Python/C API','api','contents','genindex'),
! Book('doc','Documenting Python','doc','contents'),
! Book('inst','Installing Python Modules', 'inst', 'index'),
! Book('dist','Distributing Python Modules', 'dist', 'index'),
 ],
 
 '2.1.1':
 [
! Book('.', 'Global Module Index', 'modindex'),
! Book('tut','Tutorial','tut','node2'),
! Book('lib','Library Reference','lib','contents','genindex'),
! Book('ref','Language Reference','ref','contents','genindex'),
! Book('mac','Macintosh Reference','mac','contents','genindex'),
! Book('ext','Extending and Embedding','ext','contents'),
! Book('api','Python/C API','api','contents','genindex'),
! Book('doc','Documenting Python','doc','contents'),
! Book('inst','Installing Python Modules', 'inst', 'index'),
! Book('dist','Distributing Python Modules', 'dist', 'index'),
 ],
 
 '2.0.0':
 [
! Book('.', 'Global Module Index', 'modindex'),
! Book('tut','Tutorial','tut','node2'),
! Book('lib','Library Reference','lib','contents','genindex'),
! Book('ref','Language Reference','ref','contents','genindex'),
! Book('mac','Macintosh Reference','mac','contents','genindex'),
! Book('ext','Extending and Embedding','ext','contents'),
! Book('api','Python/C API','api','contents','genindex'),
! Book('doc','Documenting Python','doc','contents'),
! Book('inst','Installing Python Modules', 'inst', 'contents'),
! Book('dist','Distributing Python Modules', 'dist', 'contents'),
 ],
 
***************
*** 149,159 ****
 '1.5.2':
 [
! ('tut','Tutorial','tut.html','node2.html',None),
! ('lib','Library Reference','lib.html','contents.html','genindex.html'),
! ('ref','Language Reference','ref.html','contents.html','genindex.html'),
! ('mac','Macintosh Reference','mac.html','contents.html','genindex.html'),
! ('ext','Extending and Embedding','ext.html','contents.html',None),
! ('api','Python/C API','api.html','contents.html','genindex.html'),
! ('doc','Documenting Python','doc.html','contents.html',None)
 ],
 
--- 167,177 ----
 '1.5.2':
 [
! Book('tut','Tutorial','tut','node2'),
! Book('lib','Library Reference','lib','contents','genindex'),
! Book('ref','Language Reference','ref','contents','genindex'),
! Book('mac','Macintosh Reference','mac','contents','genindex'),
! Book('ext','Extending and Embedding','ext','contents'),
! Book('api','Python/C API','api','contents','genindex'),
! Book('doc','Documenting Python','doc','contents')
 ],
 
***************
*** 161,169 ****
 '1.5.1':
 [
! ('tut','Tutorial','tut.html','contents.html',None),
! ('lib','Library Reference','lib.html','contents.html','genindex.html'),
! ('ref','Language Reference','ref-1.html','ref-2.html','ref-11.html'),
! ('ext','Extending and Embedding','ext.html','contents.html',None),
! ('api','Python/C API','api.html','contents.html','genindex.html')
 ],
 
--- 179,187 ----
 '1.5.1':
 [
! Book('tut','Tutorial','tut','contents'),
! Book('lib','Library Reference','lib','contents','genindex'),
! Book('ref','Language Reference','ref-1','ref-2','ref-11'),
! Book('ext','Extending and Embedding','ext','contents'),
! Book('api','Python/C API','api','contents','genindex')
 ],
 
***************
*** 171,179 ****
 '1.5':
 [
! ('tut','Tutorial','tut.html','node1.html',None),
! ('lib','Library Reference','lib.html','node1.html','node268.html'),
! ('ref','Language Reference','ref-1.html','ref-2.html','ref-11.html'),
! ('ext','Extending and Embedding','ext.html','node1.html',None),
! ('api','Python/C API','api.html','node1.html','node48.html')
 ]
 }
--- 189,197 ----
 '1.5':
 [
! Book('tut','Tutorial','tut','node1'),
! Book('lib','Library Reference','lib','node1','node268'),
! Book('ref','Language Reference','ref-1','ref-2','ref-11'),
! Book('ext','Extending and Embedding','ext','node1'),
! Book('api','Python/C API','api','node1','node48')
 ]
 }
***************
*** 264,285 ****
 
 
! def index(path, archivo, output):
 f = formatter.AbstractFormatter(AlmostNullWriter())
 parser = IdxHlpHtmlParser(f)
 parser.path = path
 parser.ft = output
! fil = path + '/' + archivo
! parser.feed(open(fil).read())
 parser.close()
 
 
! def content(path, archivo, output):
 f = formatter.AbstractFormatter(AlmostNullWriter())
 parser = TocHlpHtmlParser(f)
 parser.path = path
 parser.ft = output
! fil = path + '/' + archivo
! parser.feed(open(fil).read())
 parser.close()
 
 
--- 282,305 ----
 
 
! def index(path, indexpage, output):
 f = formatter.AbstractFormatter(AlmostNullWriter())
 parser = IdxHlpHtmlParser(f)
 parser.path = path
 parser.ft = output
! f = open(path + '/' + indexpage)
! parser.feed(f.read())
 parser.close()
+ f.close()
 
 
! def content(path, contentpage, output):
 f = formatter.AbstractFormatter(AlmostNullWriter())
 parser = TocHlpHtmlParser(f)
 parser.path = path
 parser.ft = output
! f = open(path + '/' + contentpage)
! parser.feed(f.read())
 parser.close()
+ f.close()
 
 
***************
*** 287,293 ****
 output.write('<UL>\n')
 for book in library:
! print '\t', book[2]
! if book[4]:
! index(book[0], book[4], output)
 output.write('</UL>\n')
 
--- 307,313 ----
 output.write('<UL>\n')
 for book in library:
! print '\t', book.title, '-', book.indexpage
! if book.indexpage:
! index(book.directory, book.indexpage, output)
 output.write('</UL>\n')
 
***************
*** 296,303 ****
 output.write(contents_header % version)
 for book in library:
! print '\t', book[2]
! output.write(object_sitemap % (book[0]+"/"+book[2], book[1]))
! if book[3]:
! content(book[0], book[3], output)
 output.write(contents_footer)
 
--- 316,324 ----
 output.write(contents_header % version)
 for book in library:
! print '\t', book.title, '-', book.firstpage
! output.write(object_sitemap % (book.directory + "/" + book.firstpage,
! book.title))
! if book.contentpage:
! content(book.directory, book.contentpage, output)
 output.write(contents_footer)
 
***************
*** 308,312 ****
 output.write(project_template % locals())
 for book in library:
! directory = book[0]
 path = directory + '\\%s\n'
 for page in os.listdir(directory):
--- 329,333 ----
 output.write(project_template % locals())
 for book in library:
! directory = book.directory
 path = directory + '\\%s\n'
 for page in os.listdir(directory):
***************
*** 354,358 ****
 usage()
 
! library = supported_libraries[ version ]
 
 if not (('-p','') in optlist):
--- 375,379 ----
 usage()
 
! library = supported_libraries[version]
 
 if not (('-p','') in optlist):

AltStyle によって変換されたページ (->オリジナル) /