Browse Source

Merge branches 'countrylist-module' and 'summarypage-module'

develop
Jonathan Golder 9 years ago
parent
commit
e854244f0b
  1. 2
      countrylist.py
  2. 30
      summarypage.py

2
countrylist.py

@ -77,7 +77,7 @@ class CountryList():
# Try to find year # Try to find year
self.find_year() self.find_year()
def parsing_needed( self, revid ): def is_parsing_needed( self, revid ):
""" """
Check if current revid of CountryList differs from given one Check if current revid of CountryList differs from given one

30
summarypage.py

@ -62,7 +62,7 @@ class SummaryPage():
# Get result # Get result
# We need to replace origninal entry since objectid changes due to # We need to replace origninal entry since objectid changes due to
# recreation of template object and reassignment won't be reflected # recreation of template object and reassignment won't be reflected
self.wikicode.replace( entry, summarypageentry.new_entry.template ) self.wikicode.replace( entry, summarypageentry.get_entry().template )
def get_new_text( self ): def get_new_text( self ):
""" """
@ -96,17 +96,22 @@ class SummaryPageEntry():
""" """
Controls parsing/update-sequence of entry Controls parsing/update-sequence of entry
""" """
self.parse() # Get CountryList-Object
self.get_countrylist()
# Check if parsing country list is needed
if( self.countrylist.is_parsing_needed( self.countrylist_revid )):
self.countrylist.parse()
self.correct_chartein() self.correct_chartein()
self.update_params() self.update_params()
self.is_write_needed() self.is_write_needed()
def parse( self ): def get_countrylist( self ):
""" """
Handles parsing process of entry template Get the CountryList-Object for current entry
""" """
# Get wikilink to related countrylist # Get wikilink to related countrylist
@ -130,18 +135,13 @@ class SummaryPageEntry():
try: try:
self.countrylist = CountryList( self.countrylist_wikilink ) self.countrylist = CountryList( self.countrylist_wikilink )
if self.countrylist:
self.countrylist.parse()
# Maybe fallback to last years list # Maybe fallback to last years list
except CountryListError: except CountryListError:
self.countrylist_wikilink.title = link_title self.countrylist_wikilink.title = link_title
self.countrylist = CountryList( self.countrylist_wikilink ) self.countrylist = CountryList( self.countrylist_wikilink )
if self.countrylist: if not self.countrylist:
self.countrylist.parse()
else:
raise SummaryPageEntryError( "CountryList does not exists!" ) raise SummaryPageEntryError( "CountryList does not exists!" )
def get_countrylist_wikilink( self ): def get_countrylist_wikilink( self ):
@ -213,6 +213,16 @@ class SummaryPageEntry():
type( self ).write_needed = ( ( self.old_entry != self.new_entry ) or \ type( self ).write_needed = ( ( self.old_entry != self.new_entry ) or \
type( self ).write_needed ) type( self ).write_needed )
def get_entry( self ):
"""
Returns the new entry if CountryList was parsed otherwise returns the
old one
"""
if( self.countrylist.is_parsing_needed( self.countrylist_revid )):
return self.new_entry
else:
return self.old_entry
class SummaryPageEntryTemplate(): class SummaryPageEntryTemplate():
""" """

Loading…
Cancel
Save