charmlibs-pathops 0.0.0__tar.gz → 1.0.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.
Files changed (23) hide show
  1. charmlibs_pathops-1.0.0/PKG-INFO +104 -0
  2. charmlibs_pathops-1.0.0/README.md +88 -0
  3. {charmlibs_pathops-0.0.0 → charmlibs_pathops-1.0.0}/pyproject.toml +1 -1
  4. charmlibs_pathops-1.0.0/src/charmlibs/pathops/_version.txt +1 -0
  5. charmlibs_pathops-1.0.0/src/charmlibs_pathops.egg-info/PKG-INFO +104 -0
  6. charmlibs_pathops-0.0.0/PKG-INFO +0 -27
  7. charmlibs_pathops-0.0.0/README.md +0 -11
  8. charmlibs_pathops-0.0.0/src/charmlibs/pathops/_version.txt +0 -1
  9. charmlibs_pathops-0.0.0/src/charmlibs_pathops.egg-info/PKG-INFO +0 -27
  10. {charmlibs_pathops-0.0.0 → charmlibs_pathops-1.0.0}/setup.cfg +0 -0
  11. {charmlibs_pathops-0.0.0 → charmlibs_pathops-1.0.0}/src/charmlibs/pathops/__init__.py +0 -0
  12. {charmlibs_pathops-0.0.0 → charmlibs_pathops-1.0.0}/src/charmlibs/pathops/_constants.py +0 -0
  13. {charmlibs_pathops-0.0.0 → charmlibs_pathops-1.0.0}/src/charmlibs/pathops/_container_path.py +0 -0
  14. {charmlibs_pathops-0.0.0 → charmlibs_pathops-1.0.0}/src/charmlibs/pathops/_errors.py +0 -0
  15. {charmlibs_pathops-0.0.0 → charmlibs_pathops-1.0.0}/src/charmlibs/pathops/_fileinfo.py +0 -0
  16. {charmlibs_pathops-0.0.0 → charmlibs_pathops-1.0.0}/src/charmlibs/pathops/_functions.py +0 -0
  17. {charmlibs_pathops-0.0.0 → charmlibs_pathops-1.0.0}/src/charmlibs/pathops/_local_path.py +0 -0
  18. {charmlibs_pathops-0.0.0 → charmlibs_pathops-1.0.0}/src/charmlibs/pathops/_types.py +0 -0
  19. {charmlibs_pathops-0.0.0 → charmlibs_pathops-1.0.0}/src/charmlibs/pathops/py.typed +0 -0
  20. {charmlibs_pathops-0.0.0 → charmlibs_pathops-1.0.0}/src/charmlibs_pathops.egg-info/SOURCES.txt +0 -0
  21. {charmlibs_pathops-0.0.0 → charmlibs_pathops-1.0.0}/src/charmlibs_pathops.egg-info/dependency_links.txt +0 -0
  22. {charmlibs_pathops-0.0.0 → charmlibs_pathops-1.0.0}/src/charmlibs_pathops.egg-info/requires.txt +0 -0
  23. {charmlibs_pathops-0.0.0 → charmlibs_pathops-1.0.0}/src/charmlibs_pathops.egg-info/top_level.txt +0 -0
@@ -0,0 +1,104 @@
1
+ Metadata-Version: 2.4
2
+ Name: charmlibs-pathops
3
+ Version: 1.0.0
4
+ Summary: A pathlib-like interface for Juju K8s charms to interact with files in their workload container.
5
+ Author: The Charm Tech team at Canonical Ltd.
6
+ Project-URL: Repository, https://github.com/canonical/charmtech-charmlibs
7
+ Project-URL: Issues, https://github.com/canonical/charmtech-charmlibs/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: POSIX :: Linux
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ Requires-Dist: ops~=2.19
16
+
17
+ # charmlibs-pathops
18
+
19
+ `pathops` provides a `pathlib`-like interface for local filesystem and workload container paths for Juju Charms.
20
+
21
+ To install, add `charmlibs-pathops` to your requirements. Then in your Python code, import as:
22
+
23
+ ```py
24
+ from charmlibs import pathops
25
+ ```
26
+
27
+ Check out the reference docs [here](https://canonical-charmlibs.readthedocs-hosted.com/reference/pathops/).
28
+
29
+ # Getting started
30
+
31
+ To get started, you can create an attribute `self.root` with the root directory for the local or remote paths you'll be working with.
32
+
33
+ ```py
34
+ import ops
35
+ from charmlibs import pathops
36
+
37
+ class KubernetesCharm(ops.CharmBase):
38
+ def __init__(self, framework: ops.Framework):
39
+ super().__init__(framework)
40
+ container = self.unit.get_container('container-name')
41
+ self.root = pathops.ContainerPath('/', container=container)
42
+
43
+ # or
44
+
45
+ class MachineCharm(ops.CharmBase):
46
+ def __init__(self, framework: ops.Framework):
47
+ super().__init__(framework)
48
+ self.root = pathops.LocalPath('/')
49
+ ```
50
+
51
+ You can then write code that could be used by either charm, using the `pathops.PathProtocol` type, which describes the operations supported by both local and container paths.
52
+
53
+ ```py
54
+ CONFIG_FILE_LOCATION = '/foo/bar'
55
+ CONFIG_FILE_CONTENTS = '...'
56
+
57
+ def write_config_file(root: pathops.PathProtocol) -> None:
58
+ path = root / CONFIG_FILE_LOCATION
59
+ path.write_text(CONFIG_FILE_CONTENTS)
60
+ ```
61
+
62
+ For a Kubernetes charm, this also allows you to use the same API to work with paths in the charm container or the workload container.
63
+
64
+ ```py
65
+ import ops
66
+ from charmlibs import pathops
67
+
68
+ class KubernetesCharm(ops.CharmBase):
69
+ def __init__(self, framework: ops.Framework):
70
+ super().__init__(framework)
71
+ self.charm_root = pathops.LocalPath('/')
72
+ container = self.unit.get_container('container-name')
73
+ self.workload_root = pathops.ContainerPath('/', container=container)
74
+ ...
75
+
76
+ def copy_config(self):
77
+ source = self.charm_root / 'foo/bar'
78
+ dest = self.workload_root / 'foo/bar/baz'
79
+ dest.parent.mkdir(parents=True, exist_ok=True)
80
+ dest.write_bytes(source.read_bytes())
81
+ ```
82
+
83
+ `pathops` also provides a helper function for ensuring that a file is present with specified content, which returns whether changes were made.
84
+
85
+ ```py
86
+ import ops
87
+ from charmlibs import pathops
88
+
89
+ class KubernetesCharm(ops.CharmBase):
90
+ ...
91
+
92
+ def copy_config(self):
93
+ changed = pathops.ensure_contents(
94
+ path=self.workload_root / 'foo/bar/baz',
95
+ source=(self.charm_root / 'foo/bar').read_bytes(),
96
+ )
97
+ if changed:
98
+ # make the workload reload its configuration
99
+ ...
100
+ ```
101
+
102
+ `pathops.PathProtocol` provides a subset of the `pathlib.Path` API. `PathProtocol` doesn't support relative paths, `open`, or manipulating hardlinks and symlinks.
103
+
104
+ `pathops` doesn't provide a separate `chmod` method, as Pebble doesn't currently support this. Instead, `mkdir`, `write_bytes`, and `write_text` have arguments `mode`, `user`, and `group` to set directory or file permissions and ownership. `ensure_contents` also has these arguments.
@@ -0,0 +1,88 @@
1
+ # charmlibs-pathops
2
+
3
+ `pathops` provides a `pathlib`-like interface for local filesystem and workload container paths for Juju Charms.
4
+
5
+ To install, add `charmlibs-pathops` to your requirements. Then in your Python code, import as:
6
+
7
+ ```py
8
+ from charmlibs import pathops
9
+ ```
10
+
11
+ Check out the reference docs [here](https://canonical-charmlibs.readthedocs-hosted.com/reference/pathops/).
12
+
13
+ # Getting started
14
+
15
+ To get started, you can create an attribute `self.root` with the root directory for the local or remote paths you'll be working with.
16
+
17
+ ```py
18
+ import ops
19
+ from charmlibs import pathops
20
+
21
+ class KubernetesCharm(ops.CharmBase):
22
+ def __init__(self, framework: ops.Framework):
23
+ super().__init__(framework)
24
+ container = self.unit.get_container('container-name')
25
+ self.root = pathops.ContainerPath('/', container=container)
26
+
27
+ # or
28
+
29
+ class MachineCharm(ops.CharmBase):
30
+ def __init__(self, framework: ops.Framework):
31
+ super().__init__(framework)
32
+ self.root = pathops.LocalPath('/')
33
+ ```
34
+
35
+ You can then write code that could be used by either charm, using the `pathops.PathProtocol` type, which describes the operations supported by both local and container paths.
36
+
37
+ ```py
38
+ CONFIG_FILE_LOCATION = '/foo/bar'
39
+ CONFIG_FILE_CONTENTS = '...'
40
+
41
+ def write_config_file(root: pathops.PathProtocol) -> None:
42
+ path = root / CONFIG_FILE_LOCATION
43
+ path.write_text(CONFIG_FILE_CONTENTS)
44
+ ```
45
+
46
+ For a Kubernetes charm, this also allows you to use the same API to work with paths in the charm container or the workload container.
47
+
48
+ ```py
49
+ import ops
50
+ from charmlibs import pathops
51
+
52
+ class KubernetesCharm(ops.CharmBase):
53
+ def __init__(self, framework: ops.Framework):
54
+ super().__init__(framework)
55
+ self.charm_root = pathops.LocalPath('/')
56
+ container = self.unit.get_container('container-name')
57
+ self.workload_root = pathops.ContainerPath('/', container=container)
58
+ ...
59
+
60
+ def copy_config(self):
61
+ source = self.charm_root / 'foo/bar'
62
+ dest = self.workload_root / 'foo/bar/baz'
63
+ dest.parent.mkdir(parents=True, exist_ok=True)
64
+ dest.write_bytes(source.read_bytes())
65
+ ```
66
+
67
+ `pathops` also provides a helper function for ensuring that a file is present with specified content, which returns whether changes were made.
68
+
69
+ ```py
70
+ import ops
71
+ from charmlibs import pathops
72
+
73
+ class KubernetesCharm(ops.CharmBase):
74
+ ...
75
+
76
+ def copy_config(self):
77
+ changed = pathops.ensure_contents(
78
+ path=self.workload_root / 'foo/bar/baz',
79
+ source=(self.charm_root / 'foo/bar').read_bytes(),
80
+ )
81
+ if changed:
82
+ # make the workload reload its configuration
83
+ ...
84
+ ```
85
+
86
+ `pathops.PathProtocol` provides a subset of the `pathlib.Path` API. `PathProtocol` doesn't support relative paths, `open`, or manipulating hardlinks and symlinks.
87
+
88
+ `pathops` doesn't provide a separate `chmod` method, as Pebble doesn't currently support this. Instead, `mkdir`, `write_bytes`, and `write_text` have arguments `mode`, `user`, and `group` to set directory or file permissions and ownership. `ensure_contents` also has these arguments.
@@ -11,7 +11,7 @@ classifiers = [
11
11
  "License :: OSI Approved :: Apache Software License",
12
12
  "Intended Audience :: Developers",
13
13
  "Operating System :: POSIX :: Linux",
14
- "Development Status :: 4 - Beta",
14
+ "Development Status :: 5 - Production/Stable",
15
15
  ]
16
16
  dynamic = ["version"]
17
17
  dependencies = [
@@ -0,0 +1,104 @@
1
+ Metadata-Version: 2.4
2
+ Name: charmlibs-pathops
3
+ Version: 1.0.0
4
+ Summary: A pathlib-like interface for Juju K8s charms to interact with files in their workload container.
5
+ Author: The Charm Tech team at Canonical Ltd.
6
+ Project-URL: Repository, https://github.com/canonical/charmtech-charmlibs
7
+ Project-URL: Issues, https://github.com/canonical/charmtech-charmlibs/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: POSIX :: Linux
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ Requires-Dist: ops~=2.19
16
+
17
+ # charmlibs-pathops
18
+
19
+ `pathops` provides a `pathlib`-like interface for local filesystem and workload container paths for Juju Charms.
20
+
21
+ To install, add `charmlibs-pathops` to your requirements. Then in your Python code, import as:
22
+
23
+ ```py
24
+ from charmlibs import pathops
25
+ ```
26
+
27
+ Check out the reference docs [here](https://canonical-charmlibs.readthedocs-hosted.com/reference/pathops/).
28
+
29
+ # Getting started
30
+
31
+ To get started, you can create an attribute `self.root` with the root directory for the local or remote paths you'll be working with.
32
+
33
+ ```py
34
+ import ops
35
+ from charmlibs import pathops
36
+
37
+ class KubernetesCharm(ops.CharmBase):
38
+ def __init__(self, framework: ops.Framework):
39
+ super().__init__(framework)
40
+ container = self.unit.get_container('container-name')
41
+ self.root = pathops.ContainerPath('/', container=container)
42
+
43
+ # or
44
+
45
+ class MachineCharm(ops.CharmBase):
46
+ def __init__(self, framework: ops.Framework):
47
+ super().__init__(framework)
48
+ self.root = pathops.LocalPath('/')
49
+ ```
50
+
51
+ You can then write code that could be used by either charm, using the `pathops.PathProtocol` type, which describes the operations supported by both local and container paths.
52
+
53
+ ```py
54
+ CONFIG_FILE_LOCATION = '/foo/bar'
55
+ CONFIG_FILE_CONTENTS = '...'
56
+
57
+ def write_config_file(root: pathops.PathProtocol) -> None:
58
+ path = root / CONFIG_FILE_LOCATION
59
+ path.write_text(CONFIG_FILE_CONTENTS)
60
+ ```
61
+
62
+ For a Kubernetes charm, this also allows you to use the same API to work with paths in the charm container or the workload container.
63
+
64
+ ```py
65
+ import ops
66
+ from charmlibs import pathops
67
+
68
+ class KubernetesCharm(ops.CharmBase):
69
+ def __init__(self, framework: ops.Framework):
70
+ super().__init__(framework)
71
+ self.charm_root = pathops.LocalPath('/')
72
+ container = self.unit.get_container('container-name')
73
+ self.workload_root = pathops.ContainerPath('/', container=container)
74
+ ...
75
+
76
+ def copy_config(self):
77
+ source = self.charm_root / 'foo/bar'
78
+ dest = self.workload_root / 'foo/bar/baz'
79
+ dest.parent.mkdir(parents=True, exist_ok=True)
80
+ dest.write_bytes(source.read_bytes())
81
+ ```
82
+
83
+ `pathops` also provides a helper function for ensuring that a file is present with specified content, which returns whether changes were made.
84
+
85
+ ```py
86
+ import ops
87
+ from charmlibs import pathops
88
+
89
+ class KubernetesCharm(ops.CharmBase):
90
+ ...
91
+
92
+ def copy_config(self):
93
+ changed = pathops.ensure_contents(
94
+ path=self.workload_root / 'foo/bar/baz',
95
+ source=(self.charm_root / 'foo/bar').read_bytes(),
96
+ )
97
+ if changed:
98
+ # make the workload reload its configuration
99
+ ...
100
+ ```
101
+
102
+ `pathops.PathProtocol` provides a subset of the `pathlib.Path` API. `PathProtocol` doesn't support relative paths, `open`, or manipulating hardlinks and symlinks.
103
+
104
+ `pathops` doesn't provide a separate `chmod` method, as Pebble doesn't currently support this. Instead, `mkdir`, `write_bytes`, and `write_text` have arguments `mode`, `user`, and `group` to set directory or file permissions and ownership. `ensure_contents` also has these arguments.
@@ -1,27 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: charmlibs-pathops
3
- Version: 0.0.0
4
- Summary: A pathlib-like interface for Juju K8s charms to interact with files in their workload container.
5
- Author: The Charm Tech team at Canonical Ltd.
6
- Project-URL: Repository, https://github.com/canonical/charmtech-charmlibs
7
- Project-URL: Issues, https://github.com/canonical/charmtech-charmlibs/issues
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: Apache Software License
10
- Classifier: Intended Audience :: Developers
11
- Classifier: Operating System :: POSIX :: Linux
12
- Classifier: Development Status :: 4 - Beta
13
- Requires-Python: >=3.8
14
- Description-Content-Type: text/markdown
15
- Requires-Dist: ops~=2.19
16
-
17
- # charmlibs-pathops
18
-
19
- `pathops` provides a `pathlib`-like interface for local filesystem and workload container paths for Juju Charms.
20
-
21
- To install, add `charmlibs-pathops` to your requirements. Then in your Python code, import as:
22
-
23
- ```py
24
- from charmlibs import pathops
25
- ```
26
-
27
- Check out the reference docs [here](https://canonical-charmlibs.readthedocs-hosted.com/reference/pathops/).
@@ -1,11 +0,0 @@
1
- # charmlibs-pathops
2
-
3
- `pathops` provides a `pathlib`-like interface for local filesystem and workload container paths for Juju Charms.
4
-
5
- To install, add `charmlibs-pathops` to your requirements. Then in your Python code, import as:
6
-
7
- ```py
8
- from charmlibs import pathops
9
- ```
10
-
11
- Check out the reference docs [here](https://canonical-charmlibs.readthedocs-hosted.com/reference/pathops/).
@@ -1,27 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: charmlibs-pathops
3
- Version: 0.0.0
4
- Summary: A pathlib-like interface for Juju K8s charms to interact with files in their workload container.
5
- Author: The Charm Tech team at Canonical Ltd.
6
- Project-URL: Repository, https://github.com/canonical/charmtech-charmlibs
7
- Project-URL: Issues, https://github.com/canonical/charmtech-charmlibs/issues
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: Apache Software License
10
- Classifier: Intended Audience :: Developers
11
- Classifier: Operating System :: POSIX :: Linux
12
- Classifier: Development Status :: 4 - Beta
13
- Requires-Python: >=3.8
14
- Description-Content-Type: text/markdown
15
- Requires-Dist: ops~=2.19
16
-
17
- # charmlibs-pathops
18
-
19
- `pathops` provides a `pathlib`-like interface for local filesystem and workload container paths for Juju Charms.
20
-
21
- To install, add `charmlibs-pathops` to your requirements. Then in your Python code, import as:
22
-
23
- ```py
24
- from charmlibs import pathops
25
- ```
26
-
27
- Check out the reference docs [here](https://canonical-charmlibs.readthedocs-hosted.com/reference/pathops/).