File tree 1 file changed +8
-3
lines changed
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ def __new__( # type: ignore
88
88
89
89
file_or_filename : AcceptedIOType = filename
90
90
if suffix == ".gz" :
91
- suffix , file_or_filename = Logger .compress (filename )
91
+ suffix , file_or_filename = Logger .compress (filename , * args , ** kwargs )
92
92
93
93
try :
94
94
return Logger .message_writers [suffix ](file_or_filename , * args , ** kwargs )
@@ -98,13 +98,18 @@ def __new__( # type: ignore
98
98
) from None
99
99
100
100
@staticmethod
101
- def compress (filename : StringPathLike ) -> Tuple [str , FileLike ]:
101
+ def compress (
102
+ filename : StringPathLike , * args : Any , ** kwargs : Any
103
+ ) -> Tuple [str , FileLike ]:
102
104
"""
103
105
Return the suffix and io object of the decompressed file.
104
106
File will automatically recompress upon close.
105
107
"""
106
108
real_suffix = pathlib .Path (filename ).suffixes [- 2 ].lower ()
107
- mode = "ab" if real_suffix == ".blf" else "at"
109
+ if kwargs .get ("append" , False ):
110
+ mode = "ab" if real_suffix == ".blf" else "at"
111
+ else :
112
+ mode = "wb" if real_suffix == ".blf" else "wt"
108
113
109
114
return real_suffix , gzip .open (filename , mode )
110
115
You can’t perform that action at this time.
0 commit comments