Belle II Software
release-05-02-19
Main Page
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
z
Variables
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Typedefs
a
b
c
d
e
h
i
l
m
n
p
r
s
t
v
w
Enumerations
Enumerator
c
d
f
p
t
u
v
w
Classes
Class List
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Enumerations
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
Enumerator
a
b
c
d
e
f
g
h
k
l
m
n
o
p
r
s
t
u
v
w
z
Related Functions
b
c
d
g
i
o
r
s
t
Files
File List
File Members
All
Functions
logfilter.py
1
"""
2
Log Filter class to replace string occurences in log messages to simplify testing
3
"""
4
import
re
5
6
7
class
LogReplacementFilter
:
8
"""
9
Simple class to intercept anything written to python stdout and replace
10
a given set of strings with placehholders to improve reproducibility.
11
"""
12
def
__init__
(self, out, replacements):
13
"""Setup the forwarding and replacements
14
15
Parameters:
16
out (file object): Where to forward the output too
17
replacements (dict(str, str)): Dictionary of strings and their replacements
18
"""
19
20
self.
_out
= out
21
22
self.
_replacements
= replacements
23
24
self.
_regex
= re.compile(
"|"
.join(re.escape(e)
for
e
in
replacements))
25
26
def
write
(self, data):
27
"""Check all messages for strings to replace"""
28
replaced = self.
_regex
.sub(
lambda
m: self.
_replacements
[m[0]], data)
29
self.
_out
.
write
(replaced)
30
31
def
__getattr__
(self, name):
32
"""Forward all other methods from the out stream"""
33
return
getattr(self.
_out
, name)
b2test_utils.logfilter.LogReplacementFilter.__getattr__
def __getattr__(self, name)
Definition:
logfilter.py:31
b2test_utils.logfilter.LogReplacementFilter._out
_out
where to forward output
Definition:
logfilter.py:20
b2test_utils.logfilter.LogReplacementFilter.__init__
def __init__(self, out, replacements)
Definition:
logfilter.py:12
b2test_utils.logfilter.LogReplacementFilter.write
def write(self, data)
Definition:
logfilter.py:26
b2test_utils.logfilter.LogReplacementFilter._regex
_regex
build a regular expression from dictionary keys
Definition:
logfilter.py:24
b2test_utils.logfilter.LogReplacementFilter._replacements
_replacements
what to replace
Definition:
logfilter.py:22
b2test_utils.logfilter.LogReplacementFilter
Definition:
logfilter.py:7
framework
scripts
b2test_utils
logfilter.py
Generated on Tue Jan 4 2022 02:57:13 for Belle II Software by
1.8.17