[Python-checkins] CVS: python/nondist/peps pep2html.py,1.27,1.28
Barry Warsaw
bwarsaw@users.sourceforge.net
Tue, 14 Aug 2001 14:42:41 -0700
Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv24175
Modified Files:
pep2html.py
Log Message:
fixpat: Add , to the list of punctuation allowable in a url.
fixanchor(): Adopt the algorithm for url recognition from faqwiz after
suggestion by Guido. Strip any trailing punctuation from the end
of the url.
Also, use .startswith() where appropriate.
Index: pep2html.py
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep2html.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** pep2html.py 2001/08/14 16:45:19 1.27
--- pep2html.py 2001/08/14 21:42:39 1.28
***************
*** 50,59 ****
' "http://www.w3.org/TR/REC-html40/loose.dtd">')
! fixpat = re.compile("((http|ftp):[-_a-zA-Z0-9/.+~:?#$=&]+)|(pep-\d+(.txt)?)|"
"(RFC[- ]?(?P<rfcnum>\d+))|"
"(PEP\s+(?P<pepnum>\d+))|"
".")
def usage(code, msg=''):
--- 50,62 ----
' "http://www.w3.org/TR/REC-html40/loose.dtd">')
! fixpat = re.compile("((http|ftp):[-_a-zA-Z0-9/.+~:?#$=&,]+)|(pep-\d+(.txt)?)|"
"(RFC[- ]?(?P<rfcnum>\d+))|"
"(PEP\s+(?P<pepnum>\d+))|"
".")
+ EMPTYSTRING = ''
+ SPACE = ' '
+
def usage(code, msg=''):
***************
*** 68,79 ****
text = match.group(0)
link = None
! if text[:5] == "http:" or text[:4] == "ftp:":
! link = text
! 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
--- 71,89 ----
text = match.group(0)
link = None
! if text.startswith('http:') or text.startswith('ftp:'):
! # Strip off trailing punctuation. Pattern taken from faqwiz.
! ltext = list(text)
! while ltext:
! c = ltext.pop()
! if c not in '();:,.?\'"<>':
! ltext.append(c)
! break
! link = EMPTYSTRING.join(ltext)
! elif text.startswith('pep-') and text <> current:
link = os.path.splitext(text)[0] + ".html"
! elif text.startswith('PEP'):
pepnum = int(match.group('pepnum'))
link = PEPURL % pepnum
! elif text.startswith('RFC'):
rfcnum = int(match.group('rfcnum'))
link = RFCURL % rfcnum
***************
*** 148,152 ****
else:
mailtos.append(addr)
! v = ' '.join(mailtos)
elif k.lower() in ('replaces', 'replaced-by'):
peps = ''
--- 158,162 ----
else:
mailtos.append(addr)
! v = SPACE.join(mailtos)
elif k.lower() in ('replaces', 'replaced-by'):
peps = ''
***************
*** 219,223 ****
return newfile
- SPACE = ' '
def push_pep(htmlfiles, txtfiles, username, verbose):
if verbose:
--- 229,232 ----