File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 44import colorsys
55from collections import OrderedDict
66
7+
78def match (string , patterns ):
8- if not isinstance (string , str ):
9+ if patterns is None or not isinstance (string , str ):
910 return False
1011 if isinstance (patterns , str ):
1112 patterns = [patterns ]
12- elif patterns is None :
13- return False
14- return any ([ bool ( re . search ( p , string )) for p in patterns ])
13+
14+ return any ( map ( lambda p : re . search ( p , string ), patterns ))
15+
1516
1617def inspect_callable (f ):
1718 """
Original file line number Diff line number Diff line change 1+ from stackprinter .utils import match
2+ import re
3+
4+
5+ def test_match ():
6+ assert match ('my/ignored/path' , None ) is False
7+ assert match ('my/ignored/path' , 'ignored' )
8+ assert match ('my/ignored/path' , ['not' , 'ignored' ])
9+ assert match ('my/ignored/path' , [re .compile ('not ignored' ), re .compile ('ignored' )])
You can’t perform that action at this time.
0 commit comments