code: def _check_file(filename, check):
      if not isinstance(filename, str):
          raise Exception(
              f"filename required to check file, got {filename}"
          )
      if check & S_IRANY:
          flags = os.O_RDONLY
      elif check & S_IWANY:
          flags = os.O_WRONLY
      elif check & S_IXANY:
          # We can worry about S_IXANY later
          return NotImplemented
      else:
          raise NotImplementedError(check)
  
      try:
          fd = os.open(filename, flags)
      except PermissionError:
          return False
      # We do not ignore other exceptions.
      else:
          os.close(fd)
          return True
  
imports: import fnmatch
  import glob
  import os
  import os.path
  import shutil
  import stat
  from .iterutil import iter_many
label_desc: Use image node_id 22 for calling a global function with example usage: _check_file(filename, check) and returns: True, False, NotImplemented