From 2645383a6f4975e5b06c0c19f47d092e00f9170c Mon Sep 17 00:00:00 2001 From: Martin Sekera Date: Tue, 16 Feb 2021 17:58:09 +0100 Subject: [PATCH] fix callback.path ignoring the 'exists' attr on writable paths --- over/callback.py | 10 ++++++++-- over/version.py | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/over/callback.py b/over/callback.py index 807ed35..179451b 100644 --- a/over/callback.py +++ b/over/callback.py @@ -81,8 +81,14 @@ def path(exists=False, permissions=None, validators=None): if permissions: if "r" in permissions and not os.access(path, os.R_OK): raise PermissionError("%s is not readable" %(arg)) - if "w" in permissions and not os.access(path, os.W_OK): - raise PermissionError("%s is not writable" %(arg)) + + if exists or os.path.exists(path): + if "w" in permissions and not os.access(path, os.W_OK): + raise PermissionError("%s is not writable" %(arg)) + else: + if "w" in permissions and not os.access(os.path.dirname(path), os.W_OK): + raise PermissionError("%s cannot be created" %(arg)) + if "x" in permissions and not os.access(path, os.X_OK): raise PermissionError("%s is not executable" %(arg)) diff --git a/over/version.py b/over/version.py index dcc0238..c9a41f7 100644 --- a/over/version.py +++ b/over/version.py @@ -4,5 +4,5 @@ major = 2 # VERSION_MAJOR_IDENTIFIER minor = 1 # VERSION_MINOR_IDENTIFIER # VERSION_LAST_MM 2.1 -patch = 9 # VERSION_PATCH_IDENTIFIER -str = "2.1.9" # VERSION_STRING_IDENTIFIER +patch = 10 # VERSION_PATCH_IDENTIFIER +str = "2.1.10" # VERSION_STRING_IDENTIFIER