[Pywikipedia-svn] SVN: [7247] trunk/pywikipedia/test.py

filnik at svn.wikimedia.org filnik at svn.wikimedia.org
Tue Sep 15 08:37:30 UTC 2009


Revision: 7247
Author:   filnik
Date:     2009-09-15 08:37:30 +0000 (Tue, 15 Sep 2009)

Log Message:
-----------
Bugfix by xqt, patch: #2858443

Modified Paths:
--------------
    trunk/pywikipedia/test.py

Modified: trunk/pywikipedia/test.py
===================================================================
--- trunk/pywikipedia/test.py	2009-09-15 08:34:44 UTC (rev 7246)
+++ trunk/pywikipedia/test.py	2009-09-15 08:37:30 UTC (rev 7247)
@@ -1,6 +1,12 @@
 #!/usr/bin/python
 """
-Script to perform some tests.
+Script to test whether you are logged-in
+
+Parameters:
+
+   -all         Try to test on all sites where a username is defined in
+                user-config.py.
+   -sysop       test your sysop account. (Works only with -all)
 """
 #
 # (C) Rob W.W. Hooft, 2003
@@ -9,19 +15,35 @@
 #
 __version__='$Id$'
 #
-import re,sys,wikipedia
+import re,sys,wikipedia,config
 
+def show (mysite):
+    if mysite.loggedInAs():
+        wikipedia.output(u"You are logged in on %s as %s." % (repr(mysite), mysite.loggedInAs()))
+    else:
+        wikipedia.output(u"You are not logged in on %s." % repr(mysite))
+
 def main():
+    testall = False
+    sysop   = False
     for arg in wikipedia.handleArgs():
-    wikipedia.output(u"Unknown argument: %s" % arg)
-    wikipedia.stopme()
-    sys.exit(1)
-
-    mysite = wikipedia.getSite()
-    if mysite.loggedInAs():
-    wikipedia.output(u"You are logged in on %s as %s." % (repr(mysite), mysite.loggedInAs()))
+        if arg == "-all":
+            testall = True
+        elif arg == "-sysop":
+            sysop = True
+        else:
+            wikipedia.showHelp()
+            return
+    if testall:
+        if sysop:
+            namedict = config.sysopnames
+        else:
+            namedict = config.usernames
+        for familyName in namedict.iterkeys():
+            for lang in namedict[familyName].iterkeys():
+                 show(wikipedia.getSite(lang, familyName))
     else:
-    wikipedia.output(u"You are not logged in on %s." % repr(mysite))
+        show(wikipedia.getSite())
 
 if __name__ == "__main__":
     try:





More information about the Pywikipedia-svn mailing list