diff options
author | Onderwaater <onderwaa@esrf.fr> | 2015-12-07 20:36:14 +0100 |
---|---|---|
committer | Onderwaater <onderwaa@esrf.fr> | 2015-12-07 20:36:14 +0100 |
commit | 0fda48b60e9bb4f4b914a9dc6a493992fc1e16fb (patch) | |
tree | cc81b30ceeca90bda33350cc50b253bf3423a8a1 | |
parent | 0826a84daf3626448bb89e2f755b0797f943c3e1 (diff) |
temp saving fix
-rw-r--r-- | README.md | 4 | ||||
-rwxr-xr-x | binoculars/util.py | 21 |
2 files changed, 14 insertions, 11 deletions
@@ -7,7 +7,7 @@ This work has been [published](http://dx.doi.org/10.1107/S1600576715009607) with ## Installation -Grab the [latest sourcecode as zip](https://github.com/id03/binoculars/archive/master.zip) or clone the Git repository. Run `binoculars.py`, `fitaid.py`, `gui.py` or `processgui.py` directly from the command line. +Grab the [latest sourcecode as zip](https://github.com/id03/binoculars/archive/master.zip) or clone the Git repository. Run `binoculars`, `binoculars-fitaid`, `binoculars-gui` or `binoculars-processgui` directly from the command line. ## Usage @@ -17,7 +17,7 @@ The [BINoculars wiki](https://github.com/id03/binoculars/wiki) contains a detail ## Scripting -If you want more complex operations than offered by the command line or GUI tools, you can manipulate BINoculars data directly from Python. Some examples with detailed comments can be found in the [repository](https://github.com/id03/binoculars/tree/master/examples/scripts). The API documentation on the `BINoculars` and `BINoculars.space` modules can be accessed via pydoc, e.g. run `pydoc -w BINoculars BINoculars.space` to generate HTML files. +If you want more complex operations than offered by the command line or GUI tools, you can manipulate BINoculars data directly from Python. Some examples with detailed comments can be found in the [repository](https://github.com/id03/binoculars/tree/master/examples/scripts). The API documentation on the `binoculars` and `binoculars.space` modules can be accessed via pydoc, e.g. run `pydoc -w binoculars binoculars.space` to generate HTML files. ## Extending BINoculars diff --git a/binoculars/util.py b/binoculars/util.py index 940089b..a8a037c 100755 --- a/binoculars/util.py +++ b/binoculars/util.py @@ -802,16 +802,19 @@ def atomic_write(filename): fp.write(...) """ - tmpfile = '{0}-{1}.tmp'.format(os.path.splitext(filename)[0], uniqid()) - try: - yield tmpfile - except: - raise + if isinstance(filename, h5py._hl.group.Group): + yield filename else: - best_effort_atomic_rename(tmpfile, filename) - finally: - if os.path.exists(tmpfile): - os.remove(tmpfile) + tmpfile = '{0}-{1}.tmp'.format(os.path.splitext(filename)[0], uniqid()) + try: + yield tmpfile + except: + raise + else: + best_effort_atomic_rename(tmpfile, filename) + finally: + if os.path.exists(tmpfile): + os.remove(tmpfile) def zpi_save(obj, filename): with atomic_write(filename) as tmpfile: |