Index: watchlist.py
===================================================================
--- watchlist.py	(Revision 8597)
+++ watchlist.py	(Arbeitskopie)
@@ -21,28 +21,28 @@
 
 __version__='$Id$'
 
-import wikipedia
 import re, sys, pickle
 import os.path
 import time
+import wikipedia as pywikibot
 
 cache = {}
 
 def get(site = None):
     if site is None:
-        site = wikipedia.getSite()
+        site = pywikibot.getSite()
     if site in cache:
         # Use cached copy if it exists.
         watchlist = cache[site]
     else:
-        fn = wikipedia.config.datafilepath('watchlists',
+        fn = pywikibot.config.datafilepath('watchlists',
                   'watchlist-%s-%s.dat' % (site.family.name, site.lang))
         try:
             # find out how old our saved dump is (in seconds)
             file_age = time.time() - os.path.getmtime(fn)
             # if it's older than 1 month, reload it
             if file_age > 30 * 24 * 60 * 60:
-                wikipedia.output(u'Copy of watchlist is one month old, reloading')
+                pywikibot.output(u'Copy of watchlist is one month old, reloading')
                 refresh(site)
         except OSError:
             # no saved watchlist exists yet, retrieve one
@@ -69,15 +69,15 @@
     params = {
         'action': 'query',
         'list': 'watchlist',
-        'wllimit': wikipedia.config.special_page_limit,
+        'wllimit': pywikibot.config.special_page_limit,
         'wlprop': 'title',
     }
     
-    wikipedia.output(u'Retrieving watchlist for %s via API.' % repr(site))
-    #wikipedia.put_throttle() # It actually is a get, but a heavy one.
+    pywikibot.output(u'Retrieving watchlist for %s via API.' % repr(site))
+    #pywikibot.put_throttle() # It actually is a get, but a heavy one.
     watchlist = []
     while True:
-        data = wikipedia.query.GetData(params, site, sysop=sysop)
+        data = pywikibot.query.GetData(params, site, sysop=sysop)
         if 'error' in data:
             raise RuntimeError('ERROR: %s' % data)
         watchlist.extend([w['title'] for w in data['query']['watchlist']])
@@ -90,10 +90,10 @@
     # Save the watchlist to disk
     # The file is stored in the watchlists subdir. Create if necessary.
     if sysop:
-        f = open(wikipedia.config.datafilepath('watchlists',
+        f = open(pywikibot.config.datafilepath('watchlists',
                  'watchlist-%s-%s-sysop.dat' % (site.family.name, site.lang)), 'w')    
     else:
-        f = open(wikipedia.config.datafilepath('watchlists',
+        f = open(pywikibot.config.datafilepath('watchlists',
                  'watchlist-%s-%s.dat' % (site.family.name, site.lang)), 'w')
     pickle.dump(watchlist, f)
     f.close()
@@ -101,11 +101,11 @@
 def _refreshOld(site, sysop=False):
     # get watchlist special page's URL
     path = site.watchlist_address()
-    wikipedia.output(u'Retrieving watchlist for %s' % repr(site))
-    #wikipedia.put_throttle() # It actually is a get, but a heavy one.
+    pywikibot.output(u'Retrieving watchlist for %s' % repr(site))
+    #pywikibot.put_throttle() # It actually is a get, but a heavy one.
     watchlistHTML = site.getUrl(path, sysop=sysop)
 
-    wikipedia.output(u'Parsing watchlist')
+    pywikibot.output(u'Parsing watchlist')
     watchlist = []
     for itemR in [re.compile(r'<li><input type="checkbox" name="id\[\]" value="(.+?)" />'), re.compile(r'<li><input name="titles\[\]" type="checkbox" value="(.+?)" />')]:
         for m in itemR.finditer(watchlistHTML):
@@ -115,10 +115,10 @@
     # Save the watchlist to disk
     # The file is stored in the watchlists subdir. Create if necessary.
     if sysop:
-        f = open(wikipedia.config.datafilepath('watchlists',
+        f = open(pywikibot.config.datafilepath('watchlists',
                  'watchlist-%s-%s-sysop.dat' % (site.family.name, site.lang)), 'w')    
     else:
-        f = open(wikipedia.config.datafilepath('watchlists',
+        f = open(pywikibot.config.datafilepath('watchlists',
                  'watchlist-%s-%s.dat' % (site.family.name, site.lang)), 'w')
     pickle.dump(watchlist, f)
     f.close()
@@ -126,17 +126,17 @@
 def refresh_all(new = False, sysop=False):
     if new:
         import config
-        wikipedia.output('Downloading All watchlists for your accounts in user-config.py');
+        pywikibot.output('Downloading All watchlists for your accounts in user-config.py');
         for family in config.usernames:
             for lang in config.usernames[ family ]:
-                refresh(wikipedia.getSite( code = lang, fam = family ), sysop=sysop )
+                refresh(pywikibot.getSite( code = lang, fam = family ), sysop=sysop )
         for family in config.sysopnames:
             for lang in config.sysopnames[ family ]:
-                refresh(wikipedia.getSite( code = lang, fam = family ), sysop=sysop )
+                refresh(pywikibot.getSite( code = lang, fam = family ), sysop=sysop )
 
     else:
         import dircache, time
-        filenames = dircache.listdir(wikipedia.config.datafilepath('watchlists'))
+        filenames = dircache.listdir(pywikibot.config.datafilepath('watchlists'))
         watchlist_filenameR = re.compile('watchlist-([a-z\-:]+).dat')
         for filename in filenames:
             match = watchlist_filenameR.match(filename)
@@ -144,13 +144,13 @@
                 arr = match.group(1).split('-')
                 family = arr[0]
                 lang = '-'.join(arr[1:])
-                refresh(wikipedia.getSite(code = lang, fam = family))
+                refresh(pywikibot.getSite(code = lang, fam = family))
 
 def main():
     all = False
     new = False
     sysop = False
-    for arg in wikipedia.handleArgs():
+    for arg in pywikibot.handleArgs():
         if arg == '-all' or arg == '-update':
             all = True
         elif arg == '-new':
@@ -162,16 +162,16 @@
     elif new:
         refresh_all(new, sysop=sysop)
     else:
-        refresh(wikipedia.getSite(), sysop=sysop)
+        refresh(pywikibot.getSite(), sysop=sysop)
 
-        watchlist = get(wikipedia.getSite())
-        wikipedia.output(u'%i pages in the watchlist.' % len(watchlist))
+        watchlist = get(pywikibot.getSite())
+        pywikibot.output(u'%i pages in the watchlist.' % len(watchlist))
         for pageName in watchlist:
-            wikipedia.output( pageName, toStdout = True )
+            pywikibot.output( pageName, toStdout = True )
 
 if __name__ == "__main__":
     try:
         main()
     finally:
-        wikipedia.stopme()
+        pywikibot.stopme()
 
