Test Failed
Pull Request — master (#778)
by Nicola
03:54
created

savu.plugins.loaders.utils.my_safe_constructor   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 13
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A MySafeConstructor.add_bool() 0 2 1
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