def _is_valid(self, *args, **kwargs): try: from netCDF4 import Dataset filename = args[0] with Dataset(filename) as f: f.variables['connect1'] return True except: pass
def _is_valid(self, *args, **kwargs): warn_netcdf(args[0]) try: from netCDF4 import Dataset filename = args[0] # We use keepweakref here to avoid holding onto the file handle # which can interfere with other is_valid calls. with Dataset(filename, keepweakref=True) as f: f.variables['connect1'] return True except Exception: pass