fsresource-tree 0.1.3__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.
- fsresource_tree/__init__.py +18 -0
- fsresource_tree/directory.py +27 -0
- fsresource_tree/file.py +40 -0
- fsresource_tree/filesystem.py +61 -0
- fsresource_tree-0.1.3.dist-info/METADATA +26 -0
- fsresource_tree-0.1.3.dist-info/RECORD +9 -0
- fsresource_tree-0.1.3.dist-info/WHEEL +5 -0
- fsresource_tree-0.1.3.dist-info/top_level.txt +2 -0
- tests/test_basic.py +20 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from resourcetree import Container
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Directory(Container):
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def __init__(
|
|
9
|
+
self,
|
|
10
|
+
name,
|
|
11
|
+
parent=None,
|
|
12
|
+
uid=None,
|
|
13
|
+
|
|
14
|
+
permissions="755",
|
|
15
|
+
owner=None
|
|
16
|
+
):
|
|
17
|
+
|
|
18
|
+
super().__init__(
|
|
19
|
+
name,
|
|
20
|
+
parent,
|
|
21
|
+
uid
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
self.permissions = permissions
|
|
26
|
+
|
|
27
|
+
self.owner = owner
|
fsresource_tree/file.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from resourcetree import Asset
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class File(Asset):
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def __init__(
|
|
9
|
+
self,
|
|
10
|
+
name,
|
|
11
|
+
parent=None,
|
|
12
|
+
uid=None,
|
|
13
|
+
|
|
14
|
+
content=None,
|
|
15
|
+
|
|
16
|
+
encoding="utf-8"
|
|
17
|
+
):
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
super().__init__(
|
|
21
|
+
name,
|
|
22
|
+
parent,
|
|
23
|
+
uid,
|
|
24
|
+
content
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
self.encoding = encoding
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
self.size = (
|
|
32
|
+
|
|
33
|
+
len(
|
|
34
|
+
content.encode(encoding)
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
if content
|
|
38
|
+
|
|
39
|
+
else 0
|
|
40
|
+
)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from .directory import Directory
|
|
4
|
+
from .file import File
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def from_path(path):
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
path = Path(path)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
root = Directory(
|
|
15
|
+
path.name
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
_load(
|
|
20
|
+
path,
|
|
21
|
+
root
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
return root
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _load(
|
|
31
|
+
path,
|
|
32
|
+
node
|
|
33
|
+
):
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
for item in path.iterdir():
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
if item.is_dir():
|
|
40
|
+
|
|
41
|
+
directory = Directory(
|
|
42
|
+
item.name,
|
|
43
|
+
node
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
_load(
|
|
48
|
+
item,
|
|
49
|
+
directory
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
else:
|
|
54
|
+
|
|
55
|
+
File(
|
|
56
|
+
item.name,
|
|
57
|
+
node,
|
|
58
|
+
content=item.read_text(
|
|
59
|
+
errors="ignore"
|
|
60
|
+
)
|
|
61
|
+
)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fsresource-tree
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: Filesystem resource tree implementation
|
|
5
|
+
Requires-Python: >=3.11
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: resourcetree>=0.1.2
|
|
8
|
+
|
|
9
|
+
# fsresources-tree
|
|
10
|
+
|
|
11
|
+
Filesystem implementation using resourcetree.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
Example:
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
import fsresources_tree as fs
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
root = fs.Directory("/")
|
|
21
|
+
|
|
22
|
+
file = fs.File(
|
|
23
|
+
"test.txt",
|
|
24
|
+
root,
|
|
25
|
+
content="hello"
|
|
26
|
+
)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
fsresource_tree/__init__.py,sha256=MwwMvG3rc4dsv_0UWNyEPQdrNyUkYrqIkO1moCnRWt4,200
|
|
2
|
+
fsresource_tree/directory.py,sha256=tfl3qkBTEoNc0ATruXzji91Rw9ZtquspMhhmit2m8fk,366
|
|
3
|
+
fsresource_tree/file.py,sha256=89eV3ODYn8SxHAwambyuUjsqihJeQDqLRgF-kATkkhY,494
|
|
4
|
+
fsresource_tree/filesystem.py,sha256=Fe2S2YFyGg_zhfzRo8k2zoaNNFlwOtPootmXwbroDvI,713
|
|
5
|
+
tests/test_basic.py,sha256=CpCrvI7NtaXJhHoOhPT_d-ymsb41oM3dUlwWwoJRRF4,232
|
|
6
|
+
fsresource_tree-0.1.3.dist-info/METADATA,sha256=p6lIV21kRdrxES5R2PwLR3kBrwggokZCffrpG29bNUc,418
|
|
7
|
+
fsresource_tree-0.1.3.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
8
|
+
fsresource_tree-0.1.3.dist-info/top_level.txt,sha256=RVS_qjfHkt7Qol-OeWWGmDwWFwTbojOQYNjN6RJdLRk,22
|
|
9
|
+
fsresource_tree-0.1.3.dist-info/RECORD,,
|
tests/test_basic.py
ADDED