diff --git a/ports/stm32/boards/plli2svalues.py b/ports/stm32/boards/plli2svalues.py index f872c60ebb5c5..8fdf6c0d7a187 100644 --- a/ports/stm32/boards/plli2svalues.py +++ b/ports/stm32/boards/plli2svalues.py @@ -4,6 +4,7 @@ Those processors are listed below in the mcu_support_plli2s[] list. """ +import gzip import re from collections import namedtuple @@ -129,7 +130,7 @@ def generate_c_table(plli2s_table, hse, pllm): def search_header(filename, re_define, lookup): regex_define = re.compile(re_define) val = None - with open(filename) as f: + with gzip.open(filename, "rt") as f: for line in f: line = line.strip() m = regex_define.match(line) diff --git a/ports/stm32/boards/pllvalues.py b/ports/stm32/boards/pllvalues.py index 5558d04c5b9e1..2e607861e24b5 100644 --- a/ports/stm32/boards/pllvalues.py +++ b/ports/stm32/boards/pllvalues.py @@ -4,6 +4,7 @@ for the machine.freq() function. """ +import gzip import re @@ -231,7 +232,7 @@ def search_header_for_hsx_values(filename): regex_def = re.compile( r"static.* +(micropy_hw_hs[ei]_value) = +([0-9 +-/\*()]+);", ) - with open(filename) as f: + with gzip.open(filename, "rt") as f: for line in f: line = line.strip() m = regex_def.match(line) diff --git a/py/makeqstrdefs.py b/py/makeqstrdefs.py index dd514c7033dd7..1f7bbc67a4689 100644 --- a/py/makeqstrdefs.py +++ b/py/makeqstrdefs.py @@ -5,7 +5,7 @@ This script works with Python 3.3+. """ -import io +import gzip import os import re import subprocess @@ -71,7 +71,7 @@ def run(files): except NotImplementedError: cpus = 1 p = multiprocessing.dummy.Pool(cpus) - with open(args.output[0], "wb") as out_file: + with gzip.open(args.output[0], "wb", compresslevel=1) as out_file: for flags, sources in ( (args.cflags, csources), (args.cxxflags, cxxsources), @@ -230,7 +230,7 @@ class Args: pass if args.command == "split": - with io.open(args.input_filename, encoding="utf-8") as infile: + with gzip.open(args.input_filename, "rt", encoding="utf-8") as infile: process_file(infile) if args.command == "cat":