Fix extra signature file path in pel parsing
Change-Id: Ia73a1e6ca066d5af9417313a34c744ab0e125f9a
Signed-off-by: Caleb Palmer <cnpalmer@us.ibm.com>
diff --git a/chip_data/pyprd/chip_data/peltool.py b/chip_data/pyprd/chip_data/peltool.py
index 4428b46..bc808ae 100644
--- a/chip_data/pyprd/chip_data/peltool.py
+++ b/chip_data/pyprd/chip_data/peltool.py
@@ -78,7 +78,7 @@
node[1][pos] = bit.desc
# If the input extra signature file exists, add those to the data.
- if os.path.isfile(exSigPath):
+ if exSigPath and os.path.isfile(exSigPath):
with open(exSigPath, "r") as sigFp:
fileData = sigFp.read()
sigPattern = r'PRD_EXTRA_SIG\s*\(\s*([^"]*)\s*,\s*(0x[0-9A-Fa-f]{8})\s*,\s*"([^"]*)"'
diff --git a/chip_data/pyprd/util/hash.py b/chip_data/pyprd/util/hash.py
index a807d0b..ae7a0d8 100644
--- a/chip_data/pyprd/util/hash.py
+++ b/chip_data/pyprd/util/hash.py
@@ -1,3 +1,8 @@
+#!/usr/bin/env python3
+
+import argparse
+
+
def hash_string(num_bytes: int, string: str) -> int:
"""
Converts a string into an integer hash value. This is primarily used to
@@ -40,3 +45,12 @@
Returns a formatted hex string of the given string's hash value.
"""
return "{0:0{1}x}".format(hash_string(num_bytes, string), num_bytes * 2)
+
+
+if __name__ == "__main__":
+
+ cli = argparse.ArgumentParser()
+ cli.add_argument("num_bytes", help="Number of bytes to hash to")
+ cli.add_argument("string_name", help="String to hash")
+ args = cli.parse_args()
+ print(hex(hash_string(int(args.num_bytes), args.string_name)))