Skip to content

Utilities

dm.utilities

Module providing useful functions used in several places.

guessToolsDir()

Tries to locate the directory of the tools files.

Returns:

Type Description
str

The path to the tools directory.

tryLocatingFile(filename, basedir=None)

Tries to locate a file.

The functions will try to locate a file by:

  1. Checking if the file with an absolute path exists
  2. Checking if the file relative to the basedir exists
  3. Checking if the file exists in the current directory

Parameters:

Name Type Description Default
filename str

The name of the file to locate

required
basedir str | None

The base directory to lookup files. Optional.

None

Returns:

Type Description
str

The absolute filename, if the file has been found.

Raises:

Type Description
TaskException

if the file has not been found.

tryLocatingToolsFile(filename, tool_type, toolsdir)

Tries to locate a tools file.

The functions will try to locate a tools file by:

  1. Checking if the tools file with an absolute path exists
  2. Checking if the tools file exists in the current directory
  3. Checking if the tools file exists in the tools directory
  4. Checking if the tools file is part of the python package

Parameters:

Name Type Description Default
filename str

The name of the file to locate

required
tool_type str

The type of the tool, e.g., css for css files

required
toolsdir str

The tools directory

required

Returns:

Type Description
str

The absolute filename, if the file has been found.

Raises:

Type Description
TaskException

if the file has not been found.