def create_db_dir_key(self): """Create the db_dir_key for this annotation configuration. Requires the datasources.""" self.logger.info("Generating db-dir key from datasources...") hasher = Hasher() for ds in self._datasources: self.logger.info(ds.title + " " + ds.version + " md5: " + ds.get_hashcode()) hasher.update(ds.get_hashcode()) db_dir_key = Hasher.md5_hash(hasher.hexdigest()) self.logger.info("Final db-dir md5: " + db_dir_key) return db_dir_key
def get_hashcode(self): """ Since this class can change annotation values depending on certain state attributes (e.g. tx-mode), we need the hashcode to change. The super class hashcode attribute is treated like an initial hashcode here. In other words, hashcode is not a simple attribute for this datasource class. :return: hashcode including state information """ hasher = Hasher() attrs_relevant_for_caching = [self.hashcode, self.get_tx_mode(), str(self._custom_canonical_txs)] for attr in attrs_relevant_for_caching: hasher.update(attr) return Hasher.md5_hash(hasher.hexdigest())
def create_db_dir_key_simple(self): """Create the db_dir_key for this annotation configuration. Requires the datasources.""" db_dir_key = Hasher.md5_hash(self.createHeaderString(False)) return db_dir_key
def test_simple_hash(self): """Test that the single md5 call (static) functions correctly.""" guess = Hasher.md5_hash("blah\n") self.assertTrue(guess == "0d599f0ec05c3bda8c3b8a68c32a1b47")