Skip to content

Commit

Permalink
Merge pull request #107 from rhytnen/dev
Browse files Browse the repository at this point in the history
Changed method of read validation to use the standard library function.
  • Loading branch information
fcollman committed Feb 5, 2021
2 parents afc2b92 + 4e5144f commit ca40d88
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions argschema/fields/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,11 @@ def validate_input_path(value):
if not os.path.isfile(value):
raise mm.ValidationError("%s is not a file" % value)
else:
if sys.platform == "win32":
try:
with open(value) as f:
s = f.read()
except IOError as x:
if x.errno == errno.EACCES:
raise mm.ValidationError("%s is not readable" % value)
else:
if not os.access(value, os.R_OK):
raise mm.ValidationError("%s is not readable" % value)

try:
with open(value) as f:
pass
except Exception as value:
raise mm.ValidationError("%s is not readable" % value)

class InputDir(mm.fields.Str):
"""InputDir is :class:`marshmallow.fields.Str` subclass which is a path to a
Expand Down

0 comments on commit ca40d88

Please sign in to comment.