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:
- Checking if the file with an absolute path exists
- Checking if the file relative to the basedir exists
- 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:
- Checking if the tools file with an absolute path exists
- Checking if the tools file exists in the current directory
- Checking if the tools file exists in the tools directory
- 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., |
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. |