Remove old status API

Now we use the methods of status object directly
This commit is contained in:
2017-03-07 12:06:11 +01:00
parent bf8e47f916
commit 89b50e3312
3 changed files with 29 additions and 114 deletions

View File

@@ -86,25 +86,25 @@ class RedPage( MysqlRedPage ):
@property
def archive(self):
return self.has_status("archived")
self.is_archive()
return self.status.has("archive")
def is_archive( self ):
"""
Detects wether current page is an archive of discussions
"""
if( self.archive or ( u"/Archiv" in self.page.title() ) or
if( ( u"/Archiv" in self.page.title() ) or
( "{{Archiv}}" in self.page.text ) or
( "{{Archiv|" in self.page.text ) ):
self.status.add("archive")
else:
self.status.discard("archive")
return False
def is_parsing_needed( self ):
"""
Decides wether current RedPage needs to be parsed or not
"""
return self.changedp() or not self.has_status("parsed")
return self.changedp() or not self.status.has("parsed")
def parse( self ):
"""
@@ -138,40 +138,3 @@ class RedPage( MysqlRedPage ):
Calls flush method of Mysql Interface class
"""
cls.session.commit()
def add_status(self, status):
"""
Adds a status specified by status, to status set
@param status Statusstring to add
@type status str
"""
self.status.add(status)
def remove_status(self, status, weak=True):
"""
Removes a status, specified by status from set. If weak is set to
False it will throw a KeyError when trying to remove a status not set.
@param status Statusstring to add
@type status str
@param weak Change behavior on missing status
@type bool
"""
if weak:
self.status.discard(status)
else:
self.status.remove(status)
def has_status(self, status):
"""
Returns True, if redfam has given status
@param status Statusstring to check
@type status str
@returns True if status is present else False
"""
if status in self.status:
return True
else:
return False