Skip to content

Commit 1098f94

Browse files
maubrevilleCopilot
andauthored
Update exact/util/cellvizio.py
See copilot comment, it's sensible to close the filehandle after using it. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent f81612a commit 1098f94

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

exact/util/cellvizio.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ def __init__(self,filename):
9494

9595
def getMetaInfo(self):
9696
# the meta information at the MKT file always starts with "00616C6C 6F776564 5F656761 696E5F65 6F666673 65745F70 61697273 3D" or allowed_egain_eoffset_pairs= in the hex code
97-
self.fileHandle = open(self.fileName, 'rb');
9897
# we need to read the whole file to find the meta information
99-
fileContent = self.fileHandle.read()
100-
# find start position with fileContent.find(b'allowed_egain_eoffset_pairs=') that searches for the byte sequence
101-
metaStart = fileContent.rfind(b'allowed_egain_eoffset_pairs=')
102-
metaEnd = fileContent.find(b'<CEND', metaStart)
103-
metaInfo = fileContent[metaStart:metaEnd].decode('utf-8')
98+
with open(self.fileName, 'rb') as f:
99+
fileContent = f.read()
100+
# find start position with fileContent.find(b'allowed_egain_eoffset_pairs=') that searches for the byte sequence
101+
metaStart = fileContent.rfind(b'allowed_egain_eoffset_pairs=')
102+
metaEnd = fileContent.find(b'<CEND', metaStart)
103+
metaInfo = fileContent[metaStart:metaEnd].decode('utf-8')
104104
print(f"Meta information found: ")
105105
print(metaInfo)
106106
return metaInfo

0 commit comments

Comments
 (0)