Revision: 7657
Author:   xqt
Date:     2009-11-16 13:27:51 +0000 (Mon, 16 Nov 2009)

Log Message:
-----------
enable/disable cosmetic changes of families/languages by settings in the 
user_config.py

Modified Paths:
--------------
    trunk/pywikipedia/config.py
    trunk/pywikipedia/cosmetic_changes.py
    trunk/pywikipedia/wikipedia.py

Modified: trunk/pywikipedia/config.py
===================================================================
--- trunk/pywikipedia/config.py 2009-11-16 10:48:26 UTC (rev 7656)
+++ trunk/pywikipedia/config.py 2009-11-16 13:27:51 UTC (rev 7657)
@@ -441,7 +441,19 @@
 # If you want the bot to also do cosmetic changes when editing a page on a
 # foreign wiki, set cosmetic_changes_mylang_only to False, but be careful!
 cosmetic_changes_mylang_only = True
-
+# The dictionary cosmetic_changes_enable should contain a tuple of languages
+# for each site where you wish to enable in addition to your own langlanguage
+# (if cosmetic_changes_mylang_only is set)
+# Please set your dictionary by adding such lines to your user-config.py:
+# cosmetic_changes_enable['wikipedia'] = ('de', 'en', 'fr')
+cosmetic_changes_enable = {}
+# The dictionary cosmetic_changes_disable should contain a tuple of languages
+# for each site where you wish to disable cosmetic changes. You may use it with
+# cosmetic_changes_mylang_only is False, but you can also disable your own
+# language. This also overrides the settings in the cosmetic_changes_enable
+# dictionary. Please set your dict by adding such lines to your user-config.py:
+# cosmetic_changes_disable['wikipedia'] = ('de', 'en', 'fr')
+cosmetic_changes_disable = {}
 # Use the experimental disk cache to prevent huge memory usage
 use_diskcache = False
 

Modified: trunk/pywikipedia/cosmetic_changes.py
===================================================================
--- trunk/pywikipedia/cosmetic_changes.py       2009-11-16 10:48:26 UTC (rev 
7656)
+++ trunk/pywikipedia/cosmetic_changes.py       2009-11-16 13:27:51 UTC (rev 
7657)
@@ -24,12 +24,30 @@
 
     cosmetic_changes = True
 
+You may enable cosmetic changes for additional languages by adding the
+dictionary cosmetic_changes_enable to your user-config.py. It should contain
+a tuple of languages for each site where you wish to enable in addition to
+your own langlanguage if cosmetic_changes_mylang_only is True (see below).
+Please set your dictionary by adding such lines to your user-config.py:
+
+    cosmetic_changes_enable['wikipedia'] = ('de', 'en', 'fr')
+
 There is another config variable: You can set
 
     cosmetic_changes_mylang_only = False
 
 if you're running a bot on multiple sites and want to do cosmetic changes on
 all of them, but be careful if you do.
+
+You may disable cosmetic changes by adding the all unwanted languages to the
+dictionary cosmetic_changes_disable in your user-config.py. It should contain
+a tuple of languages for each site where you wish to disable cosmetic changes.
+You may use it with cosmetic_changes_mylang_only is False, but you can also
+disable your own language. This also overrides the settings in the dictionary
+cosmetic_changes_enable. Please set this dictionary by adding such lines to
+your user-config.py:
+
+    cosmetic_changes_disable['wikipedia'] = ('de', 'en', 'fr')
 """
 __version__ = '$Id$'
 import wikipedia as pywikibot

Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py      2009-11-16 10:48:26 UTC (rev 7656)
+++ trunk/pywikipedia/wikipedia.py      2009-11-16 13:27:51 UTC (rev 7657)
@@ -1524,8 +1524,19 @@
         # If no comment is given for the change, use the default
         comment = comment or action
         if config.cosmetic_changes and not self.isTalkPage() and not 
calledModuleName() == 'cosmetic_changes':
-            old = newtext
-            if not config.cosmetic_changes_mylang_only or 
(self.site().family.name == config.family and self.site().lang == 
config.mylang):
+            if config.cosmetic_changes_mylang_only:
+                cc = (self.site().family.name == config.family and 
self.site().lang == config.mylang) or \
+                     self.site().family.name in 
config.cosmetic_changes_enable.keys() and \
+                     self.site().lang in 
config.cosmetic_changes_enable[self.site().family.name]
+            else:
+                cc = True
+            cc = cc and not \
+                 (self.site().family.name in 
config.cosmetic_changes_disable.keys() and \
+                 self.site().lang in 
config.cosmetic_changes_disable[self.site().family.name])
+            if cc:
+                old = newtext
+                if verbose:
+                    output(u'Cosmetic Changes for %s-%s enabled.' % 
(self.site().family.name, self.site().lang))
                 import cosmetic_changes
                 ccToolkit = 
cosmetic_changes.CosmeticChangesToolkit(self.site(), 
redirect=self.isRedirectPage(), namespace = self.namespace())
                 newtext = ccToolkit.change(newtext)



_______________________________________________
Pywikipedia-svn mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-svn

Reply via email to