Skip to content

Commit

Permalink
Add encode, makegen, and plate utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
Rufflewind committed Mar 13, 2016
0 parents commit 79e0a88
Show file tree
Hide file tree
Showing 13 changed files with 1,603 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# generic
.\#*
.nfs????
dist/
*~
*.log
*.tmp

# native
a.out
*.a
*.dll
*.dylib
*.exe
*.gch
*.ipch
*.lib
*.o
*.obj
*.so
*.sdf
*.stackdump

# Fortran
*.mod

# Haskell
.cabal-sandbox/
cabal.sandbox.config
*.chi
*.hcr
*.hi

# JavaScript
node_modules/

# Python
MANIFEST
__pycache__
*.pyc

# Rust
target/
Cargo.lock

# TeX
*.aux
*.bbl
*.blg
*.thm
*.toc
*Notes.bib

# web
.sass-cache
*.css.map
*.js.map
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
devutils
========

Miscellaneous development utilities.
38 changes: 38 additions & 0 deletions bin/ckencode
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python
# Wrapper around 'encode' to process checksums from tools like md5sum. Only
# lines that look like checksums are processed. The rest are passed through
# untouched.

if __name__ != "__main__":
raise ImportError("not an importable module")

import re, subprocess, sys

def call_encode(digest):
p = subprocess.Popen(
("encode", "-f", "hex", "-l", "-s") + tuple(sys.argv[1:]),
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
)
out = p.communicate(digest.encode("utf8"))[0].decode("utf8").strip()
if p.returncode != 0:
exit(1)
return out

try:
# call once to make sure the arguments are sensible
call_encode("")

for line in sys.stdin:
m = re.match(r"([-+_./A-Za-z0-9]+)( .*)", line)
if m:
digest, rest = m.groups()
sys.stdout.write(call_encode(digest) + rest + "\n")
else:
sys.stdout.write(s)
except IOError as e:
import os
sys.stderr.write("\n{0}: {1}\n".format(os.path.basename(sys.argv[0]), e))
exit(1)
except KeyboardInterrupt:
exit(1)
2 changes: 2 additions & 0 deletions bin/decode
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec encode --decode "$@"
Loading

0 comments on commit 79e0a88

Please sign in to comment.