File tree 2 files changed +14
-4
lines changed 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 4
4
import colorsys
5
5
from collections import OrderedDict
6
6
7
+
7
8
def match (string , patterns ):
8
- if not isinstance (string , str ):
9
+ if patterns is None or not isinstance (string , str ):
9
10
return False
10
11
if isinstance (patterns , str ):
11
12
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
+
15
16
16
17
def inspect_callable (f ):
17
18
"""
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