aboutsummaryrefslogtreecommitdiff
path: root/z80count.py
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2019-03-31 09:01:21 +0100
committerJuan J. Martinez <jjm@usebox.net>2019-03-31 09:01:21 +0100
commitfe518ecdf05f526fc3fe104dfa89dd54c3d15886 (patch)
treec6e9000b0d718ad6d430333272be7f6e44fa0ce2 /z80count.py
parent2a28aca766e8dde8c6ee40ae378c1e5a60c15083 (diff)
downloadz80count-fe518ecdf05f526fc3fe104dfa89dd54c3d15886.tar.gz
z80count-fe518ecdf05f526fc3fe104dfa89dd54c3d15886.zip
More testing preparation
Diffstat (limited to 'z80count.py')
-rwxr-xr-xz80count.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/z80count.py b/z80count.py
index 54757d4..6c569f7 100755
--- a/z80count.py
+++ b/z80count.py
@@ -73,6 +73,16 @@ def z80count(line, table, total, total_cond, subt, update, tabstop=2, debug=Fals
return (out, total, total_cond)
+def init_table(table_file="z80table.json"):
+ table_file = path.join(
+ path.dirname(path.realpath(__file__)), table_file)
+ with open(table_file, "rt") as fd:
+ table = json.load(fd)
+
+ for i in range(len(table)):
+ table[i]["cregex"] = re.compile(table[i]["regex"] + r"\s?(;.*)?", re.I)
+
+ return sorted(table, key=lambda o: o["w"])
def main():
@@ -100,15 +110,7 @@ def main():
in_f = args.infile
out_f = args.outfile
- table_file = path.join(
- path.dirname(path.realpath(__file__)), "z80table.json")
- with open(table_file, "rt") as fd:
- table = json.load(fd)
-
- for i in range(len(table)):
- table[i]["cregex"] = re.compile(table[i]["regex"] + r"\s?(;.*)?", re.I)
-
- table = sorted(table, key=lambda o: o["w"])
+ table = init_table()
total = total_cond = 0
while True:
line = in_f.readline()