X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=geekigeeki.py;h=b85a3a2ad1be68264733b5cae74ef9710436728e;hb=2fcd242301699667836d3dce840cb101bec904c7;hp=a7e99ed10121c9af816cfc76eddc0707edeeec94;hpb=5f99f96a7a102bb8f2c491dd1e11fe8686c7c0a0;p=geekigeeki.git diff --git a/geekigeeki.py b/geekigeeki.py old mode 100755 new mode 100644 index a7e99ed..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,71 +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): @@ -274,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. @@ -362,11 +366,15 @@ 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: - execfile("macros/" + name + ".py", globals()) + try: + exec(open("macros/" + name + ".py").read(), globals()) + except IOError as er: + if er.errno == errno.ENOENT: + pass macro = globals().get('_macro_' + name) if macro: return macro(argv) @@ -485,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
@@ -511,7 +519,7 @@ class WikiFormatter:
+ r"|(?P '
+ 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 '