From: Guido van Rossum Date: Fri, 23 May 1997 17:45:04 +0000 (+0000) Subject: - Suppress the visible text in the epilogue when "edit=no" is specified. X-Git-Tag: v1.5a3~454 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d1c1ec8a77fa8c3421d034b9a5c9c661b5e466dc;p=python - Suppress the visible text in the epilogue when "edit=no" is specified. - Add translation of *foobar* into foobar (but not inside
).
- Optimization for the translation: only translate when @ or / or * seen.
- Add some layout to front page lay-out.
---

diff --git a/Tools/faqwiz/faqmain.py b/Tools/faqwiz/faqmain.py
index 82c4657dc3..2ce723dfe0 100644
--- a/Tools/faqwiz/faqmain.py
+++ b/Tools/faqwiz/faqmain.py
@@ -27,6 +27,7 @@ XXX TO DO
 NAMEPAT = "faq??.???.htp"
 NAMEREG = "^faq\([0-9][0-9]\)\.\([0-9][0-9][0-9]\)\.htp$"
 
+# Like so many other things, this should come from a file.
 SECTIONS = {
     "1": "General information and availability",
     "2": "Python in the real world",
@@ -85,14 +86,18 @@ class FAQServer:
 	
  • Delete a FAQ entry +
    +

    Search the FAQ

    - +
    + (Case insensitive regular expressions.)
    - +
    +

    Disclaimer: these pages are intended to be edited by anyone. Please exercise discretion when editing, don't be rude, etc. """ @@ -605,7 +610,11 @@ class FAQServer: if not pre: print '

    '
     			pre = 1
    -		print self.translate(line)
    +		if '/' in line or '@' in line:
    +		    line = self.translate(line)
    + 		if not pre and '*' in line:
    + 		    line = self.emphasize(line)
    +		print line
     	if pre:
     	    print '
    ' pre = 0 @@ -663,12 +672,18 @@ class FAQServer: print def epilogue(self): + if self.edit == 'no': + global wanttime + wanttime = 0 + else: + print ''' +

    +


    + Python home / + FAQ home / + Feedback to GvR + ''' print ''' -

    -


    - Python home / - FAQ home / - Feedback to GvR ''' @@ -705,8 +720,21 @@ class FAQServer: list.append(cgi.escape(text[i:j])) return string.join(list, '') + emphasize_prog = None + + def emphasize(self, line): + import regsub + if not self.emphasize_prog: + import regex + pat = "\*\([a-zA-Z]+\)\*" + self.emphasize_prog = prog = regex.compile(pat) + else: + prog = self.emphasize_prog + return regsub.gsub(prog, "\\1", line) + print "Content-type: text/html" dt = 0 +wanttime = 1 try: import time t1 = time.time() @@ -718,7 +746,8 @@ try: except: print "\n
    Sorry, an error occurred" cgi.print_exception() -print "

    (running time = %s seconds)" % str(round(dt, 3)) +if wanttime: + print "
    (running time = %s seconds)" % str(round(dt, 3)) # The following bootstrap script must be placed in cgi-bin/faq.py: BOOTSTRAP = """