Commit 1f01dc68 authored by Jose Enrique.Ruiz's avatar Jose Enrique.Ruiz
Browse files

minor code clean up

parent f1455e8e
......@@ -510,7 +510,7 @@ def provprocessparsing():
# Checking arguments
if len(args) != 3:
standardhandle.error(tag, "incorrect number of arguments, type -h for help", 2)
if opts.filter != "r0_to_dl1" and opts.filter != "dl1_to_dl2" and opts.filter != "":
if opts.filter not in ["r0_to_dl1", "dl1_to_dl2", ""]:
standardhandle.error(tag, "incorrect value for --filter argument, type -h for help", 2)
# Set global variables
......
......@@ -188,8 +188,8 @@ def get_file_hash(str_path, buffer=get_hash_buffer(), method=get_hash_method()):
if full_path.is_file():
hash_func = getattr(hashlib, method)()
if buffer == "content":
block_size = 65536
with open(full_path, "rb") as f:
block_size = 65536
buf = f.read(block_size)
while len(buf) > 0:
hash_func.update(buf)
......@@ -197,10 +197,9 @@ def get_file_hash(str_path, buffer=get_hash_buffer(), method=get_hash_method()):
file_hash = hash_func.hexdigest()
logger.debug(f"File entity {str_path} has {method} hash {file_hash}")
return file_hash
elif "path":
else:
hash_func.update(str(full_path).encode())
hash_path = hash_func.hexdigest()
return hash_path
return hash_func.hexdigest()
else:
logger.warning(f"File entity {str_path} not found")
return str_path
......@@ -220,7 +219,7 @@ def get_entity_id(value, item):
if entity_type == "FileCollection":
filename = value
index = definition["entities"][entity_name].get("index", "")
if Path(value).is_dir() and index:
if Path(filename).is_dir() and index:
filename = Path(value) / index
return get_file_hash(filename)
if entity_type == "File":
......
......@@ -62,7 +62,7 @@ def parse_lines_log(filter_step, run_number):
tag_activity, tag_run = session_tag.split(":")
if tag_run == run_number:
keep = True
if filter_step != "" and filter_step != tag_activity:
if filter_step not in ["", tag_activity]:
keep = False
# always keep first line / session start
if keep or not filtered:
......@@ -70,8 +70,6 @@ def parse_lines_log(filter_step, run_number):
return filtered
# TODO: add used DL1DL2Collection, generated DL2Collection
#
def parse_lines_run(filter_step, prov_lines, out):
"""Process provenance info to reduce session at run/process wise scope."""
......
Markdown is supported
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