84 lines
2.1 KiB
Python
84 lines
2.1 KiB
Python
|
|
import hashlib
|
|
|
|
class RED_FAM:
|
|
|
|
def __init__( self, articlesList, beginning=None, ending=None, status=0 ):
|
|
"""
|
|
Generates a new RED_FAM object
|
|
|
|
@param articlesList list List of articles of redundance family
|
|
@param beginning datetime Beginning date of redundance diskussion
|
|
@param ending datetime Ending date of redundance diskussion
|
|
"""
|
|
|
|
self.__articlesList = articlesList
|
|
|
|
# Make sure we have 8 entrys for pages, if not fill with empty list items
|
|
while len( self.__articlesList ) < 8:
|
|
self.__articlesList.append( "" )
|
|
|
|
self.__hash = self.__get_fam_hash( )
|
|
|
|
if( beginning ):
|
|
self.__beginning = beginning
|
|
|
|
if( ending ):
|
|
self.__ending = ending
|
|
|
|
self.__status = status # __TODO__ STATUS CODE
|
|
|
|
def __get_fam_hash( self ):
|
|
"""
|
|
Calculates the SHA-1 hash for the articlesList of redundance family.
|
|
Since we don't need security SHA-1 is just fine.
|
|
|
|
@returns str String with the hexadecimal hash digest
|
|
"""
|
|
|
|
h = hashlib.sha1()
|
|
h.update( str( self.__articlesList ).encode('utf-8') )
|
|
|
|
return h.hexdigest()
|
|
|
|
def add_beginning( self, datetime ):
|
|
"""
|
|
Adds the beginning date of a redundance diskussion to the object and sets changed to True
|
|
|
|
@param datetime datetime Beginning date of redundance diskussion
|
|
"""
|
|
|
|
self.__beginning = datetime
|
|
self.__changed = True
|
|
|
|
def add_ending( self, datetime ):
|
|
"""
|
|
Adds the ending date of a redundance diskussion to the object. Also sets the status to __TODO__ STATUS NUMBER and changed to True
|
|
|
|
@param datetime datetime Ending date of redundance diskussion
|
|
"""
|
|
|
|
self.__ending = datetime
|
|
|
|
self.__status = 2 #__TODO__ STATUS NUMBER
|
|
self.__changed = True
|
|
|
|
def __repr__( self ):
|
|
|
|
if( hasattr( self, "__beginning" ) ):
|
|
beginning = ", beginning=" + repr( self.__beginning )
|
|
else:
|
|
beginning = ""
|
|
|
|
if( hasattr( self, "__ending" ) ):
|
|
ending = ", ending=" + repr( self.__ending )
|
|
else:
|
|
ending = ""
|
|
|
|
__repr = "RED_FAM( " + repr( self.__articlesList ) + beginning + ending + ", status=" + repr( self.__status ) + " )"
|
|
|
|
return __repr
|
|
|
|
x = RED_FAM( [ "Test", "Foo", "Bar" ] )
|
|
print( repr( x ) )
|