diff options
author | Daniel Gnoutcheff <gnoutchd@softwarefreedom.org> | 2017-01-23 18:38:22 -0500 |
---|---|---|
committer | Daniel Gnoutcheff <gnoutchd@softwarefreedom.org> | 2017-01-23 18:49:28 -0500 |
commit | d7c84268a26a4391af55a3533422367b02737435 (patch) | |
tree | 7dd461cc35542d9ca155ced836c0bda53450bc0d /lsbin.py | |
parent | 7fc88c0c901b68b6e223d6f1383bc1221eae8488 (diff) |
Misc. unrecorded changes
Diffstat (limited to 'lsbin.py')
-rwxr-xr-x | lsbin.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lsbin.py b/lsbin.py new file mode 100755 index 0000000..e4bd36c --- /dev/null +++ b/lsbin.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 + +import avfs +import os, sys + +# https://stackoverflow.com/questions/898669/how-can-i-detect-if-a-file-is-binary-non-text-in-python +textchars = bytearray({7,8,9,10,12,13,27} | set(range(0x20, 0x100)) - {0x7f}) +def is_binary(fname): + head = avfs.open(fname, 'rb').read(1024) + return bool(head.translate(None, textchars)) + +if __name__ == "__main__": + for fname in avfs.find(os.fsencode(sys.argv[1]), {b'.git'}): + try: + if is_binary(fname): + print(fname.decode('utf-8', 'replace')) + except: + pass + |