X-Git-Url: https://codewiz.org/gitweb?p=geekigeeki.git;a=blobdiff_plain;f=geekigeeki.py;h=ca16283d5ea2f2c78c573b3863a371add9c15aef;hp=0ff2e7a007527f0d2fa2ce9e9212ceffd839e88e;hb=7ce906e26b7c2c91e232508ccd0af6fe9ec4aeec;hpb=6fe435b1dba5647a83349f69fe95eb3c02758997
diff --git a/geekigeeki.py b/geekigeeki.py
index 0ff2e7a..ca16283 100755
--- a/geekigeeki.py
+++ b/geekigeeki.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3.0
# -*- coding: utf-8 -*-
#
# Copyright 1999, 2000 Martin Pool ' + 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. %d hits out of %d pages searched.'
+ 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
@@ -115,74 +115,74 @@ def send_title(name, text="Limbo", msg_text=None, msg_type='error', writable=Fal
# Head
emit_header()
- print ''
- print ''
+ print('')
+ print('')
- 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('"
+ print("
")
print_search_stats(len(hits), len(all_pages))
@@ -234,17 +234,17 @@ def handle_titlesearch(needle):
needle_re = re.compile(needle, re.IGNORECASE)
all_pages = page_list()
- hits = filter(needle_re.search, all_pages)
+ hits = list(filter(needle_re.search, all_pages))
- print "")
for (count, page_name) in hits:
- print '
"
+ print('"
+ print("
")
print_search_stats(len(hits), len(all_pages))
def print_search_stats(hits, searched):
- print "")
for filename in hits:
- print '
"
+ print('
last modified %s
' % mod_string) + print('') class WikiFormatter: """Object that turns Wiki markup into HTML. @@ -364,13 +364,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, err: + exec(open("macros/" + name + ".py").read(), globals()) + except IOError as err: if err.errno == errno.ENOENT: pass macro = globals().get('_macro_' + name) if macro: @@ -490,14 +490,14 @@ class WikiFormatter: return res def replace(self, match): - for rule, hit in match.groupdict().items(): + for rule, hit in list(match.groupdict().items()): if hit: return getattr(self, '_' + rule + '_repl')(hit) else: 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 @@ -544,7 +544,7 @@ class WikiFormatter: indent_re = re.compile(r"^\s*") tr_re = re.compile(r"^\s*\|\|") eol_re = re.compile(r"\r?\n") - for self.line in eol_re.split(self.raw.expandtabs()): + for self.line in eol_re.split(str(self.raw.expandtabs())): # Skip pragmas if self.in_header: if self.line.startswith('#'): @@ -552,23 +552,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 '