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

satcfdi.utils.StrEnum.__format__()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 2
dl 0
loc 2
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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