bw_processing.filesystem
Attributes
Functions
|
Clean string |
|
Generate MD5 hash for file at filepath |
|
Convert arbitrary strings to make them safe for filenames. Substitutes strange characters, and uses unicode normalization. |
Module Contents
- bw_processing.filesystem.clean_datapackage_name(name: str) str[source]
Clean string
nameof characters not allowed in data package names.Replaces with underscores, and drops multiple underscores.
- bw_processing.filesystem.md5(filepath: str | pathlib.Path, blocksize: int = 65536) str[source]
Generate MD5 hash for file at filepath
- bw_processing.filesystem.safe_filename(string: str | bytes, add_hash: bool = True, full: bool = False) str[source]
Convert arbitrary strings to make them safe for filenames. Substitutes strange characters, and uses unicode normalization.
if add_hash, appends hash of string to avoid name collisions.
From http://stackoverflow.com/questions/295135/turn-a-string-into-a-valid-filename-in-python