# HG changeset patch # User Jeff Hammel # Date 1420232919 28800 # Node ID dc90512b9c984fe2a93059a8f9c49142df80f540 boilerplate diff -r 000000000000 -r dc90512b9c98 README.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.txt Fri Jan 02 13:08:39 2015 -0800 @@ -0,0 +1,11 @@ +AtomicWrite +=========== + +write file contents atomically in one operation + +---- + +Jeff Hammel + +http://k0s.org/hg/AtomicWrite + diff -r 000000000000 -r dc90512b9c98 atomic/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atomic/__init__.py Fri Jan 02 13:08:39 2015 -0800 @@ -0,0 +1,3 @@ +# +from .writer import write + diff -r 000000000000 -r dc90512b9c98 setup.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/setup.py Fri Jan 02 13:08:39 2015 -0800 @@ -0,0 +1,43 @@ +""" +setup packaging script for AtomicWrite +""" + +import os + +version = "0.1" +dependencies = [] + +# allow use of setuptools/distribute or distutils +kw = {} +try: + from setuptools import setup + kw['entry_points'] = """ + [console_scripts] +""" + kw['install_requires'] = dependencies +except ImportError: + from distutils.core import setup + kw['requires'] = dependencies + +try: + here = os.path.dirname(os.path.abspath(__file__)) + description = file(os.path.join(here, 'README.txt')).read() +except IOError: + description = '' + + +setup(name='AtomicWrite', + version=version, + description="write file contents atomically in one operation", + long_description=description, + classifiers=[], # Get strings from http://www.python.org/pypi?%3Aaction=list_classifiers + author='Jeff Hammel', + author_email='k0scist@gmail.com', + url='http://k0s.org/hg/AtomicWrite', + license='MIT', + packages=['atomic'], + include_package_data=True, + zip_safe=False, + **kw + ) + diff -r 000000000000 -r dc90512b9c98 tests/test_atomicwrite.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test_atomicwrite.py Fri Jan 02 13:08:39 2015 -0800 @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +""" +unit tests for AtomicWrite +""" + +import os +import sys +import tempfile +import unittest + +class AtomicWriteUnitTest(unittest.TestCase): + + def test_atomicwrite(self): + tf = tempfile.mktemp() + self.assertFalse(os.path.exists(tf)) + +if __name__ == '__main__': + unittest.main() + diff -r 000000000000 -r dc90512b9c98 tests/testall.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/testall.py Fri Jan 02 13:08:39 2015 -0800 @@ -0,0 +1,40 @@ +#!/usr/bin/env python + +""" +run all unit tests +""" + +import os +import sys +import unittest + +here = os.path.dirname(os.path.abspath(__file__)) + +def main(args=sys.argv[1:]): + + results = unittest.TestResult() + suite = unittest.TestLoader().discover(here, 'test_*.py') + suite.run(results) + n_errors = len(results.errors) + n_failures = len(results.failures) + print ("Run {} tests ({} failures; {} errors)".format(results.testsRun, + n_failures, + n_errors)) + if results.wasSuccessful(): + print ("Success") + sys.exit(0) + else: + # print failures and errors + for label, item in (('FAIL', results.failures), + ('ERROR', results.errors)): + if item: + print ("\n{}::\n".format(label)) + for index, (i, message) in enumerate(item): + print ('{}) {}:'.format(index, str(i))) + print (message) + sys.exit(1) + +if __name__ == '__main__': + main() + +