Revision: 6324
Author: russblau
Date: 2009-02-04 17:20:55 +0000 (Wed, 04 Feb 2009)
Log Message:
-----------
fix mangled comments from last commit
Modified Paths:
--------------
branches/rewrite/pywikibot/family.py
Modified: branches/rewrite/pywikibot/family.py
===================================================================
--- branches/rewrite/pywikibot/family.py 2009-02-04 16:30:26 UTC (rev 6323)
+++ branches/rewrite/pywikibot/family.py 2009-02-04 17:20:55 UTC (rev 6324)
@@ -55,7 +55,9 @@
self.servergmtoffset = timedelta()
# letters that can follow a wikilink and are regarded as part of
- # this link # This depends on the linktrail setting in LanguageXx.php and on # [[MediaWiki:Linktrail]].
+ # this link
+ # This depends on the linktrail setting in LanguageXx.php and on
+ # [[MediaWiki:Linktrail]].
# Note: this is a regular expression.
self.linktrails = {
'_default': u'[a-z]*',
@@ -546,13 +548,13 @@
'arab' : [
'ar', 'arz', 'ps', 'sd', 'ur',
# languages using multiple scripts, including arabic
- 'kk', 'ku', 'tt', 'ug'
+ 'kk', 'ku', 'tt', 'ug'
],
# languages that use chinese symbols
'chinese': [
'wuu', 'zh', 'zh-classical', 'zh-yue', 'gan', 'ii',
# languages using multiple/mixed scripts, including chinese
- 'ja', 'za'
+ 'ja', 'za'
],
# languages that use the cyrillic alphabet
'cyril': [
@@ -607,7 +609,8 @@
# keys are the languages that can be linked to from the lang+ns, or
# '_default'; values are a list of namespace numbers
self.crossnamespace = {}
- #### Examples :
+ ##
+ ## Examples :
## Allowing linking to pt' 102 NS from any other lang' 0 NS is
# self.crossnamespace[0] = {
# '_default': { 'pt': [102]}
@@ -638,7 +641,122 @@
"ERROR: linktrail in language %(language_code)s unknown"
% {'language_code': code})
-## def namespace(self, code, ns_number, fallback='_default', all=False):## if not self.isDefinedNS(ns_number):## raise KeyError(##'ERROR: Unknown namespace %(ns_number)d for %(language_code)s:%(ns_name)s'## % {'ns_number': ns_number,## 'language_code': code,## 'ns_name': self.name})## elif self.isNsI18N(ns_number, code):## v = self.namespaces[ns_number][code]## if type(v) is not list:## v = [v,]## if all and self.isNsI18N(ns_number, fallback):## v2 = self.namespaces[ns_number][fallback]## if type(v2) is list:## v.extend(v2)## else:## v.append(v2)## elif fallback and self.isNsI18N(ns_number, fallback):## v = self.namespaces[ns_number][fallback]## if type(v) is not list:## v = [v,]## else:## raise KeyError(##'ERROR: title for namespace %(ns_number)d in language %(language_code)s unknown'## % {'ns_number': ns_number,## 'language_code': code})## if all:## namespaces = list(set(v))## # Lowercase versions of namespaces## if code not in self.nocapitalize:## namespaces.extend([ns[0].lower() + ns[1:]## for ns in namespaces## if ns and ns[0].lower() != ns[0].upper()])## # Underscore versions of namespaces## namespaces.extend([ns.replace(' ', '_')## for ns in namespaces if ns and ' ' in ns])## return tuple(namespaces)## else:## return v[0]#### def isDefinedNS(self, ns_number):## """Return True if the namespace has been defined in this family."""## ## return self.namespaces.has_key(ns_number)#### def isNsI18N(self, ns_number, code):## """Return True if the namespace has been internationalized.#### (it has a custom entry for a given language)#### """## return self.namespaces[ns_number].has_key(code)#### def isDefinedNSLanguage(self, ns_number, code, fallback='_default'):## """Return True if the namespace has been defined in this family## for this language or its fallback.## """## if not self.isDefinedNS(ns_number):## return False## elif self.isNsI18N(ns_number, code):## return True## elif fallback and self.isNsI18N(ns_number, fallback):## return True## else:## return False#### def normalizeNamespace(self, code, value):## """Given a value, attempt to match it with all available namespaces,## with default and localized versions. Sites may have more than one## way to write the same namespace - choose the first one in the list.## If nothing can be normalized, return the original value.## """## for ns, items in self.namespaces.iteritems():## if items.has_key(code):## v = items[code]## elif items.has_key('_default'):## v = items['_default']## else:## continue## if type(v) is list:## if value in v: return v[0]## else:## if value == v: return v## try:## if value == self.namespace('_default', ns):## return self.namespace(code, ns)## except KeyError:## pass## return value#### def getNamespaceIndex(self, lang, namespace):## """Given a namespace, attempt to match it with all available## namespaces. Sites may have more than one way to write the same## namespace - choose the first one in the list. Returns namespace## index or None.## """## namespace = namespace.lower()## for n in self.namespaces.keys():## try:## nslist = self.namespaces[n][lang]## if type(nslist) != type([]):## nslist = [nslist]## for ns in nslist:## if ns.lower() == namespace:## return n## except (KeyError,AttributeError):## # The namespace has no localized name defined## pass## if lang != '_default':## # This is not a localized namespace. Try if it## # is a default (English) namespace.## return self.getNamespaceIndex('_default', namespace)## else:## # give up## return None## def category_redirects(self, code, fallback="_default"):
+## def namespace(self, code, ns_number, fallback='_default', all=False):
+## if not self.isDefinedNS(ns_number):
+## raise KeyError(
+##'ERROR: Unknown namespace %(ns_number)d for %(language_code)s:%(ns_name)s'
+## % {'ns_number': ns_number,
+## 'language_code': code,
+## 'ns_name': self.name})
+## elif self.isNsI18N(ns_number, code):
+## v = self.namespaces[ns_number][code]
+## if type(v) is not list:
+## v = [v,]
+## if all and self.isNsI18N(ns_number, fallback):
+## v2 = self.namespaces[ns_number][fallback]
+## if type(v2) is list:
+## v.extend(v2)
+## else:
+## v.append(v2)
+## elif fallback and self.isNsI18N(ns_number, fallback):
+## v = self.namespaces[ns_number][fallback]
+## if type(v) is not list:
+## v = [v,]
+## else:
+## raise KeyError(
+##'ERROR: title for namespace %(ns_number)d in language %(language_code)s unknown'
+## % {'ns_number': ns_number,
+## 'language_code': code})
+## if all:
+## namespaces = list(set(v))
+## # Lowercase versions of namespaces
+## if code not in self.nocapitalize:
+## namespaces.extend([ns[0].lower() + ns[1:]
+## for ns in namespaces
+## if ns and ns[0].lower() != ns[0].upper()])
+## # Underscore versions of namespaces
+## namespaces.extend([ns.replace(' ', '_')
+## for ns in namespaces if ns and ' ' in ns])
+## return tuple(namespaces)
+## else:
+## return v[0]
+##
+## def isDefinedNS(self, ns_number):
+## """Return True if the namespace has been defined in this family."""
+##
+## return self.namespaces.has_key(ns_number)
+##
+## def isNsI18N(self, ns_number, code):
+## """Return True if the namespace has been internationalized.
+##
+## (it has a custom entry for a given language)
+##
+## """
+## return self.namespaces[ns_number].has_key(code)
+##
+## def isDefinedNSLanguage(self, ns_number, code, fallback='_default'):
+## """Return True if the namespace has been defined in this family
+## for this language or its fallback.
+## """
+## if not self.isDefinedNS(ns_number):
+## return False
+## elif self.isNsI18N(ns_number, code):
+## return True
+## elif fallback and self.isNsI18N(ns_number, fallback):
+## return True
+## else:
+## return False
+##
+## def normalizeNamespace(self, code, value):
+## """Given a value, attempt to match it with all available namespaces,
+## with default and localized versions. Sites may have more than one
+## way to write the same namespace - choose the first one in the list.
+## If nothing can be normalized, return the original value.
+## """
+## for ns, items in self.namespaces.iteritems():
+## if items.has_key(code):
+## v = items[code]
+## elif items.has_key('_default'):
+## v = items['_default']
+## else:
+## continue
+## if type(v) is list:
+## if value in v: return v[0]
+## else:
+## if value == v: return v
+## try:
+## if value == self.namespace('_default', ns):
+## return self.namespace(code, ns)
+## except KeyError:
+## pass
+## return value
+##
+## def getNamespaceIndex(self, lang, namespace):
+## """Given a namespace, attempt to match it with all available
+## namespaces. Sites may have more than one way to write the same
+## namespace - choose the first one in the list. Returns namespace
+## index or None.## """
+## namespace = namespace.lower()
+## for n in self.namespaces.keys():
+## try:
+## nslist = self.namespaces[n][lang]
+## if type(nslist) != type([]):
+## nslist = [nslist]
+## for ns in nslist:
+## if ns.lower() == namespace:
+## return n
+## except (KeyError,AttributeError):
+## # The namespace has no localized name defined
+## pass
+## if lang != '_default':
+## # This is not a localized namespace. Try if it
+## # is a default (English) namespace.
+## return self.getNamespaceIndex('_default', namespace)
+## else:
+## # give up
+## return None
+
+ def category_redirects(self, code, fallback="_default"):
if code in self.category_redirect_templates:
return self.category_redirect_templates[code]
elif fallback:
Bugs item #2524403, was opened at 2009-01-20 21:07
Message generated for change (Comment added) made by silvonen
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2524403&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: other
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Mikko Silvonen (silvonen)
Assigned to: Nobody/Anonymous (nobody)
Summary: featured.py -fromall gets stuck on dsbwiki
Initial Comment:
The script featured.py gets stuck on dsbwiki every time I run it to update fiwiki. Can we just comment out the following line of code? There doesn't seem to be any category called "Kategorija:Ekscelentny" on dsbwiki.
'dsb': (CAT, u"Ekscelentny"),
Test run output:
>python featured.py -fromall
...
Getting [[Kategorija:Ekscelentny]]...
Page //dsb.wikipedia.org/w/index.php?useskin=monobook&title=Kategorija%3AEkscelentny&redirect=no could not be retrieved. Check your family file ?
WARNING: Could not open 'http://dsb.wikipedia.org/w/index.php?useskin=monobook&title=Kategorija%3AEk…'. Maybe the server or your connection is down. Retrying in 1 minutes...
Page //dsb.wikipedia.org/w/index.php?useskin=monobook&title=Kategorija%3AEkscelentny&redirect=no could not be retrieved. Check your family file ?
WARNING: Could not open 'http://dsb.wikipedia.org/w/index.php?useskin=monobook&title=Kategorija%3AEk…'. Maybe the server or your connection is down. Retrying in 2 minutes...
...
> python version.py
Pywikipedia [http] trunk/pywikipedia (r6272, Jan 19 2009, 22:59:18)
Python 2.5.1 (r251:54863, May 1 2007, 17:47:05) [MSC v.1310 32 bit (Intel)]
----------------------------------------------------------------------
>Comment By: Mikko Silvonen (silvonen)
Date: 2009-02-04 08:30
Message:
I uploaded a quick fix, but it would of course be more elegant if the
script gave up on loading a non-existent category page instead of waiting
for it to be created.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2524403&group_…
Bugs item #2562477, was opened at 2009-02-03 23:30
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2562477&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: redirect.py BadTitle Exception Error
Initial Comment:
Running redirect-Bot with -moves option, a BadTitle error raised:
Getting page [[Talk:User:Hawkeye7/Sandbox]]
Traceback (m r c l):
main()
bot.run()
self.fix_double_redirects()
File redirect.py in fix_double_redirects
for redir_name in self.generator.retrieve_double_redirects():
File redirect.py in retrieve_double_redirects
for redir_page in self.get_moved_pages_redirects():
File redirect.py in get_moved_pages_redirects
if not moved_page.isRedirectPage()
File wikipedia.py in isRedirectPage
self.get()
File wikipedia.py in get
self._contents = self._getEditPage(get_redirect = get_redirect, throttle = throttle, sysop =sysop=
File wikipedia.py in _getEditPage
raise BadeTitle('BadTitle: %s' % self)
wikipedia.BadTitle: BadTitle: [[Talk:User:Hawkeye7/Sandbox]]
<w:de:User:Xqt>
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2562477&group_…
Feature Requests item #1912001, was opened at 2008-03-11 17:29
Message generated for change (Comment added) made by vargenau
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603141&aid=1912001&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: interwiki
Group: None
Status: Open
Priority: 5
Private: No
Submitted By: Marc-Etienne Vargenau (vargenau)
Assigned to: Nobody/Anonymous (nobody)
Summary: Add a new option to interwiki.py
Initial Comment:
Hello,
When working on years or birth categories for instance, I give a huge number of hints.
And I now these hint are right (when they exist).
If there is a wrong link somewhere (e.g. en:category:2000_deaths linking to fr:category:naissance_en_2000), I get a huge number of questions to which I always answer "1" (because the hint is proposed first).
So I propose to create a new option "-hintisright" (or something).
In that case, if there is a conflict between a hint and other page(s), the hint is selected automatically.
----------------------------------------------------------------------
>Comment By: Marc-Etienne Vargenau (vargenau)
Date: 2009-02-03 14:36
Message:
Hello,
Thank you for your comment.
But I do not think the -localright parameter does what I need.
I do not want to modify the local page because I do not want to add links
that do not exist (yet).
I am 100% sure the hint "fr:category:décès_en_2000" (for
"en:category:2000_deaths") is right if it exists, but it might not exist
yet.
Since the code for -localright exists, maybe the code for -hintisright can
be easily implemented.
Best regards,
----------------------------------------------------------------------
Comment By: Purodha B Blissenbach (purodha)
Date: 2009-01-23 18:34
Message:
Hint: You can also solve the problem by inserting all the hints in the
starting page, and use the -localright parameter. If you are uncertain that
you got all, use -confirm and you will be able to interrupt the bot when it
comes accross a missing link which it tries to delete.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603141&aid=1912001&group_…
Bugs item #2555767, was opened at 2009-02-01 16:25
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2555767&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: interwiki.py removes redirects
Initial Comment:
interwiki.py vers. 6312
My interwiki-options are -autonomous -force -noredirect .
As I found at this link e.g. [http://it.wikipedia.org/w/index.php?title=Assiomi_di_Huzita-Hatori&diff=217…] interwiki.py removes redirected interwiki links instead of fixing it during -noredirect option. I supposed that -noredirect ignores links coming from the redirected page and keep or fix the redirect link but not deleting it. In this given case, the english page has been moved before the bot does its work. Here are some statements from the logfile depending on this matter:
[[折り紙公ç†]]: [[ja:折り紙公ç†]] gives new interwiki [[it:Assiomi di Huzita-Hatori]]
[[折り紙公ç†]]: [[ja:折り紙公ç†]] gives new interwiki [[en:Huzita-Hatori axioms]]
[[折り紙公ç†]]: [[ja:折り紙公ç†]] gives new interwiki [[ru:Правила Худзита]]
[[折り紙公ç†]]: [[ja:折り紙公ç†]] gives new interwiki [[fa:اصل هوزیتا-هاتوری]]
Getting 60 pages from wikipedia:en...
NOTE: [[en:Huzita-Hatori axioms]] is redirect to [[en:Huzita–Hatori axioms]]
NOTE: not following redirects.
======Post-processing [[ja:折り紙公ç†]]======
Updating links on page [[it:Assiomi di Huzita-Hatori]].
Changes to be made: Aggiungo: [[ja:折り紙公ç†]] Tolgo: [[en:Huzita-Hatori axioms]]
- [[en:Huzita-Hatori axioms]]
+ [[ja:折り紙公ç†]]
ERROR: Found incorrect link to en in [[it:Assiomi di Huzita-Hatori]]
NOTE: Performing a recursive query first to save time....
NOTE: Nothing left to do 2
NOTE: Updating live wiki...
Changing page [[it:Assiomi di Huzita-Hatori]]
Updating links on page [[ja:折り紙公ç†]].
Changes to be made: 除去: [[en:Huzita-Hatori axioms]]
- [[en:Huzita-Hatori axioms]]
ERROR: Found incorrect link to en in [[ja:折り紙公ç†]]
NOTE: Performing a recursive query first to save time....
NOTE: Nothing left to do 2
NOTE: Updating live wiki...
Changing page [[折り紙公ç†]]
Updating links on page [[ru:Правила Худзита]].
Changes to be made: добавил: [[ja:折り紙公ç†]] удалил: [[en:Huzita-Hatori axioms]]
- [[en:Huzita-Hatori axioms]]
+ [[ja:折り紙公ç†]]
ERROR: Found incorrect link to en in [[ru:Правила Худзита]]
NOTE: Performing a recursive query first to save time....
NOTE: Nothing left to do 2
NOTE: Updating live wiki...
Changing page [[ru:Правила Худзита]]
Updating links on page [[fa:اصل هوزیتا-هاتوری]].
Changes to be made: اÙزودن: [[ja:折り紙公ç†]] ØØ°Ù: [[en:Huzita-Hatori axioms]]
- [[en:Huzita-Hatori axioms]]
+ [[ja:折り紙公ç†]]
ERROR: Found incorrect link to en in [[fa:اصل هوزیتا-هاتوری]]
NOTE: Performing a recursive query first to save time....
NOTE: Nothing left to do 2
NOTE: Updating live wiki...
Changing page [[fa:اصل هوزیتا-هاتوری]]
[w:de:User:Xqt]
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2555767&group_…