Closed gsemet closed 2 years ago
this probably comes the fact "\<stdout>" has invalid character for window filesystem, and it is just ignored on mac/linux...
this is not linked to colorama
Thanks for your report! I'll take a look at the issue this weekend.
I have worked around it with this code:
def anydump_stdout(data: Any, fmt: str = "json") -> None:
"""Dump data structure to standart output sys.stdout.
Supports the following format:
- ``yaml```: Yaml
- ``ini``: INI (do not use complex nested structure such as list, set, dict)
- ``toml``: Toml
- ``json``: JSON
"""
# Standard Library
from sys import stdout
if fmt == "yaml":
fmt = "ruamel.yaml"
# manually create the IOInfo to skip the anyconfig magic which crashs on
# Windows because it tries to create a pathlib.Path with the name "<name>",
# which contains invalid character for a filename on Windows File system.
# Third Party Libraries
from anyconfig.ioinfo.factory import datatypes
ioinfo = datatypes.IOInfo(stdout, datatypes.IOI_STREAM, "<stdout>", "")
anyconfig.dump(data, ioinfo, ac_parser=fmt, **_anyconfig_kwargs())
print("")
stdout.flush()
I pushed an experimental fix as #140 and merged it into the next branch. Could you please try it if that fix is correct or not?
When colorama is enabled, the factory crashes with an error
the
anyconfig.ioinfo.factory.make
function receives acolorama.ansitowin32.StreamWrapper
object that fails in the call to get_path_and_ext, but only on windows.