Added support for KiCad 6 error filters.

This commit is contained in:
Salvador E. Tropea 2020-10-15 17:00:58 -03:00
parent c80fc49b54
commit 4a97885495
4 changed files with 26 additions and 17 deletions

View File

@ -98,10 +98,11 @@ This section is used to specify tasks that will be executed before generating an
- check_zone_fills: [boolean=false] Zones are filled before doing any operation involving PCB layers.
- filters: [list(dict)] A list of entries to filter out ERC/DRC messages.
* Valid keys:
- `error`: [string=''] Error id we want to exclude. A name for KiCad 6 or a number for KiCad 5, but always a string.
- *error_number*: Alias for number.
- `filter`: [string=''] Name for the filter, for documentation purposes.
- *filter_msg*: Alias for filter.
- `number`: [number=0] Error number we want to exclude.
- `number`: [number=0] Error number we want to exclude. KiCad 5 only.
- `regex`: [string='None'] Regular expression to match the text for the error we want to exclude.
- *regexp*: Alias for regex.
- ignore_unconnected: [boolean=false] Option for `run_drc`. Ignores the unconnected nets. Useful if you didn't finish the routing.
@ -136,11 +137,11 @@ that the error must match to be ignored (`regex`). Like this:
```yaml
filters:
- filter: 'Optional filter description'
number: Numeric_error_type
error: 'Error_type'
regex: 'Expression to match'
```
Here is an example, suppose you are getting the following errors:
Here is a KiCad 5 example, suppose you are getting the following errors:
```
** Found 1 DRC errors **
@ -159,10 +160,10 @@ And you want to ignore them. You can add the following filters:
```yaml
filters:
- filter: 'Ignore C3 pad 2 too close to anything'
number: 4
error: '4'
regex: 'Pad 2 of C3'
- filter: 'Ignore unconnected pad 2 of C4'
number: 2
error: '2'
regex: 'Pad 2 of C4'
```
@ -172,6 +173,8 @@ If you have two or more different options for a text to match try using `(OPTION
A complete Python regular expressions explanation is out the scope of this manual. For a complete reference consult the [Python manual](https://docs.python.org/3/library/re.html).
KiCad 6 uses strings to differentiate errors, use them for the `error` field. To keep compatibility you can use the `number` or `error_number` options for KiCad 5.
**Important note**: this will create a file named *kibot_errors.filter* in the output directory.

View File

@ -119,11 +119,11 @@ that the error must match to be ignored (`regex`). Like this:
```yaml
filters:
- filter: 'Optional filter description'
number: Numeric_error_type
error: 'Error_type'
regex: 'Expression to match'
```
Here is an example, suppose you are getting the following errors:
Here is a KiCad 5 example, suppose you are getting the following errors:
```
** Found 1 DRC errors **
@ -142,10 +142,10 @@ And you want to ignore them. You can add the following filters:
```yaml
filters:
- filter: 'Ignore C3 pad 2 too close to anything'
number: 4
error: '4'
regex: 'Pad 2 of C3'
- filter: 'Ignore unconnected pad 2 of C4'
number: 2
error: '2'
regex: 'Pad 2 of C4'
```
@ -155,6 +155,8 @@ If you have two or more different options for a text to match try using `(OPTION
A complete Python regular expressions explanation is out the scope of this manual. For a complete reference consult the [Python manual](https://docs.python.org/3/library/re.html).
KiCad 6 uses strings to differentiate errors, use them for the `error` field. To keep compatibility you can use the `number` or `error_number` options for KiCad 5.
**Important note**: this will create a file named *kibot_errors.filter* in the output directory.

View File

@ -7,7 +7,7 @@ preflight:
# [list(dict)] A list of entries to filter out ERC/DRC messages
filters:
- filter: 'Filter description'
number: 10
error: '10'
regex: 'Regular expression to match'
# [boolean=false] Option for `run_drc`. Ignores the unconnected nets. Useful if you didn't finish the routing
ignore_unconnected: false

View File

@ -25,8 +25,10 @@ class FilterOptions(Optionable):
""" Name for the filter, for documentation purposes """
self.filter_msg = None
""" {filter} """
self.error = ''
""" Error id we want to exclude. A name for KiCad 6 or a number for KiCad 5, but always a string """
self.number = 0
""" Error number we want to exclude """
""" Error number we want to exclude. KiCad 5 only """
self.error_number = None
""" {number} """
self.regex = 'None'
@ -51,19 +53,21 @@ class FiltersOptions(Optionable):
if not isinstance(self.filters, type):
for f in self.filters:
where = ' (in `{}` filter)'.format(f.filter) if f.filter else ''
number = f.number
if not number:
raise KiPlotConfigurationError('Missing `number`'+where)
error = f.error
if not error:
if not f.number:
raise KiPlotConfigurationError('Missing `error`'+where)
error = str(f.number)
regex = f.regex
if regex == 'None':
raise KiPlotConfigurationError('Missing `regex`'+where)
comment = f.filter
logger.debug("Adding {} filter '{}','{}','{}'".format(self._filter_what, comment, number, regex))
logger.debug("Adding {} filter '{}','{}','{}'".format(self._filter_what, comment, error, regex))
if parsed is None:
parsed = ''
if comment:
parsed += '# '+comment+'\n'
parsed += '{},{}\n'.format(number, regex)
parsed += '{},{}\n'.format(error, regex)
f.regex = re.compile(regex)
# If the list is valid make a copy for the warnings filter
if parsed:
@ -82,7 +86,7 @@ class Filters(BasePreFlight): # noqa: F821
def get_example():
""" Returns a YAML value for the example config """
return "\n - filter: 'Filter description'\n number: 10\n regex: 'Regular expression to match'"
return "\n - filter: 'Filter description'\n error: '10'\n regex: 'Regular expression to match'"
@classmethod
def get_doc(cls):