Utilities

Utilities.

Functions

get_offending_hexdigests(path[, chunk_size, ...])

Check a file for hash sums.

get_hashes(path, names, *[, chunk_size])

Calculate several hexdigests of hash algorithms for a file concurrently.

raise_on_digest_mismatch(*, path[, ...])

Raise a HexDigestError if the digests do not match.

get_hexdigests_remote(hexdigests_remote[, ...])

Process hexdigests via URLs.

download(url, path[, force, ...])

Download a file from a given URL.

name_from_url(url)

Get the filename from the end of the URL.

name_from_s3_key(key)

Get the filename from the S3 key.

mkdir(path[, ensure_exists])

Make a directory (or parent directory if a file is given) if flagged with ensure_exists.

mock_envvar(envvar, value)

Mock the environment variable then delete it after the test is over.

mock_home()

Mock the PyStow home environment variable, yields the directory name.

getenv_path(envvar, default[, ensure_exists])

Get an environment variable representing a path, or use the default.

n()

Get a random string for testing.

get_df_io(df[, sep, index])

Get the dataframe as bytes.

get_np_io(arr, **kwargs)

Get the numpy object as bytes.

write_lzma_csv(df, path[, sep, index])

Write a dataframe as an lzma-compressed file.

gunzip(source, target)

Unzip a file in the source to the target.

write_zipfile_csv(df, path, inner_path[, ...])

Write a dataframe to an inner CSV file to a zip archive.

read_zipfile_csv(path, inner_path[, sep])

Read an inner CSV file from a zip archive.

write_zipfile_xml(element_tree, path, ...)

Write an XML element tree to an inner XML file to a zip archive.

read_zipfile_xml(path, inner_path, **kwargs)

Read an inner XML file from a zip archive.

write_zipfile_np(arr, path, inner_path, **kwargs)

Write a dataframe to an inner CSV file to a zip archive.

read_zip_np(path, inner_path, **kwargs)

Read an inner numpy array-like from a zip archive.

read_zipfile_rdf(path, inner_path, **kwargs)

Read an inner RDF file from a zip archive.

write_tarfile_csv(df, path, inner_path[, ...])

Write a dataframe to an inner CSV file from a tar archive.

read_tarfile_csv(path, inner_path[, sep])

Read an inner CSV file from a tar archive.

read_tarfile_xml(path, inner_path, **kwargs)

Read an inner XML file from a tar archive.

write_pickle_gz(obj, path, **kwargs)

Write an object to a gzipped pickle.

read_rdf(path, **kwargs)

Read an RDF file with rdflib.

download_from_google(file_id, path[, force, ...])

Download a file from google drive.

download_from_s3(s3_bucket, s3_key, path[, ...])

Download a file from S3.

get_commit(org, repo[, provider])

Get last commit hash for the given repo.

get_home([ensure_exists])

Get the PyStow home directory.

get_name()

Get the PyStow home directory name.

get_base(key[, ensure_exists])

Get the base directory for a module.

path_to_sqlite(path)

Convert a path to a SQLite connection string.

Classes

HexDigestMismatch(name, actual, expected)

Create new instance of HexDigestMismatch(name, actual, expected)

HexDigestError(offending_hexdigests)

Thrown if the hashsums do not match expected hashsums.

UnexpectedDirectory(path)

Thrown if a directory path is given where file path should have been.