pyrolite.util.general
- pyrolite.util.general.flatten_dict(d, climb=False, safemode=False)[source]
Flattens a nested dictionary containing only string keys.
This will work for dictionaries which don’t have two equivalent keys at the same level. If you’re worried about this, use safemode=True.
Partially taken from https://stackoverflow.com/a/6043835.
- pyrolite.util.general.swap_item(startlist: list, pull: object, push: object)[source]
Swap a specified item in a list for another.
- pyrolite.util.general.copy_file(src, dst, ext=None, permissions=None)[source]
Copy a file from one place to another. Uses the full filepath including name.
- Parameters
src (
str
|pathlib.Path
) – Source filepath.dst (
str
|pathlib.Path
) – Destination filepath or directory.ext (
str
,None
) – Optional file extension specification.