Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, filename=None, size_limit=SIZE_LIM, out_dir='./', n_coarse_chan=None, coarse_chans=None):
"""
:param filename: string, name of file (.h5 or .fil)
:param size_limit: float, maximum size in MB that the file is allowed to be
:param out_dir: string, directory where output files should be saved
"""
if filename and os.path.isfile(filename):
self.filename = filename
self.out_dir = out_dir
self.n_coarse_chan = n_coarse_chan
self.coarse_chans = coarse_chans
if not h5py.is_hdf5(filename):
if not sigproc.is_filterbank(filename):
raise IOError('No correct format, need .h5. Try again...')
else:
logger.info("File .fil detected. Attempting to create .h5 file in current directory...")
try:
self.__make_h5_file()
except:
raise IOError('Unable to create .h5 file. Please, try again with correct format.')
self.filestat = os.stat(filename)
self.filesize = self.filestat.st_size/(1024.0**2)
# Grab header from DATAH5
dobj_master = DATAH5(filename)
self.header = dobj_master.header
dobj_master.close()