1.8. find

This module provides a means by which data files distributed with the application can be found at run time by searching a configurable set of directories.

1.8.1. Data

DATA_DIRECTORY_NAME = 'king_phisher'[source]

The name of the directory containing the King Phisher data.

ENV_VAR = 'KING_PHISHER_DATA_PATH'[source]

The name of the environment variable which contains the search path.

1.8.2. Functions

data_path_append(path)[source]

Add a directory to the data search path. The directory will be used by the data_file() and data_directory() functions.

Parameters:path (str) – The path to add for searching.
data_directory(name, access_mode=4)[source]

Locate a subdirectory in the data search path.

Parameters:
  • name (str) – The directory name to locate.
  • access_mode (int) – The access that is required for the directory.
Returns:

The path to the located directory.

Return type:

str

data_file(name, access_mode=4)[source]

Locate a data file by searching the directories specified in ENV_VAR. If access_mode is specified, it needs to be a value suitable for use with os.access().

Parameters:
  • name (str) – The name of the file to locate.
  • access_mode (int) – The access that is required for the file.
Returns:

The path to the located file.

Return type:

str

init_data_path(directory=None)[source]

Add a directory to the data search path for either client or server data files.

Parameters:directory (str) – The directory to add, either ‘client’ or ‘server’.