charmlibs-pathops 1.3.0__tar.gz → 1.4.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.
- {charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/PKG-INFO +3 -3
- {charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/pyproject.toml +2 -2
- {charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/src/charmlibs/pathops/_container_path.py +40 -3
- {charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/src/charmlibs/pathops/_types.py +18 -8
- charmlibs_pathops-1.4.0/src/charmlibs/pathops/_version.txt +1 -0
- {charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/src/charmlibs_pathops.egg-info/PKG-INFO +3 -3
- charmlibs_pathops-1.3.0/src/charmlibs/pathops/_version.txt +0 -1
- {charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/README.md +0 -0
- {charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/setup.cfg +0 -0
- {charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/src/charmlibs/pathops/__init__.py +0 -0
- {charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/src/charmlibs/pathops/_constants.py +0 -0
- {charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/src/charmlibs/pathops/_errors.py +0 -0
- {charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/src/charmlibs/pathops/_fileinfo.py +0 -0
- {charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/src/charmlibs/pathops/_functions.py +0 -0
- {charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/src/charmlibs/pathops/_local_path.py +0 -0
- {charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/src/charmlibs/pathops/py.typed +0 -0
- {charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/src/charmlibs_pathops.egg-info/SOURCES.txt +0 -0
- {charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/src/charmlibs_pathops.egg-info/dependency_links.txt +0 -0
- {charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/src/charmlibs_pathops.egg-info/requires.txt +0 -0
- {charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/src/charmlibs_pathops.egg-info/top_level.txt +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: charmlibs-pathops
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: A pathlib-like interface for Juju K8s charms to interact with files in their workload container.
|
|
5
5
|
Author: The Charm Tech team at Canonical Ltd.
|
|
6
6
|
License-Expression: Apache-2.0
|
|
7
|
-
Project-URL: Documentation, https://
|
|
8
|
-
Project-URL: Repository, https://github.com/canonical/charmlibs
|
|
7
|
+
Project-URL: Documentation, https://canonical.com/juju/docs/charmlibs/reference/charmlibs/pathops/
|
|
8
|
+
Project-URL: Repository, https://github.com/canonical/charmlibs/tree/main/pathops
|
|
9
9
|
Project-URL: Issues, https://github.com/canonical/charmlibs/issues
|
|
10
10
|
Project-URL: Changelog, https://github.com/canonical/charmlibs/blob/main/pathops/CHANGELOG.md
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -29,8 +29,8 @@ integration = [
|
|
|
29
29
|
]
|
|
30
30
|
|
|
31
31
|
[project.urls]
|
|
32
|
-
"Documentation" = "https://
|
|
33
|
-
"Repository" = "https://github.com/canonical/charmlibs"
|
|
32
|
+
"Documentation" = "https://canonical.com/juju/docs/charmlibs/reference/charmlibs/pathops/"
|
|
33
|
+
"Repository" = "https://github.com/canonical/charmlibs/tree/main/pathops"
|
|
34
34
|
"Issues" = "https://github.com/canonical/charmlibs/issues"
|
|
35
35
|
"Changelog" = "https://github.com/canonical/charmlibs/blob/main/pathops/CHANGELOG.md"
|
|
36
36
|
|
{charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/src/charmlibs/pathops/_container_path.py
RENAMED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
|
|
19
19
|
import errno
|
|
20
|
+
import os
|
|
20
21
|
import pathlib
|
|
21
22
|
import re
|
|
22
23
|
import typing
|
|
@@ -27,7 +28,6 @@ from ops import pebble
|
|
|
27
28
|
from . import _constants, _errors, _fileinfo
|
|
28
29
|
|
|
29
30
|
if typing.TYPE_CHECKING:
|
|
30
|
-
import os
|
|
31
31
|
from collections.abc import Generator
|
|
32
32
|
from typing import Literal, TypeGuard
|
|
33
33
|
|
|
@@ -151,14 +151,37 @@ class ContainerPath:
|
|
|
151
151
|
"""
|
|
152
152
|
return self._path.is_absolute()
|
|
153
153
|
|
|
154
|
-
def
|
|
154
|
+
def is_relative_to(self, other: str | os.PathLike[str], /) -> bool:
|
|
155
|
+
"""Return whether this path is relative to the ``other`` path.
|
|
156
|
+
|
|
157
|
+
Only the path is matched against, the container is not considered.
|
|
158
|
+
"""
|
|
159
|
+
return self._path.is_relative_to(other)
|
|
160
|
+
|
|
161
|
+
def match(self, path_pattern: str | os.PathLike[str]) -> bool:
|
|
155
162
|
"""Return whether this path matches the given pattern.
|
|
156
163
|
|
|
157
164
|
If the pattern is relative, matching is done from the right; otherwise, the entire path is
|
|
158
165
|
matched. The recursive wildcard ``'**'`` is **not** supported by this method. Matching is
|
|
159
166
|
always case-sensitive. Only the path is matched against, the container is not considered.
|
|
167
|
+
|
|
168
|
+
Args:
|
|
169
|
+
path_pattern: A :class:`str` or :class:`os.PathLike` object.
|
|
170
|
+
|
|
171
|
+
.. warning::
|
|
172
|
+
:class:`ContainerPath` is not :class:`os.PathLike`. A :class:`ContainerPath` instance
|
|
173
|
+
is not a valid value for ``path_pattern``, and will result in a :class:`TypeError`.
|
|
160
174
|
"""
|
|
161
|
-
|
|
175
|
+
# Python 3.14's pathlib.PurePath.match accepts any object with `with_segments`, which
|
|
176
|
+
# would silently allow a ContainerPath through. Reject it explicitly to match the
|
|
177
|
+
# behaviour of joinpath / __truediv__ and stay consistent across Python versions.
|
|
178
|
+
if isinstance(path_pattern, ContainerPath):
|
|
179
|
+
raise TypeError(
|
|
180
|
+
f'ContainerPath is not a valid pattern for ContainerPath.match: {path_pattern!r}'
|
|
181
|
+
)
|
|
182
|
+
# Python <3.12 requires path_pattern to be a string. Python 3.12+ accepts any path-like.
|
|
183
|
+
# When the library requires Python 3.12+, we can drop the os.fspath call and this comment.
|
|
184
|
+
return self._path.match(os.fspath(path_pattern))
|
|
162
185
|
|
|
163
186
|
def with_name(self, name: str) -> Self:
|
|
164
187
|
"""Return a new ContainerPath, with the same container, but with the path name replaced.
|
|
@@ -174,6 +197,20 @@ class ContainerPath:
|
|
|
174
197
|
"""
|
|
175
198
|
return self.with_segments(self._path.with_name(name))
|
|
176
199
|
|
|
200
|
+
def with_stem(self, stem: str) -> Self:
|
|
201
|
+
"""Return a new ContainerPath, with the same container, but with the path stem replaced.
|
|
202
|
+
|
|
203
|
+
The stem is the path name minus its last suffix.
|
|
204
|
+
|
|
205
|
+
::
|
|
206
|
+
|
|
207
|
+
container = self.unit.get_container('c')
|
|
208
|
+
path = ContainerPath('/', 'foo', 'bar.txt', container=container)
|
|
209
|
+
repr(path.with_stem('baz'))
|
|
210
|
+
# ContainerPath('/foo/baz.txt', container=<ops.Container 'c'>)"
|
|
211
|
+
"""
|
|
212
|
+
return self.with_segments(self._path.with_stem(stem))
|
|
213
|
+
|
|
177
214
|
def with_suffix(self, suffix: str) -> Self:
|
|
178
215
|
"""Return a new ContainerPath with the same container and the suffix changed.
|
|
179
216
|
|
|
@@ -116,6 +116,11 @@ class PathProtocol(typing.Protocol):
|
|
|
116
116
|
...
|
|
117
117
|
|
|
118
118
|
# NOTE: Not supported -- (Python 3.12) ``case_sensitive`` keyword argument
|
|
119
|
+
# NOTE: Not supported -- (Python 3.12) path-like ``path_pattern``
|
|
120
|
+
# ContainerPath.match accepts str | os.PathLike[str], but the protocol stays narrow.
|
|
121
|
+
# Widening it here would oblige us to shim LocalPath.match too, and we can't write that
|
|
122
|
+
# override without also handling the case_sensitive keyword, which pathlib.Path.match
|
|
123
|
+
# doesn't have before 3.12.
|
|
119
124
|
def match(self, path_pattern: str) -> bool:
|
|
120
125
|
"""Return whether this path matches the given pattern.
|
|
121
126
|
|
|
@@ -132,6 +137,13 @@ class PathProtocol(typing.Protocol):
|
|
|
132
137
|
"""
|
|
133
138
|
...
|
|
134
139
|
|
|
140
|
+
def with_stem(self, stem: str) -> Self:
|
|
141
|
+
"""Return a new instance of the same type, with the path stem replaced.
|
|
142
|
+
|
|
143
|
+
The stem is the path name minus its last suffix.
|
|
144
|
+
"""
|
|
145
|
+
...
|
|
146
|
+
|
|
135
147
|
def with_suffix(self, suffix: str) -> Self:
|
|
136
148
|
"""Return a new instance of the same type, with the path suffix replaced.
|
|
137
149
|
|
|
@@ -594,14 +606,12 @@ class PathProtocol(typing.Protocol):
|
|
|
594
606
|
# ContainerPath to ease compatibility with pathlib.Path on 3.12+ if we someday
|
|
595
607
|
# support relative paths
|
|
596
608
|
|
|
597
|
-
# def is_relative_to(self, other: _StrPath) ->
|
|
598
|
-
#
|
|
599
|
-
#
|
|
600
|
-
|
|
601
|
-
#
|
|
602
|
-
#
|
|
603
|
-
# to ease compatibility with pathlib.Path on 3.9+
|
|
604
|
-
# could be added to the protocol if we're happy for LocalPath to double as backports
|
|
609
|
+
# def is_relative_to(self, other: _StrPath, /) -> bool: ... # 3.9+
|
|
610
|
+
# provided on ContainerPath to ease compatibility with pathlib.Path on 3.9+,
|
|
611
|
+
# but deliberately not part of the protocol: pathlib's signature is `*other` until
|
|
612
|
+
# 3.12, so the protocol would have to declare `other` as positional-only for LocalPath
|
|
613
|
+
# to satisfy it, and the 3.12 `walk_up` keyword can't be offered until the minimum
|
|
614
|
+
# supported Python is 3.12
|
|
605
615
|
|
|
606
616
|
# def with_segments(self, *pathsegments: _StrPath) -> Self: ...
|
|
607
617
|
# required for 3.12+ subclassing machinery
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.4.0
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: charmlibs-pathops
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: A pathlib-like interface for Juju K8s charms to interact with files in their workload container.
|
|
5
5
|
Author: The Charm Tech team at Canonical Ltd.
|
|
6
6
|
License-Expression: Apache-2.0
|
|
7
|
-
Project-URL: Documentation, https://
|
|
8
|
-
Project-URL: Repository, https://github.com/canonical/charmlibs
|
|
7
|
+
Project-URL: Documentation, https://canonical.com/juju/docs/charmlibs/reference/charmlibs/pathops/
|
|
8
|
+
Project-URL: Repository, https://github.com/canonical/charmlibs/tree/main/pathops
|
|
9
9
|
Project-URL: Issues, https://github.com/canonical/charmlibs/issues
|
|
10
10
|
Project-URL: Changelog, https://github.com/canonical/charmlibs/blob/main/pathops/CHANGELOG.md
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1.3.0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/src/charmlibs_pathops.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/src/charmlibs_pathops.egg-info/requires.txt
RENAMED
|
File without changes
|
{charmlibs_pathops-1.3.0 → charmlibs_pathops-1.4.0}/src/charmlibs_pathops.egg-info/top_level.txt
RENAMED
|
File without changes
|