From 6d86ef792b6157ed9ec4ee13554fdb8da24e6994 Mon Sep 17 00:00:00 2001 From: theychx Date: Sun, 22 Apr 2018 23:23:46 +0200 Subject: [PATCH] Use create dir when saving state to config dir (#90) --- catt/cli.py | 2 +- catt/controllers.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/catt/cli.py b/catt/cli.py index b3dfae2..d67ace2 100644 --- a/catt/cli.py +++ b/catt/cli.py @@ -290,7 +290,7 @@ def save(settings, path): if path and path.exists(): click.confirm("File already exists. Overwrite?", abort=True) click.echo("Saving...") - state = CastState(path or STATE_PATH) + state = CastState(path or STATE_PATH, create_dir=True if not path else False) state.set_data(cst.cc_name, {"controller": cst.name, "data": cst.media_info}) diff --git a/catt/controllers.py b/catt/controllers.py index 6a9c301..1f7fb0e 100644 --- a/catt/controllers.py +++ b/catt/controllers.py @@ -201,9 +201,10 @@ def get_data(self, name): class CastState(CattStore): - def __init__(self, state_path): + def __init__(self, state_path, create_dir=False): super(CastState, self).__init__(state_path) - + if create_dir: + self._create_store_dir() if not self.store_path.exists(): self._write_store({})