Skip to content

Commit 4434b36

Browse files
committed
Preprocess: Close destination file after completion
1 parent 8e818f4 commit 4434b36

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

commands/preprocess_cssless.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ def preprocess_html_merge_css(src_path, dst_path):
3232
cssutils.log.setLog(log)
3333

3434
with open(src_path, 'r') as a_file:
35-
with warnings.catch_warnings():
36-
warnings.simplefilter("ignore")
37-
content = transform(a_file.read(), base_url=src_path)
38-
head = os.path.dirname(dst_path)
39-
os.makedirs(head, exist_ok=True)
40-
f = open(dst_path,"w")
41-
f.write(content)
35+
content = a_file.read()
36+
37+
with warnings.catch_warnings():
38+
warnings.simplefilter("ignore")
39+
content = transform(content, base_url=src_path)
40+
41+
head = os.path.dirname(dst_path)
42+
os.makedirs(head, exist_ok=True)
43+
44+
with open(dst_path,"w") as a_file:
45+
a_file.write(content)
4246

4347
return output.getvalue()

0 commit comments

Comments
 (0)