Added Default global `dir` option

This commit is contained in:
Salvador E. Tropea 2021-11-15 14:40:30 -03:00
parent 813a5f9917
commit 998754753d
9 changed files with 60 additions and 27 deletions

View File

@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
space. This helps for cases like "10K 1%".
- Generic filter: options to match if a field is/isn't defined.
- Excellon drill: added `route_mode_for_oval_holes` option.
- Default global `dir` option.
### Changed
- Internal BoM: now components with different Tolerance, Voltage, Current

View File

@ -189,7 +189,7 @@ KiCad 6 uses strings to differentiate errors, use them for the `error` field. To
### Default global options
The section `global` contains default global options that affects all the outputs.
Currently only one option is supported.
Currently only a few option are supported.
#### Default *output* option
@ -218,6 +218,15 @@ global:
output: '%f_rev_%r-%i.%x'
```
#### Default *dir* option
The default `dir` value for any output is `.`. You can change it here.
Expansion patterns are allowed.
Note that you can use this value as a base for output's `dir` options. In this case the value defined in the `output` must start with `+`.
In this case the `+` is replaced by the default `dir` value defined here.
#### Default *variant* option
This option controls the default variant applied to all the outputs. Example:
@ -624,7 +633,7 @@ Next time you need this list just use an alias, like this:
The output can be loaded using Open Board View (https://openboardview.org/)
* Valid keys:
- `comment`: [string=''] A comment for documentation purposes.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `name`: [string=''] Used to identify this particular output definition.
- `options`: [dict] Options for the `boardview` output.
* Valid keys:
@ -641,7 +650,7 @@ Next time you need this list just use an alias, like this:
This output is what you get from the 'Tools/Generate Bill of Materials' menu in eeschema.
* Valid keys:
- `comment`: [string=''] A comment for documentation purposes.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `name`: [string=''] Used to identify this particular output definition.
- `options`: [dict] Options for the `bom` output.
* Valid keys:
@ -720,7 +729,8 @@ Next time you need this list just use an alias, like this:
- `merge_both_blank`: [boolean=true] When creating groups two components with empty/missing field will be interpreted as with the same value.
- `no_conflict`: [list(string)] List of fields where we tolerate conflicts.
Use it to avoid undesired warnings.
By default the field indicated in `fit_field`, the field used for variants and the field `part` are excluded.
By default the field indicated in `fit_field`, the field used for variants and
the field `part` are excluded.
- `no_distributors`: [string|list(string)] Exclude this distributors list. They are removed after computing `distributors`.
- `normalize_locale`: [boolean=false] When normalizing values use the locale decimal point.
- `normalize_values`: [boolean=false] Try to normalize the R, L and C values, producing uniform units and prefixes.
@ -754,7 +764,7 @@ Next time you need this list just use an alias, like this:
This is used to generate groups of files in compressed file format.
* Valid keys:
- `comment`: [string=''] A comment for documentation purposes.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `name`: [string=''] Used to identify this particular output definition.
- `options`: [dict] Options for the `compress` output.
* Valid keys:
@ -776,7 +786,7 @@ Next time you need this list just use an alias, like this:
This output is what you get from the File/Plot menu in pcbnew.
* Valid keys:
- `comment`: [string=''] A comment for documentation purposes.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `layers`: [list(dict)|list(string)|string] [all,selected,copper,technical,user]
List of PCB layers to plot.
* Valid keys:
@ -820,7 +830,7 @@ Next time you need this list just use an alias, like this:
This output is what you get from the 'File/Fabrication output/Drill Files' menu in pcbnew.
* Valid keys:
- `comment`: [string=''] A comment for documentation purposes.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `name`: [string=''] Used to identify this particular output definition.
- `options`: [dict] Options for the `excellon` output.
* Valid keys:
@ -842,6 +852,7 @@ Next time you need this list just use an alias, like this:
- `filename`: [string=''] Name of the drill report. Not generated unless a name is specified.
(%i='drill_report' %x='txt').
- `right_digits`: [number=0] number of digits for mantissa part of coordinates (0 is auto).
- `route_mode_for_oval_holes`: Undocumented.
- `use_aux_axis_as_origin`: [boolean=false] Use the auxiliary axis as origin for coordinates.
- `zeros_format`: [string='DECIMAL_FORMAT'] [DECIMAL_FORMAT,SUPPRESS_LEADING,SUPPRESS_TRAILING,KEEP_ZEROS] How to handle the zeros.
@ -852,7 +863,7 @@ Next time you need this list just use an alias, like this:
This output is what you get from the 'File/Fabrication output/Drill Files' menu in pcbnew.
* Valid keys:
- `comment`: [string=''] A comment for documentation purposes.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `name`: [string=''] Used to identify this particular output definition.
- `options`: [dict] Options for the `gerb_drill` output.
* Valid keys:
@ -876,7 +887,7 @@ Next time you need this list just use an alias, like this:
This output is what you get from the File/Plot menu in pcbnew.
* Valid keys:
- `comment`: [string=''] A comment for documentation purposes.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `layers`: [list(dict)|list(string)|string] [all,selected,copper,technical,user]
List of PCB layers to plot.
* Valid keys:
@ -925,7 +936,7 @@ Next time you need this list just use an alias, like this:
This output is what you get from the File/Plot menu in pcbnew.
* Valid keys:
- `comment`: [string=''] A comment for documentation purposes.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `layers`: [list(dict)|list(string)|string] [all,selected,copper,technical,user]
List of PCB layers to plot.
* Valid keys:
@ -971,7 +982,7 @@ Next time you need this list just use an alias, like this:
This output is what you get from the InteractiveHtmlBom plug-in (pcbnew).
* Valid keys:
- `comment`: [string=''] A comment for documentation purposes.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `name`: [string=''] Used to identify this particular output definition.
- `options`: [dict] Options for the `ibom` output.
* Valid keys:
@ -1033,7 +1044,7 @@ Next time you need this list just use an alias, like this:
This output is what you get from the 'Tools/Generate Bill of Materials' menu in eeschema.
* Valid keys:
- `comment`: [string=''] A comment for documentation purposes.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `name`: [string=''] Used to identify this particular output definition.
- `options`: [dict] Options for the `kibom` output.
* Valid keys:
@ -1124,7 +1135,7 @@ Next time you need this list just use an alias, like this:
This output is what you get from the KiCost plug-in (eeschema).
* Valid keys:
- `comment`: [string=''] A comment for documentation purposes.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `name`: [string=''] Used to identify this particular output definition.
- `options`: [dict] Options for the `kicost` output.
* Valid keys:
@ -1161,7 +1172,7 @@ Next time you need this list just use an alias, like this:
Can also render the components if the 2D models are available
* Valid keys:
- `comment`: [string=''] A comment for documentation purposes.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `name`: [string=''] Used to identify this particular output definition.
- `options`: [dict] Options for the `pcbdraw` output.
* Valid keys:
@ -1207,7 +1218,7 @@ Next time you need this list just use an alias, like this:
- `content`: [string=''] Content for the report. Use ${basename} for the project name without extension.
Use ${filename(LAYER)} for the file corresponding to LAYER.
- `output`: [string='Custom_report.txt'] File name for the custom report.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `dnf_filter`: [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.
- `drill_marks`: [string='full'] what to use to indicate the drill places, can be none, small or full (for real scale).
@ -1267,7 +1278,7 @@ Next time you need this list just use an alias, like this:
This output is what you get from the 'File/Print' menu in pcbnew.
* Valid keys:
- `comment`: [string=''] A comment for documentation purposes.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `layers`: [list(dict)|list(string)|string] [all,selected,copper,technical,user]
List of PCB layers to include in the PDF.
* Valid keys:
@ -1297,7 +1308,7 @@ Next time you need this list just use an alias, like this:
This output is what you get from the 'File/Print' menu in eeschema.
* Valid keys:
- `comment`: [string=''] A comment for documentation purposes.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `name`: [string=''] Used to identify this particular output definition.
- `options`: [dict] Options for the `pdf_sch_print` output.
* Valid keys:
@ -1313,7 +1324,7 @@ Next time you need this list just use an alias, like this:
This output is what you get from the 'File/Fabrication output/Footprint poistion (.pos) file' menu in pcbnew.
* Valid keys:
- `comment`: [string=''] A comment for documentation purposes.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `name`: [string=''] Used to identify this particular output definition.
- `options`: [dict] Options for the `position` output.
* Valid keys:
@ -1338,7 +1349,7 @@ Next time you need this list just use an alias, like this:
This output is what you get from the File/Plot menu in pcbnew.
* Valid keys:
- `comment`: [string=''] A comment for documentation purposes.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `layers`: [list(dict)|list(string)|string] [all,selected,copper,technical,user]
List of PCB layers to plot.
* Valid keys:
@ -1388,7 +1399,7 @@ Next time you need this list just use an alias, like this:
Is just a tweaked version of the original where you can look at the results.
* Valid keys:
- `comment`: [string=''] A comment for documentation purposes.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `name`: [string=''] Used to identify this particular output definition.
- `options`: [dict] Options for the `sch_variant` output.
* Valid keys:
@ -1403,7 +1414,7 @@ Next time you need this list just use an alias, like this:
This output is what you get from the 'File/Export/STEP' menu in pcbnew.
* Valid keys:
- `comment`: [string=''] A comment for documentation purposes.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `name`: [string=''] Used to identify this particular output definition.
- `options`: [dict] Options for the `step` output.
* Valid keys:
@ -1427,7 +1438,7 @@ Next time you need this list just use an alias, like this:
This output is what you get from the File/Plot menu in pcbnew.
* Valid keys:
- `comment`: [string=''] A comment for documentation purposes.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `layers`: [list(dict)|list(string)|string] [all,selected,copper,technical,user]
List of PCB layers to plot.
* Valid keys:
@ -1469,7 +1480,7 @@ Next time you need this list just use an alias, like this:
This is a format to document your schematic.
* Valid keys:
- `comment`: [string=''] A comment for documentation purposes.
- `dir`: [string='.'] Output directory for the generated files.
- `dir`: [string='.'] Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir.
- `name`: [string=''] Used to identify this particular output definition.
- `options`: [dict] Options for the `svg_sch_print` output.
* Valid keys:

View File

@ -168,7 +168,7 @@ KiCad 6 uses strings to differentiate errors, use them for the `error` field. To
### Default global options
The section `global` contains default global options that affects all the outputs.
Currently only one option is supported.
Currently only a few option are supported.
#### Default *output* option
@ -197,6 +197,15 @@ global:
output: '%f_rev_%r-%i.%x'
```
#### Default *dir* option
The default `dir` value for any output is `.`. You can change it here.
Expansion patterns are allowed.
Note that you can use this value as a base for output's `dir` options. In this case the value defined in the `output` must start with `+`.
In this case the `+` is replaced by the default `dir` value defined here.
#### Default *variant* option
This option controls the default variant applied to all the outputs. Example:

View File

@ -169,7 +169,8 @@ outputs:
merge_both_blank: true
# [list(string)] List of fields where we tolerate conflicts.
# Use it to avoid undesired warnings.
# By default the field indicated in `fit_field`, the field used for variants and the field `part` are excluded
# By default the field indicated in `fit_field`, the field used for variants and
# the field `part` are excluded
no_conflict: ['Config', 'Part']
# [string|list(string)] Exclude this distributors list. They are removed after computing `distributors`
no_distributors:
@ -340,6 +341,7 @@ outputs:
filename: ''
# [number=0] number of digits for mantissa part of coordinates (0 is auto)
right_digits: 0
route_mode_for_oval_holes: true
# [boolean=false] Use the auxiliary axis as origin for coordinates
use_aux_axis_as_origin: false
# [string='DECIMAL_FORMAT'] [DECIMAL_FORMAT,SUPPRESS_LEADING,SUPPRESS_TRAILING,KEEP_ZEROS] How to handle the zeros

View File

@ -327,6 +327,7 @@ class CfgYamlReader(object):
data = self.load_yaml(fstream)
# Transfer command line global overwrites
GS.global_output = GS.global_from_cli.get('output', None)
GS.global_dir = GS.global_from_cli.get('dir', None)
GS.global_variant = GS.global_from_cli.get('variant', None)
GS.global_kiauto_wait_start = GS.global_from_cli.get('kiauto_wait_start', None)
GS.global_kiauto_time_out_scale = GS.global_from_cli.get('kiauto_time_out_scale', None)

View File

@ -17,6 +17,8 @@ class Globals(FiltersOptions):
with document:
self.output = ''
""" Default pattern for output file names """
self.dir = ''
""" Default pattern for the output directories """
self.variant = ''
""" Default variant to apply to all outputs """
self.kiauto_wait_start = 0
@ -40,6 +42,7 @@ class Globals(FiltersOptions):
def config(self, parent):
super().config(parent)
GS.global_output = self.set_global(GS.global_output, self.output, 'output')
GS.global_dir = self.set_global(GS.global_dir, self.dir, 'dir')
GS.global_variant = self.set_global(GS.global_variant, self.variant, 'variant')
GS.global_kiauto_wait_start = self.set_global(GS.global_kiauto_wait_start, self.kiauto_wait_start, 'kiauto_wait_start')
if GS.global_kiauto_wait_start and int(GS.global_kiauto_wait_start) != GS.global_kiauto_wait_start:

View File

@ -70,6 +70,7 @@ class GS(object):
# after defining its own options to allow Optionable do the overwrite.
global_from_cli = {}
global_output = None
global_dir = None
global_variant = None
global_kiauto_wait_start = None
global_kiauto_time_out_scale = None

View File

@ -30,9 +30,11 @@ class BaseOutput(RegOutput):
self.type = ''
""" Type of output """
self.dir = '.'
""" Output directory for the generated files """
""" Output directory for the generated files. If it starts with `+` the rest is concatenated to the default dir """
self.comment = ''
""" A comment for documentation purposes """
if GS.global_dir:
self.dir = GS.global_dir
self._sch_related = False
self._unkown_is_error = True
self._done = False
@ -66,6 +68,8 @@ class BaseOutput(RegOutput):
def config(self, parent):
super().config(parent)
if self.dir[0] == '+':
self.dir = (GS.global_dir if GS.global_dir is not None else '.') + self.dir[1:]
if getattr(self, 'options', None) and isinstance(self.options, type):
# No options, get the defaults
self.options = self.options()

View File

@ -295,7 +295,8 @@ class BoMOptions(BaseOptions):
self.no_conflict = NoConflict
""" [list(string)] List of fields where we tolerate conflicts.
Use it to avoid undesired warnings.
By default the field indicated in `fit_field`, the field used for variants and the field `part` are excluded """
By default the field indicated in `fit_field`, the field used for variants and
the field `part` are excluded """
self.aggregate = Aggregate
""" [list(dict)] Add components from other projects """
self.ref_id = ''