Replaced dicts used just to test membership by sets.

This commit is contained in:
Salvador E. Tropea 2020-09-12 12:50:16 -03:00
parent 257b9fdd3f
commit 1ed960d045
5 changed files with 33 additions and 33 deletions

View File

@ -21,7 +21,7 @@ logger = log.get_logger(__name__)
# RV == Resistor Variable or Varistor
# RN == Resistor 'N'(Pack)
# RT == Thermistor
RLC_PREFIX = {'R': 1, 'L': 1, 'C': 1, 'RV': 1, 'RN': 1, 'RT': 1}
RLC_PREFIX = {'R', 'L', 'C', 'RV', 'RN', 'RT'}
def compare_value(c1, c2, cfg):

View File

@ -74,16 +74,16 @@ class ColumnList:
# Default columns
# These columns are 'immutable'
COLUMNS_PROTECTED_L = {
COL_REFERENCE_L[:-1]: 1, # The column is References and the field Reference
COL_GRP_QUANTITY_L: 1,
COL_VALUE_L: 1,
COL_PART_L: 1,
COL_PART_LIB_L: 1,
COL_REFERENCE_L[:-1], # The column is References and the field Reference
COL_GRP_QUANTITY_L,
COL_VALUE_L,
COL_PART_L,
COL_PART_LIB_L,
# COL_DESCRIPTION_L: 1,
COL_DATASHEET_L: 1,
COL_SHEETPATH_L: 1,
COL_FP_L: 1,
COL_FP_LIB_L: 1
COL_DATASHEET_L,
COL_SHEETPATH_L,
COL_FP_L,
COL_FP_LIB_L
}
# Default fields used to group components

View File

@ -943,7 +943,7 @@ class SchematicComponent(object):
# Add to the global collection
if name_lc not in fields_lc:
fields.append(field.name)
fields_lc[name_lc] = 1
fields_lc.add(name_lc)
# Add to the component
comp.add_field(field)
line = f.get_line()
@ -1330,7 +1330,7 @@ class Schematic(object):
raise SchFileError('Wrong entry in title block', line, f)
self.title_block[m.group(1)] = m.group(2)
def load(self, fname, sheet_path='', sheet_path_h='/', libs={}, fields=[], fields_lc={}):
def load(self, fname, sheet_path='', sheet_path_h='/', libs={}, fields=[], fields_lc=set()):
""" Load a v5.x KiCad Schematic.
The caller must be sure the file exists.
Only the schematics are loaded not the libs. """
@ -1419,12 +1419,12 @@ class Schematic(object):
def get_field_names(self, fields):
""" Appends the collected field names to the provided names """
fields_lc = {v.lower(): 1 for v in fields}
fields_lc = {v.lower() for v in fields}
for f in self.fields:
name_lc = f.lower()
if name_lc not in fields_lc:
fields.append(f)
fields_lc[name_lc] = 1
fields_lc.add(name_lc)
return fields
def walk_components(self, function, obj):

View File

@ -55,27 +55,27 @@ UI_VIRTUAL = 2
# Supported values for "do not fit"
DNF = {
"dnf": 1,
"dnl": 1,
"dnp": 1,
"do not fit": 1,
"do not place": 1,
"do not load": 1,
"nofit": 1,
"nostuff": 1,
"noplace": 1,
"noload": 1,
"not fitted": 1,
"not loaded": 1,
"not placed": 1,
"no stuff": 1,
"dnf",
"dnl",
"dnp",
"do not fit",
"do not place",
"do not load",
"nofit",
"nostuff",
"noplace",
"noload",
"not fitted",
"not loaded",
"not placed",
"no stuff",
}
# String matches for marking a component as "do not change" or "fixed"
DNC = {
"dnc": 1,
"do not change": 1,
"no change": 1,
"fixed": 1
"dnc",
"do not change",
"no change",
"fixed",
}

View File

@ -21,7 +21,7 @@ from .fil_base import BaseFilter, apply_exclude_filter, apply_fitted_filter, app
from . import log
logger = log.get_logger(__name__)
VALID_STYLES = {'modern-blue': 1, 'modern-green': 1, 'modern-red': 1, 'classic': 1}
VALID_STYLES = {'modern-blue', 'modern-green', 'modern-red', 'classic'}
DEFAULT_ALIASES = [['r', 'r_small', 'res', 'resistor'],
['l', 'l_small', 'inductor'],
['c', 'c_small', 'cap', 'capacitor'],