Added auto-download support for KiCost.

This commit is contained in:
Salvador E. Tropea 2022-06-29 11:35:52 -03:00
parent ce02b6d4a3
commit 35e12bb3fc
4 changed files with 18 additions and 12 deletions

View File

@ -116,7 +116,7 @@ Notes:
[**KiCad Automation tools**](https://github.com/INTI-CMNB/KiAuto) v1.6.13 (tool) (PyPi dependency)
- Mandatory for: `gencad`, `netlist`, `pdf_pcb_print`, `pdf_sch_print`, `render_3d`, `run_drc`, `run_erc`, `step`, `svg_pcb_print`, `svg_sch_print`, `update_xml`
[**KiCost**](https://github.com/INTI-CMNB/KiCost) v1.1.8 (tool)
[**KiCost**](https://github.com/INTI-CMNB/KiCost) v1.1.8 (tool) (Auto-download)
- Mandatory for `kicost`
- Optional to find components costs and specs for `bom`

View File

@ -85,7 +85,7 @@ URL_KIBOM = 'https://github.com/INTI-CMNB/KiBoM'
CMD_IBOM = 'generate_interactive_bom.py'
URL_IBOM = 'https://github.com/INTI-CMNB/InteractiveHtmlBom'
CMD_KICOST = 'kicost'
URL_KICOST = 'https://github.com/INTI-CMNB/KiCost'
URL_KICOST = 'https://github.com/hildogjr/KiCost'
KICOST_SUBMODULE = '../submodules/KiCost/src/kicost'
KICAD2STEP = 'kicad2step_do'
PCBDRAW = 'pcbdraw'
@ -397,3 +397,8 @@ def convert_dependency(output, downloader, roles=None):
def pcbdraw_dependency(output, downloader, roles=None):
return ToolDependency(output, 'PcbDraw', URL_PCBDRAW, url_down=URL_PCBDRAW+'/releases', in_debian=False,
downloader=downloader, roles=roles)
def kicost_dependency(output, downloader, roles=None):
return ToolDependency(output, 'KiCost', URL_KICOST, url_down=URL_KICOST+'/releases', in_debian=False,
downloader=downloader, roles=roles)

View File

@ -11,7 +11,7 @@ import os
import re
from copy import deepcopy
from .gs import GS
from .misc import W_BADFIELD, W_NEEDSPCB, DISTRIBUTORS, ToolDependency, ToolDependencyRole, URL_KICOST
from .misc import W_BADFIELD, W_NEEDSPCB, DISTRIBUTORS, ToolDependency, ToolDependencyRole, kicost_dependency
from .optionable import Optionable, BaseOptions
from .registrable import RegOutput, RegDependency
from .error import KiPlotConfigurationError
@ -22,6 +22,7 @@ from .bom.xlsx_writer import KICOST_SUPPORT
from .var_kibom import KiBoM
from .fil_base import (BaseFilter, apply_exclude_filter, apply_fitted_filter, apply_fixed_filter, reset_filters,
KICOST_NAME_TRANSLATIONS)
from .dep_downloader import pytool_downloader
from .macros import macros, document, output_class # noqa: F401
from . import log
# To debug the `with document` we can use:
@ -37,8 +38,9 @@ DEFAULT_ALIASES = [['r', 'r_small', 'res', 'resistor'],
['zener', 'zenersmall'],
['d', 'diode', 'd_small'],
]
RegDependency.register(ToolDependency('bom', 'KiCost', URL_KICOST, url_down=URL_KICOST+'/releases', in_debian=False,
roles=ToolDependencyRole(desc='Find components costs and specs', version=(1, 1, 8))))
kicost_dep = kicost_dependency('bom', pytool_downloader,
roles=ToolDependencyRole(desc='Find components costs and specs', version=(1, 1, 8)))
RegDependency.register(kicost_dep)
RegDependency.register(ToolDependency('bom', 'XLSXWriter', is_python=True,
roles=ToolDependencyRole(desc='Create XLSX files')))

View File

@ -8,22 +8,22 @@ from os.path import isfile, abspath, join, dirname
from subprocess import check_output, STDOUT, CalledProcessError
from tempfile import mkdtemp
from shutil import rmtree
from .misc import (CMD_KICOST, URL_KICOST, BOM_ERROR, DISTRIBUTORS, W_UNKDIST, ISO_CURRENCIES, W_UNKCUR, KICOST_SUBMODULE,
W_KICOSTFLD, W_MIXVARIANT, ToolDependency, ToolDependencyRole)
from .misc import (BOM_ERROR, DISTRIBUTORS, W_UNKDIST, ISO_CURRENCIES, W_UNKCUR, KICOST_SUBMODULE,
W_KICOSTFLD, W_MIXVARIANT, ToolDependencyRole, kicost_dependency)
from .registrable import RegDependency
from .error import KiPlotConfigurationError
from .optionable import Optionable
from .gs import GS
from .kiplot import check_script
from .out_base import VariantOptions
from .dep_downloader import check_tool, pytool_downloader
from .macros import macros, document, output_class # noqa: F401
from .fil_base import FieldRename
from . import log
logger = log.get_logger()
WARNING_MIX = ("Don't use the `kicost_variant` when using internal variants/filters")
RegDependency.register(ToolDependency('kicost', 'KiCost', URL_KICOST, url_down=URL_KICOST+'/releases', in_debian=False,
roles=ToolDependencyRole(version=(1, 1, 7))))
kicost_dep = kicost_dependency('kicost', pytool_downloader, roles=ToolDependencyRole(version=(1, 1, 7)))
RegDependency.register(kicost_dep)
class Aggregate(Optionable):
@ -170,8 +170,7 @@ class KiCostOptions(VariantOptions):
# Check KiCost is available
cmd_kicost = abspath(join(dirname(__file__), KICOST_SUBMODULE))
if not isfile(cmd_kicost):
check_script(CMD_KICOST, URL_KICOST)
cmd_kicost = CMD_KICOST
cmd_kicost = check_tool(kicost_dep, fatal=True)
# Construct the command
cmd = [cmd_kicost, '-w', '-o', name, '-i', netlist]
# Add the rest of input files and their variants