from __future__ import division

def open(filename, mode='a'):
  import h5py
  handle = h5py.File(filename, mode)
  if 'entry' in handle:
    entry = handle['entry']
    assert(entry.attrs['NX_class'] == 'NXentry')
  else:
    entry = handle.create_group('entry')
    entry.attrs['NX_class'] = 'NXentry'
  return entry

def load(filename):
  from dials.util.nexus import nx_diffraction, nx_mx
  entry = open(filename, "r")
  ref, exp_index = nx_diffraction.load(entry)
  exp = nx_mx.load(entry, exp_index)
  return exp, ref

def dump(experiments, reflections, filename):
  from dials.util.nexus import nx_diffraction, nx_mx
  entry = open(filename, "w")
  experiments = nx_mx.dump(entry, experiments)
  nx_diffraction.dump(entry, reflections, experiments)

@@ -30,20 +30,25 @@
 on%0A%0Adef 
-open
+get_entry
 (filenam
@@ -393,36 +393,41 @@
 nx_mx%0A  entry = 
-open
+get_entry
 (filename, %22r%22)%0A
@@ -641,12 +641,17 @@
 y = 
-open
+get_entry
 (fil

resolve naming conflict with python built-in function