[DOCs] Made the filters for ERC/DRC vs globals more clear

- Now the KiBot ones doesn't mention KiCad versions
- If the user uses Wxxx for the `error` in the KiBot ones we filter xxx
- Added text to clarify how to get rid of W058 warnings
- Also now we report warning counts when all filtered

Related to #214
This commit is contained in:
Salvador E. Tropea 2022-09-16 10:16:20 -03:00
parent 599ddcfc5b
commit 49b21c8e93
5 changed files with 29 additions and 11 deletions

View File

@ -362,12 +362,16 @@ This section is used to specify tasks that will be executed before generating an
- `erc_warnings`: [boolean=false] Option for `run_erc`. ERC warnings are considered errors.
- `fill_zones`: [boolean=false] Fill all zones again and save the PCB.
- `filters`: [list(dict)] A list of entries to filter out ERC/DRC messages.
Note that ignored errors will become KiBot warnings (i.e. `(W058) ...`).
To farther ignore these warnings use the `filters` option in the `global` section.
* 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`: [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. KiCad 5 only.
- `number`: [number=0] Error number we want to exclude.
KiCad 5 only.
- `regex`: [string=''] 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.
@ -700,11 +704,11 @@ global:
- `field_3D_model`: [string='_3D_model'] Name for the field controlling the 3D models used for a component.
- `filters`: [list(dict)] KiBot warnings to be ignored.
* 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`: [string=''] Error id we want to exclude.
- *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. KiCad 5 only.
- `number`: [number=0] Error number we want to exclude.
- `regex`: [string=''] Regular expression to match the text for the error we want to exclude.
- *regexp*: Alias for regex.
- `hide_excluded`: [boolean=false] Default value for the `hide_excluded` option of various PCB outputs.

View File

@ -33,6 +33,8 @@ preflight:
# [boolean=false] Fill all zones again and save the PCB.
fill_zones: true
# [list(dict)] A list of entries to filter out ERC/DRC messages.
# Note that ignored errors will become KiBot warnings (i.e. `(W058) ...`).
# To farther ignore these warnings use the `filters` option in the `global` section.
filters:
- filter: 'Filter description'
error: '10'

View File

@ -9,7 +9,7 @@ from .gs import GS
from .optionable import Optionable
from .kicad.config import expand_env
from .macros import macros, document # noqa: F401
from .pre_filters import FiltersOptions
from .pre_filters import FiltersOptions, FilterOptionsKiBot
from .log import get_logger, set_filters
from .misc import W_MUSTBEINT
from .kicad.config import KiConf
@ -241,6 +241,7 @@ class Globals(FiltersOptions):
The KIPRJMOD is also available for expansion """
self.set_doc('filters', " [list(dict)] KiBot warnings to be ignored ")
self._filter_what = 'KiBot warnings'
self.filters = FilterOptionsKiBot
self._unkown_is_error = True
self._error_context = 'global '

View File

@ -87,12 +87,13 @@ class MyLogger(logging.Logger):
pos_end = buf.find(')')
if pos_end > 0:
num_str = buf[2:pos_end]
id = buf[1:pos_end]
if num_str[0] == 'C':
number = int(buf[3:pos_end])+1000
else:
number = int(num_str)
for f in filters:
if f.number == number and f.regex.search(buf):
if (f.number == number or f.error == id) and f.regex.search(buf):
MyLogger.n_filtered += 1
return
MyLogger.warn_cnt += 1
@ -125,7 +126,7 @@ class MyLogger(logging.Logger):
super(self.__class__, self).debug(msg, *args, **kwargs)
def log_totals(self):
if MyLogger.warn_cnt:
if MyLogger.warn_cnt or MyLogger.warn_tcnt:
filt_msg = ''
if MyLogger.n_filtered:
filt_msg = ', {} filtered'.format(MyLogger.n_filtered)

View File

@ -16,7 +16,7 @@ from .log import get_logger
logger = get_logger(__name__)
class FilterOptions(Optionable):
class FilterOptionsKiBot(Optionable):
""" Valid options for a filter entry """
def __init__(self):
super().__init__()
@ -27,9 +27,9 @@ class FilterOptions(Optionable):
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 """
""" Error id we want to exclude """
self.number = 0
""" Error number we want to exclude. KiCad 5 only """
""" Error number we want to exclude """
self.error_number = None
""" {number} """
self.regex = ''
@ -38,6 +38,14 @@ class FilterOptions(Optionable):
""" {regex} """
class FilterOptions(FilterOptionsKiBot):
""" Valid options for a filter entry """
def __init__(self):
super().__init__()
self.add_to_doc('error', 'A name for KiCad 6 or a number for KiCad 5, but always a string')
self.add_to_doc('number', 'KiCad 5 only')
class FiltersOptions(Optionable):
""" A list of filter entries """
def __init__(self):
@ -78,7 +86,9 @@ class FiltersOptions(Optionable):
@pre_class
class Filters(BasePreFlight): # noqa: F821
""" [list(dict)] A list of entries to filter out ERC/DRC messages """
""" [list(dict)] A list of entries to filter out ERC/DRC messages.
Note that ignored errors will become KiBot warnings (i.e. `(W058) ...`).
To farther ignore these warnings use the `filters` option in the `global` section """
def __init__(self, name, value):
f = FiltersOptions()
f.set_tree({'filters': value})