Browse Source

Catch special case in Belgium with Flandern and Wallonie

develop
Jonathan Golder 9 years ago
parent
commit
329466c6f8
  1. 19
      charts.py

19
charts.py

@ -143,7 +143,7 @@ entry %s'
return True return True
return False return False
def parse_charts_list( self, page ): def parse_charts_list( self, page, belgien=False ):
""" """
Handles the parsing process Handles the parsing process
""" """
@ -152,7 +152,11 @@ entry %s'
wikicode = mwparser.parse( page.text ) wikicode = mwparser.parse( page.text )
# Select the section "Singles" # Select the section "Singles"
singles_section = wikicode.get_sections( matches="Singles" )[0] if belgien:
singles_section = wikicode.get_sections(
matches=belgien )[0].get_sections( matches="Singles" )[0]
else:
singles_section = wikicode.get_sections( matches="Singles" )[0]
# Select the last occurence of template "Nummer-eins-Hits Zeile" in # Select the last occurence of template "Nummer-eins-Hits Zeile" in
# "Singles"-section # "Singles"-section
@ -203,7 +207,7 @@ entry %s'
# Check if saved revid is unequal to current revid # Check if saved revid is unequal to current revid
if( str( country.get( "Liste Revision" ).value ) != if( str( country.get( "Liste Revision" ).value ) !=
list_page.latest_revision_id ): list_page.latest_revision_id ):
country = self.update_overview( country, list_page ) country = self.update_overview( country, list_page )
# If any param of any occurence of Template "/Eintrag" has changed, # If any param of any occurence of Template "/Eintrag" has changed,
@ -230,7 +234,14 @@ entry %s'
""" """
# Parse linked charts list for the country # Parse linked charts list for the country
data = self.parse_charts_list( list_page ) if "Wallonien" in str( country.get( "Liste" ).value ):
belgien = "Wallonie"
elif "Flandern" in str( country.get( "Liste" ).value ):
belgien = "Flandern"
else:
belgien = None
data = self.parse_charts_list( list_page, belgien )
# Update "Liste Revision" param # Update "Liste Revision" param
country.get( "Liste Revision" ).value = str( country.get( "Liste Revision" ).value = str(

Loading…
Cancel
Save