fsresource-tree 0.1.3__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,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,18 @@
1
+ # fsresources-tree
2
+
3
+ Filesystem implementation using resourcetree.
4
+
5
+
6
+ Example:
7
+
8
+ ```python
9
+ import fsresources_tree as fs
10
+
11
+
12
+ root = fs.Directory("/")
13
+
14
+ file = fs.File(
15
+ "test.txt",
16
+ root,
17
+ content="hello"
18
+ )
@@ -0,0 +1,18 @@
1
+ """
2
+ fsresources-tree
3
+
4
+ Filesystem implementation based on resourcetree
5
+ """#
6
+
7
+
8
+ from .directory import Directory
9
+ from .file import File
10
+
11
+
12
+ __version__ = "0.1.0"
13
+
14
+
15
+ __all__ = [
16
+ "Directory",
17
+ "File"
18
+ ]
@@ -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
@@ -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,12 @@
1
+ README.md
2
+ pyproject.toml
3
+ fsresource_tree/__init__.py
4
+ fsresource_tree/directory.py
5
+ fsresource_tree/file.py
6
+ fsresource_tree/filesystem.py
7
+ fsresource_tree.egg-info/PKG-INFO
8
+ fsresource_tree.egg-info/SOURCES.txt
9
+ fsresource_tree.egg-info/dependency_links.txt
10
+ fsresource_tree.egg-info/requires.txt
11
+ fsresource_tree.egg-info/top_level.txt
12
+ tests/test_basic.py
@@ -0,0 +1 @@
1
+ resourcetree>=0.1.2
@@ -0,0 +1,4 @@
1
+ dist
2
+ docs
3
+ fsresource_tree
4
+ tests
@@ -0,0 +1,31 @@
1
+ [project]
2
+
3
+ name = "fsresource-tree"
4
+ version = "0.1.3"
5
+
6
+ description = "Filesystem resource tree implementation"
7
+
8
+ readme = "README.md"
9
+
10
+ requires-python = ">=3.11"
11
+
12
+
13
+ dependencies = [
14
+ "resourcetree>=0.1.2"
15
+ ]
16
+
17
+
18
+ [tool.setuptools.packages.find]
19
+
20
+ where = ["."]
21
+
22
+
23
+
24
+ [build-system]
25
+
26
+ requires = [
27
+ "setuptools",
28
+ "wheel"
29
+ ]
30
+
31
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,20 @@
1
+ import fsresource_tree as fs
2
+
3
+
4
+
5
+ def test_filesystem():
6
+
7
+
8
+ root = fs.Directory("/")
9
+
10
+
11
+ file = fs.File(
12
+ "hello.txt",
13
+ root,
14
+ content="hello"
15
+ )
16
+
17
+
18
+ assert file.parent == root
19
+
20
+ assert file.size == 5