From 4987f97e9178b438ed12c0970449961aeecd2c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?GOLDERWEB=20=E2=80=93=20Jonathan=20Golder?= Date: Sat, 21 Nov 2015 11:30:37 +0100 Subject: [PATCH] SummaryPage-Module: Reimplement feature to prevent parsing for pages where revid haven't changed since last parsing --- summarypage.py | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/summarypage.py b/summarypage.py index f4518c0..f7a304a 100644 --- a/summarypage.py +++ b/summarypage.py @@ -62,7 +62,7 @@ class SummaryPage(): # Get result # We need to replace origninal entry since objectid changes due to # 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 ): """ @@ -96,17 +96,22 @@ class SummaryPageEntry(): """ Controls parsing/update-sequence of entry """ - self.parse() + # Get CountryList-Object + self.get_countrylist() - self.correct_chartein() + # Check if parsing country list is needed + if( self.countrylist.is_parsing_needed( self.countrylist_revid )): - self.update_params() + self.countrylist.parse() + self.correct_chartein() + + self.update_params() 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 @@ -130,19 +135,14 @@ class SummaryPageEntry(): try: self.countrylist = CountryList( self.countrylist_wikilink ) - if self.countrylist: - self.countrylist.parse() - # Maybe fallback to last years list except CountryListError: self.countrylist_wikilink.title = link_title self.countrylist = CountryList( self.countrylist_wikilink ) - if self.countrylist: - self.countrylist.parse() - else: - raise SummaryPageEntryError( "CountryList does not exists!" ) + if not self.countrylist: + raise SummaryPageEntryError( "CountryList does not exists!" ) 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 ) + 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(): """