]> granicus.if.org Git - esp-idf/commitdiff
gen_esp_err_to_name.py: Use normal file I/O instead of mmap()
authorAngus Gratton <angus@espressif.com>
Mon, 21 May 2018 07:33:10 +0000 (17:33 +1000)
committerAngus Gratton <gus@projectgus.com>
Mon, 21 May 2018 07:34:18 +0000 (17:34 +1000)
mmap is different on Python for Windows

tools/gen_esp_err_to_name.py

index 1dfe15bab5aeea41b9f0b8e3f7bb72dce1034263..7281ed55117ca539352a8cc327927751f5e46e56 100755 (executable)
@@ -16,7 +16,6 @@
 
 import os
 import argparse
-import mmap
 import re
 import fnmatch
 import string
@@ -277,19 +276,14 @@ def main():
             idf_path = os.path.relpath(full_path, os.environ['IDF_PATH'])
             if idf_path in ignore_files:
                 continue
-            with open(full_path, "r+b") as f:
-                try:
-                    map = mmap.mmap(f.fileno(), 0, prot=mmap.ACCESS_READ)
-                except ValueError:
-                    pass # An empty file cannot be mmaped
-                else:
-                    for line in iter(map.readline, ""):
-                        # match also ESP_OK and ESP_FAIL because some of ESP_ERRs are referencing them
-                        if re.match(r"\s*#define\s+(ESP_ERR_|ESP_OK|ESP_FAIL)", line):
-                            try:
-                                process(str.strip(line), idf_path)
-                            except InputError as e:
-                                print (e)
+            with open(full_path, "r+") as f:
+                for line in f:
+                    # match also ESP_OK and ESP_FAIL because some of ESP_ERRs are referencing them
+                    if re.match(r"\s*#define\s+(ESP_ERR_|ESP_OK|ESP_FAIL)", line):
+                        try:
+                            process(str.strip(line), idf_path)
+                        except InputError as e:
+                            print (e)
 
     process_remaining_errors()