diff options
author | Nitroretro <nitroretro@protonmail.com> | 2020-04-28 23:10:25 +0300 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2020-05-01 22:35:48 -0400 |
commit | 8fffc9dc8e5dd930785ef00e58000e5b1b2afd25 (patch) | |
tree | f187581fa5d32bc33ed2d45878085f0c2801f820 /contrib | |
parent | 9fb532abe4f55db654863ca3fa7bf877f4990875 (diff) | |
download | calcurse-8fffc9dc8e5dd930785ef00e58000e5b1b2afd25.tar.gz calcurse-8fffc9dc8e5dd930785ef00e58000e5b1b2afd25.zip |
calcurse-caldav: Ensure config and data dirs exist
Fixes #283.
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/caldav/calcurse-caldav.py | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/contrib/caldav/calcurse-caldav.py b/contrib/caldav/calcurse-caldav.py index cb777d8..7c9b89b 100755 --- a/contrib/caldav/calcurse-caldav.py +++ b/contrib/caldav/calcurse-caldav.py @@ -522,20 +522,28 @@ nsmap = {"D": "DAV:", "C": "urn:ietf:params:xml:ns:caldav"} # Initialize default values. if os.path.isdir(os.path.expanduser("~/.calcurse")): - configfn = os.path.expanduser("~/.calcurse/caldav/config") - lockfn = os.path.expanduser("~/.calcurse/caldav/lock") - syncdbfn = os.path.expanduser("~/.calcurse/caldav/sync.db") - hookdir = os.path.expanduser("~/.calcurse/caldav/hooks/") - oauth_file = os.path.expanduser("~/.calcurse/caldav/oauth2_cred") + caldav_path = os.path.expanduser("~/.calcurse/caldav") + check_dir(caldav_path) + + configfn = os.path.join(caldav_path, "config") + hookdir = os.path.join(caldav_path, "hooks") + oauth_file = os.path.join(caldav_path, "oauth2_cred") + lockfn = os.path.join(caldav_path, "lock") + syncdbfn = os.path.join(caldav_path, "sync.db") else: - calcurse_data = os.getenv("XDG_DATA_HOME", os.path.expanduser("~/.local/share")) + "/calcurse" - calcurse_config = os.getenv("XDG_CONFIG_HOME", os.path.expanduser("~/.config")) + "/calcurse" - - configfn = os.path.expanduser(calcurse_config + "/caldav/config") - lockfn = os.path.expanduser(calcurse_data + "/caldav/lock") - syncdbfn = os.path.expanduser(calcurse_data + "/caldav/sync.db") - hookdir = os.path.expanduser(calcurse_config + "/caldav/hooks/") - oauth_file = os.path.expanduser(calcurse_config + "/caldav/oauth2_cred") + xdg_config_home = os.getenv("XDG_CONFIG_HOME", os.path.expanduser("~/.config")) + xdg_data_home = os.getenv("XDG_DATA_HOME", os.path.expanduser("~/.local/share")) + caldav_config = os.path.join(xdg_config_home, "calcurse", "caldav") + caldav_data = os.path.join(xdg_data_home, "calcurse", "caldav") + check_dir(caldav_config) + check_dir(caldav_data) + + configfn = os.path.join(caldav_config, "config") + hookdir = os.path.join(caldav_config, "hooks") + oauth_file = os.path.join(caldav_config, "oauth2_cred") + + lockfn = os.path.join(caldav_data, "lock") + syncdbfn = os.path.join(caldav_data, "sync.db") # Parse command line arguments. parser = argparse.ArgumentParser('calcurse-caldav') |