pep8-compat: cleanup SummaryPage-Module
This commit is contained in:
@@ -32,6 +32,7 @@ import mwparserfromhell as mwparser
|
||||
|
||||
from countrylist import CountryList, CountryListError
|
||||
|
||||
|
||||
class SummaryPage():
|
||||
"""
|
||||
Handles summary page related actions
|
||||
@@ -118,22 +119,22 @@ class SummaryPageEntry():
|
||||
# Get saved revision of related countrylist
|
||||
self.get_countrylist_saved_revid()
|
||||
|
||||
|
||||
# Get current year
|
||||
current_year = datetime.now().year;
|
||||
current_year = datetime.now().year
|
||||
|
||||
# Store old link.title
|
||||
link_title = self.countrylist_wikilink.title
|
||||
|
||||
# If list is from last year, replace year
|
||||
if (current_year - 1) in link_title:
|
||||
self.countrylist_wikilink.title.replace( (current_year - 1), current_year )
|
||||
self.countrylist_wikilink.title.replace( (current_year - 1),
|
||||
current_year )
|
||||
|
||||
# Try to get current years list
|
||||
try:
|
||||
self.countrylist = CountryList( self.countrylist_wikilink )
|
||||
|
||||
if( self.countrylist and \
|
||||
if( self.countrylist and
|
||||
self.countrylist.is_parsing_needed( self.countrylist_revid )):
|
||||
self.countrylist.parse()
|
||||
|
||||
@@ -143,7 +144,7 @@ class SummaryPageEntry():
|
||||
self.countrylist_wikilink.title = link_title
|
||||
self.countrylist = CountryList( self.countrylist_wikilink )
|
||||
|
||||
if( self.countrylist and \
|
||||
if( self.countrylist and
|
||||
self.countrylist.is_parsing_needed( self.countrylist_revid )):
|
||||
self.countrylist.parse()
|
||||
|
||||
@@ -156,9 +157,11 @@ class SummaryPageEntry():
|
||||
"""
|
||||
if self.old_entry.Liste:
|
||||
try:
|
||||
self.countrylist_wikilink = next( self.old_entry.Liste.ifilter_wikilinks() )
|
||||
self.countrylist_wikilink = next(
|
||||
self.old_entry.Liste.ifilter_wikilinks() )
|
||||
except StopIteration:
|
||||
raise SummaryPageEntryError( "Parameter Liste does not contain valid wikilink!")
|
||||
raise SummaryPageEntryError(
|
||||
"Parameter Liste does not contain valid wikilink!" )
|
||||
else:
|
||||
raise SummaryPageEntryError( "Parameter Liste is not present!")
|
||||
|
||||
@@ -177,7 +180,8 @@ class SummaryPageEntry():
|
||||
"""
|
||||
|
||||
self.new_entry.Liste = self.countrylist_wikilink
|
||||
self.new_entry.Liste_Revision = self.countrylist.page.latest_revision_id
|
||||
self.new_entry.Liste_Revision = \
|
||||
self.countrylist.page.latest_revision_id
|
||||
self.new_entry.Interpret = self.countrylist.interpret
|
||||
self.new_entry.Titel = self.countrylist.titel
|
||||
self.new_entry.Chartein = self._corrected_chartein
|
||||
@@ -216,7 +220,7 @@ class SummaryPageEntry():
|
||||
Detects wether writing of entry is needed and stores information in
|
||||
Class-Attribute
|
||||
"""
|
||||
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 )
|
||||
|
||||
def get_entry( self ):
|
||||
@@ -256,25 +260,25 @@ class SummaryPageEntryTemplate():
|
||||
if isinstance( template_obj,
|
||||
mwparser.nodes.template.Template ):
|
||||
|
||||
self.template = template_obj;
|
||||
self.__initial = False;
|
||||
self.template = template_obj
|
||||
self.__initial = False
|
||||
|
||||
# Otherwise raise error
|
||||
else:
|
||||
raise SummaryPageEntryTemplateError( "Wrong type given" );
|
||||
raise SummaryPageEntryTemplateError( "Wrong type given" )
|
||||
|
||||
# Otherwise initialise template
|
||||
else:
|
||||
self.__initial_template()
|
||||
self.__initial = True;
|
||||
self.__initial = True
|
||||
|
||||
def __initial_template( self ):
|
||||
"""
|
||||
Builds the initial template
|
||||
"""
|
||||
|
||||
self.template = next( mwparser.parse(
|
||||
"{{Portal:Charts und Popmusik/Aktuelle Nummer-eins-Hits/Eintrag|Liste=|Liste_Revision=|Interpret=|Titel=NN\
|
||||
self.template = next( mwparser.parse( "{{Portal:Charts und Popmusik/\
|
||||
Aktuelle Nummer-eins-Hits/Eintrag|Liste=|Liste_Revision=|Interpret=|Titel=NN\
|
||||
|Chartein=|Korrektur=|Hervor=}}" ).ifilter_templates() )
|
||||
|
||||
def __getattr__( self, name ):
|
||||
@@ -335,8 +339,8 @@ class SummaryPageEntryTemplate():
|
||||
continue
|
||||
|
||||
# Compare other param values, if one unequal write is needed
|
||||
if initial.template.get( param ).value.strip() != \
|
||||
cmpto.template.get( param ).value.strip():
|
||||
if( initial.template.get( param ).value.strip() !=
|
||||
cmpto.template.get( param ).value.strip() ):
|
||||
return True
|
||||
|
||||
# If not returned True until now
|
||||
@@ -349,12 +353,14 @@ class SummaryPageError( Exception ):
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class SummaryPageEntryError( SummaryPageError ):
|
||||
"""
|
||||
Handles errors occuring in class SummaryPageEntry
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class SummaryPageEntryTemplateError( SummaryPageError ):
|
||||
"""
|
||||
Handles errors occuring in class SummaryPageEntryTemplate
|
||||
|
||||
Reference in New Issue
Block a user