Skip to content

Commit

Permalink
cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
ducky64 committed Aug 19, 2024
1 parent 0aac1ec commit f7f0b6f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
8 changes: 1 addition & 7 deletions edg/jlcparts/JlcPartsBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ def config_root_dir(root_dir: str):

@classmethod
def _make_table(cls) -> PartsTable:
return cls._jlc_table()

@classmethod
def _jlc_table(cls) -> PartsTable:
"""Return the table, cached if possible"""
if cls._cached_table is None:
cls._cached_table = cls._parse_table()
Expand Down Expand Up @@ -116,7 +112,6 @@ def _parse_table(cls) -> PartsTable:
datasheet_index = data.jlcpart_schema.index("datasheet")
attributes_index = data.jlcpart_schema.index("attributes")


for component in data.components:
row_dict: Dict[PartsTableColumn, Any] = {}

Expand All @@ -132,10 +127,9 @@ def _parse_table(cls) -> PartsTable:
if attributes.get("Status", str) in ["Discontinued"]:
continue
row_dict[cls.BASIC_PART_COL] = attributes.get("Basic/Extended", str) == "Basic"

row_dict[cls.MANUFACTURER_COL] = attributes.get("Manufacturer", str)
package = attributes.get("Package", str)

package = attributes.get("Package", str)
row_dict_opt = cls._entry_to_table_row(row_dict, filename, package, attributes)
if row_dict_opt is not None:
rows.append(PartsTableRow(row_dict_opt))
Expand Down
2 changes: 1 addition & 1 deletion edg/jlcparts/JlcPartsBjt.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _entry_to_table_row(cls, row_dict: Dict[PartsTableColumn, Any], filename: st
attributes.get("Collector-emitter breakdown voltage (vceo)", str), 'V'))
row_dict[cls.ICE_RATING] = Range.zero_to_upper(PartParserUtil.parse_value(
attributes.get("Collector current (ic)", str), 'A'))
row_dict[cls.GAIN] = Range.zero_to_upper(PartParserUtil.parse_value(
row_dict[cls.GAIN] = Range.exact(PartParserUtil.parse_value(
attributes.get("Dc current gain (hfe@ic,vce)", str).split('@')[0], ''))
row_dict[cls.POWER_RATING] = Range.zero_to_upper(
attributes.get("Power dissipation (pd)", float, sub='power'))
Expand Down
2 changes: 1 addition & 1 deletion edg/jlcparts/JlcPartsBoardTop.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def refinements(self) -> Refinements:
(Led, JlcPartsLed),
(Bjt, JlcPartsBjt),
(Fet, JlcPartsFet),
(SwitchFet, JlcSwitchFet),
# (SwitchFet, JlcSwitchFet), # TODO IMPLEMENT ME
(PptcFuse, JlcPartsPptcFuse),
(FerriteBead, JlcPartsFerriteBead)
]
Expand Down
22 changes: 22 additions & 0 deletions edg/jlcparts/JlcPartsMlcc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Any, Optional, Dict
from ..abstract_parts import *
from ..parts import JlcCapacitor
from ..parts.JlcCapacitor import JlcDummyCapacitor
from .JlcPartsBase import JlcPartsBase, JlcPartsAttributes


Expand Down Expand Up @@ -31,3 +32,24 @@ def _entry_to_table_row(cls, row_dict: Dict[PartsTableColumn, Any], filename: st
return row_dict
except (KeyError, TypeError, PartParserUtil.ParseError):
return None

@classmethod
def _row_sort_by(cls, row: PartsTableRow) -> Any:
return [row[cls.PARALLEL_COUNT], super(JlcPartsMlcc, cls)._row_sort_by(row)]

def _make_parallel_footprints(self, row: PartsTableRow) -> None:
cap_model = JlcDummyCapacitor(set_lcsc_part=row[self.LCSC_COL],
set_basic_part=row[self.BASIC_PART_COL],
footprint=row[self.KICAD_FOOTPRINT],
manufacturer=row[self.MANUFACTURER_COL], part_number=row[self.PART_NUMBER_COL],
value=row[self.DESCRIPTION_COL],
capacitance=row[self.NOMINAL_CAPACITANCE],
voltage=self.voltage)
self.c = ElementDict[JlcDummyCapacitor]()
for i in range(row[self.PARALLEL_COUNT]):
self.c[i] = self.Block(cap_model)
self.connect(self.c[i].pos, self.pos)
self.connect(self.c[i].neg, self.neg)

self.assign(self.lcsc_part, row[self.LCSC_COL])
self.assign(self.actual_basic_part, row[self.BASIC_PART_COL])

0 comments on commit f7f0b6f

Please sign in to comment.