[NEW] Add get_skip dict `re.search` option
@@ -106,6 +106,12 @@ TT_KEYS = (
'year', 'month', 'day', 'hour', 'minute', 'second', 'day_of_week',
'day_of_year', 'daylight_savings')
+SKIP_SWITCH = {
+ 'contains': lambda text, value: text in value,
+ 'intersection': lambda text, value: set(text).intersection(value),
+ 're.search': lambda text, value: re.search(text, value),
+}
+
url_quote = lambda url: quote(url, safe=URL_SAFE)
@@ -693,13 +699,7 @@ def get_skip(item, skip_if=None, **kwargs):
value = item.get(_skip['field'], '')
text = _skip.get('text')
op = _skip.get('op', 'contains')
-
- if text and op == 'contains':
- skip = text in value
- elif text and op == 'intersection':
- skip = set(text).intersection(value)
- else:
- skip = value
+ skip = SKIP_SWITCH[op](text, value) if text else value
if not _skip.get('include'):
skip = not skip
