dm_config_parser
¶
Config parser module.
DMConfigParser
¶
DMConfigParser()
Class to parse a configuration file for device connections and runtime options.
CONFIG_FILE_PATH_ENV_VARIABLE
class-attribute
instance-attribute
¶
CONFIG_FILE_PATH_ENV_VARIABLE = 'TM_DEVICES_CONFIG'
The name of the environment variable to check for a custom config file path.
This environment variable is checked to see if there is a user-provided path to a custom config file that contains a list of devices and hostnames/IP addresses.
DEFAULT_CONFIG_FILE_PATH
class-attribute
instance-attribute
¶
DEFAULT_CONFIG_FILE_PATH = './tm_devices.yaml'
The default location for the config file.
If present, the file should contain a list of devices and hostnames/IP addresses. See the configuration documentation for the config file syntax.
DEVICES_ENV_VARIABLE
class-attribute
instance-attribute
¶
DEVICES_ENV_VARIABLE = 'TM_DEVICES'
The name of the environment variable which can contain a list of device configurations.
Multiple devices are separated by “~~~”, each device contains a comma-separated list of device parameters to use when connecting to the device. See the configuration documentation for the device configuration environment variable syntax.
FileType
class-attribute
instance-attribute
¶
FileType = ConfigFileType
A convenience enumeration listing the valid config file types.
OPTIONS_ENV_VARIABLE
class-attribute
instance-attribute
¶
OPTIONS_ENV_VARIABLE = 'TM_OPTIONS'
The name of the environment variable which can contain a comma-separated list of options.
See the configuration documentation for the options environment variable syntax.
defined_config_file_path
property
¶
defined_config_file_path: str
Filepath of the config file.
Prioritizes the path contained in the environment variable defined by
DMConfigParser.CONFIG_FILE_PATH_ENV_VARIABLE
with a fallback to the default path defined by
DMConfigParser.DEFAULT_CONFIG_FILE_PATH.
devices
property
¶
devices: Mapping[str, DeviceConfigEntry]
Return the device dict as a read-only object.
add_device
¶
add_device(
*,
device_type: DeviceTypes | str,
address: str,
connection_type: ConnectionTypes | str = TCPIP,
alias: str | None = None,
lan_port: int | None = None,
lan_device_endpoint: str | None = None,
serial_config: SerialConfig | None = None,
device_driver: str | None = None,
gpib_board_number: int | None = None
) -> tuple[str, DeviceConfigEntry]
Add a new device configuration entry.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
load_config_file
¶
remove_device
¶
remove_device(device_name: str) -> None
Remove a device from the configuration.
| Parameters: |
|
|---|
to_config_file_text
¶
to_config_file_text(file_type: ConfigFileType = YAML) -> str
Return string representation of instance as config file contents.
| Parameters: |
|
|---|
update_options
¶
update_options(new_options: DMConfigOptions) -> None
Update the current configuration options.
This ensures that any time new options are loaded in only explicitly defined options will be updated.
| Parameters: |
|
|---|
write_config_to_file
¶
Write the current configuration to a config file.
This method will overwrite any existing config file with the current devices and options. If
no custom path is provided, it will write to the file defined by
DMConfigParser.defined_config_file_path.
| Parameters: |
|---|
| Returns: |
|
|---|