-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.py
More file actions
32 lines (24 loc) · 777 Bytes
/
Copy pathplugin.py
File metadata and controls
32 lines (24 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from collections.abc import Iterable, Mapping
from typing import Any
import xmltodict
from jinjanator_plugins import (
Formats,
plugin_formats_hook,
)
class XMLFormat:
name = "xml"
suffixes: Iterable[str] | None = ".xml"
option_names: Iterable[str] | None = "process-namespaces"
def __init__(self, options: Iterable[str] | None) -> None:
self.process_namespaces = False
if options:
for _option in options:
self.process_namespaces = True
def parse(
self,
data_string: str,
) -> Mapping[str, Any]:
return xmltodict.parse(data_string, process_namespaces=self.process_namespaces)
@plugin_formats_hook
def plugin_formats() -> Formats:
return {XMLFormat.name: XMLFormat}