updating hooks

fix hex gen from relative invocation path
This commit is contained in:
brent saner
2024-07-07 23:44:13 -04:00
parent 82220d5107
commit c329fc916e
4 changed files with 25 additions and 7 deletions

View File

@@ -6,6 +6,7 @@
################################################################################################################################
import binascii
import pathlib
import re
import zlib
@@ -14,6 +15,7 @@ suffixes = ('simple', 'multi')
linecharlimit = 80
linestrp = re.compile(r'^\s*(?P<hex>[A-Fa-f0-9N]+)?(?:\s*//.*)?$')
thisdir = pathlib.Path(__file__).absolute().parent
def parse(text):
@@ -44,10 +46,10 @@ for p in prefixes:
for s in suffixes:
fnamebase = '{0}.{1}'.format(p, s)
fname = '{0}.txt'.format(fnamebase)
with open(fname, 'r') as fh:
with open(thisdir.joinpath(fname), 'r') as fh:
raw = fh.read().strip()
hexstr, bytelen = parse(raw)
with open('{0}.hex'.format(fnamebase), 'w') as fh:
with open(thisdir.joinpath('{0}.hex'.format(fnamebase)), 'w') as fh:
fh.write(hexstr)
fh.write('\n')
b = binascii.unhexlify(hexstr.replace('\n', '').strip().encode('utf-8'))