Set the timezone.csv path in config.

Take into account that TZCODES_FILE can be created with a rule.
labels
junos 2021-12-15 18:09:30 +01:00
parent 352598f3da
commit e5cc02501f
3 changed files with 13 additions and 3 deletions

View File

@ -31,6 +31,7 @@ TIMEZONE:
SINGLE: SINGLE:
TZCODE: Europe/Ljubljana TZCODE: Europe/Ljubljana
MULTIPLE: MULTIPLE:
TZ_FILE: data/external/timezone.csv
TZCODES_FILE: data/external/multiple_timezones.csv TZCODES_FILE: data/external/multiple_timezones.csv
IF_MISSING_TZCODE: USE_DEFAULT IF_MISSING_TZCODE: USE_DEFAULT
DEFAULT_TZCODE: Europe/Ljubljana DEFAULT_TZCODE: Europe/Ljubljana

View File

@ -114,7 +114,16 @@ def input_tzcodes_file(wilcards):
if not config["TIMEZONE"]["MULTIPLE"]["TZCODES_FILE"].lower().endswith(".csv"): if not config["TIMEZONE"]["MULTIPLE"]["TZCODES_FILE"].lower().endswith(".csv"):
raise ValueError("[TIMEZONE][MULTIPLE][TZCODES_FILE] should point to a CSV file, instead you typed: " + config["TIMEZONE"]["MULTIPLE"]["TZCODES_FILE"]) raise ValueError("[TIMEZONE][MULTIPLE][TZCODES_FILE] should point to a CSV file, instead you typed: " + config["TIMEZONE"]["MULTIPLE"]["TZCODES_FILE"])
if not Path(config["TIMEZONE"]["MULTIPLE"]["TZCODES_FILE"]).exists(): if not Path(config["TIMEZONE"]["MULTIPLE"]["TZCODES_FILE"]).exists():
raise ValueError("[TIMEZONE][MULTIPLE][TZCODES_FILE] should point to a CSV file, the file in the path you typed does not exist: " + config["TIMEZONE"]["MULTIPLE"]["TZCODES_FILE"]) try:
config["TIMEZONE"]["MULTIPLE"]["TZ_FILE"]
except KeyError:
raise ValueError("To create TZCODES_FILE, a list of timezones should be created " +
"with the rule preprocessing.smk/prepare_tzcodes_file " +
"which will create a file specified as config['TIMEZONE']['MULTIPLE']['TZ_FILE']." +
"\n An alternative is to provide the file manually:" +
"[TIMEZONE][MULTIPLE][TZCODES_FILE] should point to a CSV file," +
"but the file in the path you typed does not exist: " +
config["TIMEZONE"]["MULTIPLE"]["TZCODES_FILE"])
return [config["TIMEZONE"]["MULTIPLE"]["TZCODES_FILE"]] return [config["TIMEZONE"]["MULTIPLE"]["TZCODES_FILE"]]
return [] return []

View File

@ -9,13 +9,13 @@ rule query_usernames_device_empatica_ids:
baseline_folder = "/mnt/e/STRAWbaseline/" baseline_folder = "/mnt/e/STRAWbaseline/"
output: output:
usernames_file = config["CREATE_PARTICIPANT_FILES"]["USERNAMES_CSV"], usernames_file = config["CREATE_PARTICIPANT_FILES"]["USERNAMES_CSV"],
timezone_file = "data/external/timezone.csv" timezone_file = config["TIMEZONE"]["MULTIPLE"]["TZ_FILE"]
script: script:
"../../participants/prepare_usernames_file.py" "../../participants/prepare_usernames_file.py"
rule prepare_tzcodes_file: rule prepare_tzcodes_file:
input: input:
timezone_file = "data/external/timezone.csv" timezone_file = config["TIMEZONE"]["MULTIPLE"]["TZ_FILE"]
output: output:
tzcodes_file = config["TIMEZONE"]["MULTIPLE"]["TZCODES_FILE"] tzcodes_file = config["TIMEZONE"]["MULTIPLE"]["TZCODES_FILE"]
script: script: