lythonic.misc¶
File system utilities.
File system utilities.
Helper functions for working with directories and paths.
from lythonic.misc import ensure_dir, tabula_rasa_path
from pathlib import Path
# Create directory if it doesn't exist
data_dir = ensure_dir("./data/cache")
# Clear a path (file or directory) and ensure parent exists
output = tabula_rasa_path("./output/results.json")
ensure_dir(dir)
¶
tabula_rasa_path(p)
¶
Ensure path doesn't exist but parent directory does.
Removes the file or directory at the path if it exists, then ensures the parent directory exists. Returns the Path ready for writing.