summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-03-26 16:17:29 +1300
committerSimon Glass <sjg@chromium.org>2021-04-06 16:33:19 +1200
commit7570d9bb47be24d9d73518742703f32126af8113 (patch)
treebee0353aea9010248bd5671b26c8342878c92567 /tools
parent4ce5b8104a1f09c41c69d17f21d9aac567173312 (diff)
downloadu-boot-7570d9bb47be24d9d73518742703f32126af8113.tar.gz
u-boot-7570d9bb47be24d9d73518742703f32126af8113.tar.xz
u-boot-7570d9bb47be24d9d73518742703f32126af8113.zip
moveconfig: Handle binary files cleanly
Some files are not actually source code and thus can produce unicode errors. Report this and continue. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/moveconfig.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/tools/moveconfig.py b/tools/moveconfig.py
index 9514d9a00c..1ac30c0028 100755
--- a/tools/moveconfig.py
+++ b/tools/moveconfig.py
@@ -12,6 +12,10 @@ config options from headers to Kconfig (defconfig).
This tool intends to help this tremendous work.
+Installing
+----------
+
+You may need to install 'python3-asteval' for the 'asteval' module.
Usage
-----
@@ -573,7 +577,11 @@ def cleanup_empty_blocks(header_path, options):
"""
pattern = re.compile(r'^\s*#\s*if.*$\n^\s*#\s*endif.*$\n*', flags=re.M)
with open(header_path) as f:
- data = f.read()
+ try:
+ data = f.read()
+ except UnicodeDecodeError as e:
+ print("Failed on file %s': %s" % (header_path, e))
+ return
new_data = pattern.sub('\n', data)
@@ -596,7 +604,11 @@ def cleanup_one_header(header_path, patterns, options):
options: option flags.
"""
with open(header_path) as f:
- lines = f.readlines()
+ try:
+ lines = f.readlines()
+ except UnicodeDecodeError as e:
+ print("Failed on file %s': %s" % (header_path, e))
+ return
matched = []
for i, line in enumerate(lines):