Test Failed
Pull Request — master (#777)
by
unknown
03:45
created

MySafeConstructor.add_bool()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
from yaml.constructor import SafeConstructor
2
3
# Create custom safe constructor class that inherits from SafeConstructor
4
class MySafeConstructor(SafeConstructor):
5
6
    # Create new method handle boolean logic
7
    def add_bool(self, node):
8
        return self.construct_scalar(node)
9
10
# Inject the above boolean logic into the custom constuctor
11
MySafeConstructor.add_constructor('tag:yaml.org,2002:bool',
12
                                      MySafeConstructor.add_bool)
13