Revision: 4019
Author: wikipedian
Date: 2007-08-09 14:44:51 +0000 (Thu, 09 Aug 2007)
Log Message:
-----------
fixed logging behavior of newlines
Modified Paths:
--------------
trunk/pywikipedia/userinterfaces/cgi_interface.py
trunk/pywikipedia/userinterfaces/terminal_interface.py
trunk/pywikipedia/userinterfaces/tkinter_interface.py
trunk/pywikipedia/userinterfaces/wxpython_interface.py
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/userinterfaces/cgi_interface.py
===================================================================
--- trunk/pywikipedia/userinterfaces/cgi_interface.py 2007-08-09 14:35:37 UTC (rev 4018)
+++ trunk/pywikipedia/userinterfaces/cgi_interface.py 2007-08-09 14:44:51 UTC (rev 4019)
@@ -4,7 +4,7 @@
def __init__(self):
pass
- def output(self, text, newline = True, toStdout = False):
+ def output(self, text, toStdout = False):
# all debug output etc. will be ignored.
if toStdout:
sys.stdout.write(text.encode('UTF-8', 'replace'))
Modified: trunk/pywikipedia/userinterfaces/terminal_interface.py
===================================================================
--- trunk/pywikipedia/userinterfaces/terminal_interface.py 2007-08-09 14:35:37 UTC (rev 4018)
+++ trunk/pywikipedia/userinterfaces/terminal_interface.py 2007-08-09 14:44:51 UTC (rev 4019)
@@ -1,4 +1,4 @@
-
+
__version__ = '$Id$'
import config, transliteration
@@ -122,7 +122,7 @@
else:
targetStream.write(text.encode(config.console_encoding, 'replace'))
- def output(self, text, newline = True, toStdout = False):
+ def output(self, text, toStdout = False):
"""
If a character can't be displayed in the encoding used by the user's
terminal, it will be replaced with a question mark or by a
@@ -162,8 +162,6 @@
transliteratedText += codecedText[i]
prev = codecedText[i]
text = transliteratedText
- if newline:
- text += u'\n'
if toStdout:
targetStream = sys.stdout
@@ -182,7 +180,8 @@
# sound the terminal bell to notify the user
if config.ring_bell:
sys.stdout.write('\07')
- self.output(question + ' ', newline = False)
+ # TODO: make sure this is logged as well
+ self.output(question + ' ')
if password:
import getpass
text = getpass.getpass('')
Modified: trunk/pywikipedia/userinterfaces/tkinter_interface.py
===================================================================
--- trunk/pywikipedia/userinterfaces/tkinter_interface.py 2007-08-09 14:35:37 UTC (rev 4018)
+++ trunk/pywikipedia/userinterfaces/tkinter_interface.py 2007-08-09 14:44:51 UTC (rev 4019)
@@ -155,7 +155,7 @@
MainloopThread(self.parent).start()
- def output(self, text, urgency = 1, newline = True, toStdout = False):
+ def output(self, text, urgency = 1, toStdout = False):
"""
urgency levels:
0 - Debug output. Won't be shown in normal mode.
@@ -192,8 +192,6 @@
#self.logBox.tag_add(colors[i], startidx , endidx)
- if newline:
- self.logBox.insert(END, '\n')
# auto-scroll down
self.logBox.see(END)
Modified: trunk/pywikipedia/userinterfaces/wxpython_interface.py
===================================================================
--- trunk/pywikipedia/userinterfaces/wxpython_interface.py 2007-08-09 14:35:37 UTC (rev 4018)
+++ trunk/pywikipedia/userinterfaces/wxpython_interface.py 2007-08-09 14:44:51 UTC (rev 4019)
@@ -12,16 +12,13 @@
def __init__(self):
pass
- def output(self, text, newline = True):
+ def output(self, text, ):
"""
If a character can't be displayed, it will be replaced with a
question mark.
"""
- if newline:
- print text.encode(config.console_encoding, 'replace')
- else:
- # comma at the end means "don't print newline"
- print text.encode(config.console_encoding, 'replace'),
+ # comma at the end means "don't print newline"
+ print text.encode(config.console_encoding, 'replace'),
def input(self, question, password = False):
"""
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2007-08-09 14:35:37 UTC (rev 4018)
+++ trunk/pywikipedia/wikipedia.py 2007-08-09 14:44:51 UTC (rev 4019)
@@ -4471,7 +4471,7 @@
# TODO: consider pre-compiling this regex for speed improvements
plaintext = colorTagR.sub('', text)
# save the text in a logfile (will be written in utf-8)
- logfile.write(plaintext + '\n')
+ logfile.write(plaintext)
logfile.flush()
@@ -4509,11 +4509,13 @@
text = unicode(text, 'utf-8')
except UnicodeDecodeError:
text = unicode(text, 'iso8859-1')
+ if newline:
+ text += u'\n'
log(text)
if input_lock.locked():
- cache_output(text, newline = newline, toStdout = toStdout)
+ cache_output(text, toStdout = toStdout)
else:
- ui.output(text, newline = newline, toStdout = toStdout)
+ ui.output(text, toStdout = toStdout)
finally:
output_lock.release()