Metadata-Version: 2.1
Name: safer
Version: 0.9.5
Summary: Try to import all modules below a given root
Home-page: https://github.com/rec/safer
Author: Tom Ritchford
Author-email: tom@swirly.com
License: MIT
Keywords: testing,modules
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Utilities

✏️safer ✏️
----------------------

Safely write or print to a file, leaving it unchanged if there's an exception

Writes happen on a temporary file, which is only copied over the original file
when the context completes successfully.

This means that ``safer`` will temporarily use as much disk space as the old
file and the new file put together.


Example:

.. code-block:: python

   import safer

   with safer.open(filename, 'w') as fp:
       for line in source():
          fp.write('this and that')

       if CHANGED_MY_MIND:
           # filename will be unchanged
           raise ValueError

   # or

   with safer.printer(filename) as print:
       print('this', 'and', 'that')
       print('two', 'lines', sep='\n', end='\n---\n')

       if CHANGED_MY_MIND:
           # filename will be unchanged
           raise ValueError


