From 33454ffe2342e4f55a01db16d0d8d78293dd5435 Mon Sep 17 00:00:00 2001 From: uPesy-laptop Date: Tue, 31 May 2022 13:08:10 +0200 Subject: [PATCH 1/4] put menu header in first when creating folder/files --- easyeda2kicad/__main__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/easyeda2kicad/__main__.py b/easyeda2kicad/__main__.py index fbb9687..54e592d 100644 --- a/easyeda2kicad/__main__.py +++ b/easyeda2kicad/__main__.py @@ -192,7 +192,7 @@ def fp_already_in_footprint_lib(lib_path: str, package_name: str) -> bool: def main(argv: List[str] = sys.argv[1:]) -> int: - + print("-- easyeda2kicad.py --") set_logger(log_file=None, log_level=logging.INFO) # cli interface @@ -206,7 +206,6 @@ def main(argv: List[str] = sys.argv[1:]) -> int: if not valid_arguments(arguments=arguments): return 1 - print("-- easyeda2kicad.py --") component_id = arguments["lcsc_id"] kicad_version = arguments["kicad_version"] sym_lib_ext = "kicad_sym" if kicad_version == KicadVersion.v6 else "lib" From 9f50b29a8df235c9af6db6673e2253571d9111ec Mon Sep 17 00:00:00 2001 From: uPesy-computer Date: Wed, 1 Jun 2022 08:53:04 +0200 Subject: [PATCH 2/4] fix 3D issue + add version info in some str --- .gitignore | 1 + easyeda2kicad/__main__.py | 4 +++- easyeda2kicad/easyeda/easyeda_api.py | 10 +++++----- easyeda2kicad/easyeda/easyeda_importer.py | 2 +- easyeda2kicad/kicad/export_kicad_3d_model.py | 4 +++- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 31f94a2..dd7a5e6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ output_lib/* scripts/* .vscode/* *.sqlite3 +TODO # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/easyeda2kicad/__main__.py b/easyeda2kicad/__main__.py index 54e592d..a3a9ddd 100644 --- a/easyeda2kicad/__main__.py +++ b/easyeda2kicad/__main__.py @@ -7,6 +7,7 @@ from textwrap import dedent from typing import List +from easyeda2kicad import __version__ from easyeda2kicad.easyeda.easyeda_api import EasyedaApi from easyeda2kicad.easyeda.easyeda_importer import ( Easyeda3dModelImporter, @@ -192,7 +193,8 @@ def fp_already_in_footprint_lib(lib_path: str, package_name: str) -> bool: def main(argv: List[str] = sys.argv[1:]) -> int: - print("-- easyeda2kicad.py --") + print(f"-- easyeda2kicad.py v{__version__} --") + set_logger(log_file=None, log_level=logging.INFO) # cli interface diff --git a/easyeda2kicad/easyeda/easyeda_api.py b/easyeda2kicad/easyeda/easyeda_api.py index 3c5b970..d26033f 100644 --- a/easyeda2kicad/easyeda/easyeda_api.py +++ b/easyeda2kicad/easyeda/easyeda_api.py @@ -3,6 +3,8 @@ import requests +from easyeda2kicad import __version__ + API_ENDPOINT = "https://easyeda.com/api/products/{lcsc_id}/components?version=6.4.19.5" ENDPOINT_3D_MODEL = "https://easyeda.com/analyzer/api/3dmodel/{uuid}" # ------------------------------------------------------------ @@ -14,11 +16,9 @@ def __init__(self) -> None: "Accept-Encoding": "gzip, deflate", "Accept": "application/json, text/javascript, */*; q=0.01", "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", - "User-Agent": ( - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML," - " like Gecko) Chrome/91.0.4472.114 Safari/537.36" - ), + "User-Agent": f"easyeda2kicad v{__version__}", } + print(self.headers) def get_info_from_easyeda_api(self, lcsc_id: str) -> dict: r = requests.get(url=API_ENDPOINT.format(lcsc_id=lcsc_id), headers=self.headers) @@ -44,6 +44,6 @@ def get_raw_3d_model_obj(self, uuid: str) -> str: headers={"User-Agent": self.headers["User-Agent"]}, ) if r.status_code != requests.codes.ok: - logging.warning(f"No 3D model found for uuid:{uuid}") + logging.error(f"No 3D model data found for uuid:{uuid} on easyeda") return None return r.content.decode() diff --git a/easyeda2kicad/easyeda/easyeda_importer.py b/easyeda2kicad/easyeda/easyeda_importer.py index 630fbeb..9cae2f6 100644 --- a/easyeda2kicad/easyeda/easyeda_importer.py +++ b/easyeda2kicad/easyeda/easyeda_importer.py @@ -252,7 +252,7 @@ def create_3d_model(self) -> Union[Ee3dModel, None]: model_3d.raw_obj = EasyedaApi().get_raw_3d_model_obj(uuid=model_3d.uuid) return model_3d - logging.warning("There is no 3D model data for this component") + logging.warning("No 3D model available for this component") return None def get_3d_model_info(self, ee_data: str) -> dict: diff --git a/easyeda2kicad/kicad/export_kicad_3d_model.py b/easyeda2kicad/kicad/export_kicad_3d_model.py index c329ea0..4741210 100644 --- a/easyeda2kicad/kicad/export_kicad_3d_model.py +++ b/easyeda2kicad/kicad/export_kicad_3d_model.py @@ -117,7 +117,9 @@ class Exporter3dModelKicad: def __init__(self, model_3d: Ee3dModel): self.input = model_3d self.output = ( - generate_wrl_model(model_3d=model_3d) if model_3d.raw_obj else None + generate_wrl_model(model_3d=model_3d) + if model_3d and model_3d.raw_obj + else None ) def export(self, lib_path: str) -> None: From 5a2ea6fc96face6c043c440223d3291fe68d8404 Mon Sep 17 00:00:00 2001 From: uPesy-computer Date: Wed, 1 Jun 2022 08:53:52 +0200 Subject: [PATCH 3/4] =?UTF-8?q?Bump=20version:=200.3.6=20=E2=86=92=200.3.7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- easyeda2kicad/__init__.py | 2 +- setup.cfg | 2 +- setup.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 13ecbe1..c28cbde 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# easyeda2kicad v0.3.6 +# easyeda2kicad v0.3.7 _________________ [![PyPI version](https://badge.fury.io/py/easyeda2kicad.svg)](https://badge.fury.io/py/easyeda2kicad) diff --git a/easyeda2kicad/__init__.py b/easyeda2kicad/__init__.py index bac2596..47316d2 100644 --- a/easyeda2kicad/__init__.py +++ b/easyeda2kicad/__init__.py @@ -1,3 +1,3 @@ -__version__ = "0.3.6" +__version__ = "0.3.7" __author__ = "uPesy" __email__ = "contact@upesy.com" diff --git a/setup.cfg b/setup.cfg index 79af730..3a9244e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.3.6 +current_version = 0.3.7 commit = True tag = True diff --git a/setup.py b/setup.py index 0de611d..3e63de1 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ ), long_description=long_description, long_description_content_type="text/markdown", - version="0.3.6", + version="0.3.7", author="uPesy", author_email="contact@upesy.com", url="https://github.com/uPesy/easyeda2kicad.py", From 08b6c22f424d493cdecde5291cc34d660a623313 Mon Sep 17 00:00:00 2001 From: uPesy-computer Date: Wed, 1 Jun 2022 08:55:25 +0200 Subject: [PATCH 4/4] remove printin headers --- easyeda2kicad/easyeda/easyeda_api.py | 1 - 1 file changed, 1 deletion(-) diff --git a/easyeda2kicad/easyeda/easyeda_api.py b/easyeda2kicad/easyeda/easyeda_api.py index d26033f..341ab45 100644 --- a/easyeda2kicad/easyeda/easyeda_api.py +++ b/easyeda2kicad/easyeda/easyeda_api.py @@ -18,7 +18,6 @@ def __init__(self) -> None: "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "User-Agent": f"easyeda2kicad v{__version__}", } - print(self.headers) def get_info_from_easyeda_api(self, lcsc_id: str) -> dict: r = requests.get(url=API_ENDPOINT.format(lcsc_id=lcsc_id), headers=self.headers)