mdbox 0.1.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.
mdbox/__init__.py ADDED
@@ -0,0 +1,49 @@
1
+ """Mdbox: Pack and unpack text files into machine-readable XML."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import IO
6
+
7
+ from mdbox.archive import BinaryFileError, MdboxFile, MdboxInfo, PathTraversalError
8
+
9
+ __version__ = "0.1.0"
10
+ __all__ = [
11
+ "__version__",
12
+ "open",
13
+ "MdboxFile",
14
+ "MdboxInfo",
15
+ "BinaryFileError",
16
+ "PathTraversalError",
17
+ ]
18
+
19
+
20
+ def open(
21
+ name: str | IO[bytes],
22
+ mode: str = "r",
23
+ preamble: str | None = None,
24
+ epilogue: str | None = None,
25
+ ) -> MdboxFile:
26
+ """Open a mdbox archive and return a [MdboxFile][] instance.
27
+
28
+ This is the top-level factory function, analogous to `zipfile.ZipFile`.
29
+
30
+ Args:
31
+ name: Path to the archive file.
32
+ mode: ``'r'`` (read) or ``'w'`` (write).
33
+ preamble: Optional text to prepend before the XML when writing.
34
+ Ignored in read mode (preamble is parsed from the file).
35
+ epilogue: Optional text to append after the XML when writing.
36
+ Ignored in read mode (epilogue is parsed from the file).
37
+
38
+ Returns:
39
+ A new [MdboxFile][] instance.
40
+
41
+ Example:
42
+ ```python
43
+ import mdbox
44
+
45
+ with mdbox.open("archive.xml", mode="w") as qf:
46
+ qf.write("README.md")
47
+ ```
48
+ """
49
+ return MdboxFile.open(name, mode, preamble=preamble, epilogue=epilogue)