|
@ -121,10 +121,10 @@ class RedFam( MysqlRedFam ): |
|
|
@type title str |
|
|
@type title str |
|
|
""" |
|
|
""" |
|
|
if title and not index: |
|
|
if title and not index: |
|
|
index = self._articlesList.index( title ) |
|
|
index = self.articlesList.index( title ) |
|
|
|
|
|
|
|
|
if isinstance( index, int ) and index < len(self._articlesList): |
|
|
if isinstance( index, int ) and index < len(self.articlesList): |
|
|
self._article_status[index].add(status) |
|
|
self.articlesStatus[index].add(status) |
|
|
else: |
|
|
else: |
|
|
raise IndexError( "No index given or wrong format!") |
|
|
raise IndexError( "No index given or wrong format!") |
|
|
|
|
|
|
|
@ -145,13 +145,13 @@ class RedFam( MysqlRedFam ): |
|
|
@type bool |
|
|
@type bool |
|
|
""" |
|
|
""" |
|
|
if title and not index: |
|
|
if title and not index: |
|
|
index = self._articlesList.index( title ) |
|
|
index = self.articlesList.index( title ) |
|
|
|
|
|
|
|
|
if isinstance( index, int ) and index < len(self._articlesList): |
|
|
if isinstance( index, int ) and index < len(self.articlesList): |
|
|
if weak: |
|
|
if weak: |
|
|
self._article_status[index].discard(status) |
|
|
self.articlesStatus[index].discard(status) |
|
|
else: |
|
|
else: |
|
|
self._article_status[index].remove(status) |
|
|
self.articlesStatus[index].remove(status) |
|
|
else: |
|
|
else: |
|
|
raise IndexError( "No index given or wrong format!") |
|
|
raise IndexError( "No index given or wrong format!") |
|
|
|
|
|
|
|
@ -168,10 +168,10 @@ class RedFam( MysqlRedFam ): |
|
|
@type title str |
|
|
@type title str |
|
|
""" |
|
|
""" |
|
|
if title and not index: |
|
|
if title and not index: |
|
|
index = self._articlesList.index( title ) |
|
|
index = self.articlesList.index( title ) |
|
|
|
|
|
|
|
|
if isinstance( index, int ) and index < len(self._articlesList): |
|
|
if isinstance( index, int ) and index < len(self.articlesList): |
|
|
if status in self._article_status[index]: |
|
|
if status in self.articlesStatus[index]: |
|
|
return True |
|
|
return True |
|
|
else: |
|
|
else: |
|
|
return False |
|
|
return False |
|
@ -458,19 +458,20 @@ class RedFamWorker( RedFam ): |
|
|
""" |
|
|
""" |
|
|
def __init__( self, mysql_data ): |
|
|
def __init__( self, mysql_data ): |
|
|
|
|
|
|
|
|
articlesList = [] |
|
|
#~ articlesList = [] |
|
|
|
|
|
|
|
|
for key in sorted( mysql_data.keys() ): |
|
|
#~ for key in sorted( mysql_data.keys() ): |
|
|
if 'article' in key and 'status' not in key and mysql_data[ key ]: |
|
|
#~ if 'article' in key and 'status' not in key and mysql_data[ key ]: |
|
|
articlesList.append( mysql_data[ key ] ) |
|
|
#~ articlesList.append( mysql_data[ key ] ) |
|
|
|
|
|
|
|
|
# Preset article status list with empty sets for existing articles |
|
|
#~ # Preset article status list with empty sets for existing articles |
|
|
self._article_status = [set() for x in range(0, len(articlesList))] |
|
|
#~ self._article_status = [set() for x in range(0, len(articlesList))] |
|
|
|
|
|
|
|
|
super().__init__( articlesList, mysql_data[ 'beginning' ], |
|
|
#~ super().__init__( articlesList, mysql_data[ 'beginning' ], |
|
|
mysql_data[ 'ending' ], mysql_data[ 'redpageid' ], |
|
|
#~ mysql_data[ 'ending' ], mysql_data[ 'redpageid' ], |
|
|
mysql_data[ 'status' ], mysql_data[ 'famhash' ], |
|
|
#~ mysql_data[ 'status' ], mysql_data[ 'famhash' ], |
|
|
mysql_data[ 'heading' ] ) |
|
|
#~ mysql_data[ 'heading' ] ) |
|
|
|
|
|
super().__init__() |
|
|
|
|
|
|
|
|
# #~ self._mysql.data = mysql_data |
|
|
# #~ self._mysql.data = mysql_data |
|
|
|
|
|
|
|
@ -510,8 +511,12 @@ class RedFamWorker( RedFam ): |
|
|
|
|
|
|
|
|
""" |
|
|
""" |
|
|
# Iterate over articles in redfam |
|
|
# Iterate over articles in redfam |
|
|
for article in self._articlesList: |
|
|
for article in self.articlesList: |
|
|
page = pywikibot.Page(pywikibot.Link(article), self.site) |
|
|
# Not all list elements contain articles |
|
|
|
|
|
if not article: |
|
|
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
page = pywikibot.Page(pywikibot.Link(article), pywikibot.Site()) |
|
|
|
|
|
|
|
|
# Exclude by article status |
|
|
# Exclude by article status |
|
|
for status in exclude_article_status: |
|
|
for status in exclude_article_status: |
|
@ -544,7 +549,10 @@ class RedFamWorker( RedFam ): |
|
|
""" |
|
|
""" |
|
|
Sets status to 3 when worked on |
|
|
Sets status to 3 when worked on |
|
|
""" |
|
|
""" |
|
|
for article in self._articlesList: |
|
|
for article in self.articlesList: |
|
|
|
|
|
if not article: |
|
|
|
|
|
break |
|
|
|
|
|
|
|
|
if self.article_has_status( "note_rej", title=article ): |
|
|
if self.article_has_status( "note_rej", title=article ): |
|
|
self.status.add( "note_rej" ) |
|
|
self.status.add( "note_rej" ) |
|
|
if self.article_has_status( "sav_err", title=article ): |
|
|
if self.article_has_status( "sav_err", title=article ): |
|
@ -554,13 +562,6 @@ class RedFamWorker( RedFam ): |
|
|
not self.status.has( "note_rej" ): |
|
|
not self.status.has( "note_rej" ): |
|
|
self.status.add( "marked" ) |
|
|
self.status.add( "marked" ) |
|
|
|
|
|
|
|
|
self._mysql.data[ 'status' ] = self._raw_status() |
|
|
|
|
|
index = 0 |
|
|
|
|
|
for article in self._articlesList: |
|
|
|
|
|
self._mysql.data[ "article" + str(index) + 'status' ] = \ |
|
|
|
|
|
self._article_raw_status( index=index ) |
|
|
|
|
|
index += 1 |
|
|
|
|
|
|
|
|
|
|
|
def get_disc_link( self ): |
|
|
def get_disc_link( self ): |
|
|
""" |
|
|
""" |
|
|
Constructs and returns the link to Redundancy discussion |
|
|
Constructs and returns the link to Redundancy discussion |
|
@ -570,7 +571,7 @@ class RedFamWorker( RedFam ): |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
# We need to Replace Links with their linktext |
|
|
# We need to Replace Links with their linktext |
|
|
anchor_code = mwparser.parse( self._mysql.data[ 'heading' ].strip() ) |
|
|
anchor_code = mwparser.parse( self.heading.strip() ) |
|
|
for link in anchor_code.ifilter_wikilinks(): |
|
|
for link in anchor_code.ifilter_wikilinks(): |
|
|
if link.text: |
|
|
if link.text: |
|
|
text = link.text |
|
|
text = link.text |
|
@ -583,7 +584,7 @@ class RedFamWorker( RedFam ): |
|
|
anchor_code.replace( " ", "_" ) |
|
|
anchor_code.replace( " ", "_" ) |
|
|
|
|
|
|
|
|
# We try it with out any more parsing as mw will do while parsing page |
|
|
# We try it with out any more parsing as mw will do while parsing page |
|
|
return ( self.redpagetitle + "#" + |
|
|
return ( self.redpage.pagetitle + "#" + |
|
|
str(anchor_code).strip() ) |
|
|
str(anchor_code).strip() ) |
|
|
|
|
|
|
|
|
def generate_disc_notice_template( self ): |
|
|
def generate_disc_notice_template( self ): |
|
@ -603,7 +604,9 @@ class RedFamWorker( RedFam ): |
|
|
param_cnt = 3 |
|
|
param_cnt = 3 |
|
|
|
|
|
|
|
|
# Iterate over articles in redfam |
|
|
# Iterate over articles in redfam |
|
|
for article in self._articlesList: |
|
|
for article in self.articlesList: |
|
|
|
|
|
if not article: |
|
|
|
|
|
break |
|
|
# Make sure to only use 8 articles (max. param 10) |
|
|
# Make sure to only use 8 articles (max. param 10) |
|
|
if param_cnt > 10: |
|
|
if param_cnt > 10: |
|
|
break |
|
|
break |
|
@ -614,11 +617,11 @@ class RedFamWorker( RedFam ): |
|
|
param_cnt += 1 |
|
|
param_cnt += 1 |
|
|
|
|
|
|
|
|
# Add begin |
|
|
# Add begin |
|
|
begin = self._mysql.data[ 'beginning' ].strftime( "%B %Y" ) |
|
|
begin = self.beginning.strftime( "%B %Y" ) |
|
|
template.add( "Beginn", begin, True ) |
|
|
template.add( "Beginn", begin, True ) |
|
|
|
|
|
|
|
|
# Add end (if not same as begin) |
|
|
# Add end (if not same as begin) |
|
|
end = self._mysql.data[ 'ending' ].strftime( "%B %Y" ) |
|
|
end = self.ending.strftime( "%B %Y" ) |
|
|
if not end == begin: |
|
|
if not end == begin: |
|
|
template.add( "Ende", end, True ) |
|
|
template.add( "Ende", end, True ) |
|
|
|
|
|
|
|
@ -650,13 +653,16 @@ class RedFamWorker( RedFam ): |
|
|
Yield red_fams stored in db by given status which have an ending after |
|
|
Yield red_fams stored in db by given status which have an ending after |
|
|
given one |
|
|
given one |
|
|
""" |
|
|
""" |
|
|
mysql = MysqlRedFam() |
|
|
from sqlalchemy import text |
|
|
for fam in mysql.get_by_status_and_ending( status, ending ): |
|
|
|
|
|
try: |
|
|
for redfam in RedFamWorker.session.query(RedFamWorker).filter( |
|
|
yield cls( fam ) |
|
|
#~ RedFamWorker._status.like('archived'), |
|
|
except RedFamHashError: |
|
|
#RedFamWorker._status.like("%{0:s}%".format(status)), |
|
|
print(fam) |
|
|
text("status LIKE '%archived%'"), |
|
|
raise |
|
|
RedFamWorker.ending >= ending |
|
|
|
|
|
): |
|
|
|
|
|
|
|
|
|
|
|
yield redfam |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RedFamError( Exception ): |
|
|
class RedFamError( Exception ): |
|
|