csdms

bmibabel.utils module

General utilities.

class bmibabel.utils.cd(dir)[source]

Bases: object

Context for changing the working directory.

class bmibabel.utils.cdtemp(**kwds)[source]

Bases: object

Context that creates a temporary working directory.

bmibabel.utils.check_output(*args, **kwds)[source]

Execute a shell command.

This is the same as the subprocess.check_output command available in Python versions greater than 2.7 but is provided for pre-2.7 versions.

bmibabel.utils.glob_cp(pattern, dest)[source]
bmibabel.utils.glob_sub(pattern, subs)[source]
bmibabel.utils.is_text(buff)[source]

Check if a string is text or binary.

bmibabel.utils.is_text_file(fname, block=1024)[source]

Check if a file is text or binary.

bmibabel.utils.mkdir_p(path)[source]
class bmibabel.utils.mktemp(**kwds)[source]

Bases: object

Context that creates a temporary directory.

bmibabel.utils.pkg_config(name, opts)[source]

Execute the pkg-config command.

Parameters:

name : str

Name of a pkg-config package.

opts : str or iterable

Command-line options to pass to pkg-config.

Returns:

str

Result of calling pkg-config.

bmibabel.utils.read_first_of(files)[source]

Read the first file found.

Parameters:

files : iterable

Ordered list of files to read.

Returns:

(str, str)

Name of the first file found and then contents of that file.

bmibabel.utils.status(message)[source]

Print a status message.

Parameters:

message : str

Status message.

bmibabel.utils.sub(fname, subs, inplace=False)[source]
bmibabel.utils.system(*args, **kwds)[source]

Execute and echo a shell command.

Parameters:

verbose : boolean

Print ouput.

bmibabel.utils.which(prog, env=None)[source]

Look for a program.

Use the system which command to look for a program. If provided, env is the name of a environment variable that may give the path to the program.

Parameters:

prog : str

Name of a program.

env : str

Look for program in a user environment.

Returns:

str

The absolute path to the program.