file_path#
- gwpy.io.utils.file_path(fobj: NamedReadable | bytes | CacheEntry) str[source]#
Determine the path of a file.
This doesn’t do any sanity checking to check that the file actually exists, or is readable.
- Parameters:
- fobj
file,str,os.PathLike,bytes,CacheEntry, … The file object or path to parse.
- fobj
- Returns:
- Raises:
ValueErrorIf a file path cannnot be determined.
Examples
>>> from gwpy.io.utils import file_path >>> import pathlib >>> file_path("test.txt") 'test.txt' >>> file_path(pathlib.Path('dir') / 'test.txt') 'dir/test.txt' >>> file_path(open("test.txt", "r")) 'test.txt' >>> file_path("file:///home/user/test.txt") '/home/user/test.txt'