Skip to content

Commit

Permalink
Merge pull request #190 from oto313/feature/lcsc-support
Browse files Browse the repository at this point in the history
Added support for LCSC eshop
  • Loading branch information
SchrodingersGat authored Aug 31, 2023
2 parents 0b6881e + 2ec9401 commit 2262b59
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions kibom/html_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def WriteHTML(filename, groups, net, headings, head_names, prefs):
if prefs.mouser_link:
link_mouser = prefs.mouser_link.split("\t")

link_lcsc = None
if prefs.lcsc_link:
link_lcsc = prefs.lcsc_link.split("\t")
with open(filename, "w") as html:

# HTML Header
Expand Down Expand Up @@ -138,6 +141,9 @@ def WriteHTML(filename, groups, net, headings, head_names, prefs):
if link_mouser and headings[n] in link_mouser:
r = '<a href="https://www.mouser.com/ProductDetail/' + r + '">' + r + '</a>'

if link_lcsc and headings[n] in link_lcsc:
r = '<a href="https://www.lcsc.com/product-detail/' + r + '.html">' + r + '</a>'

# Link this column to the datasheet?
if link_datasheet and headings[n] == link_datasheet:
r = '<a href="' + group.getField(ColumnList.COL_DATASHEET) + '">' + r + '</a>'
Expand Down Expand Up @@ -200,6 +206,9 @@ def WriteHTML(filename, groups, net, headings, head_names, prefs):
if link_mouser and headings[n] in link_mouser:
r = '<a href="https://www.mouser.com/ProductDetail/' + r + '">' + r + '</a>'

if link_lcsc and headings[n] in link_lcsc:
r = '<a href="https://www.lcsc.com/product-detail/' + r + '.html">' + r + '</a>'

if (len(r) == 0) or (r.strip() == "~"):
bg = BG_EMPTY
else:
Expand Down
10 changes: 10 additions & 0 deletions kibom/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class BomPref:

OPT_DIGIKEY_LINK = "digikey_link"
OPT_MOUSER_LINK = "mouser_link"
OPT_LCSC_LINK = "lcsc_link"
OPT_PCB_CONFIG = "pcb_configuration"
OPT_NUMBER_ROWS = "number_rows"
OPT_GROUP_CONN = "group_connectors"
Expand Down Expand Up @@ -67,6 +68,7 @@ def __init__(self):

self.digikey_link = False # Columns to link to Digi-Key
self.mouser_link = False # Columns to link to Mouser (requires Mouser-PartNO)
self.lcsc_link = False # Columns to link to LCSC
self.boards = 1 # Quantity of boards to be made
self.mergeBlankFields = True # Blanks fields will be merged when possible
self.hideHeaders = False
Expand Down Expand Up @@ -208,6 +210,11 @@ def Read(self, file, verbose=False):
self.mouser_link = cf.get(self.SECTION_GENERAL, self.OPT_MOUSER_LINK)
else:
self.mouser_link = False

if cf.has_option(self.SECTION_GENERAL, self.OPT_LCSC_LINK):
self.lcsc_link = cf.get(self.SECTION_GENERAL, self.OPT_LCSC_LINK)
else:
self.lcsc_link = False

# Read out grouping colums
if self.SECTION_GROUPING_FIELDS in cf.sections():
Expand Down Expand Up @@ -312,6 +319,9 @@ def Write(self, file):
cf.set(self.SECTION_GENERAL, '; Interpret as a MOUSER P/N and link the following field')
cf.set(self.SECTION_GENERAL, self.OPT_MOUSER_LINK, self.mouser_link)

cf.set(self.SECTION_GENERAL, '; Interpret as a LCSC P/N and link the following field')
cf.set(self.SECTION_GENERAL, self.OPT_LCSC_LINK, self.lcsc_link)

cf.add_section(self.SECTION_IGNORE)
cf.set(self.SECTION_IGNORE, "; Any column heading that appears here will be excluded from the Generated BoM")
cf.set(self.SECTION_IGNORE, "; Titles are case-insensitive")
Expand Down

0 comments on commit 2262b59

Please sign in to comment.