Skip to content

Commit

Permalink
FIX: #267 (#275)
Browse files Browse the repository at this point in the history
* FIX: use with-statement in `wradlib.io.rainbow.read_rainbow()`, remove logs-file

* FIX: move conditional `loaddata` into with-statement, fix dual use of f
  • Loading branch information
kmuehlbauer committed Aug 2, 2018
1 parent 9eff708 commit 4361cd2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Empty file removed wradlib/io/logs
Empty file.
19 changes: 8 additions & 11 deletions wradlib/io/rainbow.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,18 +438,15 @@ def read_rainbow(f, loaddata=True):
# Check if a file handle has been passed
try:
f.seek(0, 0)
fid = f
rbdict = get_rb_header(f)
if loaddata:
rbdict = get_rb_blobs_from_file(f, rbdict)
except AttributeError:
# If we did not get a file handle, assume that we got a filename and
# get a file handle for the corresponding file
try:
fid = open(f, "rb")
except IOError:
raise IOError("WRADLIB: Error opening Rainbow "
"file '{}' ".format(f))

rbdict = get_rb_header(fid)
# use with-statement to retrieve the file content
with open(f, "rb") as fid:
rbdict = get_rb_header(fid)
if loaddata:
rbdict = get_rb_blobs_from_file(fid, rbdict)

if loaddata:
rbdict = get_rb_blobs_from_file(fid, rbdict)
return rbdict

0 comments on commit 4361cd2

Please sign in to comment.