2000-07-20 18:29:24 -04:00
|
|
|
|
#!/usr/bin/env python
|
|
|
|
|
"""
|
|
|
|
|
convert PEP's to (X)HTML - courtesy of /F
|
|
|
|
|
|
2000-08-28 12:00:49 -04:00
|
|
|
|
Usage: %(PROGRAM)s [options] [peps]
|
|
|
|
|
|
2000-08-15 01:53:19 -04:00
|
|
|
|
Options:
|
2000-07-24 23:51:44 -04:00
|
|
|
|
|
2000-08-28 12:00:49 -04:00
|
|
|
|
-u/--user
|
|
|
|
|
SF username
|
|
|
|
|
|
2002-03-15 13:14:39 -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.
|
|
|
|
|
|
2000-08-15 01:53:19 -04:00
|
|
|
|
-i/--install
|
2001-03-20 10:07:21 -05:00
|
|
|
|
After generating the HTML, install it and the plain text source file
|
|
|
|
|
(.txt) SourceForge. In that case the user's name is used in the scp
|
2002-03-15 13:14:39 -05:00
|
|
|
|
and ssh commands, unless -u sf_username is given (in which case, it is
|
|
|
|
|
used instead). Without -i, -u is ignored.
|
2000-07-24 23:51:44 -04:00
|
|
|
|
|
2000-11-03 10:43:28 -05:00
|
|
|
|
-q/--quiet
|
|
|
|
|
Turn off verbose messages.
|
|
|
|
|
|
2000-08-15 01:53:19 -04:00
|
|
|
|
-h/--help
|
|
|
|
|
Print this help message and exit.
|
2001-11-12 09:58:07 -05:00
|
|
|
|
|
|
|
|
|
The optional argument `peps' is a list of either pep numbers or .txt files.
|
2000-07-20 18:29:24 -04:00
|
|
|
|
"""
|
|
|
|
|
|
2002-07-30 12:17:11 -04:00
|
|
|
|
# Requires Python 2.2
|
|
|
|
|
|
2000-08-15 01:53:19 -04:00
|
|
|
|
import sys
|
|
|
|
|
import os
|
|
|
|
|
import re
|
|
|
|
|
import cgi
|
|
|
|
|
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
|
2002-07-30 12:17:11 -04:00
|
|
|
|
from email.Utils import parseaddr
|
2000-07-20 18:29:24 -04:00
|
|
|
|
|
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'
|
2002-03-01 14:07:46 -05:00
|
|
|
|
PEPCVSURL = 'http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/nondist/peps/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
|
|
|
|
|
|
|
|
|
|
2002-04-02 18:07:13 -05:00
|
|
|
|
HOST = "www.python.org" # host for update
|
|
|
|
|
HDIR = "/ftp/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
|
|
|
|
|
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
|
|
|
|
|
2001-08-14 17:42:39 -04:00
|
|
|
|
fixpat = re.compile("((http|ftp):[-_a-zA-Z0-9/.+~:?#$=&,]+)|(pep-\d+(.txt)?)|"
|
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=''):
|
2002-02-04 17:38:27 -05:00
|
|
|
|
print >> sys.stderr, __doc__ % globals()
|
2000-08-15 01:53:19 -04:00
|
|
|
|
if msg:
|
2001-08-14 12:45:19 -04:00
|
|
|
|
print >> sys.stderr, msg
|
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
|
2001-08-14 17:42:39 -04:00
|
|
|
|
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:
|
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:
|
2001-08-14 12:45:19 -04:00
|
|
|
|
return '<a href="%s">%s</a>' % (link, cgi.escape(text))
|
2000-07-20 18:44:36 -04:00
|
|
|
|
return cgi.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
|
|
|
|
|
2000-07-20 18:29:24 -04:00
|
|
|
|
def fixfile(infile, outfile):
|
2001-08-14 12:45:19 -04:00
|
|
|
|
basename = os.path.basename(infile)
|
2000-07-20 18:29:24 -04:00
|
|
|
|
# convert plain text pep to minimal XHTML markup
|
2001-07-05 14:44:20 -04:00
|
|
|
|
try:
|
|
|
|
|
fi = open(infile)
|
|
|
|
|
except IOError, e:
|
|
|
|
|
if e.errno <> errno.ENOENT: raise
|
|
|
|
|
print >> sys.stderr, 'Error: Skipping missing PEP file:', e.filename
|
|
|
|
|
return
|
2000-07-20 18:29:24 -04:00
|
|
|
|
fo = open(outfile, "w")
|
2001-08-14 12:45:19 -04:00
|
|
|
|
print >> fo, DTD
|
|
|
|
|
print >> fo, '<html>'
|
|
|
|
|
print >> fo, '<head>'
|
2000-07-20 18:29:24 -04:00
|
|
|
|
# head
|
|
|
|
|
header = []
|
2000-07-20 18:44:36 -04:00
|
|
|
|
pep = ""
|
|
|
|
|
title = ""
|
2000-07-20 18:29:24 -04:00
|
|
|
|
while 1:
|
|
|
|
|
line = fi.readline()
|
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:
|
2001-08-14 12:45:19 -04:00
|
|
|
|
print >> fo, ' <title>%s</title>' % cgi.escape(title)
|
2002-04-04 11:13:32 -05:00
|
|
|
|
print >> fo, ' <link rel="STYLESHEET" href="style.css" type="text/css">'
|
2001-08-14 12:45:19 -04:00
|
|
|
|
print >> fo, '</head>'
|
2000-07-20 18:29:24 -04:00
|
|
|
|
# body
|
2002-04-02 18:07:13 -05:00
|
|
|
|
print >> fo, '<body bgcolor="white" marginwidth="0" marginheight="0">'
|
|
|
|
|
print >> fo, '<table class="navigation" cellpadding="0" cellspacing="0"'
|
|
|
|
|
print >> fo, ' width="100%" border="0">'
|
|
|
|
|
print >> fo, '<tr><td class="navicon" width="150" height="35">'
|
|
|
|
|
r = random.choice(range(64))
|
|
|
|
|
print >> fo, '<a href="../" title="Python Home Page">'
|
|
|
|
|
print >> fo, '<img src="../pics/PyBanner%03d.gif" alt="[Python]"' % r
|
|
|
|
|
print >> fo, ' border="0" width="150" height="35" /></a></td>'
|
|
|
|
|
print >> fo, '<td class="textlinks" align="left">'
|
|
|
|
|
print >> fo, '[<b><a href="../">Python Home</a></b>]'
|
2001-08-14 12:45:19 -04:00
|
|
|
|
if basename <> 'pep-0000.txt':
|
2002-04-02 18:07:13 -05:00
|
|
|
|
print >> fo, '[<b><a href=".">PEP Index</a></b>]'
|
2002-02-16 05:44:32 -05:00
|
|
|
|
if pep:
|
2002-04-02 18:07:13 -05:00
|
|
|
|
print >> fo, '[<b><a href="pep-%04d.txt">PEP Source</a></b>]' \
|
|
|
|
|
% int(pep)
|
|
|
|
|
print >> fo, '</td></tr></table>'
|
2001-08-14 12:45:19 -04:00
|
|
|
|
print >> fo, '<div class="header">\n<table border="0">'
|
2000-07-20 18:29:24 -04:00
|
|
|
|
for k, v in header:
|
2001-03-21 12:26:05 -05:00
|
|
|
|
if k.lower() in ('author', '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)
|
2001-03-21 12:26:05 -05:00
|
|
|
|
elif k.lower() in ('replaces', 'replaced-by'):
|
2002-03-01 14:07:46 -05:00
|
|
|
|
otherpeps = ''
|
|
|
|
|
for otherpep in v.split():
|
|
|
|
|
otherpep = int(otherpep)
|
|
|
|
|
otherpeps += '<a href="pep-%04d.html">%i</a> ' % (otherpep,
|
|
|
|
|
otherpep)
|
|
|
|
|
v = otherpeps
|
|
|
|
|
elif k.lower() in ('last-modified',):
|
|
|
|
|
url = PEPCVSURL % int(pep)
|
|
|
|
|
date = v or time.strftime('%d-%b-%Y',
|
|
|
|
|
time.localtime(os.stat(infile)[8]))
|
|
|
|
|
v = '<a href="%s">%s</a> ' % (url, cgi.escape(date))
|
2000-08-17 00:27:04 -04:00
|
|
|
|
else:
|
|
|
|
|
v = cgi.escape(v)
|
2002-04-04 11:13:32 -05:00
|
|
|
|
print >> fo, ' <tr><th>%s: </th><td>%s</td></tr>' \
|
2002-04-02 18:07:13 -05:00
|
|
|
|
% (cgi.escape(k), v)
|
2001-08-14 12:45:19 -04:00
|
|
|
|
print >> fo, '</table>'
|
|
|
|
|
print >> fo, '</div>'
|
|
|
|
|
print >> fo, '<hr />'
|
2002-04-02 18:07:13 -05:00
|
|
|
|
print >> fo, '<div class="content">'
|
2002-04-04 10:42:20 -05:00
|
|
|
|
need_pre = 1
|
2000-07-20 18:29:24 -04:00
|
|
|
|
while 1:
|
|
|
|
|
line = fi.readline()
|
|
|
|
|
if not line:
|
|
|
|
|
break
|
2001-08-14 12:45:19 -04:00
|
|
|
|
if line[0] == '\f':
|
|
|
|
|
continue
|
|
|
|
|
if line.strip() == LOCALVARS:
|
|
|
|
|
break
|
|
|
|
|
if line[0].strip():
|
|
|
|
|
if line.strip() == LOCALVARS:
|
|
|
|
|
break
|
2002-04-04 10:42:20 -05:00
|
|
|
|
if not need_pre:
|
|
|
|
|
print >> fo, '</pre>'
|
2001-08-14 12:45:19 -04:00
|
|
|
|
print >> fo, '<h3>%s</h3>' % line.strip()
|
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:
|
|
|
|
|
print >> fo, '<pre>'
|
|
|
|
|
need_pre = 0
|
2001-08-14 12:45:19 -04:00
|
|
|
|
print >> fo, re.sub(
|
|
|
|
|
parts[1],
|
|
|
|
|
'<a href="%s">%s</a>' % (url, parts[1]),
|
|
|
|
|
line, 1),
|
|
|
|
|
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:
|
|
|
|
|
print >> fo, '<pre>'
|
|
|
|
|
need_pre = 0
|
2001-08-14 12:45:19 -04:00
|
|
|
|
print >> fo, re.sub(
|
|
|
|
|
parts[-1], url, line, 1),
|
|
|
|
|
continue
|
|
|
|
|
line = fixpat.sub(lambda x, c=infile: fixanchor(c, x), line)
|
2002-04-04 10:42:20 -05:00
|
|
|
|
if need_pre:
|
|
|
|
|
print >> fo, '<pre>'
|
|
|
|
|
need_pre = 0
|
2001-08-14 12:45:19 -04:00
|
|
|
|
fo.write(line)
|
2002-04-04 10:42:20 -05:00
|
|
|
|
if not need_pre:
|
|
|
|
|
print >> fo, '</pre>'
|
2002-04-02 18:07:13 -05:00
|
|
|
|
print >> fo, '</div>'
|
2001-08-14 12:45:19 -04:00
|
|
|
|
print >> fo, '</body>'
|
|
|
|
|
print >> fo, '</html>'
|
2000-07-25 00:12:28 -04:00
|
|
|
|
fo.close()
|
|
|
|
|
os.chmod(outfile, 0664)
|
2000-07-20 18:29:24 -04:00
|
|
|
|
|
2001-08-14 12:45:19 -04:00
|
|
|
|
|
2000-08-28 12:00:49 -04:00
|
|
|
|
|
|
|
|
|
def find_pep(pep_str):
|
|
|
|
|
"""Find the .txt file indicated by a cmd line argument"""
|
|
|
|
|
if os.path.exists(pep_str):
|
|
|
|
|
return pep_str
|
|
|
|
|
num = int(pep_str)
|
|
|
|
|
return "pep-%04d.txt" % num
|
|
|
|
|
|
2000-09-06 21:26:46 -04:00
|
|
|
|
def make_html(file, verbose=0):
|
2000-08-28 12:00:49 -04:00
|
|
|
|
newfile = os.path.splitext(file)[0] + ".html"
|
2000-09-06 21:26:46 -04:00
|
|
|
|
if verbose:
|
|
|
|
|
print file, "->", newfile
|
2000-08-28 12:00:49 -04:00
|
|
|
|
fixfile(file, newfile)
|
|
|
|
|
return newfile
|
2000-07-24 23:51:44 -04:00
|
|
|
|
|
2001-03-20 10:07:21 -05:00
|
|
|
|
def push_pep(htmlfiles, txtfiles, username, verbose):
|
2000-09-08 11:31:36 -04:00
|
|
|
|
if verbose:
|
|
|
|
|
quiet = ""
|
|
|
|
|
else:
|
|
|
|
|
quiet = "-q"
|
|
|
|
|
if username:
|
|
|
|
|
username = username + "@"
|
|
|
|
|
target = username + HOST + ":" + HDIR
|
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")
|
2001-03-20 10:07:21 -05:00
|
|
|
|
filelist = SPACE.join(files)
|
2000-09-08 11:31:36 -04:00
|
|
|
|
rc = os.system("scp %s %s %s" % (quiet, filelist, target))
|
|
|
|
|
if rc:
|
|
|
|
|
sys.exit(rc)
|
|
|
|
|
rc = os.system("ssh %s%s chmod 664 %s/*" % (username, HOST, HDIR))
|
|
|
|
|
if rc:
|
|
|
|
|
sys.exit(rc)
|
|
|
|
|
|
2002-03-15 13:14:39 -05:00
|
|
|
|
|
|
|
|
|
def browse_file(pep):
|
|
|
|
|
import webbrowser
|
|
|
|
|
file = find_pep(pep)
|
|
|
|
|
if file.endswith(".txt"):
|
|
|
|
|
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)
|
|
|
|
|
if file.endswith(".txt"):
|
|
|
|
|
file = file[:-3] + "html"
|
|
|
|
|
url = PEPDIRRUL + file
|
|
|
|
|
webbrowser.open(url)
|
|
|
|
|
|
2000-08-15 01:53:19 -04:00
|
|
|
|
|
2000-07-24 23:51:44 -04:00
|
|
|
|
def main():
|
2000-08-15 01:53:19 -04:00
|
|
|
|
# defaults
|
|
|
|
|
update = 0
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
try:
|
2002-03-15 13:14:39 -05:00
|
|
|
|
opts, args = getopt.getopt(
|
|
|
|
|
sys.argv[1:], 'bihqu:',
|
|
|
|
|
['browse', 'install', 'help', 'quiet', 'user='])
|
2000-08-15 01:53:19 -04:00
|
|
|
|
except getopt.error, msg:
|
|
|
|
|
usage(1, msg)
|
|
|
|
|
|
|
|
|
|
for opt, arg in opts:
|
|
|
|
|
if opt in ('-h', '--help'):
|
|
|
|
|
usage(0)
|
|
|
|
|
elif opt in ('-i', '--install'):
|
|
|
|
|
update = 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:
|
2001-03-20 10:07:21 -05:00
|
|
|
|
peptxt = []
|
2000-08-28 12:00:49 -04:00
|
|
|
|
html = []
|
|
|
|
|
for pep in args:
|
|
|
|
|
file = find_pep(pep)
|
2001-03-20 10:07:21 -05:00
|
|
|
|
peptxt.append(file)
|
2000-09-06 21:26:46 -04:00
|
|
|
|
newfile = make_html(file, verbose=verbose)
|
2000-08-28 12:00:49 -04:00
|
|
|
|
html.append(newfile)
|
2002-03-15 13:14:39 -05:00
|
|
|
|
if browse and not update:
|
|
|
|
|
browse_file(pep)
|
2000-08-28 12:00:49 -04:00
|
|
|
|
else:
|
|
|
|
|
# do them all
|
2001-03-20 10:07:21 -05:00
|
|
|
|
peptxt = []
|
2002-03-15 13:14:39 -05:00
|
|
|
|
files = glob.glob("pep-*.txt")
|
|
|
|
|
files.sort()
|
|
|
|
|
for file in files:
|
2001-03-20 10:07:21 -05:00
|
|
|
|
peptxt.append(file)
|
2000-09-06 21:26:46 -04:00
|
|
|
|
make_html(file, verbose=verbose)
|
2000-09-08 11:31:36 -04:00
|
|
|
|
html = ["pep-*.html"]
|
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:
|
2001-03-20 10:07:21 -05:00
|
|
|
|
push_pep(html, peptxt, username, verbose)
|
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()
|