@ValidateLarchPlugin
def restore(fname,  group=None, _larch=None):
    """restore groups and data from an hdf5 Larch Save file

    restore(fname, group=None)

    Parameters
    ----------
       fname   name of output Larch save file (required)
       group   top-level group to put data in [None]

   Returns
   -------
       top-level grouop containing restored subgroups and data.

   If group is None, a group will be created and returned.

   See Also:  save()
   """
    symtable = _larch.symtable
    msg  = _larch.writer.write
    fh = h5py.File(fname, 'r')

    if fh.attrs.get('datatype', None) != 'LarchSaveFile':
        msg(fname % "File  '%s' is not a valid larch save file\n")
        return
    create_group = _larch.symtable.create_group

    from larch_plugins.xafs import (FeffPathGroup, FeffDatFile,
                                    FeffitDataSet, TransformGroup)

    def make_group(h5group):
        creators = {'TransformGroup': TransformGroup,
                    'FeffDatFile':    FeffDatFile,
                    'FeffitDataSet':  FeffitDataSet,
                    'FeffPathGroup':  FeffPathGroup}
        gtype = h5group.attrs.get('class', None)
        return creators.get(gtype, create_group)(_larch=_larch)

    def get_component(val):
        if isinstance(val, h5py.Group):
            ltype = val.attrs.get('larchtype', None)
            if ltype == 'group':
                me = make_group(val)
                for skey, sval in val.items():
                    setattr(me, skey, get_component(sval))
                return me
            elif ltype == 'parameter':
                kws = json.loads(val['json'].value)
                if kws['expr'] is not None:
                    kws.pop('val')
                kws['_larch'] = _larch
                return Parameter(**kws)
            elif ltype in ('list', 'tuple'):
                me = []
                for skey, sval in  val.items():
                    me.append(get_component(sval))
                if ltype == 'tuple':
                    me = tuple(me)
                return me
            elif ltype == 'dict':
                me = {}
                for skey, sval in  val.items():
                    me[skey] = get_component(sval)
                return me
        elif isinstance(val, h5py.Dataset):
            return val.value

    # walk through items in hdf5 save file
    if group is None:
        group = create_group()
    for  key, val in fh.items():
        setattr(group, key, get_component(val))
    fh.close()
    return group
dataset/ETHPy150Open xraypy/xraylarch/plugins/io/save_restore.py/restore/swapped operands of `%`