We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5330332 commit 81f6611Copy full SHA for 81f6611
lib/bald/__init__.py
@@ -1,5 +1,6 @@
1
import contextlib
2
import copy
3
+import os
4
import re
5
import time
6
@@ -641,12 +642,17 @@ def load(afilepath):
641
642
elif afilepath.endswith('.nc'):
643
loader = netCDF4.Dataset
644
else:
- raise ValueError('filepath suffix not supported')
645
+ raise ValueError('filepath suffix not supported: {}'.format(afilepath))
646
+ if not os.path.exists(afilepath):
647
+ raise IOError('{} not found'.format(afilepath))
648
try:
649
f = loader(afilepath, "r")
650
yield f
651
finally:
- f.close()
652
+ try:
653
+ f.close()
654
+ except NameError:
655
+ pass
656
657
def load_netcdf(afilepath, baseuri=None, alias_dict=None, cache=None):
658
"""
0 commit comments