ai-editor-tree-engine-dev 1.0.176__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ai_editor_tree_engine_dev-1.0.176.dist-info/METADATA +35 -0
- ai_editor_tree_engine_dev-1.0.176.dist-info/RECORD +121 -0
- ai_editor_tree_engine_dev-1.0.176.dist-info/WHEEL +5 -0
- ai_editor_tree_engine_dev-1.0.176.dist-info/licenses/LICENSE +21 -0
- ai_editor_tree_engine_dev-1.0.176.dist-info/top_level.txt +1 -0
- tree_engine/PUBLIC_API.md +161 -0
- tree_engine/__init__.py +327 -0
- tree_engine/checks/__init__.py +60 -0
- tree_engine/checks/builtin/__init__.py +5 -0
- tree_engine/checks/builtin/compile_check.py +53 -0
- tree_engine/checks/builtin/csv_syntax.py +51 -0
- tree_engine/checks/builtin/docstrings.py +211 -0
- tree_engine/checks/builtin/encoding.py +55 -0
- tree_engine/checks/builtin/fleet_rules.py +227 -0
- tree_engine/checks/builtin/format_syntax.py +82 -0
- tree_engine/checks/builtin/jsonl_syntax.py +49 -0
- tree_engine/checks/builtin/shipped.py +52 -0
- tree_engine/checks/builtin/syntax.py +118 -0
- tree_engine/checks/builtin/xml_wellformed.py +51 -0
- tree_engine/checks/chain.py +332 -0
- tree_engine/checks/external/__init__.py +5 -0
- tree_engine/checks/external/_base.py +61 -0
- tree_engine/checks/external/bandit.py +53 -0
- tree_engine/checks/external/black.py +48 -0
- tree_engine/checks/external/flake8.py +38 -0
- tree_engine/checks/external/isort.py +38 -0
- tree_engine/checks/external/mypy.py +45 -0
- tree_engine/checks/external/ruff.py +45 -0
- tree_engine/checks/external/runner.py +197 -0
- tree_engine/checks/model.py +110 -0
- tree_engine/checks/options.py +73 -0
- tree_engine/checks/plugin.py +171 -0
- tree_engine/checks/registry.py +349 -0
- tree_engine/core/address.py +376 -0
- tree_engine/core/identifier_map.py +266 -0
- tree_engine/core/identity.py +226 -0
- tree_engine/core/instrumentation.py +399 -0
- tree_engine/core/integrity.py +341 -0
- tree_engine/core/integrity_full.py +382 -0
- tree_engine/core/journal.py +260 -0
- tree_engine/core/journal_compose.py +571 -0
- tree_engine/core/live_tree.py +785 -0
- tree_engine/core/locking.py +188 -0
- tree_engine/core/move.py +585 -0
- tree_engine/core/move_references.py +323 -0
- tree_engine/core/node_types.py +408 -0
- tree_engine/core/nodes.py +348 -0
- tree_engine/core/offsets.py +24 -0
- tree_engine/core/operations.py +825 -0
- tree_engine/core/plugin_boundary.py +160 -0
- tree_engine/core/position_map.py +263 -0
- tree_engine/core/position_transfer.py +512 -0
- tree_engine/core/range_refresh.py +366 -0
- tree_engine/core/reference_cache.py +360 -0
- tree_engine/core/references.py +223 -0
- tree_engine/core/reparse.py +378 -0
- tree_engine/core/short_id.py +296 -0
- tree_engine/core/subtree_apply.py +397 -0
- tree_engine/core/subtree_copy.py +399 -0
- tree_engine/core/transactions.py +397 -0
- tree_engine/core/trivia.py +396 -0
- tree_engine/core/updates.py +398 -0
- tree_engine/core/validation.py +377 -0
- tree_engine/errors.py +104 -0
- tree_engine/exceptions.py +376 -0
- tree_engine/facade.py +4524 -0
- tree_engine/plugins/_statements.py +369 -0
- tree_engine/plugins/bsl/block_edit.py +449 -0
- tree_engine/plugins/bsl/blocks.py +127 -0
- tree_engine/plugins/bsl/checker.py +297 -0
- tree_engine/plugins/bsl/dialects.py +303 -0
- tree_engine/plugins/bsl/generator.py +481 -0
- tree_engine/plugins/bsl/import_map.py +995 -0
- tree_engine/plugins/bsl/plugin.py +452 -0
- tree_engine/plugins/contract.py +355 -0
- tree_engine/plugins/cpp/import_map.py +505 -0
- tree_engine/plugins/cpp/languages.py +99 -0
- tree_engine/plugins/cpp/plugin.py +501 -0
- tree_engine/plugins/csv_format.py +676 -0
- tree_engine/plugins/detachable.py +156 -0
- tree_engine/plugins/fallback.py +421 -0
- tree_engine/plugins/ini_format.py +330 -0
- tree_engine/plugins/json_format.py +813 -0
- tree_engine/plugins/json_pointer.py +203 -0
- tree_engine/plugins/jsonl_format.py +392 -0
- tree_engine/plugins/markdown_format.py +748 -0
- tree_engine/plugins/onec_query_format.py +61 -0
- tree_engine/plugins/parse_position.py +54 -0
- tree_engine/plugins/plain_text.py +1543 -0
- tree_engine/plugins/python/export_map.py +306 -0
- tree_engine/plugins/python/import_map.py +429 -0
- tree_engine/plugins/python/plugin.py +1710 -0
- tree_engine/plugins/registry.py +497 -0
- tree_engine/plugins/scan.py +87 -0
- tree_engine/plugins/selection.py +228 -0
- tree_engine/plugins/sql_format.py +61 -0
- tree_engine/plugins/toml_format.py +1072 -0
- tree_engine/plugins/xml_format.py +911 -0
- tree_engine/plugins/yaml/builder.py +49 -0
- tree_engine/plugins/yaml/emitter.py +225 -0
- tree_engine/plugins/yaml/flow.py +227 -0
- tree_engine/plugins/yaml/plugin.py +458 -0
- tree_engine/plugins/yaml/ranges.py +52 -0
- tree_engine/plugins/yaml/reader.py +359 -0
- tree_engine/plugins/yaml/scanner.py +298 -0
- tree_engine/query/adapter.py +283 -0
- tree_engine/query/engine.py +853 -0
- tree_engine/query/inspection.py +498 -0
- tree_engine/query/outline.py +288 -0
- tree_engine/query/predicates.py +263 -0
- tree_engine/query/rendered_lines.py +46 -0
- tree_engine/query/results.py +206 -0
- tree_engine/query/selector.py +400 -0
- tree_engine/query/xml_query.py +747 -0
- tree_engine/storage/codec.py +400 -0
- tree_engine/storage/document_bridge.py +579 -0
- tree_engine/storage/file_txn.py +459 -0
- tree_engine/storage/history.py +106 -0
- tree_engine/storage/lifecycle.py +622 -0
- tree_engine/storage/schema.py +403 -0
- tree_engine/storage/session_guard.py +398 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
"""Lossless INI format plugin for the tree engine.
|
|
2
|
+
|
|
3
|
+
Author: Vasiliy Zdanovskiy
|
|
4
|
+
email: vasilyvz@gmail.com
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import re
|
|
10
|
+
from dataclasses import replace
|
|
11
|
+
from typing import Any, List, Mapping, Optional, Sequence, Tuple, Union
|
|
12
|
+
|
|
13
|
+
from tree_engine.core.identity import generate_node_id
|
|
14
|
+
from tree_engine.core.nodes import Document, Node, make_node
|
|
15
|
+
from tree_engine.core.plugin_boundary import FormatBoundary
|
|
16
|
+
from tree_engine.core.short_id import ShortIdMap
|
|
17
|
+
from tree_engine.exceptions import (
|
|
18
|
+
FormatContentParseFailed,
|
|
19
|
+
FormatFragmentParseFailed,
|
|
20
|
+
FormatPluginContractError,
|
|
21
|
+
UnsupportedTranslation,
|
|
22
|
+
)
|
|
23
|
+
from tree_engine.plugins.contract import (
|
|
24
|
+
FormatPluginContract,
|
|
25
|
+
FormatPluginMetadata,
|
|
26
|
+
SemanticRoleMapping,
|
|
27
|
+
)
|
|
28
|
+
from tree_engine.plugins.json_pointer import JsonPointerNotation
|
|
29
|
+
|
|
30
|
+
__all__ = ["FORMAT_ID", "INI_POINTER", "IniFormatPlugin", "INI_FORMAT_PLUGIN"]
|
|
31
|
+
|
|
32
|
+
FORMAT_ID = "ini"
|
|
33
|
+
KIND_DOCUMENT = "ini:Document"
|
|
34
|
+
KIND_SECTION = "ini:Section"
|
|
35
|
+
KIND_KEYVALUE = "ini:KeyValue"
|
|
36
|
+
KIND_TRIVIA = "ini:Trivia"
|
|
37
|
+
|
|
38
|
+
_METADATA = FormatPluginMetadata(
|
|
39
|
+
format_id=FORMAT_ID,
|
|
40
|
+
aliases=("cfg",),
|
|
41
|
+
file_extensions=("ini", "cfg"),
|
|
42
|
+
plugin_version="1.0.0",
|
|
43
|
+
contract_version="1.0.0",
|
|
44
|
+
capabilities={
|
|
45
|
+
# Whether the Code Analysis server can save a file of this format (decision D-CB.4); the editor reads it
|
|
46
|
+
# instead of keeping its own list of unsupported suffixes.
|
|
47
|
+
"ca_save_supported": False,
|
|
48
|
+
"semantic_role_mapping": True,
|
|
49
|
+
# ini is not in pipeline/checks/check_roundtrip.py's FORMAT_SPECS
|
|
50
|
+
# (that live corpus check covers python/json/toml/yaml/plain_text/
|
|
51
|
+
# bsl only); the evidence here is this plugin's own
|
|
52
|
+
# test_byte_identical_round_trip_real_files, which round-trips
|
|
53
|
+
# every real .ini/.cfg file found on this machine byte-identical
|
|
54
|
+
# -- True is honest on that basis.
|
|
55
|
+
"byte_identical_round_trip": True,
|
|
56
|
+
# Addressable common-model tree, walkable for preview/search.
|
|
57
|
+
"navigable": True,
|
|
58
|
+
# Round trip is byte-identical -- safe for write-back.
|
|
59
|
+
"editable": True,
|
|
60
|
+
},
|
|
61
|
+
)
|
|
62
|
+
_ROLE_MAP = SemanticRoleMapping({})
|
|
63
|
+
_SECTION = re.compile(r"^[ \t]*\[([^]]+)\][ \t]*(?:[;#].*)?(?:\r?\n)?$")
|
|
64
|
+
_KEY = re.compile(r"^[ \t]*([^=:#;][^=:]*?)[ \t]*(=|:)(.*?)(?:\r?\n)?$")
|
|
65
|
+
# ConfigParser interpolation reference pattern: %(name)s
|
|
66
|
+
_INTERPOLATION = re.compile(r"%\([^)]+\)s")
|
|
67
|
+
_Source = Union[str, bytes]
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _contract_error(message: str) -> FormatPluginContractError:
|
|
71
|
+
return FormatPluginContractError(message, plugin_id=FORMAT_ID)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _unsupported(kind: str, message: str) -> UnsupportedTranslation:
|
|
75
|
+
return UnsupportedTranslation(message, node_type=kind, format_id=FORMAT_ID)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _node(
|
|
79
|
+
kind: str,
|
|
80
|
+
fields: Mapping[str, Any],
|
|
81
|
+
children: Sequence[Node],
|
|
82
|
+
short_ids: ShortIdMap,
|
|
83
|
+
) -> Node:
|
|
84
|
+
validated = make_node(kind, fields=dict(fields), children=tuple(children))
|
|
85
|
+
node_id = generate_node_id()
|
|
86
|
+
return replace(
|
|
87
|
+
validated,
|
|
88
|
+
node_id=node_id,
|
|
89
|
+
short_id=short_ids.allocate(node_id),
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _parse(text: str, malformed: type) -> Document:
|
|
94
|
+
short_ids = ShortIdMap()
|
|
95
|
+
top: List[Node] = []
|
|
96
|
+
section_name: Optional[str] = None
|
|
97
|
+
section_header = ""
|
|
98
|
+
section_children: List[Node] = []
|
|
99
|
+
# Track section names to detect duplicates (bug 75c9fb31)
|
|
100
|
+
seen_sections: set[str] = set()
|
|
101
|
+
|
|
102
|
+
def close_section() -> None:
|
|
103
|
+
nonlocal section_name, section_header, section_children
|
|
104
|
+
if section_name is None:
|
|
105
|
+
return
|
|
106
|
+
# Check for duplicate section names (bug 75c9fb31)
|
|
107
|
+
if section_name in seen_sections:
|
|
108
|
+
raise UnsupportedTranslation(
|
|
109
|
+
f"duplicate section name: {section_name!r}",
|
|
110
|
+
node_type=KIND_SECTION,
|
|
111
|
+
format_id=FORMAT_ID,
|
|
112
|
+
)
|
|
113
|
+
seen_sections.add(section_name)
|
|
114
|
+
top.append(
|
|
115
|
+
_node(
|
|
116
|
+
KIND_SECTION,
|
|
117
|
+
# 'header_raw' -- not 'raw' -- holds the section header LINE (the
|
|
118
|
+
# bracketed name plus its own inline comment, e.g. '[server] ; note\n').
|
|
119
|
+
# It is per-node identity data the parser alone populates, never a
|
|
120
|
+
# cache of the section's composed subtree, so it must stay outside
|
|
121
|
+
# ``CACHED_SOURCE_FIELDS`` (live_tree.py): a pointwise splice of this
|
|
122
|
+
# section's children invalidates composed-source caches on ancestors,
|
|
123
|
+
# but the header line itself does not depend on the children and must
|
|
124
|
+
# survive unchanged (bug 581c1fe1).
|
|
125
|
+
{"key": section_name, "header_raw": section_header},
|
|
126
|
+
section_children,
|
|
127
|
+
short_ids,
|
|
128
|
+
)
|
|
129
|
+
)
|
|
130
|
+
section_name, section_header, section_children = None, "", []
|
|
131
|
+
|
|
132
|
+
for number, raw in enumerate(text.splitlines(keepends=True), start=1):
|
|
133
|
+
content = raw.rstrip("\r\n")
|
|
134
|
+
stripped = content.strip()
|
|
135
|
+
section = _SECTION.match(raw)
|
|
136
|
+
if section is not None:
|
|
137
|
+
close_section()
|
|
138
|
+
section_name = section.group(1).strip()
|
|
139
|
+
if not section_name:
|
|
140
|
+
raise malformed(
|
|
141
|
+
f"cannot parse INI: empty section on line {number}",
|
|
142
|
+
format_id=FORMAT_ID, line=number, column=1, message="empty section name",
|
|
143
|
+
)
|
|
144
|
+
section_header = raw
|
|
145
|
+
continue
|
|
146
|
+
if not stripped or stripped.startswith(("#", ";")):
|
|
147
|
+
child = _node(KIND_TRIVIA, {"raw": raw}, (), short_ids)
|
|
148
|
+
else:
|
|
149
|
+
key = _KEY.match(raw)
|
|
150
|
+
if key is None or not key.group(1).strip():
|
|
151
|
+
raise malformed(
|
|
152
|
+
f"cannot parse INI: unsupported content on line {number}",
|
|
153
|
+
format_id=FORMAT_ID, line=number, column=1, message="unsupported content",
|
|
154
|
+
)
|
|
155
|
+
# Check for ConfigParser interpolation patterns (bug 75c9fb31)
|
|
156
|
+
value = key.group(3).strip()
|
|
157
|
+
if _INTERPOLATION.search(value):
|
|
158
|
+
raise UnsupportedTranslation(
|
|
159
|
+
f"interpolation reference %(...)s not supported: line {number}",
|
|
160
|
+
node_type=KIND_KEYVALUE,
|
|
161
|
+
format_id=FORMAT_ID,
|
|
162
|
+
)
|
|
163
|
+
child = _node(
|
|
164
|
+
KIND_KEYVALUE,
|
|
165
|
+
{
|
|
166
|
+
"key": key.group(1).strip(),
|
|
167
|
+
"separator": key.group(2),
|
|
168
|
+
"value": value,
|
|
169
|
+
"raw": raw,
|
|
170
|
+
},
|
|
171
|
+
(),
|
|
172
|
+
short_ids,
|
|
173
|
+
)
|
|
174
|
+
(section_children if section_name is not None else top).append(child)
|
|
175
|
+
close_section()
|
|
176
|
+
root = _node(KIND_DOCUMENT, {}, top, short_ids)
|
|
177
|
+
return Document(root=root, source_format_id=FORMAT_ID)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def _render(node: Node) -> str:
|
|
181
|
+
if node.kind == KIND_DOCUMENT:
|
|
182
|
+
return "".join(_render(child) for child in node.children)
|
|
183
|
+
if node.kind == KIND_SECTION:
|
|
184
|
+
header_raw = node.fields.get("header_raw")
|
|
185
|
+
if not isinstance(header_raw, str):
|
|
186
|
+
header_raw = f"[{node.fields.get('key', '')}]\n"
|
|
187
|
+
return header_raw + "".join(_render(child) for child in node.children)
|
|
188
|
+
if node.kind == KIND_KEYVALUE:
|
|
189
|
+
raw = node.fields.get("raw")
|
|
190
|
+
if isinstance(raw, str):
|
|
191
|
+
return raw
|
|
192
|
+
return (
|
|
193
|
+
f"{node.fields.get('key', '')}"
|
|
194
|
+
f"{node.fields.get('separator', '=')}"
|
|
195
|
+
f"{node.fields.get('value', '')}\n"
|
|
196
|
+
)
|
|
197
|
+
if node.kind == KIND_TRIVIA:
|
|
198
|
+
raw = node.fields.get("raw")
|
|
199
|
+
return raw if isinstance(raw, str) else "\n"
|
|
200
|
+
raise _unsupported(str(node.kind), f"node kind {node.kind!r} has no INI form")
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def _pointer_step(
|
|
204
|
+
parent: Node,
|
|
205
|
+
child: Node,
|
|
206
|
+
ordinal: int,
|
|
207
|
+
) -> Optional[Tuple[Tuple[str, ...], bool]]:
|
|
208
|
+
del parent, ordinal
|
|
209
|
+
if child.kind in (KIND_SECTION, KIND_KEYVALUE):
|
|
210
|
+
key = child.fields.get("key")
|
|
211
|
+
if isinstance(key, str) and key:
|
|
212
|
+
return ((key,), True)
|
|
213
|
+
return None
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
INI_POINTER = JsonPointerNotation(_pointer_step, root_addressable=True)
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
class IniFormatPlugin(FormatPluginContract, FormatBoundary):
|
|
220
|
+
"""Registered lossless ``format_id='ini'`` plugin."""
|
|
221
|
+
|
|
222
|
+
native_reference = INI_POINTER
|
|
223
|
+
|
|
224
|
+
#: ``parse_fragment`` returns ``_parse(...).root``, an ``ini:Document``
|
|
225
|
+
#: wrapping the fragment's own entries (the same shape ``parse_document``
|
|
226
|
+
#: gives a whole file). Without this declaration, ``facade._fragment``
|
|
227
|
+
#: cannot tell that wrapper apart from a genuine value and never unwraps
|
|
228
|
+
#: it, so ``insert()`` spliced the WHOLE wrapper document in as a literal
|
|
229
|
+
#: child of the real target instead of the fragment's own key/section
|
|
230
|
+
#: entries. Mirrors ``plugins/plain_text.py``'s identical declaration for
|
|
231
|
+
#: the identical shape.
|
|
232
|
+
fragment_container_kinds = (KIND_DOCUMENT,)
|
|
233
|
+
|
|
234
|
+
@property
|
|
235
|
+
def metadata(self) -> FormatPluginMetadata:
|
|
236
|
+
return _METADATA
|
|
237
|
+
|
|
238
|
+
@staticmethod
|
|
239
|
+
def _decode(source: _Source, label: str) -> str:
|
|
240
|
+
if isinstance(source, str):
|
|
241
|
+
return source
|
|
242
|
+
if isinstance(source, (bytes, bytearray)):
|
|
243
|
+
try:
|
|
244
|
+
return bytes(source).decode("utf-8")
|
|
245
|
+
except UnicodeDecodeError as exc:
|
|
246
|
+
raise FormatContentParseFailed(
|
|
247
|
+
f"cannot decode INI: {exc}", format_id=FORMAT_ID
|
|
248
|
+
) from exc
|
|
249
|
+
raise _contract_error(
|
|
250
|
+
f"{label} must be str or bytes, got {type(source).__name__}"
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
def parse_document(
|
|
254
|
+
self,
|
|
255
|
+
source: _Source,
|
|
256
|
+
options: Optional[Mapping[str, Any]] = None,
|
|
257
|
+
*,
|
|
258
|
+
source_format_id: Optional[str] = None,
|
|
259
|
+
) -> Document:
|
|
260
|
+
del options, source_format_id
|
|
261
|
+
return _parse(self._decode(source, "source"), FormatContentParseFailed)
|
|
262
|
+
|
|
263
|
+
def parse_fragment(
|
|
264
|
+
self,
|
|
265
|
+
source: _Source,
|
|
266
|
+
options: Optional[Mapping[str, Any]] = None,
|
|
267
|
+
*,
|
|
268
|
+
source_format_id: Optional[str] = None,
|
|
269
|
+
) -> Node:
|
|
270
|
+
del options, source_format_id
|
|
271
|
+
return _parse(
|
|
272
|
+
self._decode(source, "fragment"), FormatFragmentParseFailed
|
|
273
|
+
).root
|
|
274
|
+
|
|
275
|
+
def import_external_tree(
|
|
276
|
+
self, external_tree: Any, options: Optional[Mapping[str, Any]] = None
|
|
277
|
+
) -> Union[Node, Document]:
|
|
278
|
+
return self.import_to_common(external_tree, options)
|
|
279
|
+
|
|
280
|
+
def import_to_common(
|
|
281
|
+
self, external_representation: Any, options: Optional[Mapping[str, Any]] = None
|
|
282
|
+
) -> Union[Node, Document]:
|
|
283
|
+
del options
|
|
284
|
+
if isinstance(external_representation, (str, bytes, bytearray)):
|
|
285
|
+
return self.parse_document(external_representation)
|
|
286
|
+
raise _unsupported(
|
|
287
|
+
type(external_representation).__name__, "expected INI source text"
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
def export_from_common(
|
|
291
|
+
self, nodes: Union[Node, Document], options: Optional[Mapping[str, Any]] = None
|
|
292
|
+
) -> Any:
|
|
293
|
+
del options
|
|
294
|
+
if not isinstance(nodes, (Node, Document)):
|
|
295
|
+
raise _contract_error(
|
|
296
|
+
f"expected Node or Document, got {type(nodes).__name__}"
|
|
297
|
+
)
|
|
298
|
+
return _render(nodes.root if isinstance(nodes, Document) else nodes)
|
|
299
|
+
|
|
300
|
+
def generate_output(
|
|
301
|
+
self, target: Union[Node, Document, Any], options: Optional[Mapping[str, Any]] = None
|
|
302
|
+
) -> Union[str, bytes]:
|
|
303
|
+
options = options or {}
|
|
304
|
+
if isinstance(target, (Node, Document)):
|
|
305
|
+
text = _render(target.root if isinstance(target, Document) else target)
|
|
306
|
+
elif isinstance(target, str):
|
|
307
|
+
text = target
|
|
308
|
+
else:
|
|
309
|
+
raise _contract_error(
|
|
310
|
+
f"cannot render {type(target).__name__}; expected Node/Document/str"
|
|
311
|
+
)
|
|
312
|
+
return text.encode("utf-8") if options.get("as_bytes") else text
|
|
313
|
+
|
|
314
|
+
def semantic_role_mapping(self) -> SemanticRoleMapping:
|
|
315
|
+
return _ROLE_MAP
|
|
316
|
+
|
|
317
|
+
def render_document(self, document: Document) -> bytes:
|
|
318
|
+
result = self.generate_output(document, {"as_bytes": True})
|
|
319
|
+
if not isinstance(result, bytes):
|
|
320
|
+
raise _contract_error("render_document did not return bytes")
|
|
321
|
+
return result
|
|
322
|
+
|
|
323
|
+
def render_fragment(self, node: Node) -> str:
|
|
324
|
+
result = self.generate_output(node)
|
|
325
|
+
if not isinstance(result, str):
|
|
326
|
+
raise _contract_error("render_fragment did not return str")
|
|
327
|
+
return result
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
INI_FORMAT_PLUGIN = IniFormatPlugin()
|