[Python-checkins] peps: new usage to support conversion of only specified PEPs

georg.brandl python-checkins at python.org
Wed Mar 23 21:27:34 CET 2011


http://hg.python.org/peps/rev/13b210596813
changeset: 164:13b210596813
user: Jeremy Hylton <jeremy at alum.mit.edu>
date: Mon Aug 28 16:00:49 2000 +0000
summary:
 new usage to support conversion of only specified PEPs
Usage: %(PROGRAM)s [options] [peps]
Notes:
 The optional argument peps can be either pep numbers or .txt files.
Options:
 -u/--user
 SF username
 [rest is the same]
files:
 pep2html.py | 50 +++++++++++++++++++++++++++++++---------
 1 files changed, 38 insertions(+), 12 deletions(-)
diff --git a/pep2html.py b/pep2html.py
--- a/pep2html.py
+++ b/pep2html.py
@@ -2,10 +2,17 @@
 """
 convert PEP's to (X)HTML - courtesy of /F
 
-Usage: %(PROGRAM)s [options] [sf_username]
+Usage: %(PROGRAM)s [options] [peps]
+
+Notes:
+
+ The optional argument peps can be either pep numbers or .txt files.
 
 Options:
 
+ -u/--user
+ SF username
+
 -i/--install
 After generating the HTML, install it SourceForge. In that case the
 user's name is used in the scp and ssh commands, unless sf_username is
@@ -144,6 +151,19 @@
 fo.close()
 os.chmod(outfile, 0664)
 
+
+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
+
+def make_html(file):
+ newfile = os.path.splitext(file)[0] + ".html"
+ print file, "->", newfile
+ fixfile(file, newfile)
+ return newfile
 
 
 def main():
@@ -156,25 +176,31 @@
 except getopt.error, msg:
 usage(1, msg)
 
- if args:
- username = args[0] + '@'
- del args[0]
- if args:
- usage(1, 'unexpected arguments')
-
 for opt, arg in opts:
 if opt in ('-h', '--help'):
 usage(0)
 elif opt in ('-i', '--install'):
 update = 1
+ elif opt in ('-u', '--user'):
+ username = arg + "@"
 
- for file in glob.glob("pep-*.txt"):
- newfile = os.path.splitext(file)[0] + ".html"
- print file, "->", newfile
- fixfile(file, newfile)
+ if args:
+ html = []
+ for pep in args:
+ file = find_pep(pep)
+ newfile = make_html(file)
+ html.append(newfile)
+ os.system("scp %s style.css " % " ".join(html) \
+ + username + HOST + ":" + HDIR)
+ else:
+ # do them all
+ for file in glob.glob("pep-*.txt"):
+ make_html(file)
+ if update:
+ os.system("scp pep-*.html style.css " + \
+ username + HOST + ":" + HDIR)
 
 if update:
- os.system("scp pep-*.html style.css " + username + HOST + ":" + HDIR)
 os.system("ssh " + username + HOST + " chmod 664 " + HDIR + "/*")
 
 
-- 
Repository URL: http://hg.python.org/peps


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /