blockdevice 0.1.0__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.
@@ -0,0 +1,131 @@
1
+ # PolyForm Noncommercial License 1.0.0
2
+
3
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
4
+
5
+ ## Acceptance
6
+
7
+ In order to get any license under these terms, you must agree
8
+ to them as both strict obligations and conditions to all
9
+ your licenses.
10
+
11
+ ## Copyright License
12
+
13
+ The licensor grants you a copyright license for the
14
+ software to do everything you might do with the software
15
+ that would otherwise infringe the licensor's copyright
16
+ in it for any permitted purpose. However, you may
17
+ only distribute the software according to [Distribution
18
+ License](#distribution-license) and make changes or new works
19
+ based on the software according to [Changes and New Works
20
+ License](#changes-and-new-works-license).
21
+
22
+ ## Distribution License
23
+
24
+ The licensor grants you an additional copyright license
25
+ to distribute copies of the software. Your license
26
+ to distribute covers distributing the software with
27
+ changes and new works permitted by [Changes and New Works
28
+ License](#changes-and-new-works-license).
29
+
30
+ ## Notices
31
+
32
+ You must ensure that anyone who gets a copy of any part of
33
+ the software from you also gets a copy of these terms or the
34
+ URL for them above, as well as copies of any plain-text lines
35
+ beginning with `Required Notice:` that the licensor provided
36
+ with the software. For example:
37
+
38
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
39
+
40
+ ## Changes and New Works License
41
+
42
+ The licensor grants you an additional copyright license to
43
+ make changes and new works based on the software for any
44
+ permitted purpose.
45
+
46
+ ## Patent License
47
+
48
+ The licensor grants you a patent license for the software that
49
+ covers patent claims the licensor can license, or becomes able
50
+ to license, that you would infringe by using the software.
51
+
52
+ ## Noncommercial Purposes
53
+
54
+ Any noncommercial purpose is a permitted purpose.
55
+
56
+ ## Personal Uses
57
+
58
+ Personal use for research, experiment, and testing for
59
+ the benefit of public knowledge, personal study, private
60
+ entertainment, hobby projects, amateur pursuits, or religious
61
+ observance, without any anticipated commercial application,
62
+ is use for a permitted purpose.
63
+
64
+ ## Noncommercial Organizations
65
+
66
+ Use by any charitable organization, educational institution,
67
+ public research organization, public safety or health
68
+ organization, environmental protection organization,
69
+ or government institution is use for a permitted purpose
70
+ regardless of the source of funding or obligations resulting
71
+ from the funding.
72
+
73
+ ## Fair Use
74
+
75
+ You may have "fair use" rights for the software under the
76
+ law. These terms do not limit them.
77
+
78
+ ## No Other Rights
79
+
80
+ These terms do not allow you to sublicense or transfer any of
81
+ your licenses to anyone else, or prevent the licensor from
82
+ granting licenses to anyone else. These terms do not imply
83
+ any other licenses.
84
+
85
+ ## Patent Defense
86
+
87
+ If you make any written claim that the software infringes or
88
+ contributes to infringement of any patent, your patent license
89
+ for the software granted under these terms ends immediately. If
90
+ your company makes such a claim, your patent license ends
91
+ immediately for work on behalf of your company.
92
+
93
+ ## Violations
94
+
95
+ The first time you are notified in writing that you have
96
+ violated any of these terms, or done anything with the software
97
+ not covered by your licenses, your licenses can nonetheless
98
+ continue if you come into full compliance with these terms,
99
+ and take practical steps to correct past violations, within
100
+ 32 days of receiving notice. Otherwise, all your licenses
101
+ end immediately.
102
+
103
+ ## No Liability
104
+
105
+ ***As far as the law allows, the software comes as is, without
106
+ any warranty or condition, and the licensor will not be liable
107
+ to you for any damages arising out of these terms or the use
108
+ or nature of the software, under any kind of legal claim.***
109
+
110
+ ## Definitions
111
+
112
+ The **licensor** is the individual or entity offering these
113
+ terms, and the **software** is the software the licensor makes
114
+ available under these terms.
115
+
116
+ **You** refers to the individual or entity agreeing to these
117
+ terms.
118
+
119
+ **Your company** is any legal entity, sole proprietorship,
120
+ or other kind of organization that you work for, plus all
121
+ organizations that have control over, are under the control of,
122
+ or are under common control with that organization. **Control**
123
+ means ownership of substantially all the assets of an entity,
124
+ or the power to direct its management and policies by vote,
125
+ contract, or otherwise. Control can be direct or indirect.
126
+
127
+ **Your licenses** are all the licenses granted to you for the
128
+ software under these terms.
129
+
130
+ **Use** means anything you do with the software requiring one
131
+ of your licenses.
@@ -0,0 +1,6 @@
1
+ recursive-include include *
2
+ recursive-include tests *
3
+ recursive-include examples *
4
+ include LICENSE.md
5
+ include README.md
6
+ include requirements.txt
@@ -0,0 +1,318 @@
1
+ Metadata-Version: 2.4
2
+ Name: blockdevice
3
+ Version: 0.1.0
4
+ Summary: A simple C++ Python library for block device operations
5
+ Home-page: https://github.com/Omena0/blockdevice
6
+ Author: Omena0
7
+ Author-email: Omena0 <omena0mc@gmail.com>
8
+ License: # PolyForm Noncommercial License 1.0.0
9
+
10
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
11
+
12
+ ## Acceptance
13
+
14
+ In order to get any license under these terms, you must agree
15
+ to them as both strict obligations and conditions to all
16
+ your licenses.
17
+
18
+ ## Copyright License
19
+
20
+ The licensor grants you a copyright license for the
21
+ software to do everything you might do with the software
22
+ that would otherwise infringe the licensor's copyright
23
+ in it for any permitted purpose. However, you may
24
+ only distribute the software according to [Distribution
25
+ License](#distribution-license) and make changes or new works
26
+ based on the software according to [Changes and New Works
27
+ License](#changes-and-new-works-license).
28
+
29
+ ## Distribution License
30
+
31
+ The licensor grants you an additional copyright license
32
+ to distribute copies of the software. Your license
33
+ to distribute covers distributing the software with
34
+ changes and new works permitted by [Changes and New Works
35
+ License](#changes-and-new-works-license).
36
+
37
+ ## Notices
38
+
39
+ You must ensure that anyone who gets a copy of any part of
40
+ the software from you also gets a copy of these terms or the
41
+ URL for them above, as well as copies of any plain-text lines
42
+ beginning with `Required Notice:` that the licensor provided
43
+ with the software. For example:
44
+
45
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
46
+
47
+ ## Changes and New Works License
48
+
49
+ The licensor grants you an additional copyright license to
50
+ make changes and new works based on the software for any
51
+ permitted purpose.
52
+
53
+ ## Patent License
54
+
55
+ The licensor grants you a patent license for the software that
56
+ covers patent claims the licensor can license, or becomes able
57
+ to license, that you would infringe by using the software.
58
+
59
+ ## Noncommercial Purposes
60
+
61
+ Any noncommercial purpose is a permitted purpose.
62
+
63
+ ## Personal Uses
64
+
65
+ Personal use for research, experiment, and testing for
66
+ the benefit of public knowledge, personal study, private
67
+ entertainment, hobby projects, amateur pursuits, or religious
68
+ observance, without any anticipated commercial application,
69
+ is use for a permitted purpose.
70
+
71
+ ## Noncommercial Organizations
72
+
73
+ Use by any charitable organization, educational institution,
74
+ public research organization, public safety or health
75
+ organization, environmental protection organization,
76
+ or government institution is use for a permitted purpose
77
+ regardless of the source of funding or obligations resulting
78
+ from the funding.
79
+
80
+ ## Fair Use
81
+
82
+ You may have "fair use" rights for the software under the
83
+ law. These terms do not limit them.
84
+
85
+ ## No Other Rights
86
+
87
+ These terms do not allow you to sublicense or transfer any of
88
+ your licenses to anyone else, or prevent the licensor from
89
+ granting licenses to anyone else. These terms do not imply
90
+ any other licenses.
91
+
92
+ ## Patent Defense
93
+
94
+ If you make any written claim that the software infringes or
95
+ contributes to infringement of any patent, your patent license
96
+ for the software granted under these terms ends immediately. If
97
+ your company makes such a claim, your patent license ends
98
+ immediately for work on behalf of your company.
99
+
100
+ ## Violations
101
+
102
+ The first time you are notified in writing that you have
103
+ violated any of these terms, or done anything with the software
104
+ not covered by your licenses, your licenses can nonetheless
105
+ continue if you come into full compliance with these terms,
106
+ and take practical steps to correct past violations, within
107
+ 32 days of receiving notice. Otherwise, all your licenses
108
+ end immediately.
109
+
110
+ ## No Liability
111
+
112
+ ***As far as the law allows, the software comes as is, without
113
+ any warranty or condition, and the licensor will not be liable
114
+ to you for any damages arising out of these terms or the use
115
+ or nature of the software, under any kind of legal claim.***
116
+
117
+ ## Definitions
118
+
119
+ The **licensor** is the individual or entity offering these
120
+ terms, and the **software** is the software the licensor makes
121
+ available under these terms.
122
+
123
+ **You** refers to the individual or entity agreeing to these
124
+ terms.
125
+
126
+ **Your company** is any legal entity, sole proprietorship,
127
+ or other kind of organization that you work for, plus all
128
+ organizations that have control over, are under the control of,
129
+ or are under common control with that organization. **Control**
130
+ means ownership of substantially all the assets of an entity,
131
+ or the power to direct its management and policies by vote,
132
+ contract, or otherwise. Control can be direct or indirect.
133
+
134
+ **Your licenses** are all the licenses granted to you for the
135
+ software under these terms.
136
+
137
+ **Use** means anything you do with the software requiring one
138
+ of your licenses.
139
+
140
+ Keywords: block-device,fuse,filesystem,storage
141
+ Classifier: Development Status :: 3 - Alpha
142
+ Classifier: Intended Audience :: Developers
143
+ Classifier: Programming Language :: Python :: 3
144
+ Classifier: Programming Language :: Python :: 3.8
145
+ Classifier: Programming Language :: Python :: 3.9
146
+ Classifier: Programming Language :: Python :: 3.10
147
+ Classifier: Programming Language :: Python :: 3.11
148
+ Classifier: Programming Language :: Python :: 3.12
149
+ Classifier: Programming Language :: Python :: 3.13
150
+ Classifier: Topic :: System :: Filesystems
151
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
152
+ Requires-Python: >=3.6
153
+ Description-Content-Type: text/markdown
154
+ License-File: LICENSE.md
155
+ Provides-Extra: dev
156
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
157
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
158
+ Dynamic: author
159
+ Dynamic: home-page
160
+ Dynamic: license-file
161
+ Dynamic: requires-python
162
+
163
+ # Blockdevice
164
+
165
+ [![Build](https://github.com/Omena0/blockdevice/actions/workflows/publish.yml/badge.svg)](https://github.com/Omena0/blockdevice/actions/workflows/publish.yml)
166
+ [![pytest](https://github.com/Omena0/blockdevice/actions/workflows/pytest.yml/badge.svg)](https://github.com/Omena0/blockdevice/actions/workflows/pytest.yml)
167
+ [![Coverage](https://img.shields.io/badge/coverage-48%25-brightgreen)](https://github.com/Omena0/blockdevice/actions/workflows/pytest.yml)
168
+ ![AI Code](https://img.shields.io/badge/AI_code-99%25-red?logo=Github%20copilot)
169
+
170
+ A Python library for creating and managing block devices with FUSE filesystem support. Provides persistent object storage with compression options and real-time synchronization capabilities.
171
+
172
+ ## Features
173
+
174
+ - **Block Device Operations**: C++ extension for efficient block device operations
175
+ - **FUSE Filesystem**: Mount block devices as user-space filesystems
176
+ - **Persistent Storage**: Multiple storage backends including disk-based and compressed storage
177
+ - **Real-time Sync**: Network synchronization for distributed applications
178
+ - **Python Integration**: Seamless integration with Python applications
179
+
180
+ ## Installation
181
+
182
+ ### From Source
183
+ ```bash
184
+ git clone https://github.com/Omena0/blockdevice.git
185
+ cd blockdevice
186
+ pip install .
187
+ ```
188
+
189
+ ## Quick Start
190
+
191
+ ### Basic Usage
192
+
193
+ ```python
194
+ from blockdevice import BlockDevice, DiskObject
195
+
196
+ # Create a block device
197
+ dev = BlockDevice("/path/to/device", dolphin=True)
198
+
199
+ # Create persistent storage
200
+ storage = DiskObject("data.pkl")
201
+ storage['key'] = 'value'
202
+ print(storage['key']) # 'value'
203
+
204
+ dev.start(True) # Start FUSE filesystem
205
+ ```
206
+
207
+ ### Compressed Storage
208
+
209
+ ```python
210
+ from blockdevice import CompressedDiskObject
211
+
212
+ # Create compressed persistent storage
213
+ storage = CompressedDiskObject("data.zst", compression_level=10)
214
+ storage['large_data'] = 'x' * 10000 # Automatically compressed
215
+ ```
216
+
217
+ ### Network Synchronization
218
+
219
+ ```python
220
+ from blockdevice import NetworkObject
221
+
222
+ # Create synchronized object (connects to server or becomes server)
223
+ sync_obj = NetworkObject('localhost', 8080)
224
+ sync_obj['shared_data'] = 'available on all connected instances'
225
+ ```
226
+
227
+ ## Architecture
228
+
229
+ The library consists of several key components:
230
+
231
+ - **BlockDevice**: C++ extension providing low-level block operations
232
+ - **Storage Objects**:
233
+ - `Object`: Abstract base class for persistent objects
234
+ - `DiskObject`: Pickle-based disk storage
235
+ - `CompressedDiskObject`: Zstd-compressed disk storage
236
+ - `NetworkObject`: Real-time synchronized storage
237
+ - **FUSE Integration**: `BlockDeviceFUSE` class for filesystem mounting
238
+
239
+ ## Development
240
+
241
+ ### Setup
242
+ ```bash
243
+ git clone https://github.com/Omena0/blockdevice.git
244
+ cd blockdevice
245
+ python -m venv .venv
246
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
247
+ pip install -r requirements.txt
248
+ pip install -e .
249
+ ```
250
+
251
+ ### Testing
252
+ ```bash
253
+ # Run all tests
254
+ pytest
255
+
256
+ # Run with coverage
257
+ pytest --cov=blockdevice --cov-report=html
258
+
259
+ # Run specific test file
260
+ pytest tests/test_utils.py
261
+ ```
262
+
263
+ ### Building
264
+ ```bash
265
+ # Build the C++ extension
266
+ python setup.py build_ext --inplace
267
+
268
+ # Build distribution
269
+ python setup.py sdist bdist_wheel
270
+ ```
271
+
272
+ ## Examples
273
+
274
+ See the `examples/` directory for sample applications:
275
+
276
+ - `compressed.py`: Filesystem implementation with compression
277
+ - `network/`: Client-server examples
278
+
279
+ ## API Reference
280
+
281
+ ### BlockDevice
282
+ ```python
283
+ BlockDevice(path: str, dolphin: bool = False)
284
+ ```
285
+ Core block device operations.
286
+
287
+ ### Storage Classes
288
+
289
+ #### DiskObject
290
+ ```python
291
+ DiskObject(path: str, default_value=None)
292
+ ```
293
+ Persistent dictionary stored as pickle file.
294
+
295
+ #### CompressedDiskObject
296
+ ```python
297
+ CompressedDiskObject(path: str, default_value=None, compression_level=5)
298
+ ```
299
+ Compressed persistent storage using zstd.
300
+
301
+ #### NetworkObject
302
+ ```python
303
+ NetworkObject(host: str, port: int = None, default_value=None)
304
+ ```
305
+ Real-time synchronized storage across network.
306
+
307
+ ## Contributing
308
+
309
+ 1. Fork the repository
310
+ 2. Create a feature branch
311
+ 3. Add tests for new functionality
312
+ 4. Ensure all tests pass
313
+ 5. Submit a pull request
314
+
315
+ ## License
316
+
317
+ See LICENSE.md for license information.
318
+
@@ -0,0 +1,156 @@
1
+ # Blockdevice
2
+
3
+ [![Build](https://github.com/Omena0/blockdevice/actions/workflows/publish.yml/badge.svg)](https://github.com/Omena0/blockdevice/actions/workflows/publish.yml)
4
+ [![pytest](https://github.com/Omena0/blockdevice/actions/workflows/pytest.yml/badge.svg)](https://github.com/Omena0/blockdevice/actions/workflows/pytest.yml)
5
+ [![Coverage](https://img.shields.io/badge/coverage-48%25-brightgreen)](https://github.com/Omena0/blockdevice/actions/workflows/pytest.yml)
6
+ ![AI Code](https://img.shields.io/badge/AI_code-99%25-red?logo=Github%20copilot)
7
+
8
+ A Python library for creating and managing block devices with FUSE filesystem support. Provides persistent object storage with compression options and real-time synchronization capabilities.
9
+
10
+ ## Features
11
+
12
+ - **Block Device Operations**: C++ extension for efficient block device operations
13
+ - **FUSE Filesystem**: Mount block devices as user-space filesystems
14
+ - **Persistent Storage**: Multiple storage backends including disk-based and compressed storage
15
+ - **Real-time Sync**: Network synchronization for distributed applications
16
+ - **Python Integration**: Seamless integration with Python applications
17
+
18
+ ## Installation
19
+
20
+ ### From Source
21
+ ```bash
22
+ git clone https://github.com/Omena0/blockdevice.git
23
+ cd blockdevice
24
+ pip install .
25
+ ```
26
+
27
+ ## Quick Start
28
+
29
+ ### Basic Usage
30
+
31
+ ```python
32
+ from blockdevice import BlockDevice, DiskObject
33
+
34
+ # Create a block device
35
+ dev = BlockDevice("/path/to/device", dolphin=True)
36
+
37
+ # Create persistent storage
38
+ storage = DiskObject("data.pkl")
39
+ storage['key'] = 'value'
40
+ print(storage['key']) # 'value'
41
+
42
+ dev.start(True) # Start FUSE filesystem
43
+ ```
44
+
45
+ ### Compressed Storage
46
+
47
+ ```python
48
+ from blockdevice import CompressedDiskObject
49
+
50
+ # Create compressed persistent storage
51
+ storage = CompressedDiskObject("data.zst", compression_level=10)
52
+ storage['large_data'] = 'x' * 10000 # Automatically compressed
53
+ ```
54
+
55
+ ### Network Synchronization
56
+
57
+ ```python
58
+ from blockdevice import NetworkObject
59
+
60
+ # Create synchronized object (connects to server or becomes server)
61
+ sync_obj = NetworkObject('localhost', 8080)
62
+ sync_obj['shared_data'] = 'available on all connected instances'
63
+ ```
64
+
65
+ ## Architecture
66
+
67
+ The library consists of several key components:
68
+
69
+ - **BlockDevice**: C++ extension providing low-level block operations
70
+ - **Storage Objects**:
71
+ - `Object`: Abstract base class for persistent objects
72
+ - `DiskObject`: Pickle-based disk storage
73
+ - `CompressedDiskObject`: Zstd-compressed disk storage
74
+ - `NetworkObject`: Real-time synchronized storage
75
+ - **FUSE Integration**: `BlockDeviceFUSE` class for filesystem mounting
76
+
77
+ ## Development
78
+
79
+ ### Setup
80
+ ```bash
81
+ git clone https://github.com/Omena0/blockdevice.git
82
+ cd blockdevice
83
+ python -m venv .venv
84
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
85
+ pip install -r requirements.txt
86
+ pip install -e .
87
+ ```
88
+
89
+ ### Testing
90
+ ```bash
91
+ # Run all tests
92
+ pytest
93
+
94
+ # Run with coverage
95
+ pytest --cov=blockdevice --cov-report=html
96
+
97
+ # Run specific test file
98
+ pytest tests/test_utils.py
99
+ ```
100
+
101
+ ### Building
102
+ ```bash
103
+ # Build the C++ extension
104
+ python setup.py build_ext --inplace
105
+
106
+ # Build distribution
107
+ python setup.py sdist bdist_wheel
108
+ ```
109
+
110
+ ## Examples
111
+
112
+ See the `examples/` directory for sample applications:
113
+
114
+ - `compressed.py`: Filesystem implementation with compression
115
+ - `network/`: Client-server examples
116
+
117
+ ## API Reference
118
+
119
+ ### BlockDevice
120
+ ```python
121
+ BlockDevice(path: str, dolphin: bool = False)
122
+ ```
123
+ Core block device operations.
124
+
125
+ ### Storage Classes
126
+
127
+ #### DiskObject
128
+ ```python
129
+ DiskObject(path: str, default_value=None)
130
+ ```
131
+ Persistent dictionary stored as pickle file.
132
+
133
+ #### CompressedDiskObject
134
+ ```python
135
+ CompressedDiskObject(path: str, default_value=None, compression_level=5)
136
+ ```
137
+ Compressed persistent storage using zstd.
138
+
139
+ #### NetworkObject
140
+ ```python
141
+ NetworkObject(host: str, port: int = None, default_value=None)
142
+ ```
143
+ Real-time synchronized storage across network.
144
+
145
+ ## Contributing
146
+
147
+ 1. Fork the repository
148
+ 2. Create a feature branch
149
+ 3. Add tests for new functionality
150
+ 4. Ensure all tests pass
151
+ 5. Submit a pull request
152
+
153
+ ## License
154
+
155
+ See LICENSE.md for license information.
156
+
@@ -0,0 +1,18 @@
1
+ """
2
+ BlockDevice - A simple C++ Python library for block device operations
3
+
4
+ This module provides a BlockDevice class with decorators for read, write, and list operations.
5
+ It also includes FUSE filesystem support for mounting the block device as a real filesystem.
6
+ """
7
+
8
+ from ._blockdevice import BlockDevice
9
+ from .fuse_ops import BlockDeviceFUSE
10
+ from .utils import Object, DiskObject, CompressedDiskObject, NetworkObject
11
+
12
+ debug = False
13
+
14
+ __version__ = "0.1.0"
15
+ __author__ = "Omena0"
16
+
17
+ __all__ = ["BlockDevice", "BlockDeviceFUSE", "Object", "DiskObject", "CompressedDiskObject", "NetworkObject"]
18
+