Config

Class that allows for reading and modification of a configuration (config) file. A config file is not required but using one will make using DAPT much easier to use and greatly increase increase it’s functionality. A configuration file is simply a JSON file. There are some reserved keys but you can add your own and refer to them throughout your program.

Fields

There are several standard fields (keys) that are used by DAPT for credentials and parameter settings.

Fields Description
last-test (str) The last test id that was run.
user-name (str) The box username of the user.
sheets-spreedsheet-id (str) The Google spreedsheet ID being used.
sheets-creds-path (str) The Google Sheets credentials file path.
sheets-worksheet-id (str) The Google Sheets worksheet id. Sheets are indexed at 0.
sheets-worksheet-title (str) The Google Sheets worksheet title.
client-id (str) Box API client ID.
client-secret (str) Box API client secret.
box-folder-id (str) The box folder id to use
reset-time (str) The time that the box access-token needs to be refreshed.
num-of-runs (int) The number of paramater sets to run.
computer-strength (int) Any comments such as error messages relating to the parameter set.
access-token (str) The box access token for the particular session.
refresh-token (str) The box refresh token for the particular session.
remove-zip (bool) Have tools.data_cleanup() remove zip files if true.
remove-movie (bool) Have tools.data_cleanup() remove mp4 files if true.
class dapt.config.Config(path='config.json')

Class which loads and allows for editing of a config file

Parameters:path (string) – path to config file
static create(path='config.json')

Creates a config file with the reserved keys inserted.

Parameters:path (string) – path where config file will be written
get_value(key, recursive=False)

Get the first value of the given key or return None if one doesn’t exist.

Parameters:
  • key (str or list) – the key (given as a string) or List containing the path to the value
  • recursive (bool) – recursively look through the config for the given key. False by default. If recursive is set to True then key must be a string.
Returns:

The value associated to the given key or None if the key is not in the dictionary.

has_value(key)

Checks to see if the config contains the key and a value other than None.

Parameters:key (str) – The key to determine if it has a value
Returns:True if the key has a value, False otherwise.
read_config()

Reads the file with path set to self.path

Returns:Dictionary of config file
static safe(path='config.json')

Safe config file by removing accessToken and refreshToken.

Parameters:path (string) – path where config file will be writen
update_config(key=None, value=None)

Given a key and associated value, updated the config file. Alternatively, you can give no arguments and the config dict will be saved. You can also do both.

Parameters:
  • key (str) – the key to use. If none is given then nothing will be updated in the dictionary.
  • value (str) – the value associated ot the key.
Returns:

Dictionary of config file