blockdevice 1.14.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 @@
1
+ recursive-include include *
@@ -0,0 +1,32 @@
1
+ Metadata-Version: 2.4
2
+ Name: blockdevice
3
+ Version: 1.14.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: omena0mc@gmail.com
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Topic :: System :: Filesystems
13
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
14
+ Requires-Python: >=3.13
15
+ Description-Content-Type: text/markdown
16
+ License-File: COPYING.md
17
+ Requires-Dist: pybind11>=2.6.0
18
+ Dynamic: author
19
+ Dynamic: author-email
20
+ Dynamic: classifier
21
+ Dynamic: description
22
+ Dynamic: description-content-type
23
+ Dynamic: home-page
24
+ Dynamic: license-file
25
+ Dynamic: requires-dist
26
+ Dynamic: requires-python
27
+ Dynamic: summary
28
+
29
+
30
+ # Blockdevice
31
+
32
+ Simple library for creating Block Devices.
@@ -0,0 +1,4 @@
1
+
2
+ # Blockdevice
3
+
4
+ Simple library for creating Block Devices.
@@ -0,0 +1,26 @@
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 typing import TYPE_CHECKING
9
+
10
+ # Debug flag - set to True to enable debug output
11
+ debug = False
12
+
13
+ if TYPE_CHECKING:
14
+ from ._blockdevice import BlockDevice as _BlockDevice
15
+ BlockDevice = _BlockDevice
16
+ else:
17
+ from ._blockdevice import BlockDevice
18
+
19
+ from .fuse_ops import BlockDeviceFUSE
20
+ from .utils import *
21
+
22
+ __version__ = "0.1.0"
23
+ __author__ = "Omena0"
24
+
25
+ __all__ = ["BlockDevice", "BlockDeviceFUSE", "Object", "DiskObject", "CompressedDiskObject", "NetworkObject"]
26
+
@@ -0,0 +1,192 @@
1
+ """
2
+ Type stubs for BlockDevice C++ extension module
3
+ """
4
+
5
+ from typing import Any, Callable, List, Optional, TypeVar, overload
6
+ from typing_extensions import ParamSpec
7
+
8
+ P = ParamSpec('P')
9
+ T = TypeVar('T')
10
+
11
+ # Type aliases for callback functions
12
+ ReadCallback = Callable[[str], bytes | str]
13
+ WriteCallback = Callable[[str, bytes], bool]
14
+ ListCallback = Callable[[str], List[str]]
15
+ DeleteCallback = Callable[[str], bool]
16
+
17
+ class BlockDevice:
18
+ """
19
+ BlockDevice class for creating virtual block devices with custom read/write/list operations.
20
+
21
+ This class provides decorators (@bd.read, @bd.write, @bd.list) to register callback functions
22
+ that handle filesystem operations when the device is mounted as a FUSE filesystem.
23
+ """
24
+
25
+ def __init__(
26
+ self,
27
+ mountpoint: str,
28
+ dolphin: bool = False,
29
+ name: str = ""
30
+ ) -> None:
31
+ """
32
+ Initialize BlockDevice with mountpoint and optional parameters.
33
+
34
+ Args:
35
+ mountpoint: Path where the filesystem will be mounted
36
+ dolphin: Whether to enable Dolphin file manager integration
37
+ name: Display name for the device (defaults to mountpoint if empty)
38
+ """
39
+ ...
40
+
41
+ @property
42
+ def mountpoint(self) -> str:
43
+ """Get the mountpoint path."""
44
+ ...
45
+
46
+ @property
47
+ def name(self) -> str:
48
+ """Get the display name."""
49
+ ...
50
+
51
+ @property
52
+ def dolphin_integration(self) -> bool:
53
+ """Get whether Dolphin integration is enabled."""
54
+ ...
55
+
56
+ # Decorator methods
57
+ def read(self, func: Callable[[str], T]) -> Callable[[str], T]:
58
+ """
59
+ Decorator to register a read callback function.
60
+
61
+ The decorated function should take a file path (str) and return the file content
62
+ as bytes or string.
63
+
64
+ Example:
65
+ @bd.read
66
+ def read_file(path: str) -> bytes:
67
+ return b"file content"
68
+
69
+ Args:
70
+ func: Function that takes a path and returns file content
71
+
72
+ Returns:
73
+ The same function (for decorator chaining)
74
+ """
75
+ ...
76
+
77
+ def write(self, func: Callable[[str, bytes], bool]) -> Callable[[str, bytes], bool]:
78
+ """
79
+ Decorator to register a write callback function.
80
+
81
+ The decorated function should take a file path (str) and data (bytes),
82
+ then return True if the write was successful, False otherwise.
83
+
84
+ Example:
85
+ @bd.write
86
+ def write_file(path: str, data: bytes) -> bool:
87
+ # Save data to path
88
+ return True
89
+
90
+ Args:
91
+ func: Function that takes a path and data, returns success boolean
92
+
93
+ Returns:
94
+ The same function (for decorator chaining)
95
+ """
96
+ ...
97
+
98
+ def list(self, func: Callable[[str], List[str]]) -> Callable[[str], List[str]]:
99
+ """
100
+ Decorator to register a directory listing callback function.
101
+
102
+ The decorated function should take a directory path (str) and return
103
+ a list of filenames/subdirectories in that directory.
104
+
105
+ Example:
106
+ @bd.list
107
+ def list_directory(path: str) -> List[str]:
108
+ return ["file1.txt", "subdir/"]
109
+
110
+ Args:
111
+ func: Function that takes a path and returns list of contents
112
+
113
+ Returns:
114
+ The same function (for decorator chaining)
115
+ """
116
+ ...
117
+
118
+ def delete(self, func: Callable[[str], bool]) -> Callable[[str], bool]:
119
+ """
120
+ Decorator to register a delete callback function.
121
+
122
+ The decorated function should take a file or directory path (str)
123
+ and return True if the deletion was successful, False otherwise.
124
+
125
+ Example:
126
+ @bd.delete
127
+ def delete_file(path: str) -> bool:
128
+ # Delete file or directory at path
129
+ return True
130
+
131
+ Args:
132
+ func: Function that takes a path and returns success boolean
133
+
134
+ Returns:
135
+ The same function (for decorator chaining)
136
+ """
137
+ ...
138
+
139
+ # Direct callback setters (alternative to decorators)
140
+ def set_read_callback(self, func: ReadCallback) -> None:
141
+ """Set the read callback function directly."""
142
+ ...
143
+
144
+ def set_write_callback(self, func: WriteCallback) -> None:
145
+ """Set the write callback function directly."""
146
+ ...
147
+
148
+ def set_list_callback(self, func: ListCallback) -> None:
149
+ """Set the list callback function directly."""
150
+ ...
151
+
152
+ def set_delete_callback(self, func: DeleteCallback) -> None:
153
+ """Set the delete callback function directly."""
154
+ ...
155
+
156
+ # Callback invocation methods (used internally by FUSE operations)
157
+ def call_read(self, path: str) -> Any:
158
+ """Call the registered read callback with the given path."""
159
+ ...
160
+
161
+ def call_write(self, path: str, data: Any) -> bool:
162
+ """Call the registered write callback with the given path and data."""
163
+ ...
164
+
165
+ def call_list(self, path: str) -> List[str]:
166
+ """Call the registered list callback with the given path."""
167
+ ...
168
+
169
+ def call_delete(self, path: str) -> bool:
170
+ """Call the registered delete callback with the given path."""
171
+ ...
172
+
173
+ # FUSE filesystem methods
174
+ def mount(self) -> None:
175
+ """Mount the filesystem at the specified mountpoint."""
176
+ ...
177
+
178
+ def unmount(self) -> None:
179
+ """Unmount the filesystem."""
180
+ ...
181
+
182
+ def start(self, foreground: bool = True) -> None:
183
+ """Start the FUSE filesystem."""
184
+ ...
185
+
186
+ def stop(self) -> None:
187
+ """Stop the FUSE filesystem."""
188
+ ...
189
+
190
+ def is_mounted(self) -> bool:
191
+ """Check if the filesystem is currently mounted."""
192
+ ...