def _validate(self, value):
if not os.path.isdir(value):
try:
os.makedirs(value)
if self.mode is not None:
os.chmod(value, self.mode)
except OSError as e:
if e.errno == os.errno.EEXIST:
pass
else:
raise mm.ValidationError(
"{} is not a directory and you cannot create it".format(
value)
)
if self.mode is not None:
try:
assert((os.stat(value).st_mode & 0o777) == self.mode)
except:
raise mm.ValidationError(
"{} does not have the mode ({}) that was specified ".format(
value, self.mode)
)
# use outputfile to test that a file in this location is a valid path
validate_outpath(value)
评论列表
文章目录