Added support for filters to sch_variant
This commit is contained in:
parent
0216fc93c7
commit
c26481790a
|
|
@ -3,11 +3,11 @@
|
||||||
# Copyright (c) 2020 Instituto Nacional de Tecnología Industrial
|
# Copyright (c) 2020 Instituto Nacional de Tecnología Industrial
|
||||||
# License: GPL-3.0
|
# License: GPL-3.0
|
||||||
# Project: KiBot (formerly KiPlot)
|
# Project: KiBot (formerly KiPlot)
|
||||||
from .error import KiPlotConfigurationError
|
|
||||||
from .gs import GS
|
from .gs import GS
|
||||||
from .optionable import BaseOptions
|
from .optionable import BaseOptions, Optionable
|
||||||
from .registrable import RegOutput
|
from .registrable import RegOutput
|
||||||
from .macros import macros, document, output_class # noqa: F401
|
from .macros import macros, document, output_class # noqa: F401
|
||||||
|
from .fil_base import BaseFilter
|
||||||
from . import log
|
from . import log
|
||||||
|
|
||||||
logger = log.get_logger(__name__)
|
logger = log.get_logger(__name__)
|
||||||
|
|
@ -18,21 +18,26 @@ class Sch_Variant_Options(BaseOptions):
|
||||||
with document:
|
with document:
|
||||||
self.variant = ''
|
self.variant = ''
|
||||||
""" Board variant(s) to apply """
|
""" Board variant(s) to apply """
|
||||||
|
self.dnf_filter = Optionable
|
||||||
|
""" [string|list(string)=''] Name of the filter to mark components as not fitted.
|
||||||
|
A short-cut to use for simple cases where a variant is an overkill """
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
def config(self):
|
def config(self):
|
||||||
super().config()
|
super().config()
|
||||||
if self.variant:
|
self.variant = RegOutput.check_variant(self.variant)
|
||||||
if not RegOutput.is_variant(self.variant):
|
self.dnf_filter = BaseFilter.solve_filter(self.dnf_filter, 'dnf_filter')
|
||||||
raise KiPlotConfigurationError("Unknown variant name `{}`".format(self.variant))
|
|
||||||
self.variant = RegOutput.get_variant(self.variant)
|
|
||||||
else:
|
|
||||||
self.variant = None
|
|
||||||
|
|
||||||
def run(self, output_dir, board):
|
def run(self, output_dir, board):
|
||||||
if self.variant:
|
if self.dnf_filter or self.variant:
|
||||||
# Get the components list from the schematic
|
# Get the components list from the schematic
|
||||||
comps = GS.sch.get_components()
|
comps = GS.sch.get_components()
|
||||||
|
# Apply the filter
|
||||||
|
if self.dnf_filter:
|
||||||
|
for c in comps:
|
||||||
|
c.fitted = self.dnf_filter.filter(c)
|
||||||
|
# Apply the variant
|
||||||
|
if self.variant:
|
||||||
# Apply the variant
|
# Apply the variant
|
||||||
self.variant.filter(comps)
|
self.variant.filter(comps)
|
||||||
# Create the schematic
|
# Create the schematic
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue