[Pywikipedia-l] SVN: [6429] branches/rewrite/pywikibot/bot.py

russblau at svn.wikimedia.org russblau at svn.wikimedia.org
Mon Feb 23 14:50:57 UTC 2009


Revision: 6429
Author:   russblau
Date:     2009-02-23 14:50:57 +0000 (Mon, 23 Feb 2009)

Log Message:
-----------
fix bug 2630322, also add some comments

Modified Paths:
--------------
    branches/rewrite/pywikibot/bot.py

Modified: branches/rewrite/pywikibot/bot.py
===================================================================
--- branches/rewrite/pywikibot/bot.py	2009-02-23 11:01:43 UTC (rev 6428)
+++ branches/rewrite/pywikibot/bot.py	2009-02-23 14:50:57 UTC (rev 6429)
@@ -15,12 +15,10 @@
 
 
 import logging, logging.handlers
+       # all output goes thru python std library "logging" module
 import os.path
 import sys
-import pywikibot
-from pywikibot import config
 
-
 # logging levels
 logger = logging.getLogger("bot")
 
@@ -29,7 +27,10 @@
 VERBOSE = 18
 INPUT = 25
 
+import pywikibot
+from pywikibot import config
 
+
 class MaxLevelFilter(logging.Filter):
     """Filter that only passes records at or below a specific level.
 
@@ -134,20 +135,20 @@
 
     """
     # make sure logging system has been initialized
-    root = pywikibot.logging.getLogger()
+    root = logging.getLogger()
     if root.level == 30: # init_handlers sets this level
         init_handlers()
 
     if decoder:
         text = unicode(text, decoder)
-    elif type(text) is not unicode:
+    elif not isinstance(text, unicode):
 ##        import traceback
 ##        pywikibot.output(
 ##            u"Non-unicode (%s) passed to wikipedia.output without decoder!\n"
 ##             % type(text),
 ##            level=VERBOSE
 ##        )
-        if type(text) is not str:
+        if not isinstance(text, str):
             # looks like text is a non-text object. 
             # Maybe it has a __unicode__ builtin ?
             # (allows to print Page, Site...)
@@ -175,6 +176,11 @@
     Returns a unicode string.
 
     """
+    # make sure logging system has been initialized
+    root = logging.getLogger()
+    if root.level == 30: # init_handlers sets this level
+        init_handlers()
+
     data = ui.input(question, password)
     return data
 
@@ -196,6 +202,11 @@
     Returns a one-letter string in lowercase.
 
     """
+    # make sure logging system has been initialized
+    root = logging.getLogger()
+    if root.level == 30: # init_handlers sets this level
+        init_handlers()
+
     data = ui.inputChoice(question, answers, hotkeys, default).lower()
     return data
 





More information about the Pywikipedia-l mailing list