@@ -225,11 +225,6 @@ def _tables():
225
225
return _table_mod
226
226
227
227
228
- def h5_open (path , mode ):
229
- tables = _tables ()
230
- return tables .openFile (path , mode )
231
-
232
-
233
228
@contextmanager
234
229
def get_store (path , ** kwargs ):
235
230
"""
@@ -389,6 +384,10 @@ def root(self):
389
384
self ._check_if_open ()
390
385
return self ._handle .root
391
386
387
+ @property
388
+ def filename (self ):
389
+ return self ._path
390
+
392
391
def __getitem__ (self , key ):
393
392
return self .get (key )
394
393
@@ -475,6 +474,8 @@ def open(self, mode='a'):
475
474
mode : {'a', 'w', 'r', 'r+'}, default 'a'
476
475
See HDFStore docstring or tables.openFile for info about modes
477
476
"""
477
+ tables = _tables ()
478
+
478
479
if self ._mode != mode :
479
480
480
481
# if we are chaning a write mode to read, ok
@@ -501,13 +502,20 @@ def open(self, mode='a'):
501
502
fletcher32 = self ._fletcher32 )
502
503
503
504
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
506
507
if 'can not be written' in str (e ):
507
508
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' )
509
510
else :
510
511
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
511
519
512
520
def close (self ):
513
521
"""
0 commit comments