diff options
| author | Michal Idziorek <miguel@miguel-acer.softwarefools.com> | 2014-08-28 21:40:06 +0200 |
|---|---|---|
| committer | Michal Idziorek <miguel@miguel-acer.softwarefools.com> | 2014-08-28 21:40:06 +0200 |
| commit | 70d0b36830616a9f94ee0afa8486dc510e9743eb (patch) | |
| tree | b0ca64464c18de3eca517279a9c4a288b43df7fd /tools | |
| parent | 11b626d43e76c09d5d8ef1f7236c191590df0f30 (diff) | |
cleanup
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/binarize.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tools/binarize.py b/tools/binarize.py new file mode 100644 index 0000000..6dcbdef --- /dev/null +++ b/tools/binarize.py @@ -0,0 +1,40 @@ +# this is a simple script to convert the ascii files into binaries +# everything but 0 an 1 , or alternatively _ and X is ignored in +# source file. + +import binascii +import sys + + +f=open(sys.argv[1],'r') +o=open(sys.argv[2],'wb') + +print "binarizing " + sys.argv[1] + " to "+sys.argv[2] + "." + +b="" +l=0 + +while True: + + c=f.read(1) + + if not c: + break + + if c=="0" or c=='_': + l+=1 + b+="0" + + if c=="1" or c=='X': + l+=1 + b+="1" + + if l==8: +# print b + l=0 + o.write(chr(int(b,2))) + b="" + +o.close() + + |
