[Python-checkins] CVS: python/nondist/peps pep2html.py,1.32,1.33
Guido van Rossum
gvanrossum@users.sourceforge.net
Fri, 15 Mar 2002 10:14:41 -0800
Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv29631
Modified Files:
pep2html.py
Log Message:
Add -b/--browse option, which uses the webbrowser module to show the
generated HTML in your browser. (The local HTML without -i, the
remote HTML with -i; PEP 0 when no pep argument is given.)
Fix the help text for -i (referenced sf_username which wasn't
defined).
Sort the files when processing all of them (glob doesn't sort, alas).
Index: pep2html.py
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep2html.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** pep2html.py 1 Mar 2002 19:07:46 -0000 1.32
--- pep2html.py 15 Mar 2002 18:14:39 -0000 1.33
***************
*** 10,18 ****
SF username
-i/--install
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
! and ssh commands, unless sf_username is given (in which case, it is
! used instead). Without -i, sf_username is ignored.
-q/--quiet
--- 10,25 ----
SF username
+ -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.
+
-i/--install
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
! and ssh commands, unless -u sf_username is given (in which case, it is
! used instead). Without -i, -u is ignored.
-q/--quiet
***************
*** 38,41 ****
--- 45,49 ----
PEPURL = 'pep-%04d.html'
PEPCVSURL = 'http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/nondist/peps/pep-%04d.txt'
+ PEPDIRRUL = 'http://www.python.org/peps/'
***************
*** 255,258 ****
--- 263,284 ----
+ 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)
+
+
def main():
# defaults
***************
*** 260,267 ****
username = ''
verbose = 1
try:
! opts, args = getopt.getopt(sys.argv[1:], 'ihqu:',
! ['install', 'help', 'quiet', 'user='])
except getopt.error, msg:
usage(1, msg)
--- 286,295 ----
username = ''
verbose = 1
+ browse = 0
try:
! opts, args = getopt.getopt(
! sys.argv[1:], 'bihqu:',
! ['browse', 'install', 'help', 'quiet', 'user='])
except getopt.error, msg:
usage(1, msg)
***************
*** 276,279 ****
--- 304,309 ----
elif opt in ('-q', '--quiet'):
verbose = 0
+ elif opt in ('-b', '--browse'):
+ browse = 1
if args:
***************
*** 285,297 ****
newfile = make_html(file, verbose=verbose)
html.append(newfile)
else:
# do them all
peptxt = []
! for file in glob.glob("pep-*.txt"):
peptxt.append(file)
make_html(file, verbose=verbose)
html = ["pep-*.html"]
if update:
push_pep(html, peptxt, username, verbose)
--- 315,340 ----
newfile = make_html(file, verbose=verbose)
html.append(newfile)
+ if browse and not update:
+ browse_file(pep)
else:
# do them all
peptxt = []
! files = glob.glob("pep-*.txt")
! files.sort()
! for file in files:
peptxt.append(file)
make_html(file, verbose=verbose)
html = ["pep-*.html"]
+ if browse and not update:
+ browse_file("0")
+
if update:
push_pep(html, peptxt, username, verbose)
+ if browse:
+ if args:
+ for pep in args:
+ browse_remote(pep)
+ else:
+ browse_remote("0")