diff options
author | Collin Winter <collinw@gmail.com> | 2007-07-17 20:59:35 (GMT) |
---|---|---|
committer | Collin Winter <collinw@gmail.com> | 2007-07-17 20:59:35 (GMT) |
commit | 6f2df4d5e193d54244b0c2de91ef0ab1604b9243 (patch) | |
tree | 5e172400da7561eb4bb8fafc62c8cab511d74dad /Demo/cgi | |
parent | a8c360ee76fb76902a2e2140fbb38d4b06b2d9fb (diff) | |
download | cpython-6f2df4d5e193d54244b0c2de91ef0ab1604b9243.zip cpython-6f2df4d5e193d54244b0c2de91ef0ab1604b9243.tar.gz cpython-6f2df4d5e193d54244b0c2de91ef0ab1604b9243.tar.bz2 |
Run 2to3 over the Demo/ directory to shut up parse errors from 2to3 about lingering print statements.
Diffstat (limited to 'Demo/cgi')
-rwxr-xr-x | Demo/cgi/cgi1.py | 8 | ||||
-rwxr-xr-x | Demo/cgi/cgi2.py | 12 | ||||
-rw-r--r-- | Demo/cgi/wiki.py | 54 |
3 files changed, 37 insertions, 37 deletions
diff --git a/Demo/cgi/cgi1.py b/Demo/cgi/cgi1.py index 9d25c7d..842fef2 100755 --- a/Demo/cgi/cgi1.py +++ b/Demo/cgi/cgi1.py @@ -8,7 +8,7 @@ # If cgi0.sh works but cgi1.py doesn't, check the #! line and the file # permissions. The docs for the cgi.py module have debugging tips. -print "Content-type: text/html" -print -print "<h1>Hello world</h1>" -print "<p>This is cgi1.py" +print("Content-type: text/html") +print() +print("<h1>Hello world</h1>") +print("<p>This is cgi1.py") diff --git a/Demo/cgi/cgi2.py b/Demo/cgi/cgi2.py index d956f65..239fb6b 100755 --- a/Demo/cgi/cgi2.py +++ b/Demo/cgi/cgi2.py @@ -8,15 +8,15 @@ import cgi def main(): form = cgi.FieldStorage() - print "Content-type: text/html" - print + print("Content-type: text/html") + print() if not form: - print "<h1>No Form Keys</h1>" + print("<h1>No Form Keys</h1>") else: - print "<h1>Form Keys</h1>" - for key in form.keys(): + print("<h1>Form Keys</h1>") + for key in list(form.keys()): value = form[key].value - print "<p>", cgi.escape(key), ":", cgi.escape(value) + print("<p>", cgi.escape(key), ":", cgi.escape(value)) if __name__ == "__main__": main() diff --git a/Demo/cgi/wiki.py b/Demo/cgi/wiki.py index 2f944d6..6b97113 100644 --- a/Demo/cgi/wiki.py +++ b/Demo/cgi/wiki.py @@ -5,8 +5,8 @@ escape = cgi.escape def main(): form = cgi.FieldStorage() - print "Content-type: text/html" - print + print("Content-type: text/html") + print() cmd = form.getvalue("cmd", "view") page = form.getvalue("page", "FrontPage") wiki = WikiPage(page) @@ -20,22 +20,22 @@ class WikiPage: def __init__(self, name): if not self.iswikiword(name): - raise ValueError, "page name is not a wiki word" + raise ValueError("page name is not a wiki word") self.name = name self.load() def cmd_view(self, form): - print "<h1>", escape(self.splitwikiword(self.name)), "</h1>" - print "<p>" + print("<h1>", escape(self.splitwikiword(self.name)), "</h1>") + print("<p>") for line in self.data.splitlines(): line = line.rstrip() if not line: - print "<p>" + print("<p>") else: - print self.formatline(line) - print "<hr>" - print "<p>", self.mklink("edit", self.name, "Edit this page") + ";" - print self.mklink("view", "FrontPage", "go to front page") + "." + print(self.formatline(line)) + print("<hr>") + print("<p>", self.mklink("edit", self.name, "Edit this page") + ";") + print(self.mklink("view", "FrontPage", "go to front page") + ".") def formatline(self, line): words = [] @@ -51,32 +51,32 @@ class WikiPage: return "".join(words) def cmd_edit(self, form, label="Change"): - print "<h1>", label, self.name, "</h1>" - print '<form method="POST" action="%s">' % self.scripturl + print("<h1>", label, self.name, "</h1>") + print('<form method="POST" action="%s">' % self.scripturl) s = '<textarea cols="70" rows="20" name="text">%s</textarea>' - print s % self.data - print '<input type="hidden" name="cmd" value="create">' - print '<input type="hidden" name="page" value="%s">' % self.name - print '<br>' - print '<input type="submit" value="%s Page">' % label - print "</form>" + print(s % self.data) + print('<input type="hidden" name="cmd" value="create">') + print('<input type="hidden" name="page" value="%s">' % self.name) + print('<br>') + print('<input type="submit" value="%s Page">' % label) + print("</form>") def cmd_create(self, form): self.data = form.getvalue("text", "").strip() error = self.store() if error: - print "<h1>I'm sorry. That didn't work</h1>" - print "<p>An error occurred while attempting to write the file:" - print "<p>", escape(error) + print("<h1>I'm sorry. That didn't work</h1>") + print("<p>An error occurred while attempting to write the file:") + print("<p>", escape(error)) else: # Use a redirect directive, to avoid "reload page" problems - print "<head>" + print("<head>") s = '<meta http-equiv="refresh" content="1; URL=%s">' - print s % (self.scripturl + "?cmd=view&page=" + self.name) - print "<head>" - print "<h1>OK</h1>" - print "<p>If nothing happens, please click here:", - print self.mklink("view", self.name, self.name) + print(s % (self.scripturl + "?cmd=view&page=" + self.name)) + print("<head>") + print("<h1>OK</h1>") + print("<p>If nothing happens, please click here:", end=' ') + print(self.mklink("view", self.name, self.name)) def cmd_new(self, form): self.cmd_edit(form, label="Create") |