OS functions

Sometimes some OS functions are necessary and they are collected here:

OS interaction of DMT

class DMT.external.os.cd(newPath)[source]

Bases: object

Context manager for changing the current working directory


with cd(dir):
DMT.external.os.recursive_copy(src, dst, force=False)[source]

Recursively copies a full directory to a new destination folder.

srcstr or os.Pathlike

Path to the source folder

dststr or os.Pathlike

Path to the destination folder

forcebool, optional

When true, all files are overwritten. Else, already existing ones are kept.


rmtree method for Path objects

rootstr or os.Pathlike

Directory to remove

DMT.external.os.slugify(s: str) str[source]

https://stackoverflow.com/questions/295135/turn-a-string-into-a-valid-filename Normalizes string, converts to lowercase, removes non-alpha characters, and converts spaces to hyphens.