Skip to content

Instantly share code, notes, and snippets.

@CapnKernel
Created March 3, 2020 23:38
Show Gist options
  • Save CapnKernel/b15f2debd8e995cadfa2e34c547de5ac to your computer and use it in GitHub Desktop.
Save CapnKernel/b15f2debd8e995cadfa2e34c547de5ac to your computer and use it in GitHub Desktop.
@@ -551,20 +549,14 @@
for p in self.libparts:
s.update( p.getFieldNames() )
- # omit anything matching any regex in excluded_fields
- ret = set()
- for field in s:
- exclude = False
- for rex in excluded_fields:
- if re.match( rex, field ):
- exclude = True
- break
- if not exclude:
- ret.add(field)
+ # omit anything matching regexes in excluded_fields
+ excluded_fields_re = tuple(re.compile(excluded_field) for excluded_field in self.excluded_fields)
+
+ ret = {field for field in s if not any((excluded_field_re.match(field) for excluded_field_re in excluded_fields_re))}
return ret # this is a python 'set'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment