[Python-checkins] CVS: python/dist/src/Doc/tools indfix.py,1.4,1.5 toc2bkm.py,1.9,1.10 custlib.py,1.1,1.2

Fred L. Drake python-dev@python.org
Sat, 7 Oct 2000 05:50:08 -0700


Update of /cvsroot/python/python/dist/src/Doc/tools
In directory slayer.i.sourceforge.net:/tmp/cvs-serv26754

Modified Files:
	indfix.py toc2bkm.py custlib.py 
Log Message:

Hush the nanny.


Index: indfix.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/tools/indfix.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** indfix.py	1999/03/03 19:36:23	1.4
--- indfix.py	2000/10/07 12:50:04	1.5
***************
*** 31,42 ****
  def dump_entries(write, entries):
      if len(entries) == 1:
! 	write("  \\item %s (%s)%s\n" % entries[0])
! 	return
      write("  \item %s\n" % entries[0][0])
      # now sort these in a case insensitive manner:
      if len(entries) > 0:
! 	entries.sort(cmp_entries)
      for xxx, subitem, pages in entries:
! 	write("    \subitem %s%s\n" % (subitem, pages))
  
  
--- 31,42 ----
  def dump_entries(write, entries):
      if len(entries) == 1:
!         write("  \\item %s (%s)%s\n" % entries[0])
!         return
      write("  \item %s\n" % entries[0][0])
      # now sort these in a case insensitive manner:
      if len(entries) > 0:
!         entries.sort(cmp_entries)
      for xxx, subitem, pages in entries:
!         write("    \subitem %s%s\n" % (subitem, pages))
  
  
***************
*** 57,76 ****
      write = ofp.write
      while 1:
! 	line = ifp.readline()
! 	if not line:
! 	    break
! 	m = match(line)
! 	if m:
! 	    entry = m.group(1, 2, 3)
! 	    if entries and entries[-1][0] != entry[0]:
! 		dump_entries(write, entries)
! 		entries = []
! 	    entries.append(entry)
! 	elif entries:
! 	    dump_entries(write, entries)
! 	    entries = []
! 	    write(line)
! 	else:
! 	    write(line)
      del write
      del match
--- 57,76 ----
      write = ofp.write
      while 1:
!         line = ifp.readline()
!         if not line:
!             break
!         m = match(line)
!         if m:
!             entry = m.group(1, 2, 3)
!             if entries and entries[-1][0] != entry[0]:
!                 dump_entries(write, entries)
!                 entries = []
!             entries.append(entry)
!         elif entries:
!             dump_entries(write, entries)
!             entries = []
!             write(line)
!         else:
!             write(line)
      del write
      del match
***************
*** 79,85 ****
      ofp.close()
      if ofn == "-":
! 	ofp = sys.stdout
      else:
! 	ofp = open(ofn, "w")
      ofp.write(data)
      ofp.close()
--- 79,85 ----
      ofp.close()
      if ofn == "-":
!         ofp = sys.stdout
      else:
!         ofp = open(ofn, "w")
      ofp.write(data)
      ofp.close()
***************
*** 91,96 ****
      opts, args = getopt.getopt(sys.argv[1:], "o:")
      for opt, val in opts:
! 	if opt in ("-o", "--output"):
! 	    outfile = val
      filename = args[0]
      outfile = outfile or filename
--- 91,96 ----
      opts, args = getopt.getopt(sys.argv[1:], "o:")
      for opt, val in opts:
!         if opt in ("-o", "--output"):
!             outfile = val
      filename = args[0]
      outfile = outfile or filename

Index: toc2bkm.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/tools/toc2bkm.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** toc2bkm.py	1999/03/03 19:25:56	1.9
--- toc2bkm.py	2000/10/07 12:50:05	1.10
***************
*** 24,28 ****
  \{(?:\\numberline\ \{([0-9.A-Z]+)})?     # section number
  (.*)}                                   # title string
! \{(\d+)}$"""				# page number
  
  cline_rx = re.compile(cline_re, re.VERBOSE)
--- 24,28 ----
  \{(?:\\numberline\ \{([0-9.A-Z]+)})?     # section number
  (.*)}                                   # title string
! \{(\d+)}$"""                            # page number
  
  cline_rx = re.compile(cline_re, re.VERBOSE)
***************
*** 51,82 ****
      lineno = 0
      while 1:
! 	line = fp.readline()
! 	if not line:
! 	    break
! 	lineno = lineno + 1
! 	m = cline_rx.match(line)
! 	if m:
! 	    stype, snum, title, pageno = m.group(1, 2, 3, 4)
! 	    title = clean_title(title)
! 	    entry = (stype, snum, title, string.atoi(pageno), [])
! 	    if stype == level:
! 		toc.append(entry)
! 	    else:
                  if stype not in INCLUDED_LEVELS:
                      # we don't want paragraphs & subparagraphs
                      continue
! 		direction = _transition_map[(level, stype)]
! 		if direction == OUTER_TO_INNER:
! 		    toc = toc[-1][-1]
! 		    stack.insert(0, toc)
! 		    toc.append(entry)
! 		else:
! 		    for i in range(direction):
! 			del stack[0]
! 			toc = stack[0]
! 		    toc.append(entry)
! 		level = stype
! 	else:
! 	    sys.stderr.write("l.%s: " + line)
      return top
  
--- 51,82 ----
      lineno = 0
      while 1:
!         line = fp.readline()
!         if not line:
!             break
!         lineno = lineno + 1
!         m = cline_rx.match(line)
!         if m:
!             stype, snum, title, pageno = m.group(1, 2, 3, 4)
!             title = clean_title(title)
!             entry = (stype, snum, title, string.atoi(pageno), [])
!             if stype == level:
!                 toc.append(entry)
!             else:
                  if stype not in INCLUDED_LEVELS:
                      # we don't want paragraphs & subparagraphs
                      continue
!                 direction = _transition_map[(level, stype)]
!                 if direction == OUTER_TO_INNER:
!                     toc = toc[-1][-1]
!                     stack.insert(0, toc)
!                     toc.append(entry)
!                 else:
!                     for i in range(direction):
!                         del stack[0]
!                         toc = stack[0]
!                     toc.append(entry)
!                 level = stype
!         else:
!             sys.stderr.write("l.%s: " + line)
      return top
  
***************
*** 92,103 ****
      pos = 0
      while 1:
! 	m = title_rx.search(title, pos)
! 	if m:
! 	    start = m.start()
! 	    if title[start:start+15] != "\\textunderscore":
! 		title = title[:start] + title[m.end():]
! 	    pos = start + 1
! 	else:
! 	    break
      title = string.translate(title, title_trans, "{}")
      return title
--- 92,103 ----
      pos = 0
      while 1:
!         m = title_rx.search(title, pos)
!         if m:
!             start = m.start()
!             if title[start:start+15] != "\\textunderscore":
!                 title = title[:start] + title[m.end():]
!             pos = start + 1
!         else:
!             break
      title = string.translate(title, title_trans, "{}")
      return title
***************
*** 106,110 ****
  def write_toc(toc, fp):
      for entry in toc:
! 	write_toc_entry(entry, fp, 0)
  
  def write_toc_entry(entry, fp, layer):
--- 106,110 ----
  def write_toc(toc, fp):
      for entry in toc:
!         write_toc_entry(entry, fp, 0)
  
  def write_toc_entry(entry, fp, layer):
***************
*** 112,122 ****
      s = "\\pdfoutline goto name{page%03d}" % pageno
      if toc:
! 	s = "%s count -%d" % (s, len(toc))
      if snum:
! 	title = "%s %s" % (snum, title)
      s = "%s {%s}\n" % (s, title)
      fp.write(s)
      for entry in toc:
! 	write_toc_entry(entry, fp, layer + 1)
  
  
--- 112,122 ----
      s = "\\pdfoutline goto name{page%03d}" % pageno
      if toc:
!         s = "%s count -%d" % (s, len(toc))
      if snum:
!         title = "%s %s" % (snum, title)
      s = "%s {%s}\n" % (s, title)
      fp.write(s)
      for entry in toc:
!         write_toc_entry(entry, fp, layer + 1)
  
  
***************
*** 130,140 ****
      opts, args = getopt.getopt(sys.argv[1:], "c:")
      if opts:
! 	bigpart = opts[0][1]
      if not args:
! 	usage()
! 	sys.exit(2)
      for filename in args:
! 	base, ext = os.path.splitext(filename)
! 	ext = ext or ".toc"
          process(base + ext, base + ".bkm", bigpart)
  
--- 130,140 ----
      opts, args = getopt.getopt(sys.argv[1:], "c:")
      if opts:
!         bigpart = opts[0][1]
      if not args:
!         usage()
!         sys.exit(2)
      for filename in args:
!         base, ext = os.path.splitext(filename)
!         ext = ext or ".toc"
          process(base + ext, base + ".bkm", bigpart)
  

Index: custlib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/tools/custlib.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** custlib.py	1997/06/02 17:57:10	1.1
--- custlib.py	2000/10/07 12:50:05	1.2
***************
*** 13,29 ****
      filelist=glob.glob(os.path.join(dir, '*.py'))
      for file in filelist: 
! 	path, file = os.path.split(file)
! 	base, ext=os.path.splitext(file)
! 	modules[string.lower(base)]=base
  
      # Look for shared library files
      filelist=(glob.glob(os.path.join(dir, '*.so')) + 
! 	      glob.glob(os.path.join(dir, '*.sl')) +
! 	      glob.glob(os.path.join(dir, '*.o')) )
      for file in filelist: 
! 	path, file = os.path.split(file)
! 	base, ext=os.path.splitext(file)
! 	if base[-6:]=='module': base=base[:-6]
! 	modules[string.lower(base)]=base
  
  # Minor oddity: the types module is documented in libtypes2.tex
--- 13,29 ----
      filelist=glob.glob(os.path.join(dir, '*.py'))
      for file in filelist: 
!         path, file = os.path.split(file)
!         base, ext=os.path.splitext(file)
!         modules[string.lower(base)]=base
  
      # Look for shared library files
      filelist=(glob.glob(os.path.join(dir, '*.so')) + 
!               glob.glob(os.path.join(dir, '*.sl')) +
!               glob.glob(os.path.join(dir, '*.o')) )
      for file in filelist: 
!         path, file = os.path.split(file)
!         base, ext=os.path.splitext(file)
!         if base[-6:]=='module': base=base[:-6]
!         modules[string.lower(base)]=base
  
  # Minor oddity: the types module is documented in libtypes2.tex
***************
*** 54,58 ****
  \\title{Python Library Reference}
  \\input{boilerplate}
! \\makeindex			% tell \\index to actually write the .idx file
  \\begin{document}
  \\pagenumbering{roman}
--- 54,58 ----
  \\title{Python Library Reference}
  \\input{boilerplate}
! \\makeindex                     % tell \\index to actually write the .idx file
  \\begin{document}
  \\pagenumbering{roman}
***************
*** 70,73 ****
      
  # Write the end
! print """\\input{custlib.ind}			% Index
  \\end{document}"""
--- 70,73 ----
      
  # Write the end
! print """\\input{custlib.ind}                   % Index
  \\end{document}"""