diff options
author | Nitroretro <nitroretro@protonmail.com> | 2020-04-28 23:07:07 +0300 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2020-05-01 22:32:23 -0400 |
commit | 9fb532abe4f55db654863ca3fa7bf877f4990875 (patch) | |
tree | 74dd4f9b145395387df4f2e9a47e42e764130d48 /contrib/caldav | |
parent | f2918b1700974831fd891b17e7e2126ffa454519 (diff) | |
download | calcurse-9fb532abe4f55db654863ca3fa7bf877f4990875.tar.gz calcurse-9fb532abe4f55db654863ca3fa7bf877f4990875.zip |
calcurse-caldav: Make check_dir create directories
This patch makes check_dir(dir) create directories if they don't exist,
and it will fail if the path at dir is not a directory. It acts in a
similar fashion to io_check_dir from io.c.
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'contrib/caldav')
-rwxr-xr-x | contrib/caldav/calcurse-caldav.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/contrib/caldav/calcurse-caldav.py b/contrib/caldav/calcurse-caldav.py index beea376..cb777d8 100755 --- a/contrib/caldav/calcurse-caldav.py +++ b/contrib/caldav/calcurse-caldav.py @@ -4,6 +4,7 @@ import argparse import base64 import configparser import httplib2 +import pathlib import os import re import subprocess @@ -37,9 +38,10 @@ def die(msg): def check_dir(dir): - if not os.path.isdir(dir): - die("invalid directory: {0}".format(dir)) - + try: + pathlib.Path(dir).mkdir(parents=True, exist_ok=True) + except FileExistsError: + die("{} is not a directory".format(dir)) def die_atnode(msg, node): if debug: |