fix support for csv file argument
This commit is contained in:
parent
4d9c02ddee
commit
2f20cf4fd5
|
@ -57,6 +57,13 @@ def parse_arguments() -> dict:
|
|||
help="Path to the configuration file",
|
||||
required=False,
|
||||
)
|
||||
argparser.add_argument(
|
||||
"--csv-file",
|
||||
action="store",
|
||||
type=Path,
|
||||
help="Path to the csv file, which stores the last fetched dates",
|
||||
required=False,
|
||||
)
|
||||
argparser.add_argument(
|
||||
"--log-file",
|
||||
action="store",
|
||||
|
@ -85,7 +92,7 @@ def update_config_with_args(config: dict, args: dict) -> dict:
|
|||
update_config = {
|
||||
"services": args.get("services"),
|
||||
"locations": args.get("locations"),
|
||||
"csv_path": args.get("csv_path"),
|
||||
"csv_path": args.get("csv_file"),
|
||||
}
|
||||
for key, value in update_config.items():
|
||||
if value is not None:
|
||||
|
@ -139,16 +146,21 @@ def define_csv_path(csv_path: str|None, csv_name: str|None) -> Path:
|
|||
csv_path = Path(csv_path) if csv_path else None
|
||||
csv_name = Path(csv_name) if csv_name else None
|
||||
|
||||
if csv_path is not None and csv_path.is_file():
|
||||
return csv_path
|
||||
elif csv_path is not None and csv_path.is_dir() and csv_name is not None:
|
||||
if csv_path is not None and csv_path.is_dir() and csv_name is not None:
|
||||
return csv_path / csv_name
|
||||
elif csv_path is not None and csv_path.is_dir() and csv_name is None:
|
||||
return csv_path / "cgn-appointments.csv"
|
||||
elif csv_path is not None:
|
||||
csv_path.touch()
|
||||
return csv_path
|
||||
elif csv_name is not None:
|
||||
return Path(user_data_dir()) / csv_name
|
||||
csv_path = Path(user_data_dir()) / csv_name
|
||||
csv_path.touch()
|
||||
return csv_path
|
||||
else:
|
||||
return Path(user_data_dir()) / "cgn-appointments.csv"
|
||||
csv_path = Path(user_data_dir()) / "cgn-appointments"
|
||||
csv_path.touch()
|
||||
return csv_path / "cgn-appointments.csv"
|
||||
|
||||
|
||||
def select_options(services, selects):
|
||||
|
|
Loading…
Reference in a new issue