def check_file_exists(self, filename, resolve='<STR_LIT>', force=None):
def _warn(x):<EOL><INDENT>msg = "<STR_LIT>".format(x)<EOL>logger.warn(msg)<EOL>warnings.warn(msg)<EOL>return True<EOL><DEDENT>def _raise(x):<EOL><INDENT>msg = "<STR_LIT>".format(x)<EOL>logger.error(msg)<EOL>raise IOError(errno.EEXIST, x, msg)<EOL><DEDENT>solutions = {'<STR_LIT:ignore>': lambda x: False,      <EOL>'<STR_LIT>': lambda x: True,     <EOL>'<STR_LIT>': _warn,<EOL>'<STR_LIT>': _warn,<EOL>'<STR_LIT>': _raise,<EOL>'<STR_LIT>': _raise,<EOL>}<EOL>if force is True:<EOL><INDENT>resolve = '<STR_LIT:ignore>'<EOL><DEDENT>elif force is False:<EOL><INDENT>resolve = '<STR_LIT>'<EOL><DEDENT>if not os.path.isfile(filename):<EOL><INDENT>return False<EOL><DEDENT>else:<EOL><INDENT>return solutions[resolve](filename)<EOL><DEDENT>
If a file exists then continue with the action specified in ``resolve``.

        ``resolve`` must be one of

        "ignore"
              always return ``False``
        "indicate"
              return ``True`` if it exists
        "warn"
              indicate and issue a :exc:`UserWarning`
        "exception"
              raise :exc:`IOError` if it exists

        Alternatively, set *force* for the following behaviour (which
        ignores *resolve*):

        ``True``
              same as *resolve* = "ignore" (will allow overwriting of files)
        ``False``
              same as *resolve* = "exception" (will prevent overwriting of files)
        ``None``
              ignored, do whatever *resolve* says