From f401e775f9e95c353553ff485fd415d19730e7be Mon Sep 17 00:00:00 2001 From: Dale Mitchell Date: Fri, 24 Mar 2023 14:45:41 -0400 Subject: [PATCH 1/2] Fix issue #89 (error when parenthesis symbol in the MPN) --- easyeda2kicad/helpers.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/easyeda2kicad/helpers.py b/easyeda2kicad/helpers.py index 88fde06..7b06c6b 100644 --- a/easyeda2kicad/helpers.py +++ b/easyeda2kicad/helpers.py @@ -43,11 +43,7 @@ def set_logger(log_file: str, log_level: int) -> None: def sanitize_for_regex(field: str): - field = sanitize_fields(field) - chars_to_escape = r"(){}[],;.|\+-?*#^:$" - for char in chars_to_escape: - field = field.replace(char, rf"\{char}") - return field + return re.escape(field) def id_already_in_symbol_lib( From c3b51c96fdeb8a171f40603b747cf6e98ed94d52 Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Mon, 28 Aug 2023 15:02:15 +0200 Subject: [PATCH 2/2] Recursivily create default_folder If no output folder is supplied, and thus the default_folder is used, the application currently tries to create a new folder under `Documents/Kicad`. However, if some of these folders do not exist, python crashes with a nasty traceback. ``` -- easyeda2kicad.py v0.6.0 -- Traceback (most recent call last): File "/usr/bin/easyeda2kicad", line 33, in sys.exit(load_entry_point('easyeda2kicad==0.6.0', 'console_scripts', 'easyeda2kicad')()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/easyeda2kicad/__main__.py", line 237, in main if not valid_arguments(arguments=arguments): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/easyeda2kicad/__main__.py", line 161, in valid_arguments os.mkdir(default_folder) FileNotFoundError: [Errno 2] No such file or directory: '/home/user/Documents/Kicad/easyeda2kicad' ``` Instead, use os.makedirs, which has been available in python since 3.2 which avoids this issue altogether. --- easyeda2kicad/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easyeda2kicad/__main__.py b/easyeda2kicad/__main__.py index 7cca178..a4bec62 100644 --- a/easyeda2kicad/__main__.py +++ b/easyeda2kicad/__main__.py @@ -158,7 +158,7 @@ def valid_arguments(arguments: dict) -> bool: "easyeda2kicad", ) if not os.path.isdir(default_folder): - os.mkdir(default_folder) + os.makedirs(default_folder, exist_ok=True) base_folder = default_folder lib_name = "easyeda2kicad"