diff options
author | Tharre <tharre3@gmail.com> | 2015-05-25 00:14:40 +0200 |
---|---|---|
committer | Tharre <tharre3@gmail.com> | 2015-05-25 00:14:40 +0200 |
commit | 6eb59b79ddc5c69fc9a90f3f90408b6fdafb1836 (patch) | |
tree | 869f2de8e1ed5e21c125ed9ebe9cf5565b11c824 /print_dep.py | |
parent | 4678d9630e9f95db9d06d3423c539bcb0bcc722c (diff) | |
download | redo-6eb59b79ddc5c69fc9a90f3f90408b6fdafb1836.tar.gz redo-6eb59b79ddc5c69fc9a90f3f90408b6fdafb1836.tar.xz redo-6eb59b79ddc5c69fc9a90f3f90408b6fdafb1836.zip |
Store dependencies as plain text instead of binary
Binary files are hard to debug, and even while the code required to parsing them
is simpler it's not worth the tradeoff.
Note that handling of newlines in target names is not implemented yet, they
require some sort of special escaping.
Diffstat (limited to 'print_dep.py')
-rwxr-xr-x | print_dep.py | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/print_dep.py b/print_dep.py deleted file mode 100755 index 803b5e9..0000000 --- a/print_dep.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env python3 - -# quick and dirty utility to make the binary mess, produced by my redo program -# into something more friendly to the human eye -# requires termcolor (pip install termcolor) - -import struct -import sys -import hashlib -from binascii import hexlify -from os.path import basename -from termcolor import colored - -def convert_back(s): - return s.replace('!', '/') - -if (len(sys.argv) < 2): - print("Need an argument.") - exit(1) - -hasher = hashlib.sha1() -file = open(sys.argv[1], 'rb') -magic = file.read(4) -hash = file.read(20) -subdeps = file.read() -org_file = convert_back(basename(sys.argv[1])) - -hash_str = str(hexlify(hash), 'ascii') - -with open(org_file, 'rb') as f: - buf = f.read() - hasher.update(buf) - -print("Target: " + org_file) -print("Hash: " + hash_str + " ", end="") -if hasher.hexdigest() == hash_str: - print(colored(u"\u2714", "green", attrs=['bold'])) -else: - print(colored(u"\u2718", "red", attrs=['bold'])) - -print("Magic number: " + str(struct.unpack('i', magic)[0])) -print("Dependencies:") -start = True -thing = "" -for byte in subdeps: - if start: - print(" " + chr(byte) + "-", end="") - start = False - elif byte == 0: - start = True - print(thing) - thing = "" - else: - thing += chr(byte) - continue |