pybit7z 0.2.3__tar.gz → 0.2.4__tar.gz

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.
Files changed (106) hide show
  1. {pybit7z-0.2.3 → pybit7z-0.2.4}/PKG-INFO +18 -18
  2. {pybit7z-0.2.3 → pybit7z-0.2.4}/README.md +17 -17
  3. pybit7z-0.2.4/docs/api/index.md +8 -0
  4. pybit7z-0.2.4/src/pybit7z/__init__.py +204 -0
  5. {pybit7z-0.2.3 → pybit7z-0.2.4}/src/pybit7z/_version.py +2 -2
  6. {pybit7z-0.2.3 → pybit7z-0.2.4}/tests/test_bit7z.py +51 -51
  7. pybit7z-0.2.3/docs/api/index.md +0 -17
  8. pybit7z-0.2.3/src/pybit7z/__init__.py +0 -25
  9. {pybit7z-0.2.3 → pybit7z-0.2.4}/.clang-format +0 -0
  10. {pybit7z-0.2.3 → pybit7z-0.2.4}/.clang-tidy +0 -0
  11. {pybit7z-0.2.3 → pybit7z-0.2.4}/.copier-answers.yml +0 -0
  12. {pybit7z-0.2.3 → pybit7z-0.2.4}/.cppcheck-suppressions.txt +0 -0
  13. {pybit7z-0.2.3 → pybit7z-0.2.4}/.devcontainer/devcontainer.json +0 -0
  14. {pybit7z-0.2.3 → pybit7z-0.2.4}/.editorconfig +0 -0
  15. {pybit7z-0.2.3 → pybit7z-0.2.4}/.gitattributes +0 -0
  16. {pybit7z-0.2.3 → pybit7z-0.2.4}/.github/codecov.yml +0 -0
  17. {pybit7z-0.2.3 → pybit7z-0.2.4}/.github/codeql-config.yml +0 -0
  18. {pybit7z-0.2.3 → pybit7z-0.2.4}/.github/matchers/pylint.json +0 -0
  19. {pybit7z-0.2.3 → pybit7z-0.2.4}/.github/workflows/cd.yml +0 -0
  20. {pybit7z-0.2.3 → pybit7z-0.2.4}/.github/workflows/ci.yml +0 -0
  21. {pybit7z-0.2.3 → pybit7z-0.2.4}/.github/workflows/codeql.yml +0 -0
  22. {pybit7z-0.2.3 → pybit7z-0.2.4}/.github/workflows/pages.yml +0 -0
  23. {pybit7z-0.2.3 → pybit7z-0.2.4}/.github/workflows/renovate.yml +0 -0
  24. {pybit7z-0.2.3 → pybit7z-0.2.4}/.github/workflows/reuseable_cibuildwheel.yml +0 -0
  25. {pybit7z-0.2.3 → pybit7z-0.2.4}/.github/workflows/semantic-release.yml +0 -0
  26. {pybit7z-0.2.3 → pybit7z-0.2.4}/.gitignore +0 -0
  27. {pybit7z-0.2.3 → pybit7z-0.2.4}/.markdownlint.yaml +0 -0
  28. {pybit7z-0.2.3 → pybit7z-0.2.4}/.pre-commit-config.yaml +0 -0
  29. {pybit7z-0.2.3 → pybit7z-0.2.4}/.releaserc.js +0 -0
  30. {pybit7z-0.2.3 → pybit7z-0.2.4}/.renovaterc.json +0 -0
  31. {pybit7z-0.2.3 → pybit7z-0.2.4}/.vscode/launch.json +0 -0
  32. {pybit7z-0.2.3 → pybit7z-0.2.4}/.vscode/settings.json +0 -0
  33. {pybit7z-0.2.3 → pybit7z-0.2.4}/CMakeLists.txt +0 -0
  34. {pybit7z-0.2.3 → pybit7z-0.2.4}/CMakePresets.json +0 -0
  35. {pybit7z-0.2.3 → pybit7z-0.2.4}/LICENSE +0 -0
  36. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/ConfigureVersion.cmake +0 -0
  37. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/ConfigureWarningsAndHardening.cmake +0 -0
  38. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/arch/x64.json +0 -0
  39. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/base.json +0 -0
  40. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/compilers/gcc.json +0 -0
  41. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/compilers/llvm.json +0 -0
  42. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/compilers/mingw.json +0 -0
  43. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/compilers/msvc.json +0 -0
  44. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/default.json +0 -0
  45. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/generators/ninja.json +0 -0
  46. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/os/darwin.json +0 -0
  47. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/os/linux.json +0 -0
  48. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/os/windows.json +0 -0
  49. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/toolchains/vcpkg.json +0 -0
  50. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/triplets/x64-linux.json +0 -0
  51. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/triplets/x64-mingw-dynamic.json +0 -0
  52. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/triplets/x64-mingw-static.json +0 -0
  53. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/triplets/x64-osx.json +0 -0
  54. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/triplets/x64-windows.json +0 -0
  55. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/x64-linux-gcc.json +0 -0
  56. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/x64-linux-llvm.json +0 -0
  57. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/x64-mingw-dynamic-windows-mingw.json +0 -0
  58. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/x64-mingw-static-windows-mingw.json +0 -0
  59. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/x64-osx-gcc.json +0 -0
  60. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/x64-osx-llvm.json +0 -0
  61. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/x64-windows-llvm.json +0 -0
  62. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/presets/x64-windows-msvc.json +0 -0
  63. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/bootstrap/vcpkg-config.cmake +0 -0
  64. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake +0 -0
  65. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/bootstrap/vcpkg_chainload_toolchain.cmake +0 -0
  66. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/bootstrap/vcpkg_configure.cmake +0 -0
  67. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/bootstrap/vcpkg_export_mode.cmake +0 -0
  68. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/bootstrap/vcpkg_load_triplet.cmake +0 -0
  69. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/bootstrap/vcpkg_skip_install_on_reconfigure.cmake +0 -0
  70. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/ports/7zip/7zip-config.cmake.in +0 -0
  71. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/ports/7zip/CMakeLists.txt +0 -0
  72. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/ports/7zip/portfile.cmake +0 -0
  73. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/ports/7zip/vcpkg.json +0 -0
  74. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/ports/README.md +0 -0
  75. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/ports/bit7z/fix_compile_options.patch +0 -0
  76. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/ports/bit7z/fix_dependency.patch +0 -0
  77. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/ports/bit7z/fix_install.patch +0 -0
  78. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/ports/bit7z/portfile.cmake +0 -0
  79. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/ports/bit7z/unofficial-bit7z-config.cmake.in +0 -0
  80. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/ports/bit7z/vcpkg.json +0 -0
  81. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/ports/python3/portfile.cmake +0 -0
  82. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/ports/python3/vcpkg.json +0 -0
  83. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/scripts/build_type.cmake +0 -0
  84. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/scripts/toolchains/README.md +0 -0
  85. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/triplets/README.md +0 -0
  86. {pybit7z-0.2.3 → pybit7z-0.2.4}/cmake/vcpkg/vcpkg.toolchain.cmake +0 -0
  87. {pybit7z-0.2.3 → pybit7z-0.2.4}/docs/conf.py +0 -0
  88. {pybit7z-0.2.3 → pybit7z-0.2.4}/docs/index.md +0 -0
  89. {pybit7z-0.2.3 → pybit7z-0.2.4}/noxfile.py +0 -0
  90. {pybit7z-0.2.3 → pybit7z-0.2.4}/pyproject.toml +0 -0
  91. {pybit7z-0.2.3 → pybit7z-0.2.4}/src/CMakeLists.txt +0 -0
  92. {pybit7z-0.2.3 → pybit7z-0.2.4}/src/_core/CMakeLists.txt +0 -0
  93. {pybit7z-0.2.3 → pybit7z-0.2.4}/src/_core/include/_core.hpp +0 -0
  94. {pybit7z-0.2.3 → pybit7z-0.2.4}/src/_core/include/pybit7z.hpp +0 -0
  95. {pybit7z-0.2.3 → pybit7z-0.2.4}/src/_core/src/pybind.cpp +0 -0
  96. {pybit7z-0.2.3 → pybit7z-0.2.4}/src/_core/src/pybit7z.cpp +0 -0
  97. {pybit7z-0.2.3 → pybit7z-0.2.4}/src/_core/tests/CMakeLists.txt +0 -0
  98. {pybit7z-0.2.3 → pybit7z-0.2.4}/src/_core/tests/test_core.cpp +0 -0
  99. {pybit7z-0.2.3 → pybit7z-0.2.4}/src/_core/tests/test_data/.gitignore +0 -0
  100. {pybit7z-0.2.3 → pybit7z-0.2.4}/src/_core/tests/utils.hpp +0 -0
  101. {pybit7z-0.2.3 → pybit7z-0.2.4}/src/pybit7z/_core.pyi +0 -0
  102. {pybit7z-0.2.3 → pybit7z-0.2.4}/src/pybit7z/_version.pyi +0 -0
  103. {pybit7z-0.2.3 → pybit7z-0.2.4}/src/pybit7z/py.typed +0 -0
  104. {pybit7z-0.2.3 → pybit7z-0.2.4}/tests/test_compiled.py +0 -0
  105. {pybit7z-0.2.3 → pybit7z-0.2.4}/tests/test_package.py +0 -0
  106. {pybit7z-0.2.3 → pybit7z-0.2.4}/vcpkg.json +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pybit7z
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: A wrapper based on bit7z.
5
5
  Author-Email: "l.feng" <msclock@126.com>
6
6
  License: Apache-2.0
@@ -82,10 +82,10 @@ pip install pybit7z
82
82
  ### Extract Files from an Archive
83
83
 
84
84
  ```python
85
- from pybit7z import core
85
+ import pybit7z
86
86
 
87
87
  try:
88
- extractor = core.BitFileExtractor(core.FormatSevenZip)
88
+ extractor = pybit7z.BitFileExtractor(pybit7z.FormatSevenZip)
89
89
  extractor.extract("path/to/archive.7z", "out/dir/")
90
90
 
91
91
  # Extracting a specific file inside an archive
@@ -97,35 +97,35 @@ try:
97
97
  # Extracting an encrypted archive
98
98
  extractor.set_password("password")
99
99
  extractor.extract("path/to/another/archive.7z", "out/dir/")
100
- except core.BitException as e:
100
+ except pybit7z.BitException as e:
101
101
  ... # handle the exception
102
102
  ```
103
103
 
104
104
  Work on a single archive:
105
105
 
106
106
  ```python
107
- from pybit7z import core
107
+ import pybit7z
108
108
 
109
109
  try:
110
110
  # Opening the archive
111
- archive = core.BitArchiveReader("path/to/archive.gz", core.FormatGZip)
111
+ archive = pybit7z.BitArchiveReader("path/to/archive.gz", pybit7z.FormatGZip)
112
112
 
113
113
  # Testing the archive
114
114
  archive.test()
115
115
 
116
116
  # Extracting the archive
117
117
  archive.extract_to("out/dir/")
118
- except core.BitException as e:
118
+ except pybit7z.BitException as e:
119
119
  ... # handle the exception
120
120
  ```
121
121
 
122
122
  ### Compress Files into an Archive
123
123
 
124
124
  ```python
125
- from pybit7z import core
125
+ import pybit7z
126
126
 
127
127
  try:
128
- compressor = core.BitFileCompressor(core.FormatSevenZip)
128
+ compressor = pybit7z.BitFileCompressor(pybit7z.FormatSevenZip)
129
129
 
130
130
  files = ["path/to/file1.jpg", "path/to/file2.pdf"]
131
131
 
@@ -147,23 +147,23 @@ try:
147
147
  compressor.compress_files(files, "protected_archive.zip")
148
148
 
149
149
  # Updating an existing zip archive
150
- compressor.set_update_mode(core.UpdateMode.Append)
150
+ compressor.set_update_mode(pybit7z.UpdateMode.Append)
151
151
  compressor.compress_files(files, "existing_archive.zip")
152
152
 
153
153
  # Compressing a single file into a buffer
154
- compressor2 = core.BitFileCompressor(core.FormatBZip2)
154
+ compressor2 = pybit7z.BitFileCompressor(pybit7z.FormatBZip2)
155
155
  buffer: bytes = compressor2.compress_file(files[0])
156
- except core.BitException as e:
156
+ except pybit7z.BitException as e:
157
157
  ... # handle the exception
158
158
  ```
159
159
 
160
160
  Work on a single archive:
161
161
 
162
162
  ```python
163
- from pybit7z import core
163
+ import pybit7z
164
164
 
165
165
  try:
166
- archive = core.BitArchiveWriter(core.FormatSevenZip)
166
+ archive = pybit7z.BitArchiveWriter(pybit7z.FormatSevenZip)
167
167
 
168
168
  # Adding the items to be compressed (no compression is performed here)
169
169
  archive.add_file("path/to/file.txt")
@@ -171,17 +171,17 @@ try:
171
171
 
172
172
  # Compressing the added items to the output archive
173
173
  archive.compress_to("output.7z")
174
- except core.BitException as e:
174
+ except pybit7z.BitException as e:
175
175
  ... # handle the exception
176
176
  ```
177
177
 
178
178
  ### Read Archive Metadata
179
179
 
180
180
  ```python
181
- from pybit7z import core
181
+ import pybit7z
182
182
 
183
183
  try:
184
- arc = core.BitArchiveReader("archive.7z", core.FormatSevenZip)
184
+ arc = pybit7z.BitArchiveReader("archive.7z", pybit7z.FormatSevenZip)
185
185
 
186
186
  # Printing archive metadata
187
187
  print("Archive properties:",
@@ -202,7 +202,7 @@ try:
202
202
  "\n Size: " , item.size(),
203
203
  "\n Packed size: " , item.pack_size(),
204
204
  "\n CRC: " , item.crc())
205
- except core.BitException as e:
205
+ except pybit7z.BitException as e:
206
206
  ... # handle the exception
207
207
  ```
208
208
 
@@ -40,10 +40,10 @@ pip install pybit7z
40
40
  ### Extract Files from an Archive
41
41
 
42
42
  ```python
43
- from pybit7z import core
43
+ import pybit7z
44
44
 
45
45
  try:
46
- extractor = core.BitFileExtractor(core.FormatSevenZip)
46
+ extractor = pybit7z.BitFileExtractor(pybit7z.FormatSevenZip)
47
47
  extractor.extract("path/to/archive.7z", "out/dir/")
48
48
 
49
49
  # Extracting a specific file inside an archive
@@ -55,35 +55,35 @@ try:
55
55
  # Extracting an encrypted archive
56
56
  extractor.set_password("password")
57
57
  extractor.extract("path/to/another/archive.7z", "out/dir/")
58
- except core.BitException as e:
58
+ except pybit7z.BitException as e:
59
59
  ... # handle the exception
60
60
  ```
61
61
 
62
62
  Work on a single archive:
63
63
 
64
64
  ```python
65
- from pybit7z import core
65
+ import pybit7z
66
66
 
67
67
  try:
68
68
  # Opening the archive
69
- archive = core.BitArchiveReader("path/to/archive.gz", core.FormatGZip)
69
+ archive = pybit7z.BitArchiveReader("path/to/archive.gz", pybit7z.FormatGZip)
70
70
 
71
71
  # Testing the archive
72
72
  archive.test()
73
73
 
74
74
  # Extracting the archive
75
75
  archive.extract_to("out/dir/")
76
- except core.BitException as e:
76
+ except pybit7z.BitException as e:
77
77
  ... # handle the exception
78
78
  ```
79
79
 
80
80
  ### Compress Files into an Archive
81
81
 
82
82
  ```python
83
- from pybit7z import core
83
+ import pybit7z
84
84
 
85
85
  try:
86
- compressor = core.BitFileCompressor(core.FormatSevenZip)
86
+ compressor = pybit7z.BitFileCompressor(pybit7z.FormatSevenZip)
87
87
 
88
88
  files = ["path/to/file1.jpg", "path/to/file2.pdf"]
89
89
 
@@ -105,23 +105,23 @@ try:
105
105
  compressor.compress_files(files, "protected_archive.zip")
106
106
 
107
107
  # Updating an existing zip archive
108
- compressor.set_update_mode(core.UpdateMode.Append)
108
+ compressor.set_update_mode(pybit7z.UpdateMode.Append)
109
109
  compressor.compress_files(files, "existing_archive.zip")
110
110
 
111
111
  # Compressing a single file into a buffer
112
- compressor2 = core.BitFileCompressor(core.FormatBZip2)
112
+ compressor2 = pybit7z.BitFileCompressor(pybit7z.FormatBZip2)
113
113
  buffer: bytes = compressor2.compress_file(files[0])
114
- except core.BitException as e:
114
+ except pybit7z.BitException as e:
115
115
  ... # handle the exception
116
116
  ```
117
117
 
118
118
  Work on a single archive:
119
119
 
120
120
  ```python
121
- from pybit7z import core
121
+ import pybit7z
122
122
 
123
123
  try:
124
- archive = core.BitArchiveWriter(core.FormatSevenZip)
124
+ archive = pybit7z.BitArchiveWriter(pybit7z.FormatSevenZip)
125
125
 
126
126
  # Adding the items to be compressed (no compression is performed here)
127
127
  archive.add_file("path/to/file.txt")
@@ -129,17 +129,17 @@ try:
129
129
 
130
130
  # Compressing the added items to the output archive
131
131
  archive.compress_to("output.7z")
132
- except core.BitException as e:
132
+ except pybit7z.BitException as e:
133
133
  ... # handle the exception
134
134
  ```
135
135
 
136
136
  ### Read Archive Metadata
137
137
 
138
138
  ```python
139
- from pybit7z import core
139
+ import pybit7z
140
140
 
141
141
  try:
142
- arc = core.BitArchiveReader("archive.7z", core.FormatSevenZip)
142
+ arc = pybit7z.BitArchiveReader("archive.7z", pybit7z.FormatSevenZip)
143
143
 
144
144
  # Printing archive metadata
145
145
  print("Archive properties:",
@@ -160,7 +160,7 @@ try:
160
160
  "\n Size: " , item.size(),
161
161
  "\n Packed size: " , item.pack_size(),
162
162
  "\n CRC: " , item.crc())
163
- except core.BitException as e:
163
+ except pybit7z.BitException as e:
164
164
  ... # handle the exception
165
165
  ```
166
166
 
@@ -0,0 +1,8 @@
1
+ # pybit7z package
2
+
3
+ ```{eval-rst}
4
+ .. automodule:: pybit7z
5
+ :members:
6
+ :undoc-members:
7
+ :show-inheritance:
8
+ ```
@@ -0,0 +1,204 @@
1
+ """
2
+ Copyright (c) 2024 l.feng. All rights reserved.
3
+
4
+ pybit7z: A wrapper based on bit7z.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import pathlib
10
+
11
+ from importlib_metadata import distribution
12
+
13
+ from pybit7z._core import (
14
+ BitAbstractArchiveCreator,
15
+ BitAbstractArchiveHandler,
16
+ BitAbstractArchiveOpener,
17
+ BitArchiveEditor,
18
+ BitArchiveItem,
19
+ BitArchiveItemInfo,
20
+ BitArchiveItemOffset,
21
+ BitArchiveReader,
22
+ BitArchiveWriter,
23
+ BitCompressionLevel,
24
+ BitCompressionMethod,
25
+ BitException,
26
+ BitFileCompressor,
27
+ BitFileExtractor,
28
+ BitGenericItem,
29
+ BitInFormat,
30
+ BitInOutFormat,
31
+ BitInputArchive,
32
+ BitMemCompressor,
33
+ BitMemExtractor,
34
+ BitOutputArchive,
35
+ BitProperty,
36
+ BitPropVariant,
37
+ BitPropVariantType,
38
+ BitStringCompressor,
39
+ BitStringExtractor,
40
+ DeletePolicy,
41
+ FilterPolicy,
42
+ FormatAPM,
43
+ FormatArj,
44
+ FormatAuto,
45
+ FormatBZip2,
46
+ FormatCab,
47
+ FormatChm,
48
+ FormatCoff,
49
+ FormatCompound,
50
+ FormatCpio,
51
+ FormatCramFS,
52
+ FormatDeb,
53
+ FormatDmg,
54
+ FormatElf,
55
+ FormatExt,
56
+ FormatFat,
57
+ FormatFeatures,
58
+ FormatFlv,
59
+ FormatGpt,
60
+ FormatGZip,
61
+ FormatHfs,
62
+ FormatHxs,
63
+ FormatIHex,
64
+ FormatIso,
65
+ FormatLzh,
66
+ FormatLzma,
67
+ FormatLzma86,
68
+ FormatMacho,
69
+ FormatMbr,
70
+ FormatMslz,
71
+ FormatMub,
72
+ FormatNsis,
73
+ FormatNtfs,
74
+ FormatPe,
75
+ FormatPpmd,
76
+ FormatQcow,
77
+ FormatRar,
78
+ FormatRar5,
79
+ FormatRpm,
80
+ FormatSevenZip,
81
+ FormatSplit,
82
+ FormatSquashFS,
83
+ FormatSwf,
84
+ FormatSwfc,
85
+ FormatTar,
86
+ FormatTE,
87
+ FormatUdf,
88
+ FormatUEFIc,
89
+ FormatUEFIs,
90
+ FormatVdi,
91
+ FormatVhd,
92
+ FormatVhdx,
93
+ FormatVmdk,
94
+ FormatWim,
95
+ FormatXar,
96
+ FormatXz,
97
+ FormatZ,
98
+ FormatZip,
99
+ OverwriteMode,
100
+ UpdateMode,
101
+ set_large_page_mode,
102
+ set_lib7zip_path,
103
+ )
104
+
105
+ from ._version import version as __version__
106
+
107
+ __all__ = [
108
+ "BitAbstractArchiveCreator",
109
+ "BitAbstractArchiveHandler",
110
+ "BitAbstractArchiveOpener",
111
+ "BitArchiveEditor",
112
+ "BitArchiveItem",
113
+ "BitArchiveItemInfo",
114
+ "BitArchiveItemOffset",
115
+ "BitArchiveReader",
116
+ "BitArchiveWriter",
117
+ "BitCompressionLevel",
118
+ "BitCompressionMethod",
119
+ "BitException",
120
+ "BitFileCompressor",
121
+ "BitFileExtractor",
122
+ "BitGenericItem",
123
+ "BitInFormat",
124
+ "BitInOutFormat",
125
+ "BitInputArchive",
126
+ "BitMemCompressor",
127
+ "BitMemExtractor",
128
+ "BitOutputArchive",
129
+ "BitPropVariant",
130
+ "BitPropVariantType",
131
+ "BitProperty",
132
+ "BitStringCompressor",
133
+ "BitStringExtractor",
134
+ "DeletePolicy",
135
+ "FilterPolicy",
136
+ "FormatAPM",
137
+ "FormatArj",
138
+ "FormatAuto",
139
+ "FormatBZip2",
140
+ "FormatCab",
141
+ "FormatChm",
142
+ "FormatCoff",
143
+ "FormatCompound",
144
+ "FormatCpio",
145
+ "FormatCramFS",
146
+ "FormatDeb",
147
+ "FormatDmg",
148
+ "FormatElf",
149
+ "FormatExt",
150
+ "FormatFat",
151
+ "FormatFeatures",
152
+ "FormatFlv",
153
+ "FormatGZip",
154
+ "FormatGpt",
155
+ "FormatHfs",
156
+ "FormatHxs",
157
+ "FormatIHex",
158
+ "FormatIso",
159
+ "FormatLzh",
160
+ "FormatLzma",
161
+ "FormatLzma86",
162
+ "FormatMacho",
163
+ "FormatMbr",
164
+ "FormatMslz",
165
+ "FormatMub",
166
+ "FormatNsis",
167
+ "FormatNtfs",
168
+ "FormatPe",
169
+ "FormatPpmd",
170
+ "FormatQcow",
171
+ "FormatRar",
172
+ "FormatRar5",
173
+ "FormatRpm",
174
+ "FormatSevenZip",
175
+ "FormatSplit",
176
+ "FormatSquashFS",
177
+ "FormatSwf",
178
+ "FormatSwfc",
179
+ "FormatTE",
180
+ "FormatTar",
181
+ "FormatUEFIc",
182
+ "FormatUEFIs",
183
+ "FormatUdf",
184
+ "FormatVdi",
185
+ "FormatVhd",
186
+ "FormatVhdx",
187
+ "FormatVmdk",
188
+ "FormatWim",
189
+ "FormatXar",
190
+ "FormatXz",
191
+ "FormatZ",
192
+ "FormatZip",
193
+ "OverwriteMode",
194
+ "UpdateMode",
195
+ "__version__",
196
+ ]
197
+
198
+ if not pathlib.Path(set_lib7zip_path()).exists():
199
+ lib7zip_path = (
200
+ distribution(__package__).locate_file(__package__) / set_lib7zip_path()
201
+ )
202
+ if lib7zip_path.exists():
203
+ set_lib7zip_path(str(lib7zip_path))
204
+ set_large_page_mode()
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.2.3'
16
- __version_tuple__ = version_tuple = (0, 2, 3)
15
+ __version__ = version = '0.2.4'
16
+ __version_tuple__ = version_tuple = (0, 2, 4)
@@ -8,7 +8,7 @@ from pathlib import Path
8
8
 
9
9
  import pytest
10
10
 
11
- from pybit7z import core
11
+ import pybit7z
12
12
 
13
13
 
14
14
  @pytest.fixture
@@ -40,25 +40,25 @@ def large_file(temp_dir):
40
40
 
41
41
  def test_format():
42
42
  """Test format from bit7z"""
43
- assert core.FormatSevenZip.extension().endswith(".7z")
44
- assert core.FormatSevenZip != core.FormatZip
45
- assert core.FormatSevenZip == core.FormatSevenZip
46
- assert core.FormatSevenZip.has_feature(core.FormatFeatures.CompressionLevel)
47
- assert core.FormatSevenZip.has_feature(core.FormatFeatures.Encryption)
48
- assert core.FormatSevenZip.has_feature(core.FormatFeatures.MultipleFiles)
49
- assert core.FormatSevenZip.has_feature(core.FormatFeatures.HeaderEncryption)
50
- assert core.FormatSevenZip.has_feature(core.FormatFeatures.SolidArchive)
43
+ assert pybit7z.FormatSevenZip.extension().endswith(".7z")
44
+ assert pybit7z.FormatSevenZip != pybit7z.FormatZip
45
+ assert pybit7z.FormatSevenZip == pybit7z.FormatSevenZip
46
+ assert pybit7z.FormatSevenZip.has_feature(pybit7z.FormatFeatures.CompressionLevel)
47
+ assert pybit7z.FormatSevenZip.has_feature(pybit7z.FormatFeatures.Encryption)
48
+ assert pybit7z.FormatSevenZip.has_feature(pybit7z.FormatFeatures.MultipleFiles)
49
+ assert pybit7z.FormatSevenZip.has_feature(pybit7z.FormatFeatures.HeaderEncryption)
50
+ assert pybit7z.FormatSevenZip.has_feature(pybit7z.FormatFeatures.SolidArchive)
51
51
 
52
52
 
53
53
  def test_format_features():
54
54
  """Test format features detection"""
55
- fmt_7z = core.FormatSevenZip
56
- assert isinstance(fmt_7z, core.BitInOutFormat)
55
+ fmt_7z = pybit7z.FormatSevenZip
56
+ assert isinstance(fmt_7z, pybit7z.BitInOutFormat)
57
57
 
58
58
  # Test format properties
59
- assert fmt_7z.has_feature(core.FormatFeatures.CompressionLevel)
60
- assert fmt_7z.has_feature(core.FormatFeatures.Encryption)
61
- assert fmt_7z.has_feature(core.FormatFeatures.MultipleFiles)
59
+ assert fmt_7z.has_feature(pybit7z.FormatFeatures.CompressionLevel)
60
+ assert fmt_7z.has_feature(pybit7z.FormatFeatures.Encryption)
61
+ assert fmt_7z.has_feature(pybit7z.FormatFeatures.MultipleFiles)
62
62
 
63
63
  assert fmt_7z.extension() == ".7z"
64
64
 
@@ -73,11 +73,11 @@ def test_basic_compression(temp_dir):
73
73
  archive_path: Path = temp_dir / "test.7z"
74
74
 
75
75
  # Create a compressor for 7z format
76
- compressor = core.BitFileCompressor(core.FormatSevenZip)
76
+ compressor = pybit7z.BitFileCompressor(pybit7z.FormatSevenZip)
77
77
 
78
78
  # Set compression options
79
- compressor.set_compression_level(core.BitCompressionLevel.Normal)
80
- compressor.set_compression_method(core.BitCompressionMethod.Lzma2)
79
+ compressor.set_compression_level(pybit7z.BitCompressionLevel.Normal)
80
+ compressor.set_compression_method(pybit7z.BitCompressionMethod.Lzma2)
81
81
 
82
82
  # Compress the file
83
83
  compressor.compress_files([str(test_file)], str(archive_path))
@@ -89,18 +89,18 @@ def test_basic_compression(temp_dir):
89
89
  def test_archive_extraction(temp_dir):
90
90
  """Test archive extraction using BitFileExtractor"""
91
91
  # Create a test archive first
92
- test_file = temp_dir / "test.txt"
92
+ test_file: Path = temp_dir / "test.txt"
93
93
  test_file.write_text("Hello from bit7z!")
94
94
 
95
95
  archive_path = temp_dir / "test.7z"
96
- compressor = core.BitFileCompressor(core.FormatSevenZip)
96
+ compressor = pybit7z.BitFileCompressor(pybit7z.FormatSevenZip)
97
97
  compressor.compress([str(test_file)], str(archive_path))
98
98
 
99
99
  # Now extract it to a different directory
100
100
  extract_dir: Path = temp_dir / "extracted"
101
101
  extract_dir.mkdir()
102
102
 
103
- extractor = core.BitFileExtractor(core.FormatSevenZip)
103
+ extractor = pybit7z.BitFileExtractor(pybit7z.FormatSevenZip)
104
104
  extractor.extract(str(archive_path), str(extract_dir))
105
105
 
106
106
  # Verify extraction
@@ -117,9 +117,9 @@ def test_error_handling(temp_dir):
117
117
  nonexistent_file = temp_dir / "nonexistent.txt"
118
118
  archive_path = temp_dir / "test.7z"
119
119
 
120
- compressor = core.BitFileCompressor(core.FormatSevenZip)
120
+ compressor = pybit7z.BitFileCompressor(pybit7z.FormatSevenZip)
121
121
 
122
- with pytest.raises(core.BitException):
122
+ with pytest.raises(pybit7z.BitException):
123
123
  compressor.compress([str(nonexistent_file)], str(archive_path))
124
124
 
125
125
  # Test invalid password extraction
@@ -133,10 +133,10 @@ def test_error_handling(temp_dir):
133
133
  extract_dir: Path = temp_dir / "extracted"
134
134
  extract_dir.mkdir()
135
135
 
136
- extractor = core.BitFileExtractor(core.FormatSevenZip)
136
+ extractor = pybit7z.BitFileExtractor(pybit7z.FormatSevenZip)
137
137
  extractor.set_password("wrong_password")
138
138
 
139
- with pytest.raises(core.BitException, match="wrong password"):
139
+ with pytest.raises(pybit7z.BitException, match="wrong password"):
140
140
  extractor.extract(str(archive_path), str(extract_dir))
141
141
 
142
142
 
@@ -145,12 +145,12 @@ def test_large_file_handling(temp_dir, large_file):
145
145
 
146
146
  # Test different compression levels with large file
147
147
  for level in [
148
- core.BitCompressionLevel.Fastest,
149
- core.BitCompressionLevel.Normal,
150
- core.BitCompressionLevel.Max,
148
+ pybit7z.BitCompressionLevel.Fastest,
149
+ pybit7z.BitCompressionLevel.Normal,
150
+ pybit7z.BitCompressionLevel.Max,
151
151
  ]:
152
152
  level_archive = temp_dir / f"large_{level}.7z"
153
- compressor = core.BitFileCompressor(core.FormatSevenZip)
153
+ compressor = pybit7z.BitFileCompressor(pybit7z.FormatSevenZip)
154
154
  compressor.set_compression_level(level)
155
155
 
156
156
  compressor.compress([str(large_file)], str(level_archive))
@@ -160,14 +160,14 @@ def test_large_file_handling(temp_dir, large_file):
160
160
 
161
161
  # Extract and verify
162
162
  for level in [
163
- core.BitCompressionLevel.Fastest,
164
- core.BitCompressionLevel.Normal,
165
- core.BitCompressionLevel.Max,
163
+ pybit7z.BitCompressionLevel.Fastest,
164
+ pybit7z.BitCompressionLevel.Normal,
165
+ pybit7z.BitCompressionLevel.Max,
166
166
  ]:
167
167
  level_archive = temp_dir / f"large_{level}.7z"
168
168
  extract_dir: Path = temp_dir / "extracted_large"
169
169
 
170
- extractor = core.BitFileExtractor(core.FormatSevenZip)
170
+ extractor = pybit7z.BitFileExtractor(pybit7z.FormatSevenZip)
171
171
  extractor.extract(str(level_archive), str(extract_dir))
172
172
 
173
173
  extracted_file: Path = extract_dir / large_file.name
@@ -194,12 +194,12 @@ def test_multi_file_archive(temp_dir):
194
194
 
195
195
  # Create archive
196
196
  archive_path = temp_dir / "multi.7z"
197
- compressor = core.BitFileCompressor(core.FormatSevenZip)
197
+ compressor = pybit7z.BitFileCompressor(pybit7z.FormatSevenZip)
198
198
  compressor.compress([str(temp_dir)], str(archive_path))
199
199
 
200
200
  # Extract to new location
201
201
  extract_dir = temp_dir / "extracted_multi"
202
- extractor = core.BitFileExtractor(core.FormatSevenZip)
202
+ extractor = pybit7z.BitFileExtractor(pybit7z.FormatSevenZip)
203
203
  extractor.extract(str(archive_path), str(extract_dir))
204
204
 
205
205
  # Verify all files
@@ -212,26 +212,26 @@ def test_multi_file_archive(temp_dir):
212
212
  def test_compression_methods_comparison(temp_dir, large_file):
213
213
  """Test and compare different compression methods"""
214
214
  methods = [
215
- core.BitCompressionMethod.Lzma2,
216
- core.BitCompressionMethod.Lzma,
217
- core.BitCompressionMethod.BZip2,
218
- core.BitCompressionMethod.Copy,
215
+ pybit7z.BitCompressionMethod.Lzma2,
216
+ pybit7z.BitCompressionMethod.Lzma,
217
+ pybit7z.BitCompressionMethod.BZip2,
218
+ pybit7z.BitCompressionMethod.Copy,
219
219
  ]
220
220
 
221
221
  results = {}
222
222
  for method in methods:
223
223
  archive_path: Path = temp_dir / f"test_{method}.7z"
224
- compressor = core.BitFileCompressor(core.FormatSevenZip)
224
+ compressor = pybit7z.BitFileCompressor(pybit7z.FormatSevenZip)
225
225
  compressor.set_compression_method(method)
226
226
 
227
227
  compressor.compress([str(large_file)], str(archive_path))
228
228
  results[method] = archive_path.stat().st_size
229
229
 
230
230
  # Verify that COPY method creates the largest archive
231
- assert results[core.BitCompressionMethod.Copy] >= max(
231
+ assert results[pybit7z.BitCompressionMethod.Copy] >= max(
232
232
  size
233
233
  for method, size in results.items()
234
- if method != core.BitCompressionMethod.Copy
234
+ if method != pybit7z.BitCompressionMethod.Copy
235
235
  ), "COPY method should create the largest archive"
236
236
 
237
237
 
@@ -242,11 +242,11 @@ def test_archive_metadata(temp_dir):
242
242
  test_file.write_text("Test content")
243
243
 
244
244
  archive_path = temp_dir / "test.7z"
245
- compressor = core.BitFileCompressor(core.FormatSevenZip)
245
+ compressor = pybit7z.BitFileCompressor(pybit7z.FormatSevenZip)
246
246
  compressor.compress([str(test_file)], str(archive_path))
247
247
 
248
248
  # Read archive
249
- reader = core.BitArchiveReader(str(archive_path), core.FormatAuto)
249
+ reader = pybit7z.BitArchiveReader(str(archive_path), pybit7z.FormatAuto)
250
250
  items = reader.items()
251
251
 
252
252
  assert len(items) == 1, "Expected exactly one item in archive"
@@ -273,11 +273,11 @@ def test_mem_to_bytes():
273
273
  test_data = b"Stream compression test data" * 1000
274
274
 
275
275
  # Compress to memory
276
- mem_compressor = core.BitMemCompressor(core.FormatSevenZip)
276
+ mem_compressor = pybit7z.BitMemCompressor(pybit7z.FormatSevenZip)
277
277
  compressed_data = mem_compressor.compress_file(test_data)
278
278
 
279
279
  # Extract to memory
280
- mem_extractor = core.BitMemExtractor(core.FormatSevenZip)
280
+ mem_extractor = pybit7z.BitMemExtractor(pybit7z.FormatSevenZip)
281
281
  extracted_data = mem_extractor.extract(compressed_data)
282
282
 
283
283
  assert (
@@ -292,15 +292,15 @@ def test_different_formats(temp_dir):
292
292
  test_file.write_text("Testing different formats")
293
293
 
294
294
  formats = [
295
- (core.FormatSevenZip, "test.7z"),
296
- (core.FormatZip, "test.zip"),
297
- (core.FormatBZip2, "test.txt.bz2"),
298
- (core.FormatGZip, "test.gz"),
295
+ (pybit7z.FormatSevenZip, "test.7z"),
296
+ (pybit7z.FormatZip, "test.zip"),
297
+ (pybit7z.FormatBZip2, "test.txt.bz2"),
298
+ (pybit7z.FormatGZip, "test.gz"),
299
299
  ]
300
300
 
301
301
  for format_type, filename in formats:
302
302
  archive_path: Path = temp_dir / filename
303
- compressor = core.BitFileCompressor(format_type)
303
+ compressor = pybit7z.BitFileCompressor(format_type)
304
304
  compressor.compress([str(test_file)], str(archive_path))
305
305
 
306
306
  assert archive_path.exists(), f"Archive {filename} was not created"
@@ -311,7 +311,7 @@ def test_different_formats(temp_dir):
311
311
  # Test extraction
312
312
  extract_dir = temp_dir / f"extracted_{filename}"
313
313
 
314
- extractor = core.BitFileExtractor(format_type)
314
+ extractor = pybit7z.BitFileExtractor(format_type)
315
315
  extractor.extract(str(archive_path), str(extract_dir))
316
316
 
317
317
  extracted_file: Path = extract_dir / "test.txt"
@@ -1,17 +0,0 @@
1
- # pybit7z package
2
-
3
- ```{eval-rst}
4
- .. automodule:: pybit7z
5
- :members:
6
- :undoc-members:
7
- :show-inheritance:
8
- ```
9
-
10
- ## Submodules
11
-
12
- ```{eval-rst}
13
- .. automodule:: pybit7z._core
14
- :members:
15
- :undoc-members:
16
- :show-inheritance:
17
- ```
@@ -1,25 +0,0 @@
1
- """
2
- Copyright (c) 2024 l.feng. All rights reserved.
3
-
4
- pybit7z: A wrapper based on bit7z.
5
- """
6
-
7
- from __future__ import annotations
8
-
9
- from pathlib import Path
10
-
11
- from importlib_metadata import distribution
12
-
13
- from pybit7z import _core as core
14
-
15
- from ._version import version as __version__
16
-
17
- __all__ = ["__version__", "core"]
18
-
19
- if not Path(core.set_lib7zip_path()).exists():
20
- lib7zip_path = (
21
- distribution(__package__).locate_file(__package__) / core.set_lib7zip_path()
22
- )
23
- if lib7zip_path.exists():
24
- core.set_lib7zip_path(str(lib7zip_path))
25
- core.set_large_page_mode()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes