horton_part.scripts.program module
- class PartProg(program_name, width, description=None)
Bases:
object
- __init__(program_name, width, description=None)
- build_parser(*args, **kwargs)
Parse command-line arguments.
- check_settings(settings)
- print_charges(numbers, charges)
- print_coordinates(numbers, coordinates)
- print_header(header)
- print_line()
- print_settings(settings, fn_in, fn_out, fn_log, exclude_keys=None)
Print setting for this program.
- run(args=None)
Main entry.
- Return type:
int
- setup_logger(settings, fn_log, **kwargs)
- single_launch(*args, **kwargs)
Man entry for a single job.
- load_settings_from_yaml_file(args, sub_cmd='part-gen', fn_key='config_file')
Load settings from a YAML configuration file and update the ‘args’ object.
This function reads a YAML file specified by the ‘fn_key’ attribute of the ‘args’ object. It then updates ‘args’ with the settings found under the specified ‘cmd’ section of the YAML file.
- Parameters:
args (argparse.Namespace) – The arguments object, typically obtained from argparse. This object is updated with the settings from the YAML file.
sub_cmd (str, optional) – The key within the YAML file that contains the settings to be loaded. Only settings under this key are used to update ‘args’. Default is ‘part-gen’.
fn_key (str, optional) – The attribute name in ‘args’ that holds the path to the YAML configuration file. Default is ‘config_file’.
- Returns:
The updated arguments object with settings loaded from the YAML file.
- Return type:
argparse.Namespace
- Raises:
AssertionError – If ‘args’ does not have an attribute named ‘fn_key’, or if the ‘cmd’ key is not found in the loaded YAML settings.
Notes
The function asserts that the ‘args’ object has an attribute named as per ‘fn_key’.
It also checks if the specified YAML file exists before attempting to open it.
Settings are loaded only if the ‘cmd’ key is present in the YAML file.
Each setting under the ‘cmd’ section in the YAML file updates the corresponding attribute in the ‘args’ object.