changeset 0:dc90512b9c98

boilerplate
author Jeff Hammel <k0scist@gmail.com>
date Fri, 02 Jan 2015 13:08:39 -0800
parents
children a4188f41ca35
files README.txt atomic/__init__.py setup.py tests/test_atomicwrite.py tests/testall.py
diffstat 5 files changed, 117 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /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
+
--- /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
+
--- /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
+      )
+
--- /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()
+
--- /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()
+
+