pt = decr.process (ct)
out (pt)
+PDT_SINK = 0
+PDT_SOURCE = 1
+
+def deptdcrypt_mk_stream (kind, path, verbose=False):
+ """Create stream from file or stdio descriptor."""
+ if kind == PDT_SINK:
+ if path == "-":
+ if verbose is True: noise ("PDT: sink: stdout")
+ return sys.stdout.buffer
+ else:
+ if verbose is True: noise ("PDT: sink: file %s" % path)
+ return io.FileIO (path, "w")
+ if kind == PDT_SOURCE:
+ if path == "-":
+ if verbose is True: noise ("PDT: source: stdin")
+ return sys.stdin.buffer
+ else:
+ if verbose is True: noise ("PDT: source: file %s" % path)
+ return io.FileIO (path, "r")
+
+ raise ValueError ("bogus stream ā%sā / %s" % (kind, path))
+
def depdtcrypt_file (pw, spath, dpath, verbose=False):
"""
"""
if verbose is True:
noise ("PDT: decrypt %s ā %s" % (spath, dpath), file=sys.stderr)
- with io.FileIO (spath, "r") as ins:
- with io.FileIO (dpath, "w") as outs:
+ with deptdcrypt_mk_stream (PDT_SOURCE, spath) as ins:
+ with deptdcrypt_mk_stream (PDT_SINK, dpath) as outs:
return depdtcrypt (pw, ins, outs, verbose)