Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if header:
with fn.open('r') as f:
yield f
else:
with fn.open('r') as g:
f = io.StringIO(_opencrx(g))
yield f
elif fn.suffix == '.gz':
with gzip.open(fn, 'rt') as f:
yield f
elif fn.suffix == '.zip':
with zipfile.ZipFile(fn, 'r') as z:
flist = z.namelist()
for rinexfn in flist:
with z.open(rinexfn, 'r') as bf:
f = io.TextIOWrapper(bf, newline=None)
yield f
elif fn.suffix == '.Z':
if unlzw is None:
raise ImportError('pip install unlzw')
with fn.open('rb') as zu:
with io.StringIO(unlzw.unlzw(zu.read()).decode('ascii')) as f:
yield f
else:
with fn.open('r') as f:
yield f