Total Complexity | 8 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 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 |