@@ -14,37 +14,39 @@ def decompress(data, uncompressed_size, filters):
1414 writer .write (data )
1515
1616 temp_file_path = mktemp ('.lzham' )
17- with open (temp_file_path , 'wb' ) as f :
18- f .write (writer .buffer )
19- f .close ()
17+ with open (temp_file_path , 'wb' ) as file :
18+ file .write (writer .buffer )
2019
20+ decompressed_path = mktemp ('.lzham' )
2121 if system (f'{ path .dirname (__file__ )} /lzham.exe '
2222 f'-c -d{ filters ["dict_size_log2" ]} '
23- f'd { temp_file_path } { temp_file_path } > nul 2>&1' ):
23+ f'd { temp_file_path } { decompressed_path } > nul 2>&1' ):
24+ remove (temp_file_path )
25+ remove (decompressed_path )
2426 return None
25- with open (temp_file_path , 'rb' ) as f :
26- decompressed = f .read ()
27- f .close ()
27+ with open (decompressed_path , 'rb' ) as file :
28+ decompressed = file .read ()
2829
2930 remove (temp_file_path )
31+ remove (decompressed_path )
3032
3133 return decompressed
3234
3335 @staticmethod
3436 def compress (data , filters ):
3537 temp_file_path = mktemp ('.data' )
36- with open (temp_file_path , 'wb' ) as f :
37- f .write (data )
38- f .close ()
38+ with open (temp_file_path , 'wb' ) as file :
39+ file .write (data )
3940
4041 compressed_path = mktemp ('.lzham' )
4142 if system (f'{ path .dirname (__file__ )} /lzham.exe '
4243 f'-c -d{ filters ["dict_size_log2" ]} '
4344 f'c { temp_file_path } { compressed_path } > nul 2>&1' ):
45+ remove (temp_file_path )
46+ remove (compressed_path )
4447 return None
45- with open (compressed_path , 'rb' ) as f :
46- compressed = f .read ()[13 :]
47- f .close ()
48+ with open (compressed_path , 'rb' ) as file :
49+ compressed = file .read ()[13 :]
4850
4951 remove (temp_file_path )
5052 remove (compressed_path )
0 commit comments