From 96a5f3da21b84b9216f373ff138dbebedb7ba227 Mon Sep 17 00:00:00 2001 From: Diego Capusotto Date: Wed, 15 Dec 2021 17:39:01 -0300 Subject: [PATCH] Added support for new KiCost options `split_extra_fields` and `board_qty`. Closes #120 --- CHANGELOG.md | 1 + README.md | 3 +++ docs/samples/generic_plot.kibot.yaml | 6 ++++++ kibot/out_kicost.py | 13 +++++++++++++ 4 files changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0d502e8..90130b56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Now you can compress files relative to the current working directory. So you can create a compressed file containing the source schematic and PCB files. (#93) +- Support for new KiCost options `split_extra_fields` and `board_qty`. (#120) ### Changed - Internal BoM: now components with different Tolerance, Voltage, Current diff --git a/README.md b/README.md index feb82da4..689fb04e 100644 --- a/README.md +++ b/README.md @@ -1319,6 +1319,7 @@ Next time you need this list just use an alias, like this: - `aggregate`: [list(dict)] Add components from other projects. * Valid keys: - `file`: [string=''] Name of the XML to aggregate. + - `number`: [number=100] Number of boards to build (components multiplier). - `variant`: [string=' '] Variant for this project. - `currency`: [string|list(string)=USD] Currency priority. Use ISO4217 codes (i.e. USD, EUR). - `distributors`: [string|list(string)] Include this distributors list. Default is all the available. @@ -1333,8 +1334,10 @@ Next time you need this list just use an alias, like this: - `no_collapse`: [boolean=false] Do not collapse the part references (collapse=R1-R4). - `no_distributors`: [string|list(string)] Exclude this distributors list. They are removed after computing `distributors`. - `no_price`: [boolean=false] Do not look for components price. For testing purposes. + - `number`: [number=100] Number of boards to build (components multiplier). - `output`: [string='%f-%i%v.%x'] Filename for the output (%i=kicost, %x=xlsx). Affected by global options. - `show_cat_url`: [boolean=false] Include the catalogue links in the catalogue code. + - `split_extra_fields`: [string|list(string)] Declare part fields to include in multipart split process. - `translate_fields`: [list(dict)] Fields to rename (KiCost option, not internal filters). * Valid keys: - `field`: [string=''] Name of the field to rename. diff --git a/docs/samples/generic_plot.kibot.yaml b/docs/samples/generic_plot.kibot.yaml index a8a69a2e..ff5fefc0 100644 --- a/docs/samples/generic_plot.kibot.yaml +++ b/docs/samples/generic_plot.kibot.yaml @@ -767,6 +767,8 @@ outputs: aggregate: # [string=''] Name of the XML to aggregate - file: '' + # [number=100] Number of boards to build (components multiplier) + number: 100 # [string=' '] Variant for this project variant: ' ' # [string|list(string)=USD] Currency priority. Use ISO4217 codes (i.e. USD, EUR) @@ -792,10 +794,14 @@ outputs: no_distributors: # [boolean=false] Do not look for components price. For testing purposes no_price: false + # [number=100] Number of boards to build (components multiplier) + number: 100 # [string='%f-%i%v.%x'] Filename for the output (%i=kicost, %x=xlsx). Affected by global options output: '%f-%i%v.%x' # [boolean=false] Include the catalogue links in the catalogue code show_cat_url: false + # [string|list(string)] Declare part fields to include in multipart split process + split_extra_fields: # [list(dict)] Fields to rename (KiCost option, not internal filters) translate_fields: # [string=''] Name of the field to rename diff --git a/kibot/out_kicost.py b/kibot/out_kicost.py index aec3531b..ecc2b497 100644 --- a/kibot/out_kicost.py +++ b/kibot/out_kicost.py @@ -27,6 +27,8 @@ class Aggregate(Optionable): """ Name of the XML to aggregate """ self.variant = ' ' """ Variant for this project """ + self.number = 100 + """ Number of boards to build (components multiplier) """ def config(self, parent): super().config(parent) @@ -54,6 +56,8 @@ class KiCostOptions(VariantOptions): self.group_fields = Optionable """ [string|list(string)] List of fields that can be different for a group. Parts with differences in these fields are grouped together, but displayed individually """ + self.split_extra_fields = Optionable + """ [string|list(string)] Declare part fields to include in multipart split process """ self.ignore_fields = Optionable """ [string|list(string)] List of fields to be ignored """ self.fields = Optionable @@ -64,6 +68,8 @@ class KiCostOptions(VariantOptions): """ Regular expression to match the variant field (KiCost option, not internal variants) """ self.aggregate = Aggregate """ [list(dict)] Add components from other projects """ + self.number = 100 + """ Number of boards to build (components multiplier) """ super().__init__() self.add_to_doc('variant', WARNING_MIX) @@ -95,6 +101,7 @@ class KiCostOptions(VariantOptions): self.no_distributors = self._validate_dis(self.no_distributors) self.currency = self._validate_cur(self.currency) self.group_fields = Optionable.force_list(self.group_fields) + self.split_extra_fields = Optionable.force_list(self.split_extra_fields) self.ignore_fields = Optionable.force_list(self.ignore_fields) self.fields = Optionable.force_list(self.fields) # Adapt translate_fields to its use @@ -149,10 +156,15 @@ class KiCostOptions(VariantOptions): cmd.append(self.kicost_variant if self.kicost_variant else ' ') for p in self.aggregate: cmd.append(p.variant if p.variant else ' ') + cmd.extend(['--board_qty', str(self.number)]) + for p in self.aggregate: + cmd.append(str(p.number)) else: # Just this project if self.kicost_variant: cmd.extend(['--variant', self.kicost_variant]) + if self.number != 100: + cmd.extend(['--board_qty', str(self.number)]) # Pass the debug level if GS.debug_enabled: cmd.append('--debug={}'.format(GS.debug_level)) @@ -165,6 +177,7 @@ class KiCostOptions(VariantOptions): self.add_list_opt(cmd, 'exclude', self.no_distributors) self.add_list_opt(cmd, 'currency', self.currency) self.add_list_opt(cmd, 'group_fields', self.group_fields) + self.add_list_opt(cmd, 'split_extra_fields', self.split_extra_fields) self.add_list_opt(cmd, 'ignore_fields', self.ignore_fields) self.add_list_opt(cmd, 'fields', self.fields) # Field translation