Commit 5cf4f1c1 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[hash] Added missing documentation as well as fixed related warnings

Also unused import cleanup
parent 8265b310
......@@ -34,10 +34,6 @@ hash
Various functions for hashing platform contributions and others
"""
import os
import six
import hashlib
import collections
import simplejson
......@@ -53,6 +49,25 @@ from beat.backend.python.hash import _compact
def hashBlockOutput(block_name, algorithm_name, algorithm_hash,
parameters, environment, input_hashes, output_name):
"""Generate a hash for a given block output
Parameters:
:param str block_name: Name of the block (unused)
:param str algorithm_name: Name of the algorithm used by the block
(parameter unused)
:param str algorithm_hash: Hash of the algorithm used by the block
:param dict parameters: Configured parameters
:param dict environment: Environment parameters
:param dict input_hashes: Dictionary containing the input's hashes
:param str output_name: Name of the output
"""
# Note: 'block_name' and 'algorithm_name' aren't used to compute the hash,
# but are useful when an application wants to implement its own hash
# function
......@@ -72,6 +87,22 @@ def hashBlockOutput(block_name, algorithm_name, algorithm_hash,
def hashAnalyzer(analyzer_name, algorithm_name, algorithm_hash,
parameters, environment, input_hashes):
"""Generate a hash for a given analyzer
Parameters:
:param str analyzer_name: Name of the analyzer (unused)
:param str algorithm_name: Name of the algorithm used by the analyzer
:param str algorithm_hash: Hash of the algorithm used by the analyzer
:param dict parameters: Configured parameters
:param dict environment: Environment parameters
:param dict input_hashes: Dictionary containing the inputs's hashes
"""
# Note: 'analyzer_name' isn't used to compute the hash, but is useful when
# an applications want to implement its own hash function
s = _compact("""{
......@@ -96,7 +127,7 @@ def hashJSONStr(contents, description):
try:
return hashJSON(simplejson.loads(contents,
object_pairs_hook=collections.OrderedDict), description) #preserve order
object_pairs_hook=collections.OrderedDict), description) # preserve order
except simplejson.JSONDecodeError:
# falls back to normal file content hashing
return hash(contents)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment