File Utilities (ligo.skymap.util.file)

File tools.

ligo.skymap.util.file.rename(src, dst)[source] [edit on github]

Like os.rename, but works across different devices because it catches and handles EXDEV (Invalid cross-device link) errors.

ligo.skymap.util.file.rm_f(filename)[source] [edit on github]

Remove a file, or be silent if the file does not exist, like rm -f.


>>> with tempfile.TemporaryDirectory() as d:
...     rm_f('test')
...     with open('test', 'w') as f:
...         print('Hello world', file=f)
...     rm_f('test')