[Python-checkins] CVS: python/nondist/peps pep2html.py,1.25,1.26

Barry Warsaw bwarsaw@users.sourceforge.net
Thu, 05 Jul 2001 11:44:22 -0700


Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv26494

Modified Files:
	pep2html.py 
Log Message:
fixpat: Recognize current preferred usage for PEP references in body,
e.g. "PEP 1".

fixanchor(): Turn preferred usage for PEP references into PEP url
using the new PEPURL template (which uses the canonical
www.python.org/peps url instead of the sourceforge.net site).
(Also, get rid of base argument in int() calls; base 10 is default.)

fixfile(): If we can't open the input file, print an error message and
continue on.


Index: pep2html.py
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep2html.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -r1.25 -r1.26
*** pep2html.py	2001/06/05 17:21:19	1.25
--- pep2html.py	2001/07/05 18:44:20	1.26
***************
*** 33,39 ****
--- 33,41 ----
  import glob
  import getopt
+ import errno
  
  PROGRAM = sys.argv[0]
  RFCURL = 'http://www.faqs.org/rfcs/rfc%d.html'
+ PEPURL = 'pep-%04d.html'
  
  
***************
*** 49,53 ****
  
  fixpat = re.compile("((http|ftp):[-_a-zA-Z0-9/.+~:?#$=&]+)|(pep-\d+(.txt)?)|"
!                     "(RFC[- ]?(?P<rfcnum>\d+))|.")
  
  
--- 51,57 ----
  
  fixpat = re.compile("((http|ftp):[-_a-zA-Z0-9/.+~:?#$=&]+)|(pep-\d+(.txt)?)|"
!                     "(RFC[- ]?(?P<rfcnum>\d+))|"
!                     "(PEP\s+(?P<pepnum>\d+))|"
!                     ".")
  
  
***************
*** 71,76 ****
      elif text[:4] == "pep-" and text != current:
          link = os.path.splitext(text)[0] + ".html"
      elif text[:3] == 'RFC':
!         rfcnum = int(match.group('rfcnum'), 10)
          link = RFCURL % rfcnum
      if link:
--- 75,83 ----
      elif text[:4] == "pep-" and text != current:
          link = os.path.splitext(text)[0] + ".html"
+     elif text[:3] == 'PEP':
+         pepnum = int(match.group('pepnum'))
+         link = PEPURL % pepnum
      elif text[:3] == 'RFC':
!         rfcnum = int(match.group('rfcnum'))
          link = RFCURL % rfcnum
      if link:
***************
*** 82,86 ****
  def fixfile(infile, outfile):
      # convert plain text pep to minimal XHTML markup
!     fi = open(infile)
      fo = open(outfile, "w")
      fo.write(DTD + "\n<html>\n<head>\n")
--- 89,98 ----
  def fixfile(infile, outfile):
      # convert plain text pep to minimal XHTML markup
!     try:
!         fi = open(infile)
!     except IOError, e:
!         if e.errno <> errno.ENOENT: raise
!         print >> sys.stderr, 'Error: Skipping missing PEP file:', e.filename
!         return
      fo = open(outfile, "w")
      fo.write(DTD + "\n<html>\n<head>\n")