From 3864c9013cc047cf97d1fa26bb578d784f21e605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?GOLDERWEB=20=E2=80=93=20Jonathan=20Golder?= Date: Fri, 20 Nov 2015 14:44:26 +0100 Subject: [PATCH] CountryList-Module: Since we have multiple categories in some countrys we need to select the first wrapping template --- countrylist.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/countrylist.py b/countrylist.py index 24fa8c0..38083a7 100644 --- a/countrylist.py +++ b/countrylist.py @@ -157,9 +157,17 @@ class CountryList(): else: singles_section = self.wikicode.get_sections( matches="Singles" )[0] + # Since we have multiple categories in some countrys we need + # to select the first wrapping template + try: + wrapping_template = next( singles_section.ifilter_templates( + matches="Nummer-eins-Hits" ) ) + except StopIteration: + raise CountryListError( "Wrapping template is missing!") + # Select the last occurence of template "Nummer-eins-Hits Zeile" in - # "Singles"-section - for self.entry in singles_section.ifilter_templates( + # Wrapper-template + for self.entry in wrapping_template.get("Inhalt").value.ifilter_templates( matches="Nummer-eins-Hits Zeile" ): pass