class_docstr: A helper class for performing atomic writes. Usage::
  
      with AtomicWriter(path).open() as f:
          f.write(...)
  
  :param path: The destination filepath. May or may not exist.
  :param mode: The filemode for the temporary file. This defaults to `wb` in
      Python 2 and `w` in Python 3.
  :param overwrite: If set to false, an error is raised if ``path`` exists.
      Errors are only raised after the file has been written to.  Either way,
      the operation is atomic.
  :param open_kwargs: Keyword-arguments to pass to the underlying
      :py:func:`open` call. This can be used to set the encoding when opening
      files in text-mode.
  
  If you need further control over the exact behavior, you are encouraged to
  subclass.
class_docstr_tok: ["A","helper","class","for","performing","atomic","writes",".","Usage",":",":","with","AtomicWriter","(","path",")",".open","(",")","as","f",":","f.write","(","...",")",":","param","path",":","The","destination","filepath",".","May","or","may","not","exist",".",":","param","mode",":","The","filemode","for","the","temporary","file",".","This","defaults","to","`","wb","`","in","Python","2","and","`","w","`","in","Python","3.",":","param","overwrite",":","If","set","to","false",",","an","error","is","raised","if","``","path","``","exists",".","Errors","are","only","raised","after","the","file","has","been","written","to",".","Either","way",",","the","operation","is","atomic",".",":","param","open_kwargs",":","Keyword-arguments","to","pass","to","the","underlying",":","py",":","func",":","`","open","`","call",".","This","can","be","used","to","set","the","encoding","when","opening","files","in","text-mode",".","If","you","need","further","control","over","the","exact","behavior",",","you","are","encouraged","to","subclass","."]
code: def __init__(
      self, path, mode=DEFAULT_MODE, overwrite=False, **open_kwargs
  ):
      if "a" in mode:
          raise ValueError(
              "Appending to an existing file is not supported, because that "
              "would involve an expensive `copy`-operation to a temporary "
              "file. Open the file in normal `w`-mode and copy explicitly "
              "if that's what you're after."
          )
      if "x" in mode:
          raise ValueError("Use the `overwrite`-parameter instead.")
      if "w" not in mode:
          raise ValueError("AtomicWriters can only be written to.")
  
      # Attempt to convert `path` to `str` or `bytes`
      if fspath is not None:
          path = fspath(path)
  
      self._path = path
      self._mode = mode
      self._overwrite = overwrite
      self._open_kwargs = open_kwargs
  
file_path: catboost/contrib/python/atomicwrites/py2/atomicwrites/__init__.py
imports: import contextlib
  import io
  import os
  import sys
  import tempfile
label_desc: Use image node_id 1 to create a new AtomicWriter object from inherited base classes: object with example: obj = AtomicWriter(path, mode, overwrite)