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