aboutsummaryrefslogtreecommitdiff
path: root/z80count.py
diff options
context:
space:
mode:
authorAlexis Roda <alexis.roda.villalonga@gmail.com>2019-07-26 20:40:31 +0200
committerAlexis Roda <alexis.roda.villalonga@gmail.com>2019-07-26 20:40:31 +0200
commitb5fa3354d0d24440bc13e22fe9170c5a31d348df (patch)
tree39788c3da88eab6e51c2a824e089640ca4540a5b /z80count.py
parent1a5911f452ad999fa35ce264e7e73bbdfec58775 (diff)
downloadz80count-b5fa3354d0d24440bc13e22fe9170c5a31d348df.tar.gz
z80count-b5fa3354d0d24440bc13e22fe9170c5a31d348df.zip
Make code more pythonic.
Diffstat (limited to 'z80count.py')
-rwxr-xr-xz80count.py10
1 files changed, 3 insertions, 7 deletions
diff --git a/z80count.py b/z80count.py
index 02c75a4..c44a90a 100755
--- a/z80count.py
+++ b/z80count.py
@@ -79,8 +79,8 @@ def init_table(table_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)
+ for i in table:
+ i["cregex"] = re.compile(i["regex"] + r"\s?(;.*)?", re.I)
return sorted(table, key=lambda o: o["w"])
@@ -121,11 +121,7 @@ def main():
out_f = args.outfile
table = init_table()
total = total_cond = 0
- while True:
- line = in_f.readline()
- if not line:
- break
-
+ for line in in_f:
output, total, total_cond = z80count(
line, table, total, total_cond, args.subt, args.update, args.tabstop, args.debug)
out_f.write(output)