In this PR I have added setup functionality to create a template user configuration file and template CSV files. If the user tries to create the template file(s) and an existing version already exists, they must pass an --overwrite flag. This prevents the accidental overwrite of data that is not backed up! Tests have been added for the new functionality.
Completes one of the tasks in issue #56
Help info
(otoole) ~/repositories/otoole$ otoole setup --help
usage: otoole setup [-h] [--write_defaults] [--overwrite] {config,csv} data_path
positional arguments:
{config,csv} Type of file to setup
data_path Path to file or folder to save to
optional arguments:
-h, --help show this help message and exit
--write_defaults Writes default values
--overwrite Overwrites existing data
Examples
Create a template user configuration file called config.yaml
Create a template folder of input CSV data, in a folder called data
(otoole) ~$ ls data
ls: cannot access 'data': No such file or directory
(otoole) ~$ otoole setup csv data
(otoole) ~$ ls data
AccumulatedAnnualDemand.csv
AnnualEmissionLimit.csv
...
(otoole) ~$ cat data/AccumulatedAnnualDemand.csv
REGION,FUEL,YEAR,VALUE
(otoole) ~$ cat data/AnnualEmissionLimit.csv
REGION,EMISSION,YEAR,VALUE
Create a template configuration file called config.yaml in a location where a file called config.yaml already exists
Below demonstrates overwrite checks for the config file, but the same error will be raised if a folder of CSVs is written to and the folder name already exists
(otoole) ~$ otoole setup config config.yaml
OtooleSetupError: config.yaml -> Data already exists. Delete file/directory or pass the --overwrite flag
(otoole) ~$ otoole setup config config.yaml --overwrite
(otoole) ~$
Overview
In this PR I have added
setup
functionality to create a template user configuration file and template CSV files. If the user tries to create the template file(s) and an existing version already exists, they must pass an--overwrite
flag. This prevents the accidental overwrite of data that is not backed up! Tests have been added for the new functionality.Completes one of the tasks in issue #56
Help info
Examples
Create a template user configuration file called
config.yaml
Create a template folder of input CSV data, in a folder called
data
Create a template configuration file called
config.yaml
in a location where a file calledconfig.yaml
already existsBelow demonstrates overwrite checks for the config file, but the same error will be raised if a folder of CSVs is written to and the folder name already exists
Documentation
Will add to the
v1.0
doc updates in PR #137