@@ -225,11 +225,6 @@ def _tables():
225225 return _table_mod
226226
227227
228- def h5_open (path , mode ):
229- tables = _tables ()
230- return tables .openFile (path , mode )
231-
232-
233228@contextmanager
234229def get_store (path , ** kwargs ):
235230 """
@@ -389,6 +384,10 @@ def root(self):
389384 self ._check_if_open ()
390385 return self ._handle .root
391386
387+ @property
388+ def filename (self ):
389+ return self ._path
390+
392391 def __getitem__ (self , key ):
393392 return self .get (key )
394393
@@ -475,6 +474,8 @@ def open(self, mode='a'):
475474 mode : {'a', 'w', 'r', 'r+'}, default 'a'
476475 See HDFStore docstring or tables.openFile for info about modes
477476 """
477+ tables = _tables ()
478+
478479 if self ._mode != mode :
479480
480481 # if we are chaning a write mode to read, ok
@@ -501,13 +502,20 @@ def open(self, mode='a'):
501502 fletcher32 = self ._fletcher32 )
502503
503504 try :
504- self ._handle = h5_open (self ._path , self ._mode )
505- except IOError as e : # pragma: no cover
505+ self ._handle = tables . openFile (self ._path , self ._mode )
506+ except ( IOError ) as e : # pragma: no cover
506507 if 'can not be written' in str (e ):
507508 print ('Opening %s in read-only mode' % self ._path )
508- self ._handle = h5_open (self ._path , 'r' )
509+ self ._handle = tables . openFile (self ._path , 'r' )
509510 else :
510511 raise
512+ except (Exception ) as e :
513+
514+ # trying to read from a non-existant file causes an error which
515+ # is not part of IOError, make it one
516+ if self ._mode == 'r' and 'Unable to open/create file' in str (e ):
517+ raise IOError (str (e ))
518+ raise
511519
512520 def close (self ):
513521 """
0 commit comments