bw2data.filesystem#

Module Contents#

Functions#

check_dir(directory)

Returns True if given path is a directory and writeable, False otherwise.

create_dir(dirpath)

Create directory tree to dirpath; ignore if already exists

md5(filepath[, blocksize])

Generate MD5 hash for file at filepath

safe_filename(string[, add_hash])

Convert arbitrary strings to make them safe for filenames. Substitutes strange characters, and uses unicode normalization.

Attributes#

re_slugify

bw2data.filesystem.check_dir(directory)[source]#

Returns True if given path is a directory and writeable, False otherwise.

bw2data.filesystem.create_dir(dirpath)[source]#

Create directory tree to dirpath; ignore if already exists

bw2data.filesystem.md5(filepath, blocksize=65536)[source]#

Generate MD5 hash for file at filepath

bw2data.filesystem.safe_filename(string, add_hash=True)[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

bw2data.filesystem.re_slugify[source]#