Jean-Frédéric has uploaded a new change for review.
https://gerrit.wikimedia.org/r/233221
Change subject: Fix identification of templates from configuration
......................................................................
Fix identification of templates from configuration
To identify templates (as header, row, or CommonsCat),
each template of the page is compared to the one recorded
in the configuration.
But the template as returned is fully qualified with the Namespace
(eg Page(Modèle:Ligne de tableau Monuments (Suisse))).
To get its actual name, we need to use the title method
Change-Id: Idca0ba57be703a52fcad258e5d79d6fb62946265
---
M erfgoedbot/update_database.py
1 file changed, 4 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/labs/tools/heritage
refs/changes/21/233221/1
diff --git a/erfgoedbot/update_database.py b/erfgoedbot/update_database.py
index 802958e..96b5b9d 100755
--- a/erfgoedbot/update_database.py
+++ b/erfgoedbot/update_database.py
@@ -451,15 +451,16 @@
headerDefaults = {}
for (template, params) in templates:
- if template == countryconfig.get('headerTemplate'):
+ template_name = template.title(withNamespace=False)
+ if template_name == countryconfig.get('headerTemplate'):
headerDefaults = processHeader(params, countryconfig)
- if template == countryconfig.get('rowTemplate'):
+ if template_name == countryconfig.get('rowTemplate'):
# print template
# print params
unknownFields = processMonument(
params, source, countryconfig, conn, cursor, page,
headerDefaults, unknownFields=unknownFields)
# time.sleep(5)
- elif template == u'Commonscat' and len(params) >= 1:
+ elif template_name == u'Commonscat' and len(params) >= 1:
query = u"""REPLACE INTO commonscat (site, title, commonscat)
VALUES (%s, %s, %s)"""
cursor.execute(
query, (countryconfig.get('lang'), page.title(True),
params[0]))
--
To view, visit https://gerrit.wikimedia.org/r/233221
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idca0ba57be703a52fcad258e5d79d6fb62946265
Gerrit-PatchSet: 1
Gerrit-Project: labs/tools/heritage
Gerrit-Branch: master
Gerrit-Owner: Jean-Frédéric <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits