+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
+
from __future__ import print_function
from __future__ import absolute_import
from builtins import range
# ArvFile() (file already exists in a collection), UploadFile() (file needs to
# be uploaded to a collection), or simply returns prefix+fn (which yields the
# original parameter string).
-def statfile(prefix, fn, fnPattern="$(file %s/%s)", dirPattern="$(dir %s/%s/)"):
+def statfile(prefix, fn, fnPattern="$(file %s/%s)", dirPattern="$(dir %s/%s/)", raiseOSError=False):
absfn = os.path.abspath(fn)
try:
st = os.stat(absfn)
# trim leading '/' for path prefix test later
return UploadFile(prefix, absfn[1:])
except OSError as e:
- if e.errno == errno.ENOENT:
+ if e.errno == errno.ENOENT and not raiseOSError:
pass
else:
raise