Revision: 4138 Author: siebrand Date: 2007-08-29 22:06:09 +0000 (Wed, 29 Aug 2007)
Log Message: ----------- Revert. Gave errors on CommonsDelinker
Modified Paths: -------------- trunk/pywikipedia/checkusage.py
Modified: trunk/pywikipedia/checkusage.py =================================================================== --- trunk/pywikipedia/checkusage.py 2007-08-29 20:01:51 UTC (rev 4137) +++ trunk/pywikipedia/checkusage.py 2007-08-29 22:06:09 UTC (rev 4138) @@ -298,12 +298,12 @@ max_retries = self.http_max_retries, callback = self.http_callback)
- def get_usage(self, image, namespace = None): + def get_usage(self, image): for dbname in self.databases: - for link in self.get_usage_db(dbname, image, True, namespace): + for link in self.get_usage_db(dbname, image, True): yield self.sites[dbname], link
- def get_usage_db(self, dbname, image, shared = False, namespace = None): + def get_usage_db(self, dbname, image, shared = False): #image = strip_image(image) lang, family_name = self.sites[dbname] family = self.known_families[family_name] @@ -314,13 +314,8 @@ left_join = 'WHERE'; query = """SELECT page_namespace, page_title FROM %s.page, %s.imagelinks %s page_id = il_from AND il_to = %%s""" - query = query % (dbname, dbname, left_join) - if not namespace is None: - self.databases[dbname][1].execute(query + ' AND page_namespace = %s', - (image.encode('utf-8', 'ignore'), namespace)) - else: - self.databases[dbname][1].execute(query % (dbname, dbname, left_join), - (image.encode('utf-8', 'ignore'), )) + self.databases[dbname][1].execute(query % (dbname, dbname, left_join), + (image.encode('utf-8', 'ignore'), )) for page_namespace, page_title in self.databases[dbname][1]: stripped_title = page_title.decode('utf-8', 'ignore') if page_namespace != 0: @@ -329,7 +324,7 @@ title = stripped_title yield page_namespace, stripped_title, title
- def get_usage_live(self, site, image, shared = False, namespace = None): + def get_usage_live(self, site, image, shared = False): self.connect_http() # FIXME: Use continue @@ -338,13 +333,9 @@ if site.live_version()[:2] > (1, 10): kwargs['list'] = 'imageusage' kwargs['iulimit'] = '500' - if not namespace is None: - kwargs['iunamespace'] = str(namespace) else: kwargs['list'] = 'imagelinks' kwargs['illimit'] = '500' - if not namespace is None: - kwargs['ilnamespace'] = str(namespace) res = self.http.query_api(site.hostname(), site.apipath(), **kwargs)