markoftheweb 1.0.0.0__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.
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env python
2
+
3
+ """
4
+ markoftheweb
5
+
6
+ Tools for modeling, parsing, and writing `Zone.Identifier` files and data.
7
+ """
8
+
9
+ # (C) Copyright 2025, 2026 Markus Hammer.
10
+ #
11
+ # This program is free software: you can redistribute it and/or modify it
12
+ # under the terms of the GNU General Public License as published by the
13
+ # Free Software Foundation, either version 3 of the License,
14
+ # or (at your option) any later version.
15
+ #
16
+ # This program is distributed in the hope that it will be useful,
17
+ # but WITHOUT ANY WARRANTY;
18
+ # without even the implied warranty of
19
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20
+ # See the GNU General Public License for more details.
21
+ #
22
+ # You should have received a copy of the GNU General Public License
23
+ # along with this program.
24
+ # If not, see <https://www.gnu.org/licenses/>.
25
+
26
+
27
+ __version__ = "v1.0.0.0"
28
+
29
+ from .markoftheweb import (ZoneId, # noqa
30
+ normalize_zone_stream_path,
31
+ ZoneTransfer,
32
+ ZoneTransferCaseSensitiveKeys
33
+ )
34
+
35
+ __all__ = ["ZoneId",
36
+ "normalize_zone_stream_path",
37
+ "ZoneTransfer",
38
+ "ZoneTransferCaseSensitiveKeys"
39
+ ]
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env python
2
+
3
+ """
4
+ __main__
5
+
6
+ Contains functions that implement the main entry point
7
+ for this module.
8
+ When executed, this will call those entry points.
9
+ """
10
+
11
+ # (C) Copyright 2025, 2026 Markus Hammer.
12
+ #
13
+ # This program is free software: you can redistribute it and/or modify it
14
+ # under the terms of the GNU General Public License as published by the
15
+ # Free Software Foundation, either version 3 of the License,
16
+ # or (at your option) any later version.
17
+ #
18
+ # This program is distributed in the hope that it will be useful,
19
+ # but WITHOUT ANY WARRANTY;
20
+ # without even the implied warranty of
21
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22
+ # See the GNU General Public License for more details.
23
+ #
24
+ # You should have received a copy of the GNU General Public License
25
+ # along with this program.
26
+ # If not, see <https://www.gnu.org/licenses/>.
27
+
28
+
29
+ try:
30
+ from os import EX_OK
31
+ except ImportError:
32
+ EX_OK: int = 0 # type:ignore
33
+ from shutil import get_terminal_size
34
+ from typing import NoReturn
35
+ from sys import argv as sys_argv, exit as sys_exit
36
+ from argparse import ArgumentParser
37
+ from logging import getLogger, CRITICAL, WARNING
38
+
39
+ from .markoftheweb import (ZONE_ID_STREAM_NAME,
40
+ ZONE_TRANSFER_SECTION_NAME,
41
+ ZoneTransferCaseSensitiveKeys,
42
+ normalize_zone_stream_path
43
+ )
44
+
45
+ __all__ = ['main', 'main_entry']
46
+
47
+
48
+ def make_line() -> str:
49
+ """
50
+ make_line
51
+
52
+ Returns a string that prints the horizontal bar (`_`)
53
+ character to properly fill the current size of the terminal.
54
+ """
55
+ return "_" * max(get_terminal_size()[0], 3)
56
+
57
+
58
+ def main(*argv) -> int:
59
+ """
60
+ main
61
+
62
+ The main entry point for this module.
63
+ Expects for argv to be provided manually.
64
+
65
+ Returns:
66
+ The exit code.
67
+ """
68
+
69
+ parser = ArgumentParser(
70
+ prog = argv[0],
71
+ description="Process Zone Transfer data from provided paths."
72
+ )
73
+ parser.add_argument(
74
+ "paths",
75
+ nargs="+",
76
+ help="Paths to process"
77
+ )
78
+ parser.add_argument(
79
+ "-q",
80
+ "--quiet",
81
+ action="store_true",
82
+ help="Suppress warnings and errors"
83
+ )
84
+
85
+ args = parser.parse_args(argv[1:])
86
+
87
+ logger = getLogger()
88
+ logger.setLevel(CRITICAL if args.quiet else WARNING)
89
+
90
+ for raw_path in args.paths:
91
+ try:
92
+ path = normalize_zone_stream_path(raw_path)
93
+ zone_trans = ZoneTransferCaseSensitiveKeys.from_path(path)
94
+ except FileNotFoundError:
95
+ logger.warning("%s\npath %s does not exist, ignoring...", make_line(), raw_path)
96
+ continue
97
+ except Exception as e: # pylint:disable=broad-exception-caught
98
+ make_line()
99
+ logger.error("%s\nfailed processing %s : %s", make_line(), raw_path, e)
100
+ continue
101
+
102
+ if zone_trans is not None:
103
+ print(make_line())
104
+ print(f"{ZONE_ID_STREAM_NAME}'s {ZONE_TRANSFER_SECTION_NAME} data found for {path}:")
105
+ print()
106
+
107
+ lin = zone_trans.str_dump().splitlines()
108
+ print(lin.pop(0).strip())
109
+ print(*(" " * 3 + s.strip() for s in lin if s.strip()), sep="\n")
110
+
111
+ print(make_line())
112
+ print("Complete")
113
+
114
+ return EX_OK
115
+
116
+
117
+ def main_entry() -> NoReturn:
118
+ """
119
+ main_entry
120
+
121
+ Calls `main` with the arguments provided by `sys.argv`,
122
+ and exits with the returned exit code.
123
+
124
+ Does not return (exits).
125
+ """
126
+ sys_exit(main(*sys_argv))
127
+
128
+
129
+ if __name__ == "__main__":
130
+ main_entry()
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env python
2
+
3
+ """
4
+ _type_imports
5
+
6
+ Various imports related to type annotations.
7
+ Not expected to be imported on its own.
8
+ """
9
+
10
+ # (C) Copyright 2025, 2026 Markus Hammer.
11
+ #
12
+ # This program is free software: you can redistribute it and/or modify it
13
+ # under the terms of the GNU General Public License as published by the
14
+ # Free Software Foundation, either version 3 of the License,
15
+ # or (at your option) any later version.
16
+ #
17
+ # This program is distributed in the hope that it will be useful,
18
+ # but WITHOUT ANY WARRANTY;
19
+ # without even the implied warranty of
20
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21
+ # See the GNU General Public License for more details.
22
+ #
23
+ # You should have received a copy of the GNU General Public License
24
+ # along with this program.
25
+ # If not, see <https://www.gnu.org/licenses/>.
26
+
27
+
28
+ # pylint:disable=unused-import, ungrouped-imports
29
+
30
+ __all__ = [
31
+ 'Final',
32
+ 'Literal',
33
+ 'PathLike',
34
+ 'FrozenSet',
35
+ 'LiteralString',
36
+ 'IO',
37
+ 'TextIOBase',
38
+ 'Iterable',
39
+ 'Set',
40
+ 'Mapping',
41
+ 'Type',
42
+ ]
43
+
44
+ try:
45
+ from typing_extensions import Final
46
+ except ImportError:
47
+ from typing import Final # noqa
48
+
49
+ try:
50
+ from typing_extensions import Literal
51
+ except ImportError:
52
+ from typing import Literal # noqa
53
+
54
+ try:
55
+ from typing_extensions import LiteralString
56
+ except ImportError:
57
+ from typing import LiteralString # noqa
58
+
59
+ try:
60
+ from typing_extensions import Type
61
+ except ImportError:
62
+ from typing import Type # noqa
63
+
64
+ try:
65
+ from typing_extensions import Iterable
66
+ except ImportError:
67
+ from typing import Iterable # noqa
68
+
69
+ try:
70
+ from typing_extensions import Mapping
71
+ except ImportError:
72
+ from typing import Mapping # noqa
73
+
74
+ try:
75
+ from typing_extensions import Set
76
+ except ImportError:
77
+ from typing import Set # noqa
78
+
79
+ try:
80
+ from typing_extensions import FrozenSet
81
+ except ImportError:
82
+ from typing import FrozenSet # noqa
83
+
84
+ from os import PathLike # noqa
85
+
86
+ try:
87
+ from typing_extensions import IO
88
+ except ImportError:
89
+ from typing import IO # noqa
90
+
91
+ from io import TextIOBase # noqa