Python: made all commands handle output to buffer object (e.g. stdout)

This commit is contained in:
Celine Mercier
2020-07-24 16:09:48 +02:00
parent 46ca693ca9
commit 8aa455ad8a
18 changed files with 511 additions and 213 deletions

View File

@ -210,10 +210,11 @@ def open_uri(uri,
error = None
if scheme==b"dms" or \
(scheme==b"" and \
(((not input) and "outputformat" not in config["obi"]) or \
(input and "inputformat" not in config["obi"]))): # TODO maybe not best way
if urib != b"-" and \
(scheme==b"dms" or \
(scheme==b"" and \
(((not input) and "outputformat" not in config["obi"]) or \
(input and "inputformat" not in config["obi"])))): # TODO maybe not best way
if default_dms is not None and b"/" not in urip.path: # assuming view to open in default DMS (TODO discuss)
dms=(default_dms, urip.path)
@ -275,10 +276,10 @@ def open_uri(uri,
iseq = urib
objclass = bytes
else: # TODO update uopen to be able to write?
if urip.path:
file = open(urip.path, 'wb')
else:
if urip.path == b'-':
file = sys.stdout.buffer
elif urip.path :
file = open(urip.path, 'wb')
if file is not None:
qualifiers=parse_qs(urip.query)