Passed
Push — main ( d734b8...136ca2 )
by Sat CFDI
08:24 queued 03:47
created

satcfdi.utils   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 32
dl 0
loc 43
ccs 24
cts 24
cp 1
rs 10
c 0
b 0
f 0
wmc 8

3 Methods

Rating   Name   Duplication   Size   Complexity  
A StrEnum.__str__() 0 2 1
A StrEnum.get() 0 3 1
A StrEnum.__format__() 0 2 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A iterate() 0 10 5
1 1
import enum
2 1
from collections.abc import Sequence, Mapping
3
4 1
from lxml import etree
5
6 1
parser = etree.XMLParser(
7
    no_network=True,
8
    remove_comments=True,
9
    remove_blank_text=True,
10
    huge_tree=True,
11
    collect_ids=False,
12
    remove_pis=True,
13
    recover=True
14
)
15
16
17 1
class ScalarMap(dict):
18 1
    pass
19
20
21 1
def iterate(item):
22 1
    if isinstance(item, str | bytes | ScalarMap):
23 1
        return [item]
24 1
    if isinstance(item, Mapping):
25 1
        return item.values()
26 1
    if isinstance(item, Sequence):
27 1
        return item
28 1
    if item is None:
29 1
        return []
30 1
    return [item]
31
32
33 1
class StrEnum(str, enum.Enum):  # Compatible with Python 3.10
34 1
    def __str__(self):
35 1
        return self.value
36
37 1
    def __format__(self, format_spec):
38 1
        return self.value.__format__(format_spec)
39
40 1
    @classmethod
41 1
    def get(cls, key, default=None):
42
        return cls._member_map_.get(key, default)
43