Total Complexity | 7 |
Total Lines | 31 |
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(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 |