Expand __init__ Method of RED_FAM to catch beginning, end and status

Add a __repr__ Method to RED_FAM
This commit is contained in:
2015-09-05 18:36:30 +02:00
parent 10cfa79ee0
commit 72410d17b4

View File

@@ -3,11 +3,13 @@ import hashlib
class RED_FAM:
def __init__( self, articlesList ):
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 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
@@ -18,8 +20,13 @@ class RED_FAM:
self.__hash = self.__get_fam_hash( )
print( self.__hash )
if( beginning ):
self.__beginning = beginning
if( ending ):
self.__ending = ending
self.__status = status # __TODO__ STATUS CODE
def __get_fam_hash( self ):
"""
@@ -33,4 +40,44 @@ class RED_FAM:
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 ) )