[BoM][Added] Option to link to Mouser site.
This commit is contained in:
parent
ca1faa9102
commit
dbea3ca183
|
|
@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- `populate` to create step-by-step assembly instructions
|
||||
With support for `pcbdraw` and `render_3d`.
|
||||
- generic filters: options to filter by PCB side
|
||||
- BoM:
|
||||
- Option to link to Mouser site.
|
||||
- Diff:
|
||||
- Option to compare only the first schematic page. (See #319)
|
||||
- iBoM:
|
||||
|
|
|
|||
|
|
@ -1457,6 +1457,7 @@ Notes:
|
|||
- `hide_pcb_info`: [boolean=false] Hide project information.
|
||||
- `hide_stats_info`: [boolean=false] Hide statistics information.
|
||||
- `highlight_empty`: [boolean=true] Use a color for empty cells. Applies only when `col_colors` is `true`.
|
||||
- `mouser_link`: [string|list(string)=''] Column/s containing Mouser part numbers, will be linked to web page.
|
||||
- `style`: [string='modern-blue'] Page style. Internal styles: modern-blue, modern-green, modern-red and classic.
|
||||
Or you can provide a CSS file name. Please use .css as file extension..
|
||||
- **`ignore_dnf`**: [boolean=true] Exclude DNF (Do Not Fit) components.
|
||||
|
|
@ -1488,6 +1489,7 @@ Notes:
|
|||
- `kicost_dist_desc`: [boolean=false] Used to add a column with the distributor's description. So you can check this is the right component.
|
||||
- `logo_scale`: [number=2] Scaling factor for the logo. Note that this value isn't honored by all spreadsheet software.
|
||||
- `max_col_width`: [number=60] [20,999] Maximum column width (characters).
|
||||
- `mouser_link`: [string|list(string)=''] Column/s containing Mouser part numbers, will be linked to web page.
|
||||
- `specs_columns`: [list(dict)|list(string)] Which columns are included in the Specs worksheet. Use `References` for the references,
|
||||
'Row' for the order and 'Sep' to separate groups at the same level. By default all are included.
|
||||
Column names are distributor specific, the following aren't: '_desc', '_value', '_tolerance', '_footprint',
|
||||
|
|
@ -1718,6 +1720,9 @@ Notes:
|
|||
- `add_link_id`: [boolean=false] When enabled we create a symlink to the output file with a name that contains the
|
||||
git hashes involved in the comparison. If you plan to compress the output don't
|
||||
forget to disable the `follow_links` option.
|
||||
- `always_fail_if_missing`: [boolean=false] Always fail if the old/new file doesn't exist. Currently we don't fail if they are from a repo.
|
||||
So if you refer to a repo point where the file wasn't created KiBot will use an empty file.
|
||||
Enabling this option KiBot will report an error.
|
||||
- `cache_dir`: [string=''] Directory to cache the intermediate files. Leave it blank to disable the cache.
|
||||
- `copy_instead_of_link`: [boolean=false] Modifies the behavior of `add_link_id` to create a copy of the file instead of a
|
||||
symlink. Useful for some Windows setups.
|
||||
|
|
|
|||
|
|
@ -277,6 +277,8 @@ outputs:
|
|||
highlight_empty: true
|
||||
# [string|boolean=''] PNG file to use as logo, use false to remove
|
||||
logo: ''
|
||||
# [string|list(string)=''] Column/s containing Mouser part numbers, will be linked to web page
|
||||
mouser_link: ''
|
||||
# [string='modern-blue'] Page style. Internal styles: modern-blue, modern-green, modern-red and classic.
|
||||
# Or you can provide a CSS file name. Please use .css as file extension.
|
||||
style: 'modern-blue'
|
||||
|
|
@ -361,6 +363,8 @@ outputs:
|
|||
logo_scale: 2
|
||||
# [number=60] [20,999] Maximum column width (characters)
|
||||
max_col_width: 60
|
||||
# [string|list(string)=''] Column/s containing Mouser part numbers, will be linked to web page
|
||||
mouser_link: ''
|
||||
# [boolean=false] Enable Specs worksheet creation. Contains specifications for the components.
|
||||
# Works with only some KiCost APIs
|
||||
specs: false
|
||||
|
|
@ -490,6 +494,10 @@ outputs:
|
|||
# git hashes involved in the comparison. If you plan to compress the output don't
|
||||
# forget to disable the `follow_links` option
|
||||
add_link_id: false
|
||||
# [boolean=false] Always fail if the old/new file doesn't exist. Currently we don't fail if they are from a repo.
|
||||
# So if you refer to a repo point where the file wasn't created KiBot will use an empty file.
|
||||
# Enabling this option KiBot will report an error
|
||||
always_fail_if_missing: false
|
||||
# [string=''] Directory to cache the intermediate files. Leave it blank to disable the cache
|
||||
cache_dir: ''
|
||||
# [boolean=false] Modifies the behavior of `add_link_id` to create a copy of the file instead of a
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ def link(text):
|
|||
return text
|
||||
|
||||
|
||||
def content_table(html, groups, headings, head_names, cfg, link_datasheet, link_digikey, col_colors, dnf=False):
|
||||
def content_table(html, groups, headings, head_names, cfg, link_datasheet, link_digikey, link_mouser, col_colors, dnf=False):
|
||||
cl = ''
|
||||
# Table start
|
||||
html.write('<table class="content-table">\n')
|
||||
|
|
@ -246,6 +246,8 @@ def content_table(html, groups, headings, head_names, cfg, link_datasheet, link_
|
|||
# A link to Digi-Key?
|
||||
if link_digikey and headings[n] in link_digikey:
|
||||
r = '<a href="https://www.digikey.com/products/en?keywords=' + r + '">' + r + '</a>'
|
||||
if link_mouser and headings[n] in link_mouser:
|
||||
r = '<a href="https://www.mouser.com/ProductDetail/' + r + '">' + r + '</a>'
|
||||
# Link this column to the datasheet?
|
||||
if link_datasheet == n and datasheet.startswith('http'):
|
||||
r = '<a href="' + datasheet + '">' + r + '</a>'
|
||||
|
|
@ -369,6 +371,7 @@ def write_html(filename, groups, headings, head_names, cfg):
|
|||
if cfg.html.datasheet_as_link and cfg.html.datasheet_as_link in headings:
|
||||
link_datasheet = headings.index(cfg.html.datasheet_as_link)
|
||||
link_digikey = cfg.html.digikey_link
|
||||
link_mouser = cfg.html.mouser_link
|
||||
col_colors = cfg.html.col_colors
|
||||
# Compute the CSS
|
||||
style_name = cfg.html.style
|
||||
|
|
@ -442,12 +445,13 @@ def write_html(filename, groups, headings, head_names, cfg):
|
|||
|
||||
# Fitted groups
|
||||
html.write("<h2>Component Groups</h2>\n")
|
||||
content_table(html, groups, headings, head_names, cfg, link_datasheet, link_digikey, col_colors)
|
||||
content_table(html, groups, headings, head_names, cfg, link_datasheet, link_digikey, link_mouser, col_colors)
|
||||
|
||||
# DNF component groups
|
||||
if cfg.html.generate_dnf and cfg.n_total != cfg.n_fitted:
|
||||
html.write("<h2>Optional components (DNF=Do Not Fit)</h2>\n")
|
||||
content_table(html, groups, headings, head_names, cfg, link_datasheet, link_digikey, col_colors, True)
|
||||
content_table(html, groups, headings, head_names, cfg, link_datasheet, link_digikey, link_mouser, col_colors,
|
||||
True)
|
||||
|
||||
# Color reference
|
||||
if col_colors:
|
||||
|
|
|
|||
|
|
@ -714,6 +714,7 @@ def write_xlsx(filename, groups, col_fields, head_names, cfg):
|
|||
if cfg.xlsx.datasheet_as_link and cfg.xlsx.datasheet_as_link in col_fields:
|
||||
link_datasheet = col_fields.index(cfg.xlsx.datasheet_as_link)
|
||||
link_digikey = cfg.xlsx.digikey_link
|
||||
link_mouser = cfg.xlsx.mouser_link
|
||||
hl_empty = cfg.xlsx.highlight_empty
|
||||
|
||||
workbook = Workbook(filename)
|
||||
|
|
@ -793,6 +794,10 @@ def write_xlsx(filename, groups, col_fields, head_names, cfg):
|
|||
elif link_digikey and col_fields[i] in link_digikey:
|
||||
url = 'https://www.digikey.com/products/en?keywords=' + cell
|
||||
worksheet.write_url(row_count, i, url, fmt, cell)
|
||||
# A link to Mouser?
|
||||
elif link_mouser and col_fields[i] in link_mouser:
|
||||
url = 'https://www.mouser.com/ProductDetail/' + cell
|
||||
worksheet.write_url(row_count, i, url, fmt, cell)
|
||||
else:
|
||||
worksheet.write_string(row_count, i, cell, fmt)
|
||||
if len(cell) > column_widths[i] - 5:
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ class Optionable(object):
|
|||
return Optionable.expand_filename_both(self, name)
|
||||
|
||||
@staticmethod
|
||||
def force_list(val, comma_sep=True):
|
||||
def force_list(val, comma_sep=True, lower_case=False):
|
||||
""" Used for values that accept a string or a list of strings.
|
||||
The string can be a comma separated list """
|
||||
if isinstance(val, type):
|
||||
|
|
@ -369,6 +369,8 @@ class Optionable(object):
|
|||
else:
|
||||
# Empty string
|
||||
val = []
|
||||
if lower_case:
|
||||
return [c.lower() for c in val]
|
||||
return val
|
||||
|
||||
@classmethod
|
||||
|
|
|
|||
|
|
@ -184,6 +184,8 @@ class BoMLinkable(Optionable):
|
|||
""" *Column with links to the datasheet """
|
||||
self.digikey_link = Optionable
|
||||
""" [string|list(string)=''] Column/s containing Digi-Key part numbers, will be linked to web page """
|
||||
self.mouser_link = Optionable
|
||||
""" [string|list(string)=''] Column/s containing Mouser part numbers, will be linked to web page """
|
||||
self.generate_dnf = True
|
||||
""" *Generate a separated section for DNF (Do Not Fit) components """
|
||||
self.hide_pcb_info = False
|
||||
|
|
@ -201,11 +203,9 @@ class BoMLinkable(Optionable):
|
|||
|
||||
def config(self, parent):
|
||||
super().config(parent)
|
||||
# digikey_link
|
||||
if isinstance(self.digikey_link, type):
|
||||
self.digikey_link = []
|
||||
elif isinstance(self.digikey_link, list):
|
||||
self.digikey_link = [c.lower() for c in self.digikey_link]
|
||||
# *_link
|
||||
self.digikey_link = self.force_list(self.digikey_link, comma_sep=False, lower_case=True)
|
||||
self.mouser_link = self.force_list(self.mouser_link, comma_sep=False, lower_case=True)
|
||||
# Logo
|
||||
if isinstance(self.logo, type):
|
||||
self.logo = ''
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ F 3 "https://www.molex.com/webdocs/datasheets/pdf/en-us//0022232021_PCB_HEADERS.
|
|||
F 4 "900-0022232021-ND" H 2850 2300 50 0001 C CNN "digikey#"
|
||||
F 5 "0022232021" H 2850 2300 50 0001 C CNN "manf#"
|
||||
F 6 "WM2700-ND" H 2850 2300 50 0001 C CNN "digikey_alt#"
|
||||
F 7 "538-22-23-2021" H 2850 2300 50 0001 C CNN "mouser#"
|
||||
F 8 "538-22-11-2022" H 2850 2300 50 0001 C CNN "mouser_alt#"
|
||||
1 2850 2300
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
|
|
@ -40,6 +42,8 @@ F 3 "https://www.molex.com/webdocs/datasheets/pdf/en-us//0022232021_PCB_HEADERS.
|
|||
F 4 "900-0022232021-ND" H 4500 2300 50 0001 C CNN "digikey#"
|
||||
F 5 "0022232021" H 4500 2300 50 0001 C CNN "manf#"
|
||||
F 6 "WM2700-ND" H 4500 2300 50 0001 C CNN "digikey_alt#"
|
||||
F 7 "538-22-23-2021" H 2850 2300 50 0001 C CNN "mouser#"
|
||||
F 8 "538-22-11-2022" H 2850 2300 50 0001 C CNN "mouser_alt#"
|
||||
1 4500 2300
|
||||
-1 0 0 -1
|
||||
$EndComp
|
||||
|
|
@ -54,6 +58,8 @@ F 3 "https://www.bourns.com/docs/product-datasheets/CRxxxxx.pdf" H 3450 2300 50
|
|||
F 4 "CR0805-JW-102ELFCT-ND" V 3450 2300 50 0001 C CNN "digikey#"
|
||||
F 5 "CR0805-JW-102ELF" V 3450 2300 50 0001 C CNN "manf#"
|
||||
F 6 "CRS0805-JX-102ELFCT-ND" V 3450 2300 50 0001 C CNN "digikey_alt#"
|
||||
F 7 "652-CR0805JW-102ELF" H 2850 2300 50 0001 C CNN "mouser#"
|
||||
F 8 "652-CRS0805JX102ELF" H 2850 2300 50 0001 C CNN "mouser_alt#"
|
||||
1 3450 2300
|
||||
0 1 1 0
|
||||
$EndComp
|
||||
|
|
@ -69,6 +75,8 @@ F 4 "399-1147-1-ND" H 3750 2500 50 0001 C CNN "digikey#"
|
|||
F 5 "C0805C102K5RACTU" H 3750 2500 50 0001 C CNN "manf#"
|
||||
F 6 "DNF" H 3750 2500 50 0001 C CNN "Config"
|
||||
F 7 "399-1149-1-ND" H 3750 2500 50 0001 C CNN "digikey_alt#"
|
||||
F 8 "80-C0805C102K5R" H 2850 2300 50 0001 C CNN "mouser#"
|
||||
F 9 "80-C0805C102K5R7210" H 2850 2300 50 0001 C CNN "mouser_alt#"
|
||||
1 3750 2500
|
||||
1 0 0 -1
|
||||
$EndComp
|
||||
|
|
|
|||
|
|
@ -239,6 +239,12 @@
|
|||
(property "digikey_alt#" "WM2700-ND" (id 6) (at 72.39 58.42 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "mouser#" "538-22-23-2021" (id 4) (at 72.39 58.42 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "mouser_alt#" "538-22-11-2022" (id 4) (at 72.39 58.42 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(pin "1" (uuid 3a983f51-42e8-405a-9e04-43b2dcabad73))
|
||||
(pin "2" (uuid 44467fec-706c-4fae-80bc-b9e34c67559e))
|
||||
)
|
||||
|
|
@ -267,6 +273,12 @@
|
|||
(property "digikey_alt#" "WM2700-ND" (id 6) (at 114.3 58.42 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "mouser#" "538-22-23-2021" (id 4) (at 72.39 58.42 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "mouser_alt#" "538-22-11-2022" (id 4) (at 72.39 58.42 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(pin "1" (uuid 23133abe-63f6-4718-9f66-696cfc78619f))
|
||||
(pin "2" (uuid 8d936772-f6fa-4d42-bb01-ee988a455edf))
|
||||
)
|
||||
|
|
@ -291,6 +303,12 @@
|
|||
(property "digikey_alt#" "CRS0805-JX-102ELFCT-ND" (id 6) (at 87.63 58.42 90)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "mouser#" "652-CR0805JW-102ELF" (id 4) (at 72.39 58.42 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "mouser_alt#" "652-CRS0805JX102ELF" (id 4) (at 72.39 58.42 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(pin "1" (uuid 2de833b3-282a-488d-ba66-338c569a1889))
|
||||
(pin "2" (uuid 60a539f2-60cc-48f9-87ad-8cf3118ca160))
|
||||
)
|
||||
|
|
@ -322,6 +340,12 @@
|
|||
(property "digikey_alt#" "399-1149-1-ND" (id 7) (at 95.25 63.5 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "mouser#" "80-C0805C102K5R" (id 4) (at 72.39 58.42 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "mouser_alt#" "80-C0805C102K5R7210" (id 4) (at 72.39 58.42 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(pin "1" (uuid 67b819b7-12c7-4dd7-bd3a-61ec6664e433))
|
||||
(pin "2" (uuid 751f729a-b418-440a-860e-106b8be28d8c))
|
||||
)
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ KIBOM_STATS = [KIBOM_TEST_GROUPS+len(KIBOM_TEST_EXCLUDE),
|
|||
len(KIBOM_TEST_COMPONENTS)]
|
||||
LINKS_STATS = [3, '4 (2 SMD/ 2 THT)', '3 (1 SMD/ 2 THT)', 1, 3]
|
||||
VARIANTE_PRJ_INFO = ['kibom-variante', 'default', 'A', '2020-03-12', None]
|
||||
LINK_HEAD = ['References', 'Part', 'Value', 'Quantity Per PCB', 'digikey#', 'digikey_alt#', 'manf#']
|
||||
LINK_HEAD = ['References', 'Part', 'Value', 'Quantity Per PCB', 'digikey#', 'digikey_alt#', 'mouser#', 'mouser_alt#', 'manf#']
|
||||
LINKS_COMPONENTS = ['J1', 'J2', 'R1']
|
||||
LINKS_EXCLUDE = ['C1']
|
||||
LINKS_GROUPS = 2
|
||||
|
|
@ -575,6 +575,7 @@ def test_int_bom_digikey_link(test_dir):
|
|||
# Look for reference and quantity columns
|
||||
ref_column = headers[0].index(REF_COLUMN_NAME)
|
||||
dk_column = headers[0].index('digikey#')
|
||||
mo_column = headers[0].index('mouser#')
|
||||
# Check the normal table
|
||||
check_kibom_test_netlist(rows[0], ref_column, LINKS_GROUPS, LINKS_EXCLUDE, LINKS_COMPONENTS)
|
||||
# Check the DNF table
|
||||
|
|
@ -585,6 +586,11 @@ def test_int_bom_digikey_link(test_dir):
|
|||
assert c.strip().startswith('<a href')
|
||||
assert 'digikey' in c
|
||||
logging.debug(c + ' OK')
|
||||
parts = get_column(rows[0]+rows[1], mo_column, False)
|
||||
for c in parts:
|
||||
assert c.strip().startswith('<a href')
|
||||
assert 'mouser' in c
|
||||
logging.debug(c + ' OK')
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
|
|
@ -605,6 +611,8 @@ def test_int_bom_digikey_links(test_dir):
|
|||
ref_column = headers[0].index(REF_COLUMN_NAME)
|
||||
dk_column = headers[0].index('digikey#')
|
||||
dk2_column = headers[0].index('digikey_alt#')
|
||||
mo_column = headers[0].index('mouser#')
|
||||
mo2_column = headers[0].index('mouser_alt#')
|
||||
# Check the normal table
|
||||
check_kibom_test_netlist(rows[0], ref_column, LINKS_GROUPS, LINKS_EXCLUDE, LINKS_COMPONENTS)
|
||||
# Check the DNF table
|
||||
|
|
@ -620,6 +628,16 @@ def test_int_bom_digikey_links(test_dir):
|
|||
assert c.strip().startswith('<a href')
|
||||
assert 'digikey' in c
|
||||
logging.debug(c + ' OK')
|
||||
parts = get_column(rows[0]+rows[1], mo_column, False)
|
||||
for c in parts:
|
||||
assert c.strip().startswith('<a href')
|
||||
assert 'mouser' in c
|
||||
logging.debug(c + ' OK')
|
||||
parts = get_column(rows[0]+rows[1], mo2_column, False)
|
||||
for c in parts:
|
||||
assert c.strip().startswith('<a href')
|
||||
assert 'mouser' in c
|
||||
logging.debug(c + ' OK')
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ outputs:
|
|||
options:
|
||||
html:
|
||||
digikey_link: 'digikey#'
|
||||
mouser_link: 'mouser#'
|
||||
output: '%f.%x'
|
||||
columns:
|
||||
- References
|
||||
|
|
@ -18,4 +19,6 @@ outputs:
|
|||
- Quantity Per PCB
|
||||
- digikey#
|
||||
- digikey_alt#
|
||||
- mouser#
|
||||
- mouser_alt#
|
||||
- manf#
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ outputs:
|
|||
options:
|
||||
xlsx:
|
||||
digikey_link: 'digikey#'
|
||||
mouser_link: 'mouser#'
|
||||
output: '%f.%x'
|
||||
columns:
|
||||
- References
|
||||
|
|
@ -18,4 +19,6 @@ outputs:
|
|||
- Quantity Per PCB
|
||||
- digikey#
|
||||
- digikey_alt#
|
||||
- mouser#
|
||||
- mouser_alt#
|
||||
- manf#
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ outputs:
|
|||
options:
|
||||
html:
|
||||
digikey_link: ['digikey#', 'digikey_alt#']
|
||||
mouser_link: ['mouser#', 'mouser_alt#']
|
||||
output: '%f.%x'
|
||||
columns:
|
||||
- References
|
||||
|
|
@ -18,4 +19,6 @@ outputs:
|
|||
- Quantity Per PCB
|
||||
- digikey#
|
||||
- digikey_alt#
|
||||
- mouser#
|
||||
- mouser_alt#
|
||||
- manf#
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ outputs:
|
|||
options:
|
||||
xlsx:
|
||||
digikey_link: ['digikey#', 'digikey_alt#']
|
||||
mouser_link: ['mouser#', 'mouser_alt#']
|
||||
output: '%f.%x'
|
||||
columns:
|
||||
- References
|
||||
|
|
@ -18,4 +19,6 @@ outputs:
|
|||
- Quantity Per PCB
|
||||
- digikey#
|
||||
- digikey_alt#
|
||||
- mouser#
|
||||
- mouser_alt#
|
||||
- manf#
|
||||
|
|
|
|||
Loading…
Reference in New Issue