Skip to content

Commit

Permalink
fix 3D issue + add version info in some str
Browse files Browse the repository at this point in the history
fix 3D issue + add version info in some str
  • Loading branch information
uPesy authored Jun 1, 2022
2 parents 6418ea5 + 08b6c22 commit 6e0cbba
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ output_lib/*
scripts/*
.vscode/*
*.sqlite3
TODO

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion easyeda2kicad/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "0.3.6"
__version__ = "0.3.7"
__author__ = "uPesy"
__email__ = "[email protected]"
3 changes: 2 additions & 1 deletion easyeda2kicad/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -192,6 +193,7 @@ def fp_already_in_footprint_lib(lib_path: str, package_name: str) -> bool:


def main(argv: List[str] = sys.argv[1:]) -> int:
print(f"-- easyeda2kicad.py v{__version__} --")

set_logger(log_file=None, log_level=logging.INFO)

Expand All @@ -206,7 +208,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"
Expand Down
9 changes: 4 additions & 5 deletions easyeda2kicad/easyeda/easyeda_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
# ------------------------------------------------------------
Expand All @@ -14,10 +16,7 @@ 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__}",
}

def get_info_from_easyeda_api(self, lcsc_id: str) -> dict:
Expand All @@ -44,6 +43,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()
2 changes: 1 addition & 1 deletion easyeda2kicad/easyeda/easyeda_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion easyeda2kicad/kicad/export_kicad_3d_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.3.6
current_version = 0.3.7
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]",
url="https://github.com/uPesy/easyeda2kicad.py",
Expand Down

0 comments on commit 6e0cbba

Please sign in to comment.