def _validate_fname(fname, arg_name):
if fname is not None:<EOL><INDENT>msg = "<STR_LIT>".format(arg_name)<EOL>if (not isinstance(fname, str)) or (isinstance(fname, str) and ("<STR_LIT>" in fname)):<EOL><INDENT>raise RuntimeError(msg)<EOL><DEDENT>try:<EOL><INDENT>if not os.path.exists(fname):<EOL><INDENT>os.access(fname, os.W_OK)<EOL><DEDENT><DEDENT>except (TypeError, ValueError):  <EOL><INDENT>raise RuntimeError(msg)<EOL><DEDENT><DEDENT>
Validate that a string is a valid file name.