X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=geekigeeki.py;h=b85a3a2ad1be68264733b5cae74ef9710436728e;hb=2fcd242301699667836d3dce840cb101bec904c7;hp=1221e701f7f1437d09cc64913287da0ebf90b9cb;hpb=0115a854ee709025539aa8498947dddb0ca04ad0;p=geekigeeki.git diff --git a/geekigeeki.py b/geekigeeki.py old mode 100755 new mode 100644 index 1221e70..b85a3a2 --- a/geekigeeki.py +++ b/geekigeeki.py @@ -59,7 +59,7 @@ def get_hostname(addr): try: from socket import gethostbyaddr return gethostbyaddr(addr)[0] + ' (' + addr + ')' - except Exception, er: + except Exception as er: return addr def relative_url(pathname, privileged=False): @@ -76,19 +76,19 @@ def permalink(s): # Formatting stuff -------------------------------------------------- def emit_header(mime_type="text/html"): - print "Content-type: " + mime_type + "; charset=utf-8\n" + print("Content-type: " + mime_type + "; charset=utf-8\n") def send_guru(msg_text, msg_type): if not msg_text: return - print '
' + print('') # FIXME: This little JS snippet is harder to pass than ACID 3.0 - print """ + print(""" """ + """) def send_title(name, text="Limbo", msg_text=None, msg_type='error', writable=False): global title_done @@ -116,75 +116,75 @@ def send_title(name, text="Limbo", msg_text=None, msg_type='error', writable=Fal # Head emit_header() - print '' - print '' + print('') + print('') site_name = globals().get('site_name', 'Unconfigured Site') - print "') if msg_type == 'error': - print ' Software Failure. Press left mouse button to continue.\n' - print msg_text + print(' Software Failure. Press left mouse button to continue.\n') + print(msg_text) if msg_type == 'error': - print '\n Guru Meditation #DEADBEEF.ABADC0DE' - print '' + print('\n Guru Meditation #DEADBEEF.ABADC0DE') + print('
' + Page(page_name).link_to() - print ' . . . . ' + `count` - print ['match', 'matches'][count != 1] - print '
' + Page(page_name).link_to()) + print(' . . . . ' + repr(count)) + print(['match', 'matches'][count != 1]) + print('
' + Page(filename).link_to() + "
' + Page(filename).link_to() + "
%d hits out of %d pages searched.
" % (hits, searched) + print("%d hits out of %d pages searched.
" % (hits, searched)) def handle_raw(pagename): if not file_re.match(pagename): @@ -278,7 +278,7 @@ def handle_edit(pagename): pg.send_editor(text) def make_index_key(): - links = map(lambda ch: '%s' % (ch, ch), 'abcdefghijklmnopqrstuvwxyz') + links = ['%s' % (ch, ch) for ch in 'abcdefghijklmnopqrstuvwxyz'] return 'last modified %s
' % mod_string) + print('') class WikiFormatter: """Object that turns Wiki markup into HTML. @@ -366,13 +366,13 @@ class WikiFormatter: argv = [name] if m.group(2): argv.extend(m.group(2).split('|')) - argv = map(str.strip, argv) + argv = list(map(str.strip, argv)) macro = globals().get('_macro_' + name) if not macro: try: - execfile("macros/" + name + ".py", globals()) - except IOError, er: + exec(open("macros/" + name + ".py").read(), globals()) + except IOError as er: if er.errno == errno.ENOENT: pass macro = globals().get('_macro_' + name) @@ -493,14 +493,14 @@ class WikiFormatter: return res def replace(self, match): - for type, hit in match.groupdict().items(): + for type, hit in list(match.groupdict().items()): if hit: return getattr(self, '_' + type + '_repl')(hit) else: - raise "Can't handle match " + `match` + raise "Can't handle match " + repr(match) def print_html(self): - print '' + print('
') # For each line, we scan through looking for magic # strings, outputting verbatim any intervening text @@ -555,23 +555,23 @@ class WikiFormatter: self.in_header = False if self.in_pre: - print re.sub(pre_re, self.replace, self.line) + print(re.sub(pre_re, self.replace, self.line)) else: if self.in_table and not tr_re.match(self.line): self.in_table = False - print '
' + print('
') if blank_re.match(self.line): - print '
' + print('
') else: indent = indent_re.match(self.line) - print self._indent_to(len(indent.group(0))) , - print re.sub(scan_re, self.replace, self.line) + print(self._indent_to(len(indent.group(0))), end=' ') + print(re.sub(scan_re, self.replace, self.line)) - if self.in_pre: print '' - if self.in_table: print '
' - print self._undent() - print '
') + print(self._undent()) + print('
Editing ' + self.page_name + print(('
Editing ' + self.page_name + ' for ' + cgi.escape(remote_user()) + ' from ' + cgi.escape(get_hostname(remote_host())) - + '
') - print '