Revision: 6426
Author: nicdumz
Date: 2009-02-23 09:35:21 +0000 (Mon, 23 Feb 2009)
Log Message:
-----------
Using Link() to construct links from scraped wikitext.
Deprecating @insite Category() argument, site Page's @insite is
Modified Paths:
--------------
branches/rewrite/pywikibot/page.py
branches/rewrite/pywikibot/textlib.py
Modified: branches/rewrite/pywikibot/page.py
===================================================================
--- branches/rewrite/pywikibot/page.py 2009-02-23 09:22:34 UTC (rev 6425)
+++ branches/rewrite/pywikibot/page.py 2009-02-23 09:35:21 UTC (rev 6426)
@@ -1325,7 +1325,8 @@
class Category(Page):
"""A page in the Category: namespace"""
- def __init__(self, source, title=u"", insite=None, sortKey=None):
+ @deprecate_arg("insite", None)
+ def __init__(self, source, title=u"", sortKey=None):
"""All parameters are the same as for Page() constructor.
"""
Modified: branches/rewrite/pywikibot/textlib.py
===================================================================
--- branches/rewrite/pywikibot/textlib.py 2009-02-23 09:22:34 UTC (rev 6425)
+++ branches/rewrite/pywikibot/textlib.py 2009-02-23 09:35:21 UTC (rev 6426)
@@ -299,13 +299,7 @@
pagetitle = pagetitle[:pagetitle.index('|')]
# we want the actual page objects rather than the titles
site = insite.getSite(code = lang)
- try:
- result[site] = pywikibot.Page(site, pagetitle, insite = insite)
- except InvalidTitle:
- output(
- u"[getLanguageLinks] Text contains invalid interwiki link [[%s:%s]]."
- % (lang, pagetitle))
- continue
+ result[site] = pywikibot.Page(pywikibot.Link(pagetitle, site))
return result
@@ -483,9 +477,10 @@
r'(?:\|(?P<sortKey>.+?))?\s*\]\]'
% catNamespace, re.I)
for match in R.finditer(text):
- cat = pywikibot.Category(site,
+ cat = pywikibot.Category(pywikibot.Link(
'%s:%s' % (match.group('namespace'),
match.group('catName')),
+ site),
sortKey = match.group('sortKey'))
result.append(cat)
return result
Show replies by date