Clean up PEP8 styleguide compatibility with flake8

This commit is contained in:
2015-09-13 11:53:47 +02:00
parent cafe08dd7f
commit 74b2dc727c
4 changed files with 205 additions and 142 deletions

View File

@@ -2,34 +2,35 @@
# -*- coding: utf-8 -*-
#
# redpage.py
#
#
# Copyright 2015 GOLDERWEB Jonathan Golder <jonathan@golderweb.de>
#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#
#
"""
Provides a class for handling redundance discussion pages and archives
"""
import pywikibot
import pywikibot # noqa
from mysqlred import MysqlRedPage
from redfam import RedFamParser
class RedPage:
"""
Class for handling redundance discussion pages and archives
@@ -39,7 +40,7 @@ class RedPage:
"""
Generate a new RedPage object based on the given pywikibot page object
@param page page Pywikibot/MediaWiki page object for page to work on
@param page page Pywikibot/MediaWiki page object for page
"""
# Safe the pywikibot page object
@@ -72,7 +73,10 @@ class RedPage:
Check wether the page was changed since last run
"""
if( self.__mysql.data != { 'page_id': self.page._pageid, 'rev_id': self.page._revid, 'page_title': self.page.title(), 'status': self.__mysql.data[ 'status' ] } ):
if( self.__mysql.data != { 'page_id': self.page._pageid,
'rev_id': self.page._revid,
'page_title': self.page.title(),
'status': self.__mysql.data[ 'status' ] } ):
self._changed = True
else:
self._changed = False
@@ -82,10 +86,13 @@ class RedPage:
Detects wether current page is an archive of discussions
"""
if self._archive or ( u"/Archiv" in self.page.title() ) or ( "{{Archiv}}" in self.page.text ) or ( "{{Archiv|" in self.page.text ):
return True
if( self._archive or ( u"/Archiv" in self.page.title() ) or
( "{{Archiv}}" in self.page.text ) or
( "{{Archiv|" in self.page.text ) ):
return True
else:
return False
return False
def parse( self ):
"""
@@ -108,7 +115,7 @@ class RedPage:
# Iterate over the lines of the page
for line in text_lines:
# Check wether we have an "Redundance-Family"-Section heading (Level 3)
# Check wether we have an "Redundance-Family"-Section heading
if RedFamParser.is_sectionheading( line ):
# Save line number for last detected Redundance-Family
@@ -120,16 +127,18 @@ class RedPage:
beginning = None
ending = None
# Check wether we are currently in an "Redundance-Family"-Section Body
# Check wether we are currently in an "Redundance-Family"-Section
if i > last_fam and last_fam > 0:
# Check if we have alredy recognized the beginning date of the discussion (in former iteration) or if we have a done-notice
# Check if we have alredy recognized the beginning date of the
# discussion (in former iteration) or if we have a done-notice
if not beginning:
beginning = RedFamParser.is_beginning( line )
elif not ending:
ending = RedFamParser.is_ending( line )
# Detect end of red_fam section (next line is new sectionheading) or end of file
# Detect end of red_fam section (next line is new sectionheading)
# or end of file
# Prevent from running out of index
if i < (length - 1):
test = RedFamParser.is_sectionheading( text_lines[ i + 1 ] )
@@ -140,7 +149,8 @@ class RedPage:
# Create the red_fam object
if( fam_heading and beginning ):
#Maybe we can find a ending by feed if we have None yet (No done notice on archive pages)
# Maybe we can find a ending by feed if we have None yet
# (No done notice on archive pages)
if not ending and self.is_archive():
j = i
while (j > last_fam) and not ending:
@@ -148,7 +158,9 @@ class RedPage:
ending = RedFamParser.is_ending2( text_lines[ j ] )
# Create the RedFam object
red_fam = RedFamParser( fam_heading, self.page._pageid, self.is_archive(), beginning, ending )
red_fam = RedFamParser( fam_heading, self.page._pageid,
self.is_archive(), beginning,
ending )
# Increment line counter
i += 1