Revision: 5297
Author: russblau
Date: 2008-05-02 20:29:49 +0000 (Fri, 02 May 2008)
Log Message:
-----------
page.py: to normalize titles, use pywikibot.Page(pywikibot.Link("foo:bar")) in place of Page(mysite, "foo:bar").
site.py: fix bug in namespace loading.
comms/threadedhttp.py: more logging.
Modified Paths:
--------------
branches/rewrite/pywikibot/comms/threadedhttp.py
branches/rewrite/pywikibot/page.py
branches/rewrite/pywikibot/site.py
Modified: branches/rewrite/pywikibot/comms/threadedhttp.py
===================================================================
--- branches/rewrite/pywikibot/comms/threadedhttp.py 2008-05-02 14:32:04 UTC (rev 5296)
+++ branches/rewrite/pywikibot/comms/threadedhttp.py 2008-05-02 20:29:49 UTC (rev 5297)
@@ -34,7 +34,8 @@
try:
import pkg_resources
except ImportError:
- print "Error : You need the python module setuptools to use this module"
+ logging.critical(
+ "Error : You need the python module setuptools to use this module")
sys.exit(1)
pkg_resources.require("httplib2")
import httplib2
@@ -194,7 +195,8 @@
follow_redirects = self.follow_redirects
self.follow_redirects = False
logging.debug('%r' % (
- (uri, method, body, headers, max_redirects, connection_type),))
+ (uri.replace("%7C","|"),
+ method, body, headers, max_redirects, connection_type),))
try:
(response, content) = httplib2.Http.request(
self, uri, method, body, headers,
Modified: branches/rewrite/pywikibot/page.py
===================================================================
--- branches/rewrite/pywikibot/page.py 2008-05-02 14:32:04 UTC (rev 5296)
+++ branches/rewrite/pywikibot/page.py 2008-05-02 20:29:49 UTC (rev 5297)
@@ -75,7 +75,6 @@
"Invalid namespace '%i' for site %s."
% (ns, source.sitename()))
self._ns = ns
- title = title[0].upper() + title[1:]
if ns and not title.startswith(source.namespace(ns)+u":"):
title = source.namespace(ns) + u":" + title
elif not ns and u":" in title:
@@ -83,7 +82,6 @@
nsindex = source.getNamespaceIndex(title[ :pos])
if nsindex:
self._ns = nsindex
- title = title[:pos+1] + title[pos+1].upper() + title[pos+2:]
if u"#" in title:
title, self._section = title.split(u"#", 1)
else:
@@ -1381,10 +1379,10 @@
% text)
t = t[t.index(u":"): ].lstrip(u":").lstrip(u" ")
if prefix in fam.langs.keys():
- newsite = pywikibot.Site(pre, fam)
+ newsite = pywikibot.Site(prefix, fam)
else:
- otherlang = self.site.lang
- familyName = fam.get_known_families(site=self.site)[pre]
+ otherlang = self.site.language()
+ familyName = fam.get_known_families(site=self.site)[prefix]
if familyName in ['commons', 'meta']:
otherlang = familyName
try:
Modified: branches/rewrite/pywikibot/site.py
===================================================================
--- branches/rewrite/pywikibot/site.py 2008-05-02 14:32:04 UTC (rev 5296)
+++ branches/rewrite/pywikibot/site.py 2008-05-02 20:29:49 UTC (rev 5297)
@@ -168,9 +168,9 @@
def getNamespaceIndex(self, namespace):
"""Given a namespace name, return its int index, or None if invalid."""
- for ns in self._namespaces:
+ for ns in self.namespaces():
if namespace.lower() in [name.lower()
- for name in self._namespaces[ns]]:
+ for name in self.namespaces()[ns]]:
return ns
return None
@@ -490,10 +490,9 @@
values for this namespace.
"""
- self.getsiteinfo()
if all:
- return self._namespaces[num]
- return self._namespaces[num][0]
+ return self.namespaces()[num]
+ return self.namespaces()[num][0]
def getpageinfo(self, page):
"""Load page info from api and save in page attributes"""