2000-07-20 18:29:24 -04:00
|
|
|
|
#!/usr/bin/env python
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
"""Convert PEPs to (X)HTML - courtesy of /F
|
2000-07-20 18:29:24 -04:00
|
|
|
|
|
2004-04-02 14:20:13 -05:00
|
|
|
|
Usage: %(PROGRAM)s [options] [<peps> ...]
|
2000-08-28 12:00:49 -04:00
|
|
|
|
|
2000-08-15 01:53:19 -04:00
|
|
|
|
Options:
|
2000-07-24 23:51:44 -04:00
|
|
|
|
|
2004-04-02 14:20:13 -05:00
|
|
|
|
-u, --user
|
|
|
|
|
python.org username
|
2000-08-28 12:00:49 -04:00
|
|
|
|
|
2004-04-02 14:20:13 -05:00
|
|
|
|
-b, --browse
|
|
|
|
|
After generating the HTML, direct your web browser to view it
|
|
|
|
|
(using the Python webbrowser module). If both -i and -b are
|
|
|
|
|
given, this will browse the on-line HTML; otherwise it will
|
|
|
|
|
browse the local HTML. If no pep arguments are given, this
|
|
|
|
|
will browse PEP 0.
|
2002-03-15 13:14:39 -05:00
|
|
|
|
|
2004-04-02 14:20:13 -05:00
|
|
|
|
-i, --install
|
|
|
|
|
After generating the HTML, install it and the plaintext source file
|
|
|
|
|
(.txt) on python.org. In that case the user's name is used in the scp
|
|
|
|
|
and ssh commands, unless "-u username" is given (in which case, it is
|
|
|
|
|
used instead). Without -i, -u is ignored.
|
2000-07-24 23:51:44 -04:00
|
|
|
|
|
2004-04-02 14:20:13 -05:00
|
|
|
|
-l, --local
|
|
|
|
|
Same as -i/--install, except install on the local machine. Use this
|
2005-10-12 12:08:28 -04:00
|
|
|
|
when logged in to the python.org machine (dinsdale).
|
2002-11-11 19:56:27 -05:00
|
|
|
|
|
2004-04-02 14:20:13 -05:00
|
|
|
|
-q, --quiet
|
|
|
|
|
Turn off verbose messages.
|
2000-11-03 10:43:28 -05:00
|
|
|
|
|
2004-04-02 14:20:13 -05:00
|
|
|
|
-h, --help
|
|
|
|
|
Print this help message and exit.
|
2001-11-12 09:58:07 -05:00
|
|
|
|
|
2016-06-23 18:57:01 -04:00
|
|
|
|
The optional arguments ``peps`` are either pep numbers, .rst or .txt files.
|
2000-07-20 18:29:24 -04:00
|
|
|
|
"""
|
|
|
|
|
|
2015-04-12 23:27:02 -04:00
|
|
|
|
from __future__ import print_function, unicode_literals
|
|
|
|
|
|
2000-08-15 01:53:19 -04:00
|
|
|
|
import sys
|
|
|
|
|
import os
|
|
|
|
|
import re
|
|
|
|
|
import glob
|
|
|
|
|
import getopt
|
2001-07-05 14:44:20 -04:00
|
|
|
|
import errno
|
2002-04-02 18:07:13 -05:00
|
|
|
|
import random
|
2002-03-01 14:07:46 -05:00
|
|
|
|
import time
|
2015-04-12 23:27:02 -04:00
|
|
|
|
from io import open
|
2016-05-03 03:51:13 -04:00
|
|
|
|
try:
|
|
|
|
|
from html import escape
|
|
|
|
|
except ImportError:
|
|
|
|
|
from cgi import escape
|
2000-07-20 18:29:24 -04:00
|
|
|
|
|
2017-06-11 15:42:47 -04:00
|
|
|
|
from docutils import core, nodes, utils
|
|
|
|
|
from docutils.readers import standalone
|
|
|
|
|
from docutils.transforms import peps, references, misc, frontmatter, Transform
|
|
|
|
|
from docutils.parsers import rst
|
|
|
|
|
|
2017-09-05 14:05:57 -04:00
|
|
|
|
class DataError(Exception):
|
|
|
|
|
pass
|
|
|
|
|
|
2015-04-12 23:27:02 -04:00
|
|
|
|
REQUIRES = {'python': '2.6',
|
2002-10-18 21:33:12 -04:00
|
|
|
|
'docutils': '0.2.7'}
|
2000-08-15 01:53:19 -04:00
|
|
|
|
PROGRAM = sys.argv[0]
|
2001-06-05 13:21:19 -04:00
|
|
|
|
RFCURL = 'http://www.faqs.org/rfcs/rfc%d.html'
|
2001-07-05 14:44:20 -04:00
|
|
|
|
PEPURL = 'pep-%04d.html'
|
2014-10-07 16:04:45 -04:00
|
|
|
|
PEPCVSURL = ('https://hg.python.org/peps/file/tip/pep-%04d.txt')
|
2002-03-15 13:14:39 -05:00
|
|
|
|
PEPDIRRUL = 'http://www.python.org/peps/'
|
2000-08-15 01:53:19 -04:00
|
|
|
|
|
|
|
|
|
|
2005-10-12 12:08:28 -04:00
|
|
|
|
HOST = "dinsdale.python.org" # host for update
|
2005-10-13 17:04:15 -04:00
|
|
|
|
HDIR = "/data/ftp.python.org/pub/www.python.org/peps" # target host directory
|
2000-07-28 02:40:10 -04:00
|
|
|
|
LOCALVARS = "Local Variables:"
|
2000-07-25 00:12:28 -04:00
|
|
|
|
|
2002-11-07 22:43:48 -05:00
|
|
|
|
COMMENT = """<!--
|
|
|
|
|
This HTML is auto-generated. DO NOT EDIT THIS FILE! If you are writing a new
|
|
|
|
|
PEP, see http://www.python.org/peps/pep-0001.html for instructions and links
|
|
|
|
|
to templates. DO NOT USE THIS HTML FILE AS YOUR TEMPLATE!
|
|
|
|
|
-->"""
|
|
|
|
|
|
2000-08-15 01:53:19 -04:00
|
|
|
|
# The generated HTML doesn't validate -- you cannot use <hr> and <h3> inside
|
|
|
|
|
# <pre> tags. But if I change that, the result doesn't look very nice...
|
2000-07-24 23:51:44 -04:00
|
|
|
|
DTD = ('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"\n'
|
|
|
|
|
' "http://www.w3.org/TR/REC-html40/loose.dtd">')
|
2000-07-20 18:44:36 -04:00
|
|
|
|
|
2016-06-23 18:57:01 -04:00
|
|
|
|
fixpat = re.compile("((https?|ftp):[-_a-zA-Z0-9/.+~:?#$=&,]+)|(pep-\d+(.txt|.rst)?)|"
|
2001-07-05 14:44:20 -04:00
|
|
|
|
"(RFC[- ]?(?P<rfcnum>\d+))|"
|
|
|
|
|
"(PEP\s+(?P<pepnum>\d+))|"
|
|
|
|
|
".")
|
2000-07-20 18:29:24 -04:00
|
|
|
|
|
2001-08-14 17:42:39 -04:00
|
|
|
|
EMPTYSTRING = ''
|
|
|
|
|
SPACE = ' '
|
2002-07-30 12:17:11 -04:00
|
|
|
|
COMMASPACE = ', '
|
2001-08-14 17:42:39 -04:00
|
|
|
|
|
2000-08-15 01:53:19 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def usage(code, msg=''):
|
2004-04-02 14:20:13 -05:00
|
|
|
|
"""Print usage message and exit. Uses stderr if code != 0."""
|
|
|
|
|
if code == 0:
|
|
|
|
|
out = sys.stdout
|
|
|
|
|
else:
|
|
|
|
|
out = sys.stderr
|
2015-04-12 23:27:02 -04:00
|
|
|
|
print(__doc__ % globals(), file=out)
|
2000-08-15 01:53:19 -04:00
|
|
|
|
if msg:
|
2015-04-12 23:27:02 -04:00
|
|
|
|
print(msg, file=out)
|
2000-08-15 01:53:19 -04:00
|
|
|
|
sys.exit(code)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-07-24 23:51:44 -04:00
|
|
|
|
def fixanchor(current, match):
|
2000-07-20 18:29:24 -04:00
|
|
|
|
text = match.group(0)
|
|
|
|
|
link = None
|
2004-07-19 15:05:01 -04:00
|
|
|
|
if (text.startswith('http:') or text.startswith('https:')
|
|
|
|
|
or text.startswith('ftp:')):
|
2001-08-14 17:42:39 -04:00
|
|
|
|
# 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)
|
2015-04-12 23:27:02 -04:00
|
|
|
|
elif text.startswith('pep-') and text != current:
|
2000-07-20 18:29:24 -04:00
|
|
|
|
link = os.path.splitext(text)[0] + ".html"
|
2001-08-14 17:42:39 -04:00
|
|
|
|
elif text.startswith('PEP'):
|
2001-07-05 14:44:20 -04:00
|
|
|
|
pepnum = int(match.group('pepnum'))
|
|
|
|
|
link = PEPURL % pepnum
|
2001-08-14 17:42:39 -04:00
|
|
|
|
elif text.startswith('RFC'):
|
2001-07-05 14:44:20 -04:00
|
|
|
|
rfcnum = int(match.group('rfcnum'))
|
2001-06-05 13:21:19 -04:00
|
|
|
|
link = RFCURL % rfcnum
|
2000-07-20 18:29:24 -04:00
|
|
|
|
if link:
|
2016-05-03 03:51:13 -04:00
|
|
|
|
return '<a href="%s">%s</a>' % (escape(link), escape(text))
|
|
|
|
|
return escape(match.group(0)) # really slow, but it works...
|
2000-07-20 18:29:24 -04:00
|
|
|
|
|
2000-08-15 01:53:19 -04:00
|
|
|
|
|
2002-05-28 11:46:24 -04:00
|
|
|
|
|
|
|
|
|
NON_MASKED_EMAILS = [
|
|
|
|
|
'peps@python.org',
|
|
|
|
|
'python-list@python.org',
|
|
|
|
|
'python-dev@python.org',
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
def fixemail(address, pepno):
|
|
|
|
|
if address.lower() in NON_MASKED_EMAILS:
|
|
|
|
|
# return hyperlinked version of email address
|
|
|
|
|
return linkemail(address, pepno)
|
|
|
|
|
else:
|
|
|
|
|
# return masked version of email address
|
|
|
|
|
parts = address.split('@', 1)
|
|
|
|
|
return '%s at %s' % (parts[0], parts[1])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def linkemail(address, pepno):
|
|
|
|
|
parts = address.split('@', 1)
|
|
|
|
|
return ('<a href="mailto:%s@%s?subject=PEP%%20%s">'
|
|
|
|
|
'%s at %s</a>'
|
|
|
|
|
% (parts[0], parts[1], pepno, parts[0], parts[1]))
|
|
|
|
|
|
2000-08-15 01:53:19 -04:00
|
|
|
|
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
def fixfile(inpath, input_lines, outfile):
|
2015-04-12 23:27:02 -04:00
|
|
|
|
try:
|
|
|
|
|
from email.Utils import parseaddr
|
|
|
|
|
except ImportError:
|
|
|
|
|
from email.utils import parseaddr
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
basename = os.path.basename(inpath)
|
|
|
|
|
infile = iter(input_lines)
|
2002-08-29 23:22:58 -04:00
|
|
|
|
# convert plaintext pep to minimal XHTML markup
|
2015-04-12 23:27:02 -04:00
|
|
|
|
print(DTD, file=outfile)
|
|
|
|
|
print('<html>', file=outfile)
|
|
|
|
|
print(COMMENT, file=outfile)
|
|
|
|
|
print('<head>', file=outfile)
|
2000-07-20 18:29:24 -04:00
|
|
|
|
# head
|
|
|
|
|
header = []
|
2000-07-20 18:44:36 -04:00
|
|
|
|
pep = ""
|
|
|
|
|
title = ""
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
for line in infile:
|
2000-07-27 15:18:59 -04:00
|
|
|
|
if not line.strip():
|
2000-07-20 18:29:24 -04:00
|
|
|
|
break
|
2000-07-27 15:18:59 -04:00
|
|
|
|
if line[0].strip():
|
|
|
|
|
if ":" not in line:
|
|
|
|
|
break
|
|
|
|
|
key, value = line.split(":", 1)
|
|
|
|
|
value = value.strip()
|
|
|
|
|
header.append((key, value))
|
|
|
|
|
else:
|
|
|
|
|
# continuation line
|
|
|
|
|
key, value = header[-1]
|
|
|
|
|
value = value + line
|
|
|
|
|
header[-1] = key, value
|
2000-07-20 18:29:24 -04:00
|
|
|
|
if key.lower() == "title":
|
2000-07-20 18:44:36 -04:00
|
|
|
|
title = value
|
2000-07-27 15:18:59 -04:00
|
|
|
|
elif key.lower() == "pep":
|
2000-07-20 18:44:36 -04:00
|
|
|
|
pep = value
|
|
|
|
|
if pep:
|
|
|
|
|
title = "PEP " + pep + " -- " + title
|
|
|
|
|
if title:
|
2016-05-03 03:51:13 -04:00
|
|
|
|
print(' <title>%s</title>' % escape(title), file=outfile)
|
2015-04-12 23:27:02 -04:00
|
|
|
|
r = random.choice(list(range(64)))
|
|
|
|
|
print((
|
2002-11-11 19:56:27 -05:00
|
|
|
|
' <link rel="STYLESHEET" href="style.css" type="text/css" />\n'
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
'</head>\n'
|
2002-11-11 19:56:27 -05:00
|
|
|
|
'<body bgcolor="white">\n'
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
'<table class="navigation" cellpadding="0" cellspacing="0"\n'
|
|
|
|
|
' width="100%%" border="0">\n'
|
|
|
|
|
'<tr><td class="navicon" width="150" height="35">\n'
|
|
|
|
|
'<a href="../" title="Python Home Page">\n'
|
|
|
|
|
'<img src="../pics/PyBanner%03d.gif" alt="[Python]"\n'
|
|
|
|
|
' border="0" width="150" height="35" /></a></td>\n'
|
|
|
|
|
'<td class="textlinks" align="left">\n'
|
2015-04-12 23:27:02 -04:00
|
|
|
|
'[<b><a href="../">Python Home</a></b>]' % r), file=outfile)
|
|
|
|
|
if basename != 'pep-0000.txt':
|
|
|
|
|
print('[<b><a href=".">PEP Index</a></b>]', file=outfile)
|
2002-02-16 05:44:32 -05:00
|
|
|
|
if pep:
|
2002-08-29 23:22:58 -04:00
|
|
|
|
try:
|
2015-04-12 23:27:02 -04:00
|
|
|
|
print(('[<b><a href="pep-%04d.txt">PEP Source</a>'
|
|
|
|
|
'</b>]' % int(pep)), file=outfile)
|
|
|
|
|
except ValueError as error:
|
|
|
|
|
print(('ValueError (invalid PEP number): %s'
|
|
|
|
|
% error), file=sys.stderr)
|
|
|
|
|
print('</td></tr></table>', file=outfile)
|
|
|
|
|
print('<div class="header">\n<table border="0">', file=outfile)
|
2000-07-20 18:29:24 -04:00
|
|
|
|
for k, v in header:
|
2013-06-05 15:03:27 -04:00
|
|
|
|
if k.lower() in ('author', 'bdfl-delegate', 'discussions-to'):
|
2000-08-17 00:27:04 -04:00
|
|
|
|
mailtos = []
|
2002-07-30 12:17:11 -04:00
|
|
|
|
for part in re.split(',\s*', v):
|
|
|
|
|
if '@' in part:
|
|
|
|
|
realname, addr = parseaddr(part)
|
2002-05-28 11:46:24 -04:00
|
|
|
|
if k.lower() == 'discussions-to':
|
|
|
|
|
m = linkemail(addr, pep)
|
|
|
|
|
else:
|
|
|
|
|
m = fixemail(addr, pep)
|
2002-07-30 12:17:11 -04:00
|
|
|
|
mailtos.append('%s <%s>' % (realname, m))
|
|
|
|
|
elif part.startswith('http:'):
|
2001-03-21 13:59:03 -05:00
|
|
|
|
mailtos.append(
|
2002-07-30 12:17:11 -04:00
|
|
|
|
'<a href="%s">%s</a>' % (part, part))
|
2000-08-17 00:27:04 -04:00
|
|
|
|
else:
|
2002-07-30 12:17:11 -04:00
|
|
|
|
mailtos.append(part)
|
|
|
|
|
v = COMMASPACE.join(mailtos)
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
elif k.lower() in ('replaces', 'replaced-by', 'requires'):
|
2002-03-01 14:07:46 -05:00
|
|
|
|
otherpeps = ''
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
for otherpep in re.split(',?\s+', v):
|
2002-03-01 14:07:46 -05:00
|
|
|
|
otherpep = int(otherpep)
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
otherpeps += '<a href="pep-%04d.html">%i</a> ' % (otherpep,
|
2002-03-01 14:07:46 -05:00
|
|
|
|
otherpep)
|
|
|
|
|
v = otherpeps
|
|
|
|
|
elif k.lower() in ('last-modified',):
|
|
|
|
|
date = v or time.strftime('%d-%b-%Y',
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
time.localtime(os.stat(inpath)[8]))
|
2014-10-07 12:11:48 -04:00
|
|
|
|
if date.startswith('$' 'Date: ') and date.endswith(' $'):
|
|
|
|
|
date = date[6:-2]
|
2013-09-28 15:10:28 -04:00
|
|
|
|
if basename == 'pep-0000.txt':
|
2002-08-29 23:22:58 -04:00
|
|
|
|
v = date
|
2013-09-28 15:10:28 -04:00
|
|
|
|
else:
|
|
|
|
|
try:
|
|
|
|
|
url = PEPCVSURL % int(pep)
|
2016-05-03 03:51:13 -04:00
|
|
|
|
v = '<a href="%s">%s</a> ' % (url, escape(date))
|
2015-04-12 23:27:02 -04:00
|
|
|
|
except ValueError as error:
|
2013-09-28 15:10:28 -04:00
|
|
|
|
v = date
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
elif k.lower() in ('content-type',):
|
|
|
|
|
url = PEPURL % 9
|
|
|
|
|
pep_type = v or 'text/plain'
|
2016-05-03 03:51:13 -04:00
|
|
|
|
v = '<a href="%s">%s</a> ' % (url, escape(pep_type))
|
2014-10-07 12:12:47 -04:00
|
|
|
|
elif k.lower() == 'version':
|
|
|
|
|
if v.startswith('$' 'Revision: ') and v.endswith(' $'):
|
2016-05-03 03:51:13 -04:00
|
|
|
|
v = escape(v[11:-2])
|
2000-08-17 00:27:04 -04:00
|
|
|
|
else:
|
2016-05-03 03:51:13 -04:00
|
|
|
|
v = escape(v)
|
2015-04-12 23:27:02 -04:00
|
|
|
|
print(' <tr><th>%s: </th><td>%s</td></tr>' \
|
2016-05-03 03:51:13 -04:00
|
|
|
|
% (escape(k), v), file=outfile)
|
2015-04-12 23:27:02 -04:00
|
|
|
|
print('</table>', file=outfile)
|
|
|
|
|
print('</div>', file=outfile)
|
|
|
|
|
print('<hr />', file=outfile)
|
|
|
|
|
print('<div class="content">', file=outfile)
|
2002-04-04 10:42:20 -05:00
|
|
|
|
need_pre = 1
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
for line in infile:
|
2001-08-14 12:45:19 -04:00
|
|
|
|
if line[0] == '\f':
|
|
|
|
|
continue
|
|
|
|
|
if line.strip() == LOCALVARS:
|
|
|
|
|
break
|
|
|
|
|
if line[0].strip():
|
2002-04-04 10:42:20 -05:00
|
|
|
|
if not need_pre:
|
2015-04-12 23:27:02 -04:00
|
|
|
|
print('</pre>', file=outfile)
|
|
|
|
|
print('<h3>%s</h3>' % line.strip(), file=outfile)
|
2002-04-04 10:42:20 -05:00
|
|
|
|
need_pre = 1
|
|
|
|
|
elif not line.strip() and need_pre:
|
|
|
|
|
continue
|
2001-08-14 12:45:19 -04:00
|
|
|
|
else:
|
|
|
|
|
# PEP 0 has some special treatment
|
|
|
|
|
if basename == 'pep-0000.txt':
|
|
|
|
|
parts = line.split()
|
|
|
|
|
if len(parts) > 1 and re.match(r'\s*\d{1,4}', parts[1]):
|
|
|
|
|
# This is a PEP summary line, which we need to hyperlink
|
|
|
|
|
url = PEPURL % int(parts[1])
|
2002-04-04 10:42:20 -05:00
|
|
|
|
if need_pre:
|
2015-04-12 23:27:02 -04:00
|
|
|
|
print('<pre>', file=outfile)
|
2002-04-04 10:42:20 -05:00
|
|
|
|
need_pre = 0
|
2015-04-12 23:27:02 -04:00
|
|
|
|
print(re.sub(
|
2001-08-14 12:45:19 -04:00
|
|
|
|
parts[1],
|
|
|
|
|
'<a href="%s">%s</a>' % (url, parts[1]),
|
2018-02-15 19:54:56 -05:00
|
|
|
|
line, 1), end='', file=outfile)
|
2001-08-14 12:45:19 -04:00
|
|
|
|
continue
|
|
|
|
|
elif parts and '@' in parts[-1]:
|
2002-05-28 11:46:24 -04:00
|
|
|
|
# This is a pep email address line, so filter it.
|
|
|
|
|
url = fixemail(parts[-1], pep)
|
2002-04-04 10:42:20 -05:00
|
|
|
|
if need_pre:
|
2015-04-12 23:27:02 -04:00
|
|
|
|
print('<pre>', file=outfile)
|
2002-04-04 10:42:20 -05:00
|
|
|
|
need_pre = 0
|
2015-04-12 23:27:02 -04:00
|
|
|
|
print(re.sub(
|
2018-02-15 19:54:56 -05:00
|
|
|
|
parts[-1], url, line, 1), end='', file=outfile)
|
2001-08-14 12:45:19 -04:00
|
|
|
|
continue
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
line = fixpat.sub(lambda x, c=inpath: fixanchor(c, x), line)
|
2002-04-04 10:42:20 -05:00
|
|
|
|
if need_pre:
|
2015-04-12 23:27:02 -04:00
|
|
|
|
print('<pre>', file=outfile)
|
2002-04-04 10:42:20 -05:00
|
|
|
|
need_pre = 0
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
outfile.write(line)
|
2002-04-04 10:42:20 -05:00
|
|
|
|
if not need_pre:
|
2015-04-12 23:27:02 -04:00
|
|
|
|
print('</pre>', file=outfile)
|
|
|
|
|
print('</div>', file=outfile)
|
|
|
|
|
print('</body>', file=outfile)
|
|
|
|
|
print('</html>', file=outfile)
|
2000-07-20 18:29:24 -04:00
|
|
|
|
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
|
2002-10-18 01:19:08 -04:00
|
|
|
|
docutils_settings = None
|
|
|
|
|
"""Runtime settings object used by Docutils. Can be set by the client
|
|
|
|
|
application when this module is imported."""
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
|
2017-06-11 15:42:47 -04:00
|
|
|
|
class PEPHeaders(Transform):
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
Process fields in a PEP's initial RFC-2822 header.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
default_priority = 360
|
|
|
|
|
|
|
|
|
|
pep_url = 'pep-%04d'
|
|
|
|
|
pep_cvs_url = PEPCVSURL
|
|
|
|
|
rcs_keyword_substitutions = (
|
|
|
|
|
(re.compile(r'\$' r'RCSfile: (.+),v \$$', re.IGNORECASE), r'\1'),
|
|
|
|
|
(re.compile(r'\$[a-zA-Z]+: (.+) \$$'), r'\1'),)
|
|
|
|
|
|
|
|
|
|
def apply(self):
|
|
|
|
|
if not len(self.document):
|
|
|
|
|
# @@@ replace these DataErrors with proper system messages
|
|
|
|
|
raise DataError('Document tree is empty.')
|
|
|
|
|
header = self.document[0]
|
|
|
|
|
if not isinstance(header, nodes.field_list) or \
|
|
|
|
|
'rfc2822' not in header['classes']:
|
|
|
|
|
raise DataError('Document does not begin with an RFC-2822 '
|
|
|
|
|
'header; it is not a PEP.')
|
|
|
|
|
pep = None
|
|
|
|
|
for field in header:
|
|
|
|
|
if field[0].astext().lower() == 'pep': # should be the first field
|
|
|
|
|
value = field[1].astext()
|
|
|
|
|
try:
|
|
|
|
|
pep = int(value)
|
|
|
|
|
cvs_url = self.pep_cvs_url % pep
|
|
|
|
|
except ValueError:
|
|
|
|
|
pep = value
|
|
|
|
|
cvs_url = None
|
|
|
|
|
msg = self.document.reporter.warning(
|
|
|
|
|
'"PEP" header must contain an integer; "%s" is an '
|
|
|
|
|
'invalid value.' % pep, base_node=field)
|
|
|
|
|
msgid = self.document.set_id(msg)
|
|
|
|
|
prb = nodes.problematic(value, value or '(none)',
|
|
|
|
|
refid=msgid)
|
|
|
|
|
prbid = self.document.set_id(prb)
|
|
|
|
|
msg.add_backref(prbid)
|
|
|
|
|
if len(field[1]):
|
|
|
|
|
field[1][0][:] = [prb]
|
|
|
|
|
else:
|
|
|
|
|
field[1] += nodes.paragraph('', '', prb)
|
|
|
|
|
break
|
|
|
|
|
if pep is None:
|
|
|
|
|
raise DataError('Document does not contain an RFC-2822 "PEP" '
|
|
|
|
|
'header.')
|
|
|
|
|
if pep == 0:
|
|
|
|
|
# Special processing for PEP 0.
|
2017-11-10 02:21:15 -05:00
|
|
|
|
pending = nodes.pending(peps.PEPZero)
|
2017-06-11 15:42:47 -04:00
|
|
|
|
self.document.insert(1, pending)
|
|
|
|
|
self.document.note_pending(pending)
|
|
|
|
|
if len(header) < 2 or header[1][0].astext().lower() != 'title':
|
|
|
|
|
raise DataError('No title!')
|
|
|
|
|
for field in header:
|
|
|
|
|
name = field[0].astext().lower()
|
|
|
|
|
body = field[1]
|
|
|
|
|
if len(body) > 1:
|
|
|
|
|
raise DataError('PEP header field body contains multiple '
|
|
|
|
|
'elements:\n%s' % field.pformat(level=1))
|
|
|
|
|
elif len(body) == 1:
|
|
|
|
|
if not isinstance(body[0], nodes.paragraph):
|
|
|
|
|
raise DataError('PEP header field body may only contain '
|
|
|
|
|
'a single paragraph:\n%s'
|
|
|
|
|
% field.pformat(level=1))
|
|
|
|
|
elif name == 'last-modified':
|
|
|
|
|
date = time.strftime(
|
|
|
|
|
'%d-%b-%Y',
|
|
|
|
|
time.localtime(os.stat(self.document['source'])[8]))
|
|
|
|
|
if cvs_url:
|
|
|
|
|
body += nodes.paragraph(
|
|
|
|
|
'', '', nodes.reference('', date, refuri=cvs_url))
|
|
|
|
|
else:
|
|
|
|
|
# empty
|
|
|
|
|
continue
|
|
|
|
|
para = body[0]
|
2017-06-11 15:43:16 -04:00
|
|
|
|
if name in ('author', 'bdfl-delegate'):
|
2017-06-11 15:42:47 -04:00
|
|
|
|
for node in para:
|
|
|
|
|
if isinstance(node, nodes.reference):
|
|
|
|
|
node.replace_self(peps.mask_email(node))
|
|
|
|
|
elif name == 'discussions-to':
|
|
|
|
|
for node in para:
|
|
|
|
|
if isinstance(node, nodes.reference):
|
|
|
|
|
node.replace_self(peps.mask_email(node, pep))
|
|
|
|
|
elif name in ('replaces', 'replaced-by', 'requires'):
|
|
|
|
|
newbody = []
|
|
|
|
|
space = nodes.Text(' ')
|
|
|
|
|
for refpep in re.split(r',?\s+', body.astext()):
|
|
|
|
|
pepno = int(refpep)
|
|
|
|
|
newbody.append(nodes.reference(
|
|
|
|
|
refpep, refpep,
|
|
|
|
|
refuri=(self.document.settings.pep_base_url
|
|
|
|
|
+ self.pep_url % pepno)))
|
|
|
|
|
newbody.append(space)
|
|
|
|
|
para[:] = newbody[:-1] # drop trailing space
|
|
|
|
|
elif name == 'last-modified':
|
|
|
|
|
utils.clean_rcs_keywords(para, self.rcs_keyword_substitutions)
|
|
|
|
|
if cvs_url:
|
|
|
|
|
date = para.astext()
|
|
|
|
|
para[:] = [nodes.reference('', date, refuri=cvs_url)]
|
|
|
|
|
elif name == 'content-type':
|
|
|
|
|
pep_type = para.astext()
|
|
|
|
|
uri = self.document.settings.pep_base_url + self.pep_url % 12
|
|
|
|
|
para[:] = [nodes.reference('', pep_type, refuri=uri)]
|
|
|
|
|
elif name == 'version' and len(body):
|
|
|
|
|
utils.clean_rcs_keywords(para, self.rcs_keyword_substitutions)
|
|
|
|
|
|
|
|
|
|
class PEPReader(standalone.Reader):
|
|
|
|
|
|
|
|
|
|
supported = ('pep',)
|
|
|
|
|
"""Contexts this reader supports."""
|
|
|
|
|
|
|
|
|
|
settings_spec = (
|
|
|
|
|
'PEP Reader Option Defaults',
|
|
|
|
|
'The --pep-references and --rfc-references options (for the '
|
|
|
|
|
'reStructuredText parser) are on by default.',
|
|
|
|
|
())
|
|
|
|
|
|
|
|
|
|
config_section = 'pep reader'
|
|
|
|
|
config_section_dependencies = ('readers', 'standalone reader')
|
|
|
|
|
|
|
|
|
|
def get_transforms(self):
|
|
|
|
|
transforms = standalone.Reader.get_transforms(self)
|
|
|
|
|
# We have PEP-specific frontmatter handling.
|
|
|
|
|
transforms.remove(frontmatter.DocTitle)
|
|
|
|
|
transforms.remove(frontmatter.SectionSubTitle)
|
|
|
|
|
transforms.remove(frontmatter.DocInfo)
|
|
|
|
|
transforms.extend([PEPHeaders, peps.Contents, peps.TargetNotes])
|
|
|
|
|
return transforms
|
|
|
|
|
|
|
|
|
|
settings_default_overrides = {'pep_references': 1, 'rfc_references': 1}
|
|
|
|
|
|
|
|
|
|
inliner_class = rst.states.Inliner
|
|
|
|
|
|
|
|
|
|
def __init__(self, parser=None, parser_name=None):
|
|
|
|
|
"""`parser` should be ``None``."""
|
|
|
|
|
if parser is None:
|
|
|
|
|
parser = rst.Parser(rfc2822=True, inliner=self.inliner_class())
|
|
|
|
|
standalone.Reader.__init__(self, parser, '')
|
|
|
|
|
|
|
|
|
|
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
def fix_rst_pep(inpath, input_lines, outfile):
|
2002-10-18 21:33:12 -04:00
|
|
|
|
output = core.publish_string(
|
|
|
|
|
source=''.join(input_lines),
|
|
|
|
|
source_path=inpath,
|
|
|
|
|
destination_path=outfile.name,
|
2017-06-11 15:42:47 -04:00
|
|
|
|
reader=PEPReader(),
|
2002-10-18 21:33:12 -04:00
|
|
|
|
parser_name='restructuredtext',
|
|
|
|
|
writer_name='pep_html',
|
2004-04-02 14:20:13 -05:00
|
|
|
|
settings=docutils_settings,
|
|
|
|
|
# Allow Docutils traceback if there's an exception:
|
2016-07-05 13:14:38 -04:00
|
|
|
|
settings_overrides={'traceback': 1, 'halt_level': 2})
|
2015-04-12 23:27:02 -04:00
|
|
|
|
outfile.write(output.decode('utf-8'))
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_pep_type(input_lines):
|
|
|
|
|
"""
|
|
|
|
|
Return the Content-Type of the input. "text/plain" is the default.
|
|
|
|
|
Return ``None`` if the input is not a PEP.
|
|
|
|
|
"""
|
|
|
|
|
pep_type = None
|
|
|
|
|
for line in input_lines:
|
|
|
|
|
line = line.rstrip().lower()
|
|
|
|
|
if not line:
|
|
|
|
|
# End of the RFC 2822 header (first blank line).
|
|
|
|
|
break
|
|
|
|
|
elif line.startswith('content-type: '):
|
|
|
|
|
pep_type = line.split()[1] or 'text/plain'
|
|
|
|
|
break
|
|
|
|
|
elif line.startswith('pep: '):
|
|
|
|
|
# Default PEP type, used if no explicit content-type specified:
|
|
|
|
|
pep_type = 'text/plain'
|
|
|
|
|
return pep_type
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_input_lines(inpath):
|
|
|
|
|
try:
|
2015-04-12 23:27:02 -04:00
|
|
|
|
infile = open(inpath, encoding='utf-8')
|
|
|
|
|
except IOError as e:
|
|
|
|
|
if e.errno != errno.ENOENT: raise
|
|
|
|
|
print('Error: Skipping missing PEP file:', e.filename, file=sys.stderr)
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
sys.stderr.flush()
|
2007-05-10 18:55:31 -04:00
|
|
|
|
return None
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
lines = infile.read().splitlines(1) # handles x-platform line endings
|
|
|
|
|
infile.close()
|
|
|
|
|
return lines
|
2001-08-14 12:45:19 -04:00
|
|
|
|
|
2000-08-28 12:00:49 -04:00
|
|
|
|
|
|
|
|
|
def find_pep(pep_str):
|
2016-06-23 18:57:01 -04:00
|
|
|
|
"""Find the .rst or .txt file indicated by a cmd line argument"""
|
2000-08-28 12:00:49 -04:00
|
|
|
|
if os.path.exists(pep_str):
|
|
|
|
|
return pep_str
|
|
|
|
|
num = int(pep_str)
|
2016-06-23 18:57:01 -04:00
|
|
|
|
rstpath = "pep-%04d.rst" % num
|
|
|
|
|
if os.path.exists(rstpath):
|
|
|
|
|
return rstpath
|
2000-08-28 12:00:49 -04:00
|
|
|
|
return "pep-%04d.txt" % num
|
|
|
|
|
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
def make_html(inpath, verbose=0):
|
|
|
|
|
input_lines = get_input_lines(inpath)
|
2007-05-10 18:55:31 -04:00
|
|
|
|
if input_lines is None:
|
|
|
|
|
return None
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
pep_type = get_pep_type(input_lines)
|
|
|
|
|
if pep_type is None:
|
2015-04-12 23:27:02 -04:00
|
|
|
|
print('Error: Input file %s is not a PEP.' % inpath, file=sys.stderr)
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
sys.stdout.flush()
|
|
|
|
|
return None
|
2015-04-12 23:27:02 -04:00
|
|
|
|
elif pep_type not in PEP_TYPE_DISPATCH:
|
|
|
|
|
print(('Error: Unknown PEP type for input file %s: %s'
|
|
|
|
|
% (inpath, pep_type)), file=sys.stderr)
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
sys.stdout.flush()
|
|
|
|
|
return None
|
|
|
|
|
elif PEP_TYPE_DISPATCH[pep_type] == None:
|
|
|
|
|
pep_type_error(inpath, pep_type)
|
|
|
|
|
return None
|
|
|
|
|
outpath = os.path.splitext(inpath)[0] + ".html"
|
2000-09-06 21:26:46 -04:00
|
|
|
|
if verbose:
|
2015-04-12 23:27:02 -04:00
|
|
|
|
print(inpath, "(%s)" % pep_type, "->", outpath)
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
sys.stdout.flush()
|
2015-04-12 23:27:02 -04:00
|
|
|
|
outfile = open(outpath, "w", encoding='utf-8')
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
PEP_TYPE_DISPATCH[pep_type](inpath, input_lines, outfile)
|
|
|
|
|
outfile.close()
|
2015-04-12 23:27:02 -04:00
|
|
|
|
os.chmod(outfile.name, 0o664)
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
return outpath
|
2000-07-24 23:51:44 -04:00
|
|
|
|
|
2002-11-11 19:56:27 -05:00
|
|
|
|
def push_pep(htmlfiles, txtfiles, username, verbose, local=0):
|
|
|
|
|
quiet = ""
|
|
|
|
|
if local:
|
|
|
|
|
if verbose:
|
|
|
|
|
quiet = "-v"
|
|
|
|
|
target = HDIR
|
|
|
|
|
copy_cmd = "cp"
|
|
|
|
|
chmod_cmd = "chmod"
|
2000-09-08 11:31:36 -04:00
|
|
|
|
else:
|
2002-11-11 19:56:27 -05:00
|
|
|
|
if not verbose:
|
|
|
|
|
quiet = "-q"
|
|
|
|
|
if username:
|
|
|
|
|
username = username + "@"
|
|
|
|
|
target = username + HOST + ":" + HDIR
|
|
|
|
|
copy_cmd = "scp"
|
|
|
|
|
chmod_cmd = "ssh %s%s chmod" % (username, HOST)
|
2001-03-20 10:07:21 -05:00
|
|
|
|
files = htmlfiles[:]
|
|
|
|
|
files.extend(txtfiles)
|
2000-09-08 11:31:36 -04:00
|
|
|
|
files.append("style.css")
|
2002-08-26 13:02:09 -04:00
|
|
|
|
files.append("pep.css")
|
2001-03-20 10:07:21 -05:00
|
|
|
|
filelist = SPACE.join(files)
|
2002-11-11 19:56:27 -05:00
|
|
|
|
rc = os.system("%s %s %s %s" % (copy_cmd, quiet, filelist, target))
|
2000-09-08 11:31:36 -04:00
|
|
|
|
if rc:
|
|
|
|
|
sys.exit(rc)
|
2005-10-14 11:22:30 -04:00
|
|
|
|
## rc = os.system("%s 664 %s/*" % (chmod_cmd, HDIR))
|
|
|
|
|
## if rc:
|
|
|
|
|
## sys.exit(rc)
|
2000-09-08 11:31:36 -04:00
|
|
|
|
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
|
|
|
|
|
PEP_TYPE_DISPATCH = {'text/plain': fixfile,
|
|
|
|
|
'text/x-rst': fix_rst_pep}
|
|
|
|
|
PEP_TYPE_MESSAGES = {}
|
|
|
|
|
|
|
|
|
|
def check_requirements():
|
|
|
|
|
# Check Python:
|
2015-04-12 23:27:02 -04:00
|
|
|
|
# This is pretty much covered by the __future__ imports...
|
|
|
|
|
if sys.version_info < (2, 6, 0):
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
PEP_TYPE_DISPATCH['text/plain'] = None
|
|
|
|
|
PEP_TYPE_MESSAGES['text/plain'] = (
|
|
|
|
|
'Python %s or better required for "%%(pep_type)s" PEP '
|
|
|
|
|
'processing; %s present (%%(inpath)s).'
|
|
|
|
|
% (REQUIRES['python'], sys.version.split()[0]))
|
|
|
|
|
# Check Docutils:
|
|
|
|
|
try:
|
|
|
|
|
import docutils
|
|
|
|
|
except ImportError:
|
|
|
|
|
PEP_TYPE_DISPATCH['text/x-rst'] = None
|
|
|
|
|
PEP_TYPE_MESSAGES['text/x-rst'] = (
|
|
|
|
|
'Docutils not present for "%(pep_type)s" PEP file %(inpath)s. '
|
2016-06-23 18:57:01 -04:00
|
|
|
|
'See README.rst for installation.')
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
else:
|
2004-04-02 14:20:13 -05:00
|
|
|
|
installed = [int(part) for part in docutils.__version__.split('.')]
|
|
|
|
|
required = [int(part) for part in REQUIRES['docutils'].split('.')]
|
|
|
|
|
if installed < required:
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
PEP_TYPE_DISPATCH['text/x-rst'] = None
|
|
|
|
|
PEP_TYPE_MESSAGES['text/x-rst'] = (
|
|
|
|
|
'Docutils must be reinstalled for "%%(pep_type)s" PEP '
|
|
|
|
|
'processing (%%(inpath)s). Version %s or better required; '
|
2016-06-23 18:57:01 -04:00
|
|
|
|
'%s present. See README.rst for installation.'
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
% (REQUIRES['docutils'], docutils.__version__))
|
|
|
|
|
|
|
|
|
|
def pep_type_error(inpath, pep_type):
|
2015-04-12 23:27:02 -04:00
|
|
|
|
print('Error: ' + PEP_TYPE_MESSAGES[pep_type] % locals(), file=sys.stderr)
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
sys.stdout.flush()
|
|
|
|
|
|
2002-03-15 13:14:39 -05:00
|
|
|
|
|
|
|
|
|
def browse_file(pep):
|
|
|
|
|
import webbrowser
|
|
|
|
|
file = find_pep(pep)
|
2016-06-23 18:57:01 -04:00
|
|
|
|
if file.startswith('pep-') and file.endswith((".txt", '.rst')):
|
2002-03-15 13:14:39 -05:00
|
|
|
|
file = file[:-3] + "html"
|
|
|
|
|
file = os.path.abspath(file)
|
|
|
|
|
url = "file:" + file
|
|
|
|
|
webbrowser.open(url)
|
|
|
|
|
|
|
|
|
|
def browse_remote(pep):
|
|
|
|
|
import webbrowser
|
|
|
|
|
file = find_pep(pep)
|
2016-06-23 18:57:01 -04:00
|
|
|
|
if file.startswith('pep-') and file.endswith((".txt", '.rst')):
|
2002-03-15 13:14:39 -05:00
|
|
|
|
file = file[:-3] + "html"
|
|
|
|
|
url = PEPDIRRUL + file
|
|
|
|
|
webbrowser.open(url)
|
|
|
|
|
|
2000-08-15 01:53:19 -04:00
|
|
|
|
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
def main(argv=None):
|
2000-08-15 01:53:19 -04:00
|
|
|
|
# defaults
|
|
|
|
|
update = 0
|
2002-11-11 19:56:27 -05:00
|
|
|
|
local = 0
|
2000-08-15 01:53:19 -04:00
|
|
|
|
username = ''
|
2000-09-06 21:26:46 -04:00
|
|
|
|
verbose = 1
|
2002-03-15 13:14:39 -05:00
|
|
|
|
browse = 0
|
2000-08-15 01:53:19 -04:00
|
|
|
|
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
check_requirements()
|
|
|
|
|
|
|
|
|
|
if argv is None:
|
|
|
|
|
argv = sys.argv[1:]
|
|
|
|
|
|
2000-08-15 01:53:19 -04:00
|
|
|
|
try:
|
2002-03-15 13:14:39 -05:00
|
|
|
|
opts, args = getopt.getopt(
|
2002-11-11 19:56:27 -05:00
|
|
|
|
argv, 'bilhqu:',
|
|
|
|
|
['browse', 'install', 'local', 'help', 'quiet', 'user='])
|
2015-04-12 23:27:02 -04:00
|
|
|
|
except getopt.error as msg:
|
2000-08-15 01:53:19 -04:00
|
|
|
|
usage(1, msg)
|
|
|
|
|
|
|
|
|
|
for opt, arg in opts:
|
|
|
|
|
if opt in ('-h', '--help'):
|
|
|
|
|
usage(0)
|
|
|
|
|
elif opt in ('-i', '--install'):
|
|
|
|
|
update = 1
|
2002-11-11 19:56:27 -05:00
|
|
|
|
elif opt in ('-l', '--local'):
|
|
|
|
|
update = 1
|
|
|
|
|
local = 1
|
2000-08-28 12:00:49 -04:00
|
|
|
|
elif opt in ('-u', '--user'):
|
2000-09-08 11:31:36 -04:00
|
|
|
|
username = arg
|
2000-09-06 21:26:46 -04:00
|
|
|
|
elif opt in ('-q', '--quiet'):
|
|
|
|
|
verbose = 0
|
2002-03-15 13:14:39 -05:00
|
|
|
|
elif opt in ('-b', '--browse'):
|
|
|
|
|
browse = 1
|
2000-08-15 01:53:19 -04:00
|
|
|
|
|
2000-08-28 12:00:49 -04:00
|
|
|
|
if args:
|
2016-06-23 18:57:01 -04:00
|
|
|
|
pep_list = []
|
2000-08-28 12:00:49 -04:00
|
|
|
|
html = []
|
|
|
|
|
for pep in args:
|
|
|
|
|
file = find_pep(pep)
|
2016-06-23 18:57:01 -04:00
|
|
|
|
pep_list.append(file)
|
2000-09-06 21:26:46 -04:00
|
|
|
|
newfile = make_html(file, verbose=verbose)
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
if newfile:
|
|
|
|
|
html.append(newfile)
|
2007-05-10 18:55:31 -04:00
|
|
|
|
if browse and not update:
|
|
|
|
|
browse_file(pep)
|
2000-08-28 12:00:49 -04:00
|
|
|
|
else:
|
|
|
|
|
# do them all
|
2016-06-23 18:57:01 -04:00
|
|
|
|
pep_list = []
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
html = []
|
2016-06-23 18:57:01 -04:00
|
|
|
|
files = glob.glob("pep-*.txt") + glob.glob("pep-*.rst")
|
2002-03-15 13:14:39 -05:00
|
|
|
|
files.sort()
|
|
|
|
|
for file in files:
|
2016-06-23 18:57:01 -04:00
|
|
|
|
pep_list.append(file)
|
David Goodger writes:
* Refactored the file I/O model throughout, to support multiple
processing paths. PEP source text is now read into a list of lines.
* In ``fixfile()``:
- Updated its parameters for the new I/O model.
- Changed ``fo`` to ``outfile``, ``fi`` to ``inpath`` and
``input_lines``.
- Input is read in by iterating over the list of input lines, rather
than using "readlines()".
- Opening and closing of files is done by the caller, "make_html()".
- Added PEP number processing in Requires header.
- Linked "Content-Type: text/plain" to PEP 9.
* Added ``fix_rst_pep()``, which imports and calls Docutils code.
* Added ``get_pep_type()``, which checks for a Content-Type header and
returns the value, defaulting to "text/plain". If no PEP header is
found, ``None`` is returned: input is not a PEP.
* Added ``get_input_lines()`` to read input file into a list.
* Expanded ``make_html()`` to catch errors and process the different
PEP formats via the new ``PEP_TYPE_DISPATCH`` dict.
* Added ``check_requirements()`` to check both Python and Docutils
requirements. ``pep_type_error()`` is called if the required
software is not available.
* In ``main()``:
- Added an ``argv`` parameter, so that pep2html.py can be imported
and command-line options passed in. Yes, I use this functionality
in the Docutils "buildhtml.py" front end.
- Files skipped (due to an error) are not pushed onto the server.
2002-08-26 12:54:54 -04:00
|
|
|
|
newfile = make_html(file, verbose=verbose)
|
|
|
|
|
if newfile:
|
|
|
|
|
html.append(newfile)
|
2002-03-15 13:14:39 -05:00
|
|
|
|
if browse and not update:
|
|
|
|
|
browse_file("0")
|
|
|
|
|
|
2000-07-24 23:51:44 -04:00
|
|
|
|
if update:
|
2016-06-23 18:57:01 -04:00
|
|
|
|
push_pep(html, pep_list, username, verbose, local=local)
|
2002-03-15 13:14:39 -05:00
|
|
|
|
if browse:
|
|
|
|
|
if args:
|
|
|
|
|
for pep in args:
|
|
|
|
|
browse_remote(pep)
|
|
|
|
|
else:
|
|
|
|
|
browse_remote("0")
|
2000-07-24 23:51:44 -04:00
|
|
|
|
|
2001-08-14 12:45:19 -04:00
|
|
|
|
|
2000-08-15 01:53:19 -04:00
|
|
|
|
|
2000-07-24 23:51:44 -04:00
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|