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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
from typing import NotRequired, List, Any, TypedDict
from debputy.manifest_parser.tagging_types import (
DebputyParsedContent,
TypeMapping,
)
from debputy.manifest_parser.base_types import OctalMode
from debputy.manifest_parser.declarative_parser import ParserGenerator
from debputy.plugin.api.impl_types import KnownPackagingFileInfo
class PPFReferenceDocumentation(TypedDict):
description: NotRequired[str]
format_documentation_uris: NotRequired[list[str]]
class PackagerProvidedFileJsonDescription(DebputyParsedContent):
stem: str
installed_path: str
default_mode: NotRequired[OctalMode]
default_priority: NotRequired[int]
allow_name_segment: NotRequired[bool]
allow_architecture_segment: NotRequired[bool]
reference_documentation: NotRequired[PPFReferenceDocumentation]
class ManifestVariableJsonDescription(DebputyParsedContent):
name: str
value: str
reference_documentation: NotRequired[str]
class PluginJsonMetadata(DebputyParsedContent):
api_compat_version: int
module: NotRequired[str]
plugin_initializer: NotRequired[str]
packager_provided_files: NotRequired[list[Any]]
manifest_variables: NotRequired[list[Any]]
known_packaging_files: NotRequired[list[Any]]
def _initialize_plugin_metadata_parser_generator() -> ParserGenerator:
pc = ParserGenerator()
pc.register_mapped_type(
TypeMapping(
OctalMode,
str,
lambda v, ap, _: OctalMode.parse_filesystem_mode(v, ap),
)
)
return pc
PLUGIN_METADATA_PARSER_GENERATOR = _initialize_plugin_metadata_parser_generator()
PLUGIN_METADATA_PARSER = PLUGIN_METADATA_PARSER_GENERATOR.generate_parser(
PluginJsonMetadata
)
PLUGIN_PPF_PARSER = PLUGIN_METADATA_PARSER_GENERATOR.generate_parser(
PackagerProvidedFileJsonDescription
)
PLUGIN_MANIFEST_VARS_PARSER = PLUGIN_METADATA_PARSER_GENERATOR.generate_parser(
ManifestVariableJsonDescription
)
PLUGIN_KNOWN_PACKAGING_FILES_PARSER = PLUGIN_METADATA_PARSER_GENERATOR.generate_parser(
KnownPackagingFileInfo
)
|