Passed
Push — main ( b7a3d7...c85aa4 )
by Sat CFDI
05:14
created

satcfdi.utils   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 31
ccs 21
cts 21
cp 1
rs 10
c 0
b 0
f 0
wmc 7

2 Methods

Rating   Name   Duplication   Size   Complexity  
A StrEnum.__str__() 0 2 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(no_network=True, remove_comments=True, remove_blank_text=True, huge_tree=True, collect_ids=False, remove_pis=True)
7
8
9 1
class ScalarMap(dict):
10 1
    pass
11
12
13 1
def iterate(item):
14 1
    if isinstance(item, str | bytes | ScalarMap):
15 1
        return [item]
16 1
    if isinstance(item, Mapping):
17 1
        return item.values()
18 1
    if isinstance(item, Sequence):
19 1
        return item
20 1
    if item is None:
21 1
        return []
22 1
    return [item]
23
24
25 1
class StrEnum(str, enum.Enum):  # Compatible with Python 3.10
26 1
    def __str__(self):
27 1
        return self.value
28
29 1
    def __format__(self, format_spec):
30
        return self.value.__format__(format_spec)
31