Revision: 8319
Author: xqt
Date: 2010-06-24 15:26:33 +0000 (Thu, 24 Jun 2010)
Log Message:
-----------
i18n for pt-wiki, submitted by Alchimista die to bug #3020485. Thanks
Modified Paths:
--------------
trunk/pywikipedia/category_redirect.py
Modified: trunk/pywikipedia/category_redirect.py
===================================================================
--- trunk/pywikipedia/category_redirect.py 2010-06-24 15:13:18 UTC (rev 8318)
+++ trunk/pywikipedia/category_redirect.py 2010-06-24 15:26:33 UTC (rev 8319)
@@ -67,6 +67,7 @@
'ja': "Category:移行中のカテゴリ",
'no': "Kategori:Wikipedia omdirigertekategorier",
'pl': "Kategoria:Przekierowania kategorii",
+ 'pt': "Categoria:!Redirecionamentos de categorias",
'simple': "Category:Category redirects",
'vi': u"Thể loại:Thể loại đổi hướng",
'zh': u"Category:已重定向的分类",
@@ -87,6 +88,7 @@
'ksh': u"Bot: Sigk uß en ömjeleidt Saachjropp eruß jesammdt.",
'no': u"Robot: Flytter sider ut av omdirigeringskategori",
'pl': u"Robot: Usuwa strony z przekierowanej kategorii",
+ 'pt': u"Bot: movendo páginas de redirecionamentos de categorias",
'commons': u'Robot: Changing category link (following [[Template:Category redirect|category redirect]])',
'vi': u"Robot: bỏ trang ra khỏi thể loại đổi hướng",
'zh': u'机器人:改变已重定向分类中的页面的分类',
@@ -103,6 +105,7 @@
'ksh':u"Bot: Ömleidungsschalbon dobeijedonn.",
'no':u"Robot: Legger til vedlikeholdsmal for kategoriomdirigering",
'pl':u"Robot: Dodaje szablon przekierowanej kategorii",
+ 'pt':u"Bot: adicionando a predefinição de redirecionamento de categoria",
'vi':u"Robot: thêm bản mẫu đổi hướng thể loại để dễ bảo trì",
'zh':u"机器人: 增加分类重定向模板,用于维护",
}
@@ -119,6 +122,7 @@
'no': u"Robot: Ordner doble omdirigeringer",
'ksh': u"Bot: dubbel Ömleidung eruß jemaat.",
'pl': u"Robot: Poprawia podwójne przekierowanie",
+ 'pt': u"Bot: Corrigindo redirecionamento duplo",
'vi': u"Robot: sửa thể loại đổi hướng kép",
'zh': u"Bot: 修复双重重定向",
}
@@ -135,6 +139,7 @@
'no': u"Bot for vedlikehold av kategoriomdirigeringer",
'ksh': u"Bot för de Saachjroppe ier Ömleidunge.",
'pl': u"Robot porządkujący przekierowania kategorii",
+ 'pt': u"Bot de manutenção de categorias de redirecionamento",
'vi': u"Robot theo dõi thể loại đổi hướng",
'zh': u"分类重定向维护机器人",
}
@@ -164,6 +169,13 @@
%s
~~~~
""",
+ 'pt': u"""\
+As seguintes páginas protegidas foram detectadas como carecendo de actualizações de \
+ligações de categorias:
+%s
+~~~~
+""",
+
'vi': u"""\
Các trang đã khóa sau cần phải cập nhật \
liên kết thể loại:
@@ -186,6 +198,7 @@
'fr': u"* %s est dans %s, qui est une redirection vers %s",
'ksh': u"* %s es en %s, un dat es en Ömleidung op %s",
'pl': u"* %s jest w %s, która jest przekierowaniem do %s",
+ 'pt': u"* %s está em %s, que redireciona para %s",
'vi': u"* %s đang thuộc %s, là thể loại đổi hướng đến %s",
})
Revision: 8318
Author: xqt
Date: 2010-06-24 15:13:18 +0000 (Thu, 24 Jun 2010)
Log Message:
-----------
new method Page.isStaticRedirect(), needed for several requests (bug #3012516, bug #2685388, bug #2612266)
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2010-06-24 08:18:58 UTC (rev 8317)
+++ trunk/pywikipedia/wikipedia.py 2010-06-24 15:13:18 UTC (rev 8318)
@@ -1019,6 +1019,21 @@
return False
return False
+ def isStaticRedirect(self, force=False):
+ """Return True if this is a redirect containing the magic word
+ __STATICREDIRECT__, False if not or not existing."""
+ if self.isRedirectPage():
+ staticKeys = self.site().getmagicwords('staticredirect')
+ text = self.get(get_redirect=True, force=force)
+ if staticKeys:
+ found = False
+ for key in staticKeys:
+ if key in text:
+ found = True
+ break
+ if found: return True
+ return False
+
def isEmpty(self):
"""Return True if the page text has less than 4 characters.
Revision: 8317
Author: filnik
Date: 2010-06-24 08:18:58 +0000 (Thu, 24 Jun 2010)
Log Message:
-----------
Adding the noreorder feature
Modified Paths:
--------------
trunk/pywikipedia/add_text.py
Modified: trunk/pywikipedia/add_text.py
===================================================================
--- trunk/pywikipedia/add_text.py 2010-06-24 07:47:20 UTC (rev 8316)
+++ trunk/pywikipedia/add_text.py 2010-06-24 08:18:58 UTC (rev 8317)
@@ -36,6 +36,8 @@
-up If used, put the text at the top of the page
+-noreorder Avoid to reorder cats and interwiki
+
--- Example ---
1.
# This is a script to add a template to the top of the pages with
@@ -152,7 +154,7 @@
def add_text(page = None, addText = None, summary = None, regexSkip = None,
regexSkipUrl = None, always = False, up = False, putText = True,
- oldTextGiven = None, create=False):
+ oldTextGiven = None, reorderEnabled = True, create=False):
if not addText:
raise NoEnoughData('You have to specify what text you want to add!')
if not summary:
@@ -230,45 +232,49 @@
# If not up, text put below
if not up:
newtext = text
- # Getting the categories
- categoriesInside = pywikibot.getCategoryLinks(newtext, site)
- # Deleting the categories
- newtext = pywikibot.removeCategoryLinks(newtext, site)
- # Getting the interwiki
- interwikiInside = pywikibot.getLanguageLinks(newtext, site)
- # Removing the interwiki
- newtext = pywikibot.removeLanguageLinks(newtext, site)
- # nn got a message between the categories and the iw's and they want to
- # keep it there, first remove it
- if (site.language()==u'nn'):
- newtext = newtext.replace(nn_iw_msg, '')
# Translating the \\n into binary \n
addText = addText.replace('\\n', '\n')
- # Adding the text
- newtext += u"\n%s" % addText
- # Reputting the categories
- newtext = pywikibot.replaceCategoryLinks(newtext,
+ if (reorderEnabled):
+ # Getting the categories
+ categoriesInside = pywikibot.getCategoryLinks(newtext, site)
+ # Deleting the categories
+ newtext = pywikibot.removeCategoryLinks(newtext, site)
+ # Getting the interwiki
+ interwikiInside = pywikibot.getLanguageLinks(newtext, site)
+ # Removing the interwiki
+ newtext = pywikibot.removeLanguageLinks(newtext, site)
+ # nn got a message between the categories and the iw's and they want to
+ # keep it there, first remove it
+ if (site.language()==u'nn'):
+ newtext = newtext.replace(nn_iw_msg, '')
+ # Adding the text
+ newtext += u"\n%s" % addText
+ # Reputting the categories
+ newtext = pywikibot.replaceCategoryLinks(newtext,
categoriesInside, site, True)
- #Put the nn iw message back
- if (site.language()==u'nn'):
- newtext = newtext + u'\n' + nn_iw_msg
- # Dealing the stars' issue
- allstars = []
- starstext = pywikibot.removeDisabledParts(text)
- for star in starsList:
- regex = re.compile('(\{\{(?:template:|)%s\|.*?\}\}[\s]*)' % star,
- re.I)
- found = regex.findall(starstext)
- if found != []:
- newtext = regex.sub('', newtext)
- allstars += found
- if allstars != []:
- newtext = newtext.strip()+'\r\n\r\n'
- allstars.sort()
- for element in allstars:
- newtext += '%s\r\n' % element.strip()
- # Adding the interwiki
- newtext = pywikibot.replaceLanguageLinks(newtext, interwikiInside, site)
+ #Put the nn iw message back
+ if (site.language()==u'nn'):
+ newtext = newtext + u'\n' + nn_iw_msg
+ # Dealing the stars' issue
+ allstars = []
+ starstext = pywikibot.removeDisabledParts(text)
+ for star in starsList:
+ regex = re.compile('(\{\{(?:template:|)%s\|.*?\}\}[\s]*)' % star,
+ re.I)
+ found = regex.findall(starstext)
+ if found != []:
+ newtext = regex.sub('', newtext)
+ allstars += found
+ if allstars != []:
+ newtext = newtext.strip()+'\r\n\r\n'
+ allstars.sort()
+ for element in allstars:
+ newtext += '%s\r\n' % element.strip()
+ # Adding the interwiki
+ newtext = pywikibot.replaceLanguageLinks(newtext, interwikiInside, site)
+ else:
+ # Adding the text
+ newtext += u"\n%s" % addText
# If instead the text must be added above...
else:
newtext = addText + '\n' + text
@@ -331,6 +337,7 @@
generator = None; always = False
textfile=None
talkPage=False
+ reorderEnabled = True
namespaces=[]
# Load a lot of default generators
genFactory = pagegenerators.GeneratorFactory()
@@ -381,6 +388,8 @@
generator = untaggedGenerator(untaggedProject)
elif arg == '-up':
up = True
+ elif arg == '-noreorder':
+ reorderEnabled = False
elif arg == '-always':
always = True
elif arg == '-talk' or arg == '-talkpage':
@@ -409,7 +418,7 @@
# Main Loop
for page in generator:
(text, newtext, always) = add_text(page, addText, summary, regexSkip,
- regexSkipUrl, always, up, True,
+ regexSkipUrl, always, up, True, reorderEnabled=reorderEnabled,
create=talkPage)
if __name__ == "__main__":
Revision: 8316
Author: xqt
Date: 2010-06-24 07:47:20 +0000 (Thu, 24 Jun 2010)
Log Message:
-----------
use pagegenerators for filtering namespaces. (Bug #3020101)
Modified Paths:
--------------
trunk/pywikipedia/fixing_redirects.py
Modified: trunk/pywikipedia/fixing_redirects.py
===================================================================
--- trunk/pywikipedia/fixing_redirects.py 2010-06-24 06:39:09 UTC (rev 8315)
+++ trunk/pywikipedia/fixing_redirects.py 2010-06-24 07:47:20 UTC (rev 8316)
@@ -16,6 +16,8 @@
#
# This script based on disambredir.py and solve_disambiguation.py
#
+# (C) Pywikipedia team, 2004-2010
+#
# Distributed under the terms of the MIT license.
#
__version__='$Id$'
@@ -185,9 +187,7 @@
wikipedia.output('Error: unable to put %s' % page.aslink())
def main():
- start = '!'
featured = False
- namespace = None
gen = None
# This factory is responsible for processing command line arguments
@@ -198,33 +198,22 @@
for arg in wikipedia.handleArgs():
if arg == '-featured':
featured = True
- elif arg.startswith('-namespace'):
- if len(arg) == 10:
- namespace = int(wikipedia.input(u'Which namespace should be processed?'))
- else:
- namespace = int(arg[11:])
else:
genFactory.handleArg(arg)
- gen = genFactory.getCombinedGenerator()
-
mysite = wikipedia.getSite()
if mysite.sitename() == 'wikipedia:nl':
wikipedia.output(u'\03{lightred}There is consensus on the Dutch Wikipedia that bots should not be used to fix redirects.\03{default}')
sys.exit()
- linktrail = mysite.linktrail()
if featured:
featuredList = wikipedia.translate(mysite, featured_articles)
ref = wikipedia.Page(wikipedia.getSite(), featuredList)
gen = pagegenerators.ReferringPageGenerator(ref)
- generator = pagegenerators.NamespaceFilterPageGenerator(gen, [0])
- for page in generator:
- workon(page)
- elif namespace is not None:
- for page in pagegenerators.AllpagesPageGenerator(start=start, namespace=namespace, includeredirects=False):
- workon(page)
- elif gen:
+ gen = pagegenerators.NamespaceFilterPageGenerator(gen, [0])
+ if not gen:
+ gen = genFactory.getCombinedGenerator()
+ if gen:
for page in pagegenerators.PreloadingGenerator(gen):
workon(page)
else: