http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10171
Revision: 10171
Author: xqt
Date: 2012-05-03 10:49:55 +0000 (Thu, 03 May 2012)
Log Message:
-----------
new ImagePage.getFirstUploader() method
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2012-05-03 07:49:44 UTC (rev 10170)
+++ trunk/pywikipedia/wikipedia.py 2012-05-03 10:49:55 UTC (rev 10171)
@@ -3920,6 +3920,11 @@
result.append((datetime, username, resolution, size, comment))
return result
+ def getFirstUploader(self):
+ """ Function that uses the APIs to detect the first uploader of the image """
+ inf = self.getFileVersionHistory()[-1]
+ return [inf[1], inf[0]]
+
def getLatestUploader(self):
""" Function that uses the APIs to detect the latest uploader of the image """
if not self._infoLoaded:
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10170
Revision: 10170
Author: xqt
Date: 2012-05-03 07:49:44 +0000 (Thu, 03 May 2012)
Log Message:
-----------
minor docs changes from trunk
Modified Paths:
--------------
branches/rewrite/scripts/replace.py
Modified: branches/rewrite/scripts/replace.py
===================================================================
--- branches/rewrite/scripts/replace.py 2012-05-02 05:52:15 UTC (rev 10169)
+++ branches/rewrite/scripts/replace.py 2012-05-03 07:49:44 UTC (rev 10170)
@@ -64,8 +64,8 @@
in order not to waste too much CPU.
-fix:XYZ Perform one of the predefined replacements tasks, which are
- given in the dictionary 'fixes' defined inside the file
- fixes.py.
+ given in the dictionary 'fixes' defined inside the files
+ fixes.py and user-fixes.py.
The -regex and -nocase argument and given replacements will
be ignored if you use -fix.
Currently available predefined fixes are:
@@ -110,10 +110,12 @@
talk about HTTP, where the typo has become part of the standard:
python replace.py referer referrer -file:typos.txt -excepttext:HTTP
+
+Please type "replace.py -help | more" if you can't read the top of the help.
"""
from __future__ import generators
#
-# (C) Daniel Herding & the Pywikipedia team, 2004-2011
+# (C) Daniel Herding & the Pywikipedia team, 2004-2012
#
__version__='$Id$'
#
@@ -183,7 +185,8 @@
and not self.isTextExcepted(entry.text):
new_text = entry.text
for old, new in self.replacements:
- new_text = pywikibot.replaceExcept(new_text, old, new, self.excsInside, self.site)
+ new_text = pywikibot.replaceExcept(
+ new_text, old, new, self.excsInside, self.site)
if new_text != entry.text:
yield pywikibot.Page(self.site, entry.title)
except KeyboardInterrupt:
@@ -613,7 +616,7 @@
caseInsensitive = fix['nocase']
replacements = fix['replacements']
- #Set the regular expression flags
+ # Set the regular expression flags
flags = re.UNICODE
if caseInsensitive:
flags = flags | re.IGNORECASE
@@ -630,7 +633,8 @@
oldR = re.compile(old, flags)
replacements[i] = oldR, new
- for exceptionCategory in ['title', 'require-title', 'text-contains', 'inside']:
+ for exceptionCategory in [
+ 'title', 'require-title', 'text-contains', 'inside']:
if exceptionCategory in exceptions:
patterns = exceptions[exceptionCategory]
if not regex:
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10169
Revision: 10169
Author: xqt
Date: 2012-05-02 05:52:15 +0000 (Wed, 02 May 2012)
Log Message:
-----------
follow up for r10167: subst the /Text
Modified Paths:
--------------
trunk/pywikipedia/clean_sandbox.py
Modified: trunk/pywikipedia/clean_sandbox.py
===================================================================
--- trunk/pywikipedia/clean_sandbox.py 2012-05-02 05:40:17 UTC (rev 10168)
+++ trunk/pywikipedia/clean_sandbox.py 2012-05-02 05:52:15 UTC (rev 10169)
@@ -72,7 +72,7 @@
'pl': u'{{Prosimy - NIE ZMIENIAJ, NIE KASUJ, NIE PRZENOŚ tej linijki - pisz niżej}}',
'pt': u'<!--não apague esta linha-->{{página de testes}}<!--não apagar-->\r\n',
'ru': u'{{/Пишите ниже}}\n<!-- Не удаляйте, пожалуйста, эту строку, тестируйте ниже -->',
- 'simple': u'{{Please leave this line alone (sandbox heading)}}\n<!-- Hello! Feel free to try your formatting and editing skills below this line. As this page is for editing experiments, this page will automatically be cleaned every so-often. -->',
+ 'simple': u'{{subst:/Text}}',
'sco': u'Feel free tae test here',
'sr': u'{{песак}}\n<!-- Молимо, испробавајте испод ове линије. Хвала. -->',
'sv': u'{{subst:Sandlådan}}',
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10168
Revision: 10168
Author: xqt
Date: 2012-05-02 05:40:17 +0000 (Wed, 02 May 2012)
Log Message:
-----------
userinterface_lang in use now, change doc
Modified Paths:
--------------
trunk/pywikipedia/config.py
Modified: trunk/pywikipedia/config.py
===================================================================
--- trunk/pywikipedia/config.py 2012-05-02 05:30:02 UTC (rev 10167)
+++ trunk/pywikipedia/config.py 2012-05-02 05:40:17 UTC (rev 10168)
@@ -119,7 +119,6 @@
# i18n setting for user interface language
# default is config.mylang or 'en'
-# isn't yet ready
userinterface_lang = None
# Should we transliterate characters that do not exist in the console
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10167
Revision: 10167
Author: xqt
Date: 2012-05-02 05:30:02 +0000 (Wed, 02 May 2012)
Log Message:
-----------
fix message on simple-wiki due to bot war http://simple.wikipedia.org/w/index.php?title=Wikipedia%3ASandbox&diff=3545…
Modified Paths:
--------------
trunk/pywikipedia/clean_sandbox.py
Modified: trunk/pywikipedia/clean_sandbox.py
===================================================================
--- trunk/pywikipedia/clean_sandbox.py 2012-05-01 19:04:43 UTC (rev 10166)
+++ trunk/pywikipedia/clean_sandbox.py 2012-05-02 05:30:02 UTC (rev 10167)
@@ -72,7 +72,7 @@
'pl': u'{{Prosimy - NIE ZMIENIAJ, NIE KASUJ, NIE PRZENOŚ tej linijki - pisz niżej}}',
'pt': u'<!--não apague esta linha-->{{página de testes}}<!--não apagar-->\r\n',
'ru': u'{{/Пишите ниже}}\n<!-- Не удаляйте, пожалуйста, эту строку, тестируйте ниже -->',
- 'simple': u'{{Please leave this line alone (sandbox heading)}}\n<!-- Hello! Feel free to try your formatting and editing skills below this line. As this page is for editing experiments, this page will automatically be cleaned every 2 hours. -->',
+ 'simple': u'{{Please leave this line alone (sandbox heading)}}\n<!-- Hello! Feel free to try your formatting and editing skills below this line. As this page is for editing experiments, this page will automatically be cleaned every so-often. -->',
'sco': u'Feel free tae test here',
'sr': u'{{песак}}\n<!-- Молимо, испробавајте испод ове линије. Хвала. -->',
'sv': u'{{subst:Sandlådan}}',
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10166
Revision: 10166
Author: xqt
Date: 2012-05-01 19:04:43 +0000 (Tue, 01 May 2012)
Log Message:
-----------
fix for template identifier, follow-ups for r7533, r8189
Modified Paths:
--------------
trunk/pywikipedia/featured.py
Modified: trunk/pywikipedia/featured.py
===================================================================
--- trunk/pywikipedia/featured.py 2012-05-01 15:20:22 UTC (rev 10165)
+++ trunk/pywikipedia/featured.py 2012-05-01 19:04:43 UTC (rev 10166)
@@ -584,34 +584,34 @@
if part:
try:
# BUG: range with zh-min-nan (3 "-")
- if len(fromlang)==1 and fromlang[0].index("-")>=0:
- ll1,ll2=fromlang[0].split("--",1)
- if not ll1: ll1=""
- if not ll2: ll2="zzzzzzz"
+ if len(fromlang) == 1 and fromlang[0].index("-") >= 0:
+ start, end = fromlang[0].split("--", 1)
+ if not start: start = ""
+ if not end: end = "zzzzzzz"
if processType == 'good':
- fromlang=[ll for ll in good_name.keys()
- if ll>=ll1 and ll<=ll2]
+ fromlang = [lang for lang in good_name.keys()
+ if lang >= start and lang <= end]
elif processType == 'list':
- fromlang=[ll for ll in good_lists.keys()
- if ll>=ll1 and ll<=ll2]
+ fromlang = [lang for lang in lists_name.keys()
+ if lang >= start and lang <= end]
elif processType == 'former':
- fromlang=[ll for ll in former_lists.keys()
- if ll>=ll1 and ll<=ll2]
+ fromlang = [lang for lang in former_name.keys()
+ if lang >= start and lang <= end]
else:
- fromlang=[ll for ll in featured_name.keys()
- if ll>=ll1 and ll<=ll2]
+ fromlang = [lang for lang in featured_name.keys()
+ if lang >= start and lang <= end]
except:
pass
if doAll:
if processType == 'good':
- fromlang=good_name.keys()
+ fromlang = good_name.keys()
elif processType == 'list':
- fromlang=lists_name.keys()
+ fromlang = lists_name.keys()
elif processType == 'former':
- fromlang=former_name.keys()
+ fromlang = former_name.keys()
else:
- fromlang=featured_name.keys()
+ fromlang = featured_name.keys()
filename="cache/" + processType
try:
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10165
Revision: 10165
Author: xqt
Date: 2012-05-01 15:20:22 +0000 (Tue, 01 May 2012)
Log Message:
-----------
introduce userinterface_lang from trunk r9496
Modified Paths:
--------------
branches/rewrite/pywikibot/config2.py
Modified: branches/rewrite/pywikibot/config2.py
===================================================================
--- branches/rewrite/pywikibot/config2.py 2012-05-01 15:03:51 UTC (rev 10164)
+++ branches/rewrite/pywikibot/config2.py 2012-05-01 15:20:22 UTC (rev 10165)
@@ -177,6 +177,10 @@
# tkinter isn't yet ready
userinterface = 'terminal'
+# i18n setting for user interface language
+# default is config.mylang or 'en'
+userinterface_lang = None
+
# Should we transliterate characters that do not exist in the console
# character set?
# True: whenever possible
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10164
Revision: 10164
Author: xqt
Date: 2012-05-01 15:03:51 +0000 (Tue, 01 May 2012)
Log Message:
-----------
i18n.input() from trunk r10132 and xdict for different families from trunk release
Modified Paths:
--------------
branches/rewrite/pywikibot/i18n.py
Modified: branches/rewrite/pywikibot/i18n.py
===================================================================
--- branches/rewrite/pywikibot/i18n.py 2012-05-01 14:40:41 UTC (rev 10163)
+++ branches/rewrite/pywikibot/i18n.py 2012-05-01 15:03:51 UTC (rev 10164)
@@ -3,7 +3,7 @@
and for TranslateWiki-based translations
"""
#
-# (C) Pywikipedia bot team, 2004-2011
+# (C) Pywikipedia bot team, 2004-2012
#
# Distributed under the terms of the MIT license.
#
@@ -12,6 +12,8 @@
import re
from pywikibot import Error
from plural import plural_rules
+import pywikibot
+import config2 as config
# Languages to use for comment text after the actual language but before
# en:. For example, if for language 'xx', you want the preference of
@@ -128,7 +130,7 @@
if code == 'ltg':
return ['lv']
#Dutch
- if code in ['fy', 'li', 'pap', 'srn', 'vls', 'zea']:
+ if code in ['af', 'fy', 'li', 'pap', 'srn', 'vls', 'zea']:
return ['nl']
if code == ['nds-nl']:
return ['nds', 'nl']
@@ -205,6 +207,8 @@
return ['kj', 'ng']
if code in ['meu', 'hmo']:
return ['meu', 'hmo']
+ if code == ['as']:
+ return ['bn']
#Default value
return []
@@ -222,10 +226,20 @@
list.
"""
+ family = pywikibot.default_family
# If a site is given instead of a code, use its language
if hasattr(code, 'lang'):
+ family = code.family.name
code = code.lang
+ # Check whether xdict has multiple projects
+ if family in xdict:
+ xdict = xdict[family]
+ elif 'wikipedia' in xdict:
+ xdict = xdict['wikipedia']
+ if type(xdict) != dict:
+ return xdict
+
if code in xdict:
return xdict[code]
if not fallback:
@@ -250,8 +264,7 @@
@param code The language code
@param twtitle The TranslateWiki string title, in <package>-<key> format
- @param parameters For passing parameters. In the future, this will
- be used for plural support.
+ @param parameters For passing parameters.
The translations are retrieved from i18n.<package>, based on the callers
import table.
@@ -304,7 +317,7 @@
@param code The language code
@param twtitle The TranslateWiki string title, in <package>-<key> format
- @param parameters For passing parameters.
+ @param parameters For passing (plural) parameters.
Support is implemented like in MediaWiki extension. If the tw message
contains a plural tag inside which looks like
@@ -406,3 +419,22 @@
if hasattr(code, 'lang'):
code = code.lang
return code in transdict and twtitle in transdict[code]
+
+def input(twtitle, parameters=None, password=False):
+ """ Ask the user a question, return the user's answer.
+ @param twtitle The TranslateWiki string title, in <package>-<key> format
+ @param parameters For passing parameters. In the future, this will
+ be used for plural support.
+ @param password Hides the user's input (for password entry)
+ Returns a unicode string
+
+ The translations are retrieved from i18n.<package>, based on the callers
+ import table.
+ Translation code should be set by in the user_config.py like
+ userinterface_lang = 'de'
+ default is mylang setting
+
+ """
+ code = config.userinterface_lang or config.mylang
+ trans = twtranslate(code, twtitle, parameters)
+ return pywikibot.input(trans, password)