Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ All notable changes to this project will be documented in this file, following t
## v1.0.8 - 2017-08-17
### Fixed
- Changing ascii to utf8 #29

## v1.0.x - 20XX-XX-XX
### Fixed
- Don't leak open file handles #32
3 changes: 2 additions & 1 deletion mmtf/api/default_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def parse(file_path):
:param file_path: the input file path. Data is not entropy compressed (e.g. gzip)
:return an API to decoded data """
newDecoder = MMTFDecoder()
newDecoder.decode_data(msgpack.unpackb(open(file_path, "rb").read()))
with open(file_path, "rb") as fh:
newDecoder.decode_data(msgpack.unpackb(fh.read()))
return newDecoder


Expand Down
4 changes: 2 additions & 2 deletions mmtf/api/mmtf_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ def get_msgpack(self):


def write_file(self, file_path):
out_f = open(file_path, "wb")
out_f.write(self.get_msgpack())
with open(file_path, "wb") as out_f:
out_f.write(self.get_msgpack())


def init_structure(self, total_num_bonds, total_num_atoms,
Expand Down
3 changes: 2 additions & 1 deletion mmtf/tests/codec_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ def test_round_trip(self):
decoded.decode_data(msgpack.unpackb(packed))

def test_gzip_open(self):
ungzip_data(open("mmtf/tests/testdatastore/4CUP.mmtf.gz","rb").read())
with open("mmtf/tests/testdatastore/4CUP.mmtf.gz","rb") as fh:
ungzip_data(fh.read())

def test_fetch(self):
if _internet_on(BASE_URL):
Expand Down