From f5b0f92bb718dff195a4d99d498bdd3b2d835dd2 Mon Sep 17 00:00:00 2001 From: David Leach Date: Wed, 23 Jun 2021 15:18:22 -0500 Subject: [PATCH] scripts: dictionary: rename parser module to avoid name collision The parser module collides with a module in python called parser. Doesn't seem to be a problem in Linux but for some reason the search/include order in Windows causes python to import the wrong parser. The change is to rename the module to dictionary_parser to avoid the name space collision. fixes: #36339 Signed-off-by: David Leach --- scripts/logging/dictionary/database_gen.py | 8 ++++---- .../dictionary/{parser => dictionary_parser}/__init__.py | 0 .../{parser => dictionary_parser}/log_database.py | 0 .../{parser => dictionary_parser}/log_parser.py | 0 .../{parser => dictionary_parser}/log_parser_v1.py | 0 .../dictionary/{parser => dictionary_parser}/utils.py | 0 scripts/logging/dictionary/log_parser.py | 8 ++++---- 7 files changed, 8 insertions(+), 8 deletions(-) rename scripts/logging/dictionary/{parser => dictionary_parser}/__init__.py (100%) rename scripts/logging/dictionary/{parser => dictionary_parser}/log_database.py (100%) rename scripts/logging/dictionary/{parser => dictionary_parser}/log_parser.py (100%) rename scripts/logging/dictionary/{parser => dictionary_parser}/log_parser_v1.py (100%) rename scripts/logging/dictionary/{parser => dictionary_parser}/utils.py (100%) diff --git a/scripts/logging/dictionary/database_gen.py b/scripts/logging/dictionary/database_gen.py index 52749cdecf9..d0f6d288bb2 100755 --- a/scripts/logging/dictionary/database_gen.py +++ b/scripts/logging/dictionary/database_gen.py @@ -18,8 +18,8 @@ import os import struct import sys -import parser.log_database -from parser.log_database import LogDatabase +import dictionary_parser.log_database +from dictionary_parser.log_database import LogDatabase import elftools from elftools.elf.elffile import ELFFile @@ -175,7 +175,7 @@ def process_kconfigs(elf, database): database.set_tgt_bits(64 if "CONFIG_64BIT" in kconfigs else 32) # Architecture - for name, arch in parser.log_database.ARCHS.items(): + for name, arch in dictionary_parser.log_database.ARCHS.items(): if arch['kconfig'] in kconfigs: database.set_arch(name) break @@ -194,7 +194,7 @@ def extract_static_string_sections(elf, database): # Some architectures may put static strings into additional sections. # So need to extract them too. - arch_data = parser.log_database.ARCHS[database.get_arch()] + arch_data = dictionary_parser.log_database.ARCHS[database.get_arch()] if "extra_string_section" in arch_data: string_sections.extend(arch_data['extra_string_section']) diff --git a/scripts/logging/dictionary/parser/__init__.py b/scripts/logging/dictionary/dictionary_parser/__init__.py similarity index 100% rename from scripts/logging/dictionary/parser/__init__.py rename to scripts/logging/dictionary/dictionary_parser/__init__.py diff --git a/scripts/logging/dictionary/parser/log_database.py b/scripts/logging/dictionary/dictionary_parser/log_database.py similarity index 100% rename from scripts/logging/dictionary/parser/log_database.py rename to scripts/logging/dictionary/dictionary_parser/log_database.py diff --git a/scripts/logging/dictionary/parser/log_parser.py b/scripts/logging/dictionary/dictionary_parser/log_parser.py similarity index 100% rename from scripts/logging/dictionary/parser/log_parser.py rename to scripts/logging/dictionary/dictionary_parser/log_parser.py diff --git a/scripts/logging/dictionary/parser/log_parser_v1.py b/scripts/logging/dictionary/dictionary_parser/log_parser_v1.py similarity index 100% rename from scripts/logging/dictionary/parser/log_parser_v1.py rename to scripts/logging/dictionary/dictionary_parser/log_parser_v1.py diff --git a/scripts/logging/dictionary/parser/utils.py b/scripts/logging/dictionary/dictionary_parser/utils.py similarity index 100% rename from scripts/logging/dictionary/parser/utils.py rename to scripts/logging/dictionary/dictionary_parser/utils.py diff --git a/scripts/logging/dictionary/log_parser.py b/scripts/logging/dictionary/log_parser.py index bfbe379c159..273b0cc239f 100755 --- a/scripts/logging/dictionary/log_parser.py +++ b/scripts/logging/dictionary/log_parser.py @@ -16,8 +16,8 @@ import binascii import logging import sys -import parser -from parser.log_database import LogDatabase +import dictionary_parser +from dictionary_parser.log_database import LogDatabase LOGGER_FORMAT = "%(message)s" @@ -63,7 +63,7 @@ def main(): if args.hex: if args.rawhex: # Simply log file with only hexadecimal data - logdata = parser.utils.convert_hex_file_to_bin(args.logfile) + logdata = dictionary_parser.utils.convert_hex_file_to_bin(args.logfile) else: hexdata = '' @@ -109,7 +109,7 @@ def main(): logfile.close() - log_parser = parser.get_parser(database) + log_parser = dictionary_parser.get_parser(database) if log_parser is not None: logger.debug("# Build ID: %s", database.get_build_id()) logger.debug("# Target: %s, %d-bit", database.get_arch(), database.get_tgt_bits())