Skip to content

Commit

Permalink
Add purge cli for purge nand2tetris compare data
Browse files Browse the repository at this point in the history
  • Loading branch information
mlouielu committed Jul 3, 2017
1 parent d5bb98e commit f4bc9d1
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/data/pruge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#! /usr/local/bin/python3
# -*- coding: utf-8 -*-

import argparse


def pruge(path):
with open(path) as f:
result = [l.strip('\n').replace(' ', '').strip('|') for l in f.readlines()]
return result


def save(data, path):
with open(path, 'w') as f:
f.write('\n'.join(data))


if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('input')
parser.add_argument('-w', action='store_true')

args = parser.parse_args()

data = pruge(args.input)
if args.w:
save(data, args.input)
else:
for i in data:
print(i)

0 comments on commit f4bc9d1

Please sign in to comment.