When using without the --output option, it prints a Python bytes literal string containing the JSON to stdout like (truncated):
b'{\n "folders": [\n {\n "id": ...
I think print(decryptedJSON.encode("utf-8")) needs to be changed to just print(decryptedJSON) (L601).
It looks like you were trying to ensure output is UTF-8 encoded. I think the way to do this is calling sys.stdout.reconfigure(encoding='utf-8') before the print call. (See https://stackoverflow.com/questions/4374455/how-to-set-sys-stdout-encoding-in-python-3 for this and other ways to do this).
Or, leave it up to the user to set the encoding they want (e.g. they can control this independently of your script by using the PYTHONIOENCODING environment variable, or configuring their system). In practice, this is often an issue for Windows users because the default encoding in the terminal is not always UTF-8, but on other platforms the encoding is usually set to a sane default. So you could special-case Windows and leave the stdout encoding as is on other platforms.
When using without the
--output
option, it prints a Python bytes literal string containing the JSON to stdout like (truncated):I think
print(decryptedJSON.encode("utf-8"))
needs to be changed to justprint(decryptedJSON)
(L601). It looks like you were trying to ensure output is UTF-8 encoded. I think the way to do this is callingsys.stdout.reconfigure(encoding='utf-8')
before theprint
call. (See https://stackoverflow.com/questions/4374455/how-to-set-sys-stdout-encoding-in-python-3 for this and other ways to do this). Or, leave it up to the user to set the encoding they want (e.g. they can control this independently of your script by using the PYTHONIOENCODING environment variable, or configuring their system). In practice, this is often an issue for Windows users because the default encoding in the terminal is not always UTF-8, but on other platforms the encoding is usually set to a sane default. So you could special-case Windows and leave thestdout
encoding as is on other platforms.