We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8fc83ae commit cb27a35Copy full SHA for cb27a35
pythainlp/corpus/__init__.py
@@ -165,12 +165,12 @@ def _check_hash(dst: str, md5: str) -> NoReturn:
165
@param: md5 place to hash the file (MD5)
166
"""
167
if md5 and md5 != "-":
168
- f = open(get_full_data_path(dst), "rb")
169
- content = f.read()
170
- file_md5 = hashlib.md5(content).hexdigest()
+ with open(get_full_data_path(dst), "rb") as f:
+ content = f.read()
+ file_md5 = hashlib.md5(content).hexdigest()
171
172
- if md5 != file_md5:
173
- raise Exception("Hash does not match expected.")
+ if md5 != file_md5:
+ raise Exception("Hash does not match expected.")
174
175
176
def download(name: str, force: bool = False) -> NoReturn:
0 commit comments