[flake8] Optimized use of map+lambda
This commit is contained in:
parent
39e9d5c28c
commit
950a875c33
|
|
@ -201,10 +201,10 @@ class ComponentGroup(object):
|
||||||
def get_count(self, project=None):
|
def get_count(self, project=None):
|
||||||
if project is None:
|
if project is None:
|
||||||
# Total components
|
# Total components
|
||||||
qty = sum(map(lambda c: c.qty, self.components))
|
qty = sum((c.qty for c in self.components))
|
||||||
else:
|
else:
|
||||||
# Only for the specified project
|
# Only for the specified project
|
||||||
qty = sum(map(lambda c: c.qty if c.project == project else 0, self.components))
|
qty = sum((c.qty for c in self.components if c.project == project))
|
||||||
return self.round_qty(qty)
|
return self.round_qty(qty)
|
||||||
|
|
||||||
def get_build_count(self):
|
def get_build_count(self):
|
||||||
|
|
@ -213,10 +213,10 @@ class ComponentGroup(object):
|
||||||
return 0
|
return 0
|
||||||
if len(self.cfg.aggregate) == 1:
|
if len(self.cfg.aggregate) == 1:
|
||||||
# Just one project
|
# Just one project
|
||||||
qty = sum(map(lambda c: c.qty, self.components))*self.cfg.number
|
qty = sum((c.qty for c in self.components))*self.cfg.number
|
||||||
else:
|
else:
|
||||||
# Multiple projects, count them using the number of board for each project
|
# Multiple projects, count them using the number of board for each project
|
||||||
qty = sum(map(lambda c: self.cfg.qtys[c.project]*c.qty, self.components))
|
qty = sum((self.cfg.qtys[c.project]*c.qty for c in self.components))
|
||||||
return self.round_qty(qty)
|
return self.round_qty(qty)
|
||||||
|
|
||||||
def get_sources(self):
|
def get_sources(self):
|
||||||
|
|
@ -533,7 +533,7 @@ def do_bom(file_name, ext, comps, cfg):
|
||||||
# Create the BoM
|
# Create the BoM
|
||||||
logger.debug("Saving BOM File: "+file_name)
|
logger.debug("Saving BOM File: "+file_name)
|
||||||
number = cfg.number
|
number = cfg.number
|
||||||
cfg.number = sum(map(lambda prj: prj.number, cfg.aggregate))
|
cfg.number = sum((prj.number for prj in cfg.aggregate))
|
||||||
# Pre-format the total and fitted strings
|
# Pre-format the total and fitted strings
|
||||||
cfg.total_str = smd_tht(cfg, cfg.n_total, cfg.n_total_smd, cfg.n_total_tht)
|
cfg.total_str = smd_tht(cfg, cfg.n_total, cfg.n_total_smd, cfg.n_total_tht)
|
||||||
cfg.fitted_str = smd_tht(cfg, cfg.n_fitted, cfg.n_fitted_smd, cfg.n_fitted_tht)
|
cfg.fitted_str = smd_tht(cfg, cfg.n_fitted, cfg.n_fitted_smd, cfg.n_fitted_tht)
|
||||||
|
|
|
||||||
|
|
@ -231,7 +231,7 @@ def comp_match(component, ref_prefix, ref=None, relax_severity=False, stronger=F
|
||||||
check_extra_data(result, original)
|
check_extra_data(result, original)
|
||||||
result = value_from_grammar(result)
|
result = value_from_grammar(result)
|
||||||
if result and result.get_extra('discarded'):
|
if result and result.get_extra('discarded'):
|
||||||
discarded = " ".join(list(map(lambda x: '`'+x+'`', result.get_extra('discarded'))))
|
discarded = " ".join(('`'+x+'`' for x in result.get_extra('discarded')))
|
||||||
log_func_warn(W_BADVAL4+"Malformed value: `{}` (discarded: {}{})".format(original, discarded, where))
|
log_func_warn(W_BADVAL4+"Malformed value: `{}` (discarded: {}{})".format(original, discarded, where))
|
||||||
if not result:
|
if not result:
|
||||||
log_func_warn(W_BADVAL1+"Malformed value: `{}` (no match{})".format(original, where))
|
log_func_warn(W_BADVAL1+"Malformed value: `{}` (no match{})".format(original, where))
|
||||||
|
|
|
||||||
|
|
@ -340,7 +340,7 @@ class CfgYamlReader(object):
|
||||||
if explicit_outs:
|
if explicit_outs:
|
||||||
logger.warning(W_NOOUTPUTS+"No outputs found in `{}`".format(fn_rel))
|
logger.warning(W_NOOUTPUTS+"No outputs found in `{}`".format(fn_rel))
|
||||||
else:
|
else:
|
||||||
logger.debug('Outputs loaded from `{}`: {}'.format(fn_rel, list(map(lambda c: c.name, sel_outs))))
|
logger.debug('Outputs loaded from `{}`: {}'.format(fn_rel, (c.name for c in sel_outs)))
|
||||||
if outs is None and explicit_outs and 'outputs' not in data:
|
if outs is None and explicit_outs and 'outputs' not in data:
|
||||||
logger.warning(W_NOOUTPUTS+"No outputs found in `{}`".format(fn_rel))
|
logger.warning(W_NOOUTPUTS+"No outputs found in `{}`".format(fn_rel))
|
||||||
return sel_outs
|
return sel_outs
|
||||||
|
|
@ -364,7 +364,7 @@ class CfgYamlReader(object):
|
||||||
if explicit_pres:
|
if explicit_pres:
|
||||||
logger.warning(W_NOPREFLIGHTS+"No preflights found in `{}`".format(fn_rel))
|
logger.warning(W_NOPREFLIGHTS+"No preflights found in `{}`".format(fn_rel))
|
||||||
else:
|
else:
|
||||||
logger.debug('Preflights loaded from `{}`: {}'.format(fn_rel, list(map(lambda c: c._name, sel_pres))))
|
logger.debug('Preflights loaded from `{}`: {}'.format(fn_rel, (c._name for c in sel_pres)))
|
||||||
if pre is None and explicit_pres and 'preflight' not in data:
|
if pre is None and explicit_pres and 'preflight' not in data:
|
||||||
logger.warning(W_NOPREFLIGHTS+"No preflights found in `{}`".format(fn_rel))
|
logger.warning(W_NOPREFLIGHTS+"No preflights found in `{}`".format(fn_rel))
|
||||||
return sel_pres
|
return sel_pres
|
||||||
|
|
|
||||||
|
|
@ -625,7 +625,7 @@ class GS(object):
|
||||||
For tuples we assume the result is SVG coordinates, for 1 value a scale """
|
For tuples we assume the result is SVG coordinates, for 1 value a scale """
|
||||||
if GS.ki5:
|
if GS.ki5:
|
||||||
if isinstance(values, tuple):
|
if isinstance(values, tuple):
|
||||||
return tuple(map(lambda x: int(round(x*KICAD5_SVG_SCALE)), values))
|
return (int(round(x*KICAD5_SVG_SCALE)) for x in values)
|
||||||
return values*KICAD5_SVG_SCALE
|
return values*KICAD5_SVG_SCALE
|
||||||
if GS.ki7:
|
if GS.ki7:
|
||||||
if isinstance(values, tuple):
|
if isinstance(values, tuple):
|
||||||
|
|
@ -634,7 +634,7 @@ class GS(object):
|
||||||
# KiCad 6
|
# KiCad 6
|
||||||
mult = 10.0 ** (svg_precision - 6)
|
mult = 10.0 ** (svg_precision - 6)
|
||||||
if isinstance(values, tuple):
|
if isinstance(values, tuple):
|
||||||
return tuple(map(lambda x: int(round(x*mult)), values))
|
return (int(round(x*mult)) for x in values)
|
||||||
return values*mult
|
return values*mult
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue