databankr

Casio Databank/Telememo record format encoder/decoder
git clone git://git.luxferre.top/databankr.git
Log | Files | Refs | README

commit f08b73a18642ed6e8a75476e5f0963a0cd49a425
parent b035c1c12e2cc8499af8a39eeee315d588476c23
Author: Luxferre <lux@ferre>
Date:   Tue, 21 May 2024 20:24:06 +0300

Fixed stdio flows

Diffstat:
Mdatabankr.py | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/databankr.py b/databankr.py @@ -139,7 +139,9 @@ if __name__ == '__main__': # main app start else: infd = open(args.input_file, mode='rb') indata = infd.read() - if infd != sys.stdin: + if infd == sys.stdin: # perform additional conversion + indata = indata.encode('utf-8') + else: infd.close() except: print('Error reading the input data!') @@ -171,10 +173,12 @@ if __name__ == '__main__': # main app start try: if args.output_file == '-': outfd = sys.stdout + if type(outdata) == type(b''): + outdata = outdata.decode('utf-8') outfd.write(outdata) else: outfd = open(args.output_file, mode='wb') - if type(outdata) == 'str': + if type(outdata) == type(''): outdata = outdata.encode('utf-8') outfd.write(outdata) if outfd != sys.stdout: