http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9972
Revision: 9972
Author: xqt
Date: 2012-03-09 09:42:53 +0000 (Fri, 09 Mar 2012)
Log Message:
-----------
Revert 9965 of trunk/pywikipedia/families/wikipedia_family.py:
sr and zh are now 1.19
Modified Paths:
--------------
trunk/pywikipedia/families/wikipedia_family.py
Modified: trunk/pywikipedia/families/wikipedia_family.py
===================================================================
--- trunk/pywikipedia/families/wikipedia_family.py 2012-03-08 16:18:42 UTC (rev 9971)
+++ trunk/pywikipedia/families/wikipedia_family.py 2012-03-09 09:42:53 UTC (rev 9972)
@@ -1478,12 +1478,6 @@
# xxwikipedia for Wikipedias.
return '%swiki_p' % code
- def version(self, code):
- """Return MediaWiki version number as a string."""
- # Don't use this, use versionnumber() instead. This only exists
- # to not break family files.
- return code in ['sr', 'zh'] and '1.18wmf1' or '1.19wmf1'
-
def code2encodings(self, code):
"""Return a list of historical encodings for a specific language
wikipedia"""
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9971
Revision: 9971
Author: binbot
Date: 2012-03-08 16:18:42 +0000 (Thu, 08 Mar 2012)
Log Message:
-----------
Starting the survey for old Python versions. See
http://thread.gmane.org/gmane.comp.python.pywikipediabot.general/12473
Modified Paths:
--------------
trunk/pywikipedia/config.py
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/config.py
===================================================================
--- trunk/pywikipedia/config.py 2012-03-05 17:48:45 UTC (rev 9970)
+++ trunk/pywikipedia/config.py 2012-03-08 16:18:42 UTC (rev 9971)
@@ -584,6 +584,10 @@
print " Was: ",ot
print " Now: ",nt
del nt, ot
+ elif _key == 'suppresssurvey':
+ # Temporary solution for 2012 version survey, search for this key
+ # in wikipedia.py
+ pass
else:
print "WARNING: Configuration variable %r is defined but unknown. Misspelled?" %_key
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2012-03-05 17:48:45 UTC (rev 9970)
+++ trunk/pywikipedia/wikipedia.py 2012-03-08 16:18:42 UTC (rev 9971)
@@ -8234,6 +8234,28 @@
MyURLopener.addheaders = [('User-agent', useragent)]
+# This is a temporary part for the 2012 version survey
+# http://thread.gmane.org/gmane.comp.python.pywikipediabot.general/12473
+# Upon removing the connected lines from config.py should be removed, too.
+if sys.version < '2.7.2':
+ try:
+ if config.suppresssurvey == True:
+ pass
+ else:
+ raise AttributeError
+ except AttributeError:
+ output(
+"""
+\03{lightyellow}Dear Pwikipedia user!\03{default}
+Pywikibot has detected that you use an outdated version of Python.
+We would like to hear your voice before ceasing support of this version.
+Please update to \03{lightyellow}Python 2.7.2\03{default} if possible or visit
+http://www.mediawiki.org/wiki/Pywikipediabot/Survey2012 to tell us why we
+should support your version and to learn how to hide this message.
+After collecting opinions for a time we will decide and announce the deadline
+of deprecating use of old Python versions for Pywikipedia.
+""")
+
if __name__ == '__main__':
import doctest
print 'Pywikipediabot %s' % version.getversion()
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9969
Revision: 9969
Author: xqt
Date: 2012-03-04 15:55:41 +0000 (Sun, 04 Mar 2012)
Log Message:
-----------
fixReferences(), some parts from AnomieBOT
Modified Paths:
--------------
trunk/pywikipedia/cosmetic_changes.py
Modified: trunk/pywikipedia/cosmetic_changes.py
===================================================================
--- trunk/pywikipedia/cosmetic_changes.py 2012-03-04 15:32:08 UTC (rev 9968)
+++ trunk/pywikipedia/cosmetic_changes.py 2012-03-04 15:55:41 UTC (rev 9969)
@@ -170,6 +170,7 @@
text = self.removeNonBreakingSpaceBeforePercent(text)
text = self.fixSyntaxSave(text)
text = self.fixHtml(text)
+ text = self.fixReferences(text)
text = self.fixStyle(text)
text = self.fixTypo(text)
if self.site.lang in ['ckb', 'fa']:
@@ -614,9 +615,18 @@
text = pywikibot.replaceExcept(text,
r'(?i)([\r\n]) *<h%d> *([^<]+?) *</h%d> *([\r\n])'%(level, level),
r'%s'%equals, exceptions)
+ # TODO: maybe we can make the bot replace <p> tags with \r\n's.
+ return text
+
+ def fixReferences(self, text):
+ #http://en.wikipedia.org/wiki/User:AnomieBOT/source/tasks/OrphanReferenceFixer.pm
+ exceptions = ['nowiki', 'comment', 'math', 'pre', 'source', 'startspace']
+
+ # it should be name = " or name=" NOT name ="
+ text = re.sub(r'(?i)<ref +name(= *| *=)"', r'<ref name="', text)
#remove empty <ref/>-tag
text = pywikibot.replaceExcept(text, r'(?i)(<ref\s*/>|<ref *>\s*</ref>)', r'', exceptions)
- # TODO: maybe we can make the bot replace <p> tags with \r\n's.
+ text = pywikibot.replaceExcept(text, r'(?i)<ref\s+([^>]+?)\s*>\s*</ref>', r'<ref \1/>', exceptions)
return text
def fixStyle(self, text):
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9966
Revision: 9966
Author: xqt
Date: 2012-03-04 11:45:34 +0000 (Sun, 04 Mar 2012)
Log Message:
-----------
sr and zh are still 1.18; update from trunk r9965
Modified Paths:
--------------
branches/rewrite/pywikibot/families/wikipedia_family.py
Modified: branches/rewrite/pywikibot/families/wikipedia_family.py
===================================================================
--- branches/rewrite/pywikibot/families/wikipedia_family.py 2012-03-04 11:44:29 UTC (rev 9965)
+++ branches/rewrite/pywikibot/families/wikipedia_family.py 2012-03-04 11:45:34 UTC (rev 9966)
@@ -573,6 +573,12 @@
# xxwikipedia for Wikipedias.
return '%swiki_p' % code
+ def version(self, code):
+ """Return MediaWiki version number as a string."""
+ # Don't use this, use versionnumber() instead. This only exists
+ # to not break family files.
+ return code in ['sr', 'zh'] and '1.18wmf1' or '1.19wmf1'
+
def code2encodings(self, code):
"""Return a list of historical encodings for a specific language
wikipedia"""
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9965
Revision: 9965
Author: xqt
Date: 2012-03-04 11:44:29 +0000 (Sun, 04 Mar 2012)
Log Message:
-----------
sr and zh are still 1.18
Modified Paths:
--------------
trunk/pywikipedia/families/wikipedia_family.py
Modified: trunk/pywikipedia/families/wikipedia_family.py
===================================================================
--- trunk/pywikipedia/families/wikipedia_family.py 2012-03-04 10:09:53 UTC (rev 9964)
+++ trunk/pywikipedia/families/wikipedia_family.py 2012-03-04 11:44:29 UTC (rev 9965)
@@ -1478,6 +1478,12 @@
# xxwikipedia for Wikipedias.
return '%swiki_p' % code
+ def version(self, code):
+ """Return MediaWiki version number as a string."""
+ # Don't use this, use versionnumber() instead. This only exists
+ # to not break family files.
+ return code in ['sr', 'zh'] and '1.18wmf1' or '1.19wmf1'
+
def code2encodings(self, code):
"""Return a list of historical encodings for a specific language
wikipedia"""
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9964
Revision: 9964
Author: xqt
Date: 2012-03-04 10:09:53 +0000 (Sun, 04 Mar 2012)
Log Message:
-----------
extract the module name by splitting
Modified Paths:
--------------
trunk/pywikipedia/wikipediatools.py
Modified: trunk/pywikipedia/wikipediatools.py
===================================================================
--- trunk/pywikipedia/wikipediatools.py 2012-03-03 13:05:53 UTC (rev 9963)
+++ trunk/pywikipedia/wikipediatools.py 2012-03-04 10:09:53 UTC (rev 9964)
@@ -47,8 +47,8 @@
raise RuntimeError("Directory '%s' does not exist." % base_dir)
if not os.path.exists(os.path.join(base_dir, "user-config.py")):
print("No user-config.py found in directory '%s'" % base_dir)
- called = os.path.basename(sys.argv[0].strip())
- if not ('version' in called):
+ called = os.path.basename(sys.argv[0].strip()).split('.')[0]
+ if called != 'version':
print("Creating...\n")
create_user_config_file(base_dir)
return base_dir