ebm.cmd.prepare_main module
Utility functions for __main__
- class EbmConfig(default_input: str = None, calibration_year: int = 2023, years: YearRange = YearRange(start=2020, end=2050), output_directory: Path = PosixPath('output'), input_directory: Path = PosixPath('input'), force_overwrite: bool = False, open_after_writing: bool = False, csv_delimiter: str = ',', always_open: bool = False, write_to_disk: bool = False)[source]
Bases:
objectPrototype for an argument or configuation class to be used by main. Its purpose is improved readability.
- default_input: str = None
- calibration_year: int = 2023
- output_directory: Path = PosixPath('output')
- input_directory: Path = PosixPath('input')
- force_overwrite: bool = False
- open_after_writing: bool = False
- csv_delimiter: str = ','
- always_open: bool = False
- write_to_disk: bool = False
- __init__(default_input: str = None, calibration_year: int = 2023, years: YearRange = YearRange(start=2020, end=2050), output_directory: Path = PosixPath('output'), input_directory: Path = PosixPath('input'), force_overwrite: bool = False, open_after_writing: bool = False, csv_delimiter: str = ',', always_open: bool = False, write_to_disk: bool = False) None
- make_arguments(program_name, default_path: Path) Namespace[source]
Create and parse command-line arguments for the area forecast calculation.
Parameters
- program_namestr
Name of this program
- default_pathpathlib.Path
Default path for the output file.
Returns
- argparse.Namespace
Parsed command-line arguments.
Notes
The function sets up an argument parser with various options including version, debug mode, filename, force write, open file after writing, CSV delimiter, building categories, creating default input, start year, and end year.
- check_output_file_status(output_file: Path, force: bool = False, default_path: Path = None, program_name: str = 'ebm') ReturnCode[source]
Checks if the output file exists and that it is writable. If force is true the output_file will be opened for appending. A permission denied at that point is an indication that the file is already open by another process.
- The following values may be returned
0 RETURN_CODE_OK
1 RETURN_CODE_FILE_NOT_ACCESSIBLE
2 RETURN_CODE_FILE_EXISTS
Parameters
output_file : pathlib.Path force : bool default_path : pathlib.Path program_name : str
Returns
ReturnCode