calcurse-caldav: Ensure config and data dirs exist
Fixes #283. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
9fb532abe4
commit
8fffc9dc8e
@ -522,20 +522,28 @@ nsmap = {"D": "DAV:", "C": "urn:ietf:params:xml:ns:caldav"}
|
|||||||
|
|
||||||
# Initialize default values.
|
# Initialize default values.
|
||||||
if os.path.isdir(os.path.expanduser("~/.calcurse")):
|
if os.path.isdir(os.path.expanduser("~/.calcurse")):
|
||||||
configfn = os.path.expanduser("~/.calcurse/caldav/config")
|
caldav_path = os.path.expanduser("~/.calcurse/caldav")
|
||||||
lockfn = os.path.expanduser("~/.calcurse/caldav/lock")
|
check_dir(caldav_path)
|
||||||
syncdbfn = os.path.expanduser("~/.calcurse/caldav/sync.db")
|
|
||||||
hookdir = os.path.expanduser("~/.calcurse/caldav/hooks/")
|
|
||||||
oauth_file = os.path.expanduser("~/.calcurse/caldav/oauth2_cred")
|
|
||||||
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")
|
configfn = os.path.join(caldav_path, "config")
|
||||||
lockfn = os.path.expanduser(calcurse_data + "/caldav/lock")
|
hookdir = os.path.join(caldav_path, "hooks")
|
||||||
syncdbfn = os.path.expanduser(calcurse_data + "/caldav/sync.db")
|
oauth_file = os.path.join(caldav_path, "oauth2_cred")
|
||||||
hookdir = os.path.expanduser(calcurse_config + "/caldav/hooks/")
|
lockfn = os.path.join(caldav_path, "lock")
|
||||||
oauth_file = os.path.expanduser(calcurse_config + "/caldav/oauth2_cred")
|
syncdbfn = os.path.join(caldav_path, "sync.db")
|
||||||
|
else:
|
||||||
|
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.
|
# Parse command line arguments.
|
||||||
parser = argparse.ArgumentParser('calcurse-caldav')
|
parser = argparse.ArgumentParser('calcurse-caldav')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user