import hashlib from datetime import datetime 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 self.__hash = self.__get_fam_hash( ) if( beginning ): self.__beginning = beginning else: self.__beginning = None if( ending ): self.__ending = ending else: self.__ending = None 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( self.__beginning ): print( self.__beginning ) beginning = ", beginning=" + repr( self.__beginning ) else: beginning = "" if( 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 ) )