<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> import logging <EOL> import uuid <EOL> from distutils import version <EOL> import numpy as np <EOL> import quantities as pq <EOL> try : <EOL> import tables as tb <EOL> except ImportError as err : <EOL> HAVE_TABLES = False <EOL> TABLES_ERR = err <EOL> else : <EOL> if version . LooseVersion ( tb . __version__ ) < '<STR_LIT>' : <EOL> HAVE_TABLES = False <EOL> TABLES_ERR = ImportError ( "<STR_LIT>" + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" % tb . __version__ ) <EOL> else : <EOL> HAVE_TABLES = True <EOL> TABLES_ERR = None <EOL> from neo . core import Block , objectlist , objectnames , class_by_name <EOL> from neo . io . baseio import BaseIO <EOL> from neo . io . tools import LazyList <EOL> logger = logging . getLogger ( "<STR_LIT>" ) <EOL> def _func_wrapper ( func ) : <EOL> try : <EOL> return func <EOL> except IOError : <EOL> raise IOError ( "<STR_LIT>" ) <EOL> complex_relationships = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> lazy_shape_arrays = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } <EOL> class NeoHdf5IO ( BaseIO ) : <EOL> """<STR_LIT>""" <EOL> supported_objects = objectlist <EOL> readable_objects = objectlist <EOL> writeable_objects = objectlist <EOL> read_params = dict ( zip ( objectlist , [ ] * len ( objectlist ) ) ) <EOL> write_params = dict ( zip ( objectlist , [ ] * len ( objectlist ) ) ) <EOL> name = '<STR_LIT>' <EOL> extensions = [ '<STR_LIT>' ] <EOL> mode = '<STR_LIT:file>' <EOL> is_readable = True <EOL> is_writable = True <EOL> def __init__ ( self , filename = None , array_dtype = np . float64 , ** kwargs ) : <EOL> if not HAVE_TABLES : <EOL> raise TABLES_ERR <EOL> BaseIO . __init__ ( self , filename = filename ) <EOL> self . array_dtype = array_dtype <EOL> self . connected = False <EOL> self . objects_by_ref = { } <EOL> self . parent_paths = { } <EOL> self . name_indices = { } <EOL> if filename : <EOL> self . connect ( filename = filename ) <EOL> def _read_entity ( self , path = "<STR_LIT:/>" , cascade = True , lazy = False ) : <EOL> """<STR_LIT>""" <EOL> ob = self . get ( path , cascade , lazy ) <EOL> if cascade and cascade != '<STR_LIT>' : <EOL> ob . create_many_to_one_relationship ( ) <EOL> return ob <EOL> def _write_entity ( self , obj , where = "<STR_LIT:/>" , cascade = True , lazy = False ) : <EOL> """<STR_LIT>""" <EOL> self . save ( obj , where , cascade , lazy ) <EOL> def connect ( self , filename ) : <EOL> """<STR_LIT>""" <EOL> if not self . connected : <EOL> try : <EOL> if tb . isHDF5File ( filename ) : <EOL> self . _data = tb . openFile ( filename , mode = "<STR_LIT:a>" , title = filename ) <EOL> self . connected = True <EOL> else : <EOL> raise TypeError ( '<STR_LIT>' % filename ) <EOL> except IOError : <EOL> self . _data = tb . openFile ( filename , mode = "<STR_LIT:w>" , title = filename ) <EOL> self . connected = True <EOL> except : <EOL> raise NameError ( "<STR_LIT>" ) <EOL> self . objects_by_ref = { } <EOL> self . name_indices = { } <EOL> else : <EOL> logger . info ( "<STR_LIT>" ) <EOL> def close ( self ) : <EOL> """<STR_LIT>""" <EOL> self . objects_by_ref = { } <EOL> self . parent_paths = { } <EOL> self . name_indices = { } <EOL> self . _data . close ( ) <EOL> self . connected = False <EOL> def _get_class_by_node ( self , node ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> obj_type = node . _f_getAttr ( "<STR_LIT>" ) <EOL> return class_by_name [ obj_type ] <EOL> except : <EOL> return None <EOL> def _update_path ( self , obj , node ) : <EOL> setattr ( obj , "<STR_LIT>" , node . _v_pathname ) <EOL> def _get_next_name ( self , obj_type , where ) : <EOL> """<STR_LIT>""" <EOL> if not ( obj_type , where ) in self . name_indices : <EOL> self . name_indices [ ( obj_type , where ) ] = <NUM_LIT:0> <EOL> index_num = self . name_indices [ ( obj_type , where ) ] <EOL> prefix = str ( obj_type ) + "<STR_LIT:_>" <EOL> if where + '<STR_LIT:/>' + prefix + str ( index_num ) not in self . _data : <EOL> self . name_indices [ ( obj_type , where ) ] = index_num + <NUM_LIT:1> <EOL> return prefix + str ( index_num ) <EOL> nodes = [ ] <EOL> for node in self . _data . iterNodes ( where ) : <EOL> index = node . _v_name [ node . _v_name . find ( prefix ) + len ( prefix ) : ] <EOL> if len ( index ) > <NUM_LIT:0> : <EOL> try : <EOL> nodes . append ( int ( index ) ) <EOL> except ValueError : <EOL> pass <EOL> nodes . sort ( reverse = True ) <EOL> if len ( nodes ) > <NUM_LIT:0> : <EOL> self . name_indices [ ( obj_type , where ) ] = nodes [ <NUM_LIT:0> ] + <NUM_LIT:2> <EOL> return prefix + str ( nodes [ <NUM_LIT:0> ] + <NUM_LIT:1> ) <EOL> else : <EOL> self . name_indices [ ( obj_type , where ) ] = <NUM_LIT:1> <EOL> return prefix + "<STR_LIT:0>" <EOL> @ _func_wrapper <EOL> def save ( self , obj , where = "<STR_LIT:/>" , cascade = True , lazy = False ) : <EOL> """<STR_LIT>""" <EOL> def assign_attribute ( obj_attr , attr_name , path , node ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( obj_attr , pq . Quantity ) or isinstance ( obj_attr , np . ndarray ) : <EOL> if not lazy : <EOL> if isinstance ( obj_attr , pq . Quantity ) : <EOL> for un in obj_attr . dimensionality . keys ( ) : <EOL> if not un . name in pq . units . __dict__ or not isinstance ( pq . units . __dict__ [ un . name ] , pq . Quantity ) : <EOL> obj_attr = obj_attr . simplified <EOL> break <EOL> if obj_attr . size == <NUM_LIT:0> : <EOL> np_type = obj_attr . dtype if self . array_dtype is None else self . array_dtype <EOL> atom = tb . Atom . from_dtype ( np . dtype ( ( np_type , ( <NUM_LIT:1> , ) ) ) ) <EOL> new_arr = self . _data . createEArray ( path , attr_name + "<STR_LIT>" , atom , shape = ( <NUM_LIT:0> , ) , expectedrows = <NUM_LIT:1> ) <EOL> else : <EOL> new_arr = self . _data . createArray ( path , attr_name + "<STR_LIT>" , obj_attr ) <EOL> if hasattr ( obj_attr , "<STR_LIT>" ) : <EOL> for un in obj_attr . dimensionality . items ( ) : <EOL> new_arr . _f_setAttr ( "<STR_LIT>" + un [ <NUM_LIT:0> ] . name , un [ <NUM_LIT:1> ] ) <EOL> try : <EOL> self . _data . removeNode ( path , attr_name ) <EOL> except : <EOL> pass <EOL> self . _data . renameNode ( path , attr_name , name = attr_name + "<STR_LIT>" ) <EOL> elif obj_attr is not None : <EOL> node . _f_setAttr ( attr_name , obj_attr ) <EOL> obj_type = obj . __class__ . __name__ <EOL> if self . _data . mode != '<STR_LIT:w>' and hasattr ( obj , "<STR_LIT>" ) : <EOL> path = str ( obj . hdf5_path ) <EOL> try : <EOL> node = self . _data . getNode ( obj . hdf5_path ) <EOL> except tb . NoSuchNodeError : <EOL> raise LookupError ( "<STR_LIT>" % path ) <EOL> else : <EOL> node = self . _data . createGroup ( where , self . _get_next_name ( obj_type , where ) ) <EOL> node . _f_setAttr ( "<STR_LIT>" , obj_type ) <EOL> path = node . _v_pathname <EOL> if len ( getattr ( obj , '<STR_LIT>' , [ ] ) ) > <NUM_LIT:1> : <EOL> for par_cont in obj . _single_parent_containers : <EOL> node . _f_setAttr ( par_cont , '<STR_LIT>' ) <EOL> for attr in obj . _all_attrs : <EOL> if hasattr ( obj , attr [ <NUM_LIT:0> ] ) : <EOL> assign_attribute ( getattr ( obj , attr [ <NUM_LIT:0> ] ) , attr [ <NUM_LIT:0> ] , path , node ) <EOL> if hasattr ( obj , '<STR_LIT>' ) : <EOL> assign_attribute ( obj , obj . _quantity_attr , path , node ) <EOL> if hasattr ( obj , "<STR_LIT>" ) : <EOL> node . _f_setAttr ( "<STR_LIT>" , getattr ( obj , "<STR_LIT>" ) ) <EOL> node . _f_setAttr ( "<STR_LIT>" , uuid . uuid4 ( ) . hex ) <EOL> if cascade : <EOL> for container in getattr ( obj , '<STR_LIT>' , [ ] ) : <EOL> try : <EOL> ch = self . _data . getNode ( node , container ) <EOL> except tb . NoSuchNodeError : <EOL> ch = self . _data . createGroup ( node , container ) <EOL> saved = [ ] <EOL> for child in getattr ( obj , container ) : <EOL> new_name = None <EOL> child_node = None <EOL> if hasattr ( child , "<STR_LIT>" ) : <EOL> if not child . hdf5_path . startswith ( ch . _v_pathname ) : <EOL> try : <EOL> target = self . _data . getNode ( child . hdf5_path ) <EOL> new_name = self . _get_next_name ( <EOL> child . __class__ . __name__ , ch . _v_pathname ) <EOL> if not hasattr ( ch , new_name ) : <EOL> child_node = self . _data . createHardLink ( ch . _v_pathname , new_name , target ) <EOL> except tb . NoSuchNodeError : <EOL> pass <EOL> if child_node is None : <EOL> child_node = self . save ( child , where = ch . _v_pathname ) <EOL> if len ( child . _single_parent_containers ) > <NUM_LIT:1> : <EOL> child_node . _f_setAttr ( obj_type . lower ( ) , path ) <EOL> for par_cont in child . _multi_parent_containers : <EOL> parents = [ ] <EOL> if par_cont in child_node . _v_attrs : <EOL> parents = child_node . _v_attrs [ par_cont ] <EOL> parents . append ( path ) <EOL> child_node . _f_setAttr ( par_cont , parents ) <EOL> if not new_name : <EOL> new_name = child . hdf5_path . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] <EOL> saved . append ( new_name ) <EOL> for child in self . _data . iterNodes ( ch . _v_pathname ) : <EOL> if child . _v_name not in saved : <EOL> self . _data . removeNode ( ch . _v_pathname , child . _v_name , recursive = True ) <EOL> self . _update_path ( obj , node ) <EOL> return node <EOL> def _get_parent ( self , path , ref , parent_type ) : <EOL> """<STR_LIT>""" <EOL> parts = path . split ( '<STR_LIT:/>' ) <EOL> if ( parent_type . lower ( ) == '<STR_LIT>' or <EOL> parts [ - <NUM_LIT:4> ] == parent_type . lower ( ) + '<STR_LIT:s>' ) : <EOL> return '<STR_LIT:/>' . join ( parts [ : - <NUM_LIT:2> ] ) <EOL> object_folder = parts [ - <NUM_LIT:2> ] <EOL> parent_folder = parts [ - <NUM_LIT:4> ] <EOL> if parent_folder in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> block_path = '<STR_LIT:/>' . join ( parts [ : - <NUM_LIT:6> ] ) <EOL> else : <EOL> block_path = '<STR_LIT:/>' . join ( parts [ : - <NUM_LIT:4> ] ) <EOL> if parent_type . lower ( ) in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> path = block_path + '<STR_LIT>' <EOL> for n in self . _data . iterNodes ( path ) : <EOL> if not '<STR_LIT>' in n . _v_attrs : <EOL> continue <EOL> p = self . _search_parent ( <EOL> '<STR_LIT>' % ( n . _v_pathname , parent_type . lower ( ) ) , <EOL> object_folder , ref ) <EOL> if p != '<STR_LIT>' : <EOL> return p <EOL> return '<STR_LIT>' <EOL> if parent_type . lower ( ) == '<STR_LIT>' : <EOL> path = block_path + '<STR_LIT>' <EOL> elif parent_type . lower ( ) in ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) : <EOL> path = block_path + '<STR_LIT>' <EOL> else : <EOL> return '<STR_LIT>' <EOL> return self . _search_parent ( path , object_folder , ref ) <EOL> def _get_rcgs ( self , path , ref ) : <EOL> """<STR_LIT>""" <EOL> parts = path . split ( '<STR_LIT:/>' ) <EOL> object_folder = parts [ - <NUM_LIT:2> ] <EOL> block_path = '<STR_LIT:/>' . join ( parts [ : - <NUM_LIT:4> ] ) <EOL> path = block_path + '<STR_LIT>' <EOL> return self . _search_parent ( path , object_folder , ref , True ) <EOL> def _search_parent ( self , path , object_folder , ref , multi = False ) : <EOL> """<STR_LIT>""" <EOL> if multi : <EOL> ret = [ ] <EOL> else : <EOL> ret = '<STR_LIT>' <EOL> for n in self . _data . iterNodes ( path ) : <EOL> if not '<STR_LIT>' in n . _v_attrs : <EOL> continue <EOL> for c in self . _data . iterNodes ( n . _f_getChild ( object_folder ) ) : <EOL> try : <EOL> if c . _f_getAttr ( "<STR_LIT>" ) == ref : <EOL> if not multi : <EOL> return n . _v_pathname <EOL> else : <EOL> ret . append ( n . _v_pathname ) <EOL> except AttributeError : <EOL> pass <EOL> return ret <EOL> _second_parent = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } <EOL> def load_lazy_cascade ( self , path , lazy ) : <EOL> """<STR_LIT>""" <EOL> o = self . get ( path , cascade = '<STR_LIT>' , lazy = lazy ) <EOL> t = type ( o ) . __name__ <EOL> node = self . _data . getNode ( path ) <EOL> if not path in self . parent_paths : <EOL> ppaths = [ ] <EOL> if len ( getattr ( o , '<STR_LIT>' , [ ] ) ) > <NUM_LIT:1> : <EOL> for par_cont in o . _single_parent_containers : <EOL> if par_cont in node . _v_attrs : <EOL> ppaths . append ( node . _f_getAttr ( par_cont ) ) <EOL> else : <EOL> ppaths . append ( None ) <EOL> self . parent_paths [ path ] = ppaths <EOL> elif t == '<STR_LIT>' : <EOL> if '<STR_LIT>' in node . _v_attrs : <EOL> self . parent_paths [ path ] = node . _f_getAttr ( '<STR_LIT>' ) <EOL> if path in self . parent_paths : <EOL> paths = self . parent_paths [ path ] <EOL> if t == '<STR_LIT>' : <EOL> for rcg in self . parent_paths [ path ] : <EOL> o . recordingchannelgroups . append ( self . get ( rcg , cascade = '<STR_LIT>' , lazy = lazy ) ) <EOL> else : <EOL> if paths [ <NUM_LIT:0> ] is None : <EOL> paths [ <NUM_LIT:0> ] = self . _get_parent ( <EOL> path , self . _data . getNodeAttr ( path , '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> if paths [ <NUM_LIT:0> ] : <EOL> o . segment = self . get ( paths [ <NUM_LIT:0> ] , cascade = '<STR_LIT>' , lazy = lazy ) <EOL> parent = self . _second_parent [ t ] <EOL> if paths [ <NUM_LIT:1> ] is None : <EOL> paths [ <NUM_LIT:1> ] = self . _get_parent ( <EOL> path , self . _data . getNodeAttr ( path , '<STR_LIT>' ) , <EOL> parent ) <EOL> if paths [ <NUM_LIT:1> ] : <EOL> setattr ( o , parent . lower ( ) , self . get ( paths [ <NUM_LIT:1> ] , cascade = '<STR_LIT>' , lazy = lazy ) ) <EOL> elif t != '<STR_LIT>' : <EOL> ref = self . _data . getNodeAttr ( path , '<STR_LIT>' ) <EOL> if t == '<STR_LIT>' : <EOL> rcg_paths = self . _get_rcgs ( path , ref ) <EOL> for rcg in rcg_paths : <EOL> o . recordingchannelgroups . append ( self . get ( rcg , cascade = '<STR_LIT>' , lazy = lazy ) ) <EOL> self . parent_paths [ path ] = rcg_paths <EOL> else : <EOL> for p in o . _single_parent_containers : <EOL> parent = self . _get_parent ( path , ref , p ) <EOL> if parent : <EOL> setattr ( o , p . lower ( ) , self . get ( parent , cascade = '<STR_LIT>' , lazy = lazy ) ) <EOL> return o <EOL> def load_lazy_object ( self , obj ) : <EOL> """<STR_LIT>""" <EOL> return self . get ( obj . hdf5_path , cascade = False , lazy = False , lazy_loaded = True ) <EOL> @ _func_wrapper <EOL> def get ( self , path = "<STR_LIT:/>" , cascade = True , lazy = False , lazy_loaded = False ) : <EOL> """<STR_LIT>""" <EOL> def fetch_attribute ( attr_name , attr , node ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> if attr [ <NUM_LIT:1> ] == pq . Quantity : <EOL> arr = self . _data . getNode ( node , attr_name ) <EOL> units = "<STR_LIT>" <EOL> for unit in arr . _v_attrs . _f_list ( attrset = '<STR_LIT:user>' ) : <EOL> if unit . startswith ( "<STR_LIT>" ) : <EOL> units += "<STR_LIT>" + str ( unit [ <NUM_LIT:6> : ] ) + "<STR_LIT>" + str ( arr . _f_getAttr ( unit ) ) <EOL> units = units . replace ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:1> ) <EOL> if not lazy or sum ( arr . shape ) <= <NUM_LIT:1> : <EOL> nattr = pq . Quantity ( arr . read ( ) , units ) <EOL> else : <EOL> nattr = pq . Quantity ( np . empty ( tuple ( [ <NUM_LIT:0> for _ in range ( attr [ <NUM_LIT:2> ] ) ] ) ) , units ) <EOL> elif attr [ <NUM_LIT:1> ] == np . ndarray : <EOL> arr = self . _data . getNode ( node , attr_name ) <EOL> if not lazy : <EOL> nattr = np . array ( arr . read ( ) , attr [ <NUM_LIT:3> ] ) <EOL> if nattr . shape == ( <NUM_LIT:0> , <NUM_LIT:1> ) : <EOL> nattr = nattr . reshape ( - <NUM_LIT:1> ) <EOL> else : <EOL> nattr = np . empty ( <NUM_LIT:0> , attr [ <NUM_LIT:3> ] ) <EOL> else : <EOL> nattr = node . _f_getAttr ( attr_name ) <EOL> if attr [ <NUM_LIT:1> ] == str or attr [ <NUM_LIT:1> ] == int : <EOL> nattr = attr [ <NUM_LIT:1> ] ( nattr ) <EOL> except ( AttributeError , tb . NoSuchNodeError ) : <EOL> nattr = None <EOL> return nattr <EOL> def get_lazy_shape ( obj , node ) : <EOL> attr = lazy_shape_arrays [ type ( obj ) . __name__ ] <EOL> arr = self . _data . getNode ( node , attr ) <EOL> return arr . shape <EOL> if path == "<STR_LIT:/>" : <EOL> found = False <EOL> for n in self . _data . iterNodes ( path ) : <EOL> for obj_type in objectnames : <EOL> if obj_type . lower ( ) in str ( n . _v_name ) . lower ( ) : <EOL> path = n . _v_pathname <EOL> found = True <EOL> if found : <EOL> break <EOL> try : <EOL> if path == "<STR_LIT:/>" : <EOL> raise ValueError ( ) <EOL> node = self . _data . getNode ( path ) <EOL> except ( tb . NoSuchNodeError , ValueError ) : <EOL> raise LookupError ( "<STR_LIT>" + <EOL> str ( path ) + '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> classname = self . _get_class_by_node ( node ) <EOL> if not classname : <EOL> raise LookupError ( "<STR_LIT>" + str ( path ) + <EOL> "<STR_LIT>" ) <EOL> obj_type = classname . __name__ <EOL> try : <EOL> object_ref = self . _data . getNodeAttr ( node , '<STR_LIT>' ) <EOL> except AttributeError : <EOL> object_ref = None <EOL> if object_ref in self . objects_by_ref and not lazy_loaded : <EOL> obj = self . objects_by_ref [ object_ref ] <EOL> if cascade == '<STR_LIT>' or obj_type not in complex_relationships : <EOL> return obj <EOL> else : <EOL> kwargs = { } <EOL> attrs = classname . _necessary_attrs + classname . _recommended_attrs <EOL> for i , attr in enumerate ( attrs ) : <EOL> attr_name = attr [ <NUM_LIT:0> ] <EOL> nattr = fetch_attribute ( attr_name , attr , node ) <EOL> if nattr is not None : <EOL> kwargs [ attr_name ] = nattr <EOL> obj = class_by_name [ obj_type ] ( ** kwargs ) <EOL> if lazy and obj_type in lazy_shape_arrays : <EOL> obj . lazy_shape = get_lazy_shape ( obj , node ) <EOL> self . _update_path ( obj , node ) <EOL> try : <EOL> setattr ( obj , "<STR_LIT>" , node . _f_getAttr ( "<STR_LIT>" ) ) <EOL> except AttributeError : <EOL> pass <EOL> if object_ref and not lazy_loaded : <EOL> self . objects_by_ref [ object_ref ] = obj <EOL> if cascade : <EOL> for containername in getattr ( obj , '<STR_LIT>' , [ ] ) : <EOL> if cascade == '<STR_LIT>' : <EOL> relatives = LazyList ( self , lazy ) <EOL> else : <EOL> relatives = [ ] <EOL> container = self . _data . getNode ( node , containername ) <EOL> for n in self . _data . iterNodes ( container ) : <EOL> if cascade == '<STR_LIT>' : <EOL> relatives . append ( n . _v_pathname ) <EOL> else : <EOL> try : <EOL> typename = n . _f_getAttr ( "<STR_LIT>" ) . lower ( ) + '<STR_LIT:s>' <EOL> if typename == containername : <EOL> relatives . append ( self . get ( n . _v_pathname , lazy = lazy ) ) <EOL> except AttributeError : <EOL> pass <EOL> setattr ( obj , containername , relatives ) <EOL> if not cascade == '<STR_LIT>' : <EOL> if obj_type == "<STR_LIT>" and containername == "<STR_LIT>" : <EOL> for r in relatives : <EOL> r . recordingchannel = obj <EOL> if obj_type == "<STR_LIT>" and not object_ref : <EOL> for r in relatives : <EOL> r . recordingchannelgroups = [ obj ] <EOL> if obj_type == "<STR_LIT>" : <EOL> if hasattr ( node , '<STR_LIT>' ) : <EOL> parent = node . _v_parent <EOL> if hasattr ( parent , '<STR_LIT>' ) : <EOL> parent = parent . _v_parent <EOL> if '<STR_LIT>' in parent . _v_attrs : <EOL> obj . recordingchannelgroups . append ( self . get ( <EOL> parent . _v_pathname , lazy = lazy ) ) <EOL> return obj <EOL> @ _func_wrapper <EOL> def read_all_blocks ( self , lazy = False , cascade = True , ** kargs ) : <EOL> """<STR_LIT>""" <EOL> blocks = [ ] <EOL> for n in self . _data . iterNodes ( self . _data . root ) : <EOL> if self . _get_class_by_node ( n ) == Block : <EOL> blocks . append ( self . read_block ( n . _v_pathname , lazy = lazy , cascade = cascade , ** kargs ) ) <EOL> return blocks <EOL> @ _func_wrapper <EOL> def write_all_blocks ( self , blocks , ** kargs ) : <EOL> """<STR_LIT>""" <EOL> for b in blocks : <EOL> self . write_block ( b ) <EOL> @ _func_wrapper <EOL> def delete ( self , path , cascade = False ) : <EOL> """<STR_LIT>""" <EOL> self . _data . removeNode ( path , recursive = cascade ) <EOL> @ _func_wrapper <EOL> def reset ( self , obj ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> @ _func_wrapper <EOL> def get_info ( self ) : <EOL> """<STR_LIT>""" <EOL> logger . info ( "<STR_LIT>" ) <EOL> info = { } <EOL> info = info . fromkeys ( objectnames , <NUM_LIT:0> ) <EOL> for node in self . _data . walkNodes ( ) : <EOL> try : <EOL> t = node . _f_getAttr ( "<STR_LIT>" ) <EOL> info [ t ] += <NUM_LIT:1> <EOL> except : <EOL> pass <EOL> return info <EOL> for obj_type in NeoHdf5IO . writeable_objects : <EOL> setattr ( NeoHdf5IO , "<STR_LIT>" + obj_type . __name__ . lower ( ) , NeoHdf5IO . _write_entity ) <EOL> for obj_type in NeoHdf5IO . readable_objects : <EOL> setattr ( NeoHdf5IO , "<STR_LIT>" + obj_type . __name__ . lower ( ) , NeoHdf5IO . _read_entity ) </s>
