CountryList-Module: Implement method for detecting year related to list

This commit is contained in:
2015-11-09 20:01:55 +01:00
parent abc30707b5
commit 4a790912fc

View File

@@ -74,6 +74,9 @@ class CountryList():
for attr in __attr: for attr in __attr:
setattr( self, attr, None ) setattr( self, attr, None )
# Try to find year
self.find_year()
def parsing_needed( self, revid ): def parsing_needed( self, revid ):
""" """
Check if current revid of CountryList differs from given one Check if current revid of CountryList differs from given one
@@ -88,3 +91,16 @@ class CountryList():
return True return True
else: else:
return False return False
def find_year( self ):
"""
Try to find the year related to CountryList
"""
self.year = datetime.now().year
# Check if year is in page.title, if not try last year
if str( self.year ) not in self.page.title():
self.year -= 1
# If last year does not match, raise YearError
if str( self.year ) not in self.page.title():
raise CountryListYearError