def _instancecheck_impl(self, value, info: Info) -> InfoMsg:
if not isinstance(value, str):
return info.errormsg(self)
is_valid = True
if os.path.exists(value):
if os.path.isdir(value) and os.access(os.path.abspath(value), os.W_OK)\
and (self.constraint is None or self.constraint(value)):
return info.wrap(True)
return info.errormsg(self)
abs_name = os.path.abspath(value)
dir_name = os.path.dirname(abs_name)
if os.path.exists(dir_name) and os.access(dir_name, os.EX_OK) and os.access(dir_name, os.W_OK) \
and (self.constraint is None or self.constraint(value)):
return info.wrap(True)
return info.errormsg(self)
评论列表
文章目录