jenkins-bot has submitted this change and it was merged. Change subject: license: replace MIT with MIT/X11 license ......................................................................
license: replace MIT with MIT/X11 license MIT alone does not exist as a license. Also add an assert to not silentely ignore that kind of mistake. Change-Id: I41015e1367eb482fe0d0f44c9fb9c854a27d2462 Signed-off-by: Loic Dachary <l...@dachary.org> --- M FLOSSbot/license.py M FLOSSbot/plugin.py M tests/test_license.py 3 files changed, 21 insertions(+), 15 deletions(-) Approvals: Dachary: Looks good to me, approved jenkins-bot: Verified diff --git a/FLOSSbot/license.py b/FLOSSbot/license.py index 7f8fd09..8f881b7 100644 --- a/FLOSSbot/license.py +++ b/FLOSSbot/license.py @@ -118,16 +118,19 @@ item.get() self.debug(item, " verifying") + def set_en_licenses(self): + self.licenses = { + 'en': { + 'names': dict([ + (l, l) for (l, i) in self.license2item.items() + ]), + }, + } + def get_names(self, lang): if self.license2item is None: self.set_license2item() - self.licenses = { - 'en': { - 'names': dict([ - (l, l) for (l, i) in self.license2item.items() - ]), - }, - } + self.set_en_licenses() self.set_redirects('en') if lang not in self.licenses: self.set_names(lang) @@ -193,8 +196,8 @@ licenses = [] for license in self.args.license: licenses.append("STR(?label) = '" + license + "'") - licenses = ('?item rdfs:label ?label FILTER(' + - " || ".join(licenses) + ")") + licenses = ('?item rdfs:label ?label FILTER((' + + ") || (".join(licenses) + "))") format_args['licenses'] = licenses query = """ SELECT DISTINCT ?item WHERE {{ diff --git a/FLOSSbot/plugin.py b/FLOSSbot/plugin.py index 7eefa2b..d5664bc 100644 --- a/FLOSSbot/plugin.py +++ b/FLOSSbot/plugin.py @@ -321,13 +321,14 @@ return self.title_translation[title].get(lang) def get_redirects(self, title, lang): - log.debug("get_redirects " + title + " " + lang) site = pywikibot.site.APISite.fromDBName(lang + 'wiki') p = pywikibot.Page(site, title) - return [r.title() for r in p.getReferences(follow_redirects=False, - withTemplateInclusion=False, - redirectsOnly=True, - total=5000)] + r = [r.title() for r in p.getReferences(follow_redirects=False, + withTemplateInclusion=False, + redirectsOnly=True, + total=5000)] + log.debug("get_redirects " + title + " " + lang + " " + str(r)) + return r def get_sitelink_item(self, dbname): if dbname not in self.dbname2item: diff --git a/tests/test_license.py b/tests/test_license.py index 62de15a..54c6d64 100644 --- a/tests/test_license.py +++ b/tests/test_license.py @@ -68,7 +68,9 @@ def test_template_parse_license(self): bot = Bot.factory(['--verbose'] + self.args) license = License(bot, bot.args) - found = license.template_parse_license('[[GPL]] [[MIT|]]', 'en') + found = license.template_parse_license( + '[[GNU GPL]] [[MIT/X11 license|]]', 'en') + assert 2 == len(found) for item in found: item.get() license.debug(item, "FOUND") -- To view, visit https://gerrit.wikimedia.org/r/316350 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I41015e1367eb482fe0d0f44c9fb9c854a27d2462 Gerrit-PatchSet: 1 Gerrit-Project: pywikibot/bots/FLOSSbot Gerrit-Branch: master Gerrit-Owner: Dachary <l...@dachary.org> Gerrit-Reviewer: Dachary <l...@dachary.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits