fgpyo
fgpyo copied to clipboard
`io.assert_path_is_writeable()` should return True for "/dev/stdout"
In [5]: io.assert_path_is_writeable(Path("/dev/stdout"))
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
Cell In[5], line 1
----> 1 io.assert_path_is_writeable(Path("/dev/stdout"))
File ~/.mambaforge-x86/envs/gta/lib/python3.10/site-packages/fgpyo/io/__init__.py:108, in assert_path_is_writeable(path, parent_must_exist)
106 # If file exists, it must be writeable
107 if path.exists():
--> 108 assert path.is_file() and os.access(
109 path, os.W_OK
110 ), f"File exists but is not writeable: {path}"
112 # Else if file doesnt exist and parent_must_exist is True then check
113 # that path.absolute().parent exists, is a directory and is writeable
114 elif parent_must_exist:
AssertionError: File exists but is not writeable: /dev/stdout
In [6]: with Path("/dev/stdout").open("w") as fout:
...: fout.write("abc\n")
...:
abc