Implement a class/modul RED_FAM for handling redundance families
This commit is contained in:
36
red_fam.py
Normal file
36
red_fam.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
import hashlib
|
||||||
|
|
||||||
|
class RED_FAM:
|
||||||
|
|
||||||
|
def __init__( self, articlesList ):
|
||||||
|
"""
|
||||||
|
Generates a new RED_FAM object
|
||||||
|
|
||||||
|
@param articlesList list List of articles of redundance family
|
||||||
|
"""
|
||||||
|
|
||||||
|
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( )
|
||||||
|
|
||||||
|
print( self.__hash )
|
||||||
|
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
Reference in New Issue
Block a user