pathlib-next 0.1.6__tar.gz → 0.1.8__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.
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/PKG-INFO +1 -1
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/pyproject.toml +1 -1
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/src/pathlib_next/mempath.py +0 -3
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/src/pathlib_next/path.py +15 -8
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/src/pathlib_next/utils/glob.py +3 -8
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/.gitignore +0 -0
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/LICENSE +0 -0
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/README.md +0 -0
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/src/example.py +0 -0
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/src/pathlib_next/__init__.py +0 -0
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/src/pathlib_next/fspath.py +0 -0
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/src/pathlib_next/uri/__init__.py +0 -0
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/src/pathlib_next/uri/query.py +0 -0
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/src/pathlib_next/uri/schemes/__init__.py +0 -0
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/src/pathlib_next/uri/schemes/file.py +0 -0
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/src/pathlib_next/uri/schemes/http.py +0 -0
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/src/pathlib_next/uri/schemes/sftp.py +0 -0
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/src/pathlib_next/uri/source.py +0 -0
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/src/pathlib_next/utils/__init__.py +0 -0
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/src/pathlib_next/utils/stat.py +0 -0
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/src/pathlib_next/utils/sync.py +0 -0
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/tests/test_local.py +0 -0
- {pathlib_next-0.1.6 → pathlib_next-0.1.8}/tests/test_uri.py +0 -0
|
@@ -92,9 +92,6 @@ class MemPath(Path):
|
|
|
92
92
|
def as_uri(self):
|
|
93
93
|
return f"mempath:{_urlquote(self.as_posix())}"
|
|
94
94
|
|
|
95
|
-
def as_posix(self):
|
|
96
|
-
return "/".join(self.segments)
|
|
97
|
-
|
|
98
95
|
def _parent_container(self) -> tuple[dict[str, bytearray], str]:
|
|
99
96
|
parent = self.backend
|
|
100
97
|
*ancestors, name = self.normalized
|
|
@@ -5,14 +5,14 @@ paths with operations that have semantics appropriate for different
|
|
|
5
5
|
operating systems.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
+
import abc as _abc
|
|
9
|
+
import io as _io
|
|
8
10
|
import os as _os
|
|
9
11
|
import re as _re
|
|
12
|
+
import shutil as _shutil
|
|
10
13
|
import stat as _stat
|
|
11
|
-
from pathlib import _ignore_error
|
|
12
14
|
import typing as _ty
|
|
13
|
-
|
|
14
|
-
import io as _io
|
|
15
|
-
import shutil as _shutil
|
|
15
|
+
from pathlib import _ignore_error
|
|
16
16
|
|
|
17
17
|
from . import utils as _utils
|
|
18
18
|
from .utils import glob as _glob
|
|
@@ -36,6 +36,7 @@ _os.PathLike.register(FsPathLike)
|
|
|
36
36
|
|
|
37
37
|
_FsPathLike = str | FsPathLike
|
|
38
38
|
|
|
39
|
+
|
|
39
40
|
class _PathnameParents(_ty.Sequence[PN]):
|
|
40
41
|
"""This object provides sequence-like access to the logical ancestors
|
|
41
42
|
of a path. Don't try to construct it yourself."""
|
|
@@ -69,6 +70,7 @@ class _PathnameParents(_ty.Sequence[PN]):
|
|
|
69
70
|
def __repr__(self):
|
|
70
71
|
return "<{}.parents>".format(type(self._path).__name__)
|
|
71
72
|
|
|
73
|
+
|
|
72
74
|
class Pathname(FsPathLike, _ty.Generic[_P]):
|
|
73
75
|
"""Base class for manipulating paths without I/O."""
|
|
74
76
|
|
|
@@ -184,10 +186,9 @@ class Pathname(FsPathLike, _ty.Generic[_P]):
|
|
|
184
186
|
"""The logical parent of the path."""
|
|
185
187
|
|
|
186
188
|
@property
|
|
187
|
-
def parents(self)->_ty.Sequence[_ty.Self]:
|
|
189
|
+
def parents(self) -> _ty.Sequence[_ty.Self]:
|
|
188
190
|
return _PathnameParents(self)
|
|
189
191
|
|
|
190
|
-
|
|
191
192
|
@_utils.notimplemented
|
|
192
193
|
def is_absolute(self) -> bool:
|
|
193
194
|
"""True if the path is absolute (has both a root and, if applicable,
|
|
@@ -207,8 +208,14 @@ class Pathname(FsPathLike, _ty.Generic[_P]):
|
|
|
207
208
|
path_pattern = _glob.compile_pattern(path_pattern, case_sensitive)
|
|
208
209
|
return path_pattern.match(path) is not None
|
|
209
210
|
|
|
210
|
-
|
|
211
|
-
|
|
211
|
+
def as_posix(self) -> str:
|
|
212
|
+
return "/".join(self.segments)
|
|
213
|
+
|
|
214
|
+
def has_glob_pattern(self):
|
|
215
|
+
for segment in self.segments:
|
|
216
|
+
if _glob.WILCARD_PATTERN.match(segment) != None:
|
|
217
|
+
return True
|
|
218
|
+
return False
|
|
212
219
|
|
|
213
220
|
|
|
214
221
|
PurePathLike = str | Pathname
|
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
"""Filename globbing utility."""
|
|
5
5
|
|
|
6
6
|
import fnmatch as _fnmatch
|
|
7
|
-
import typing as _ty
|
|
8
7
|
import functools as _func
|
|
9
8
|
import re as _re
|
|
10
|
-
|
|
9
|
+
import typing as _ty
|
|
11
10
|
|
|
12
11
|
RECURSIVE = "**"
|
|
13
12
|
ANY_PATTERN = _re.compile(_fnmatch.translate("*"))
|
|
@@ -33,7 +32,7 @@ def glob(
|
|
|
33
32
|
root_dir: _Globable | None = None,
|
|
34
33
|
recursive: bool = False,
|
|
35
34
|
include_hidden: bool = False,
|
|
36
|
-
case_sensitive: bool | None = None
|
|
35
|
+
case_sensitive: bool | None = None,
|
|
37
36
|
) -> _ty.Iterable[_Globable]:
|
|
38
37
|
"""Return an iterator which yields the paths matching a pathname pattern.
|
|
39
38
|
|
|
@@ -52,12 +51,8 @@ def glob(
|
|
|
52
51
|
pattern = compile_pattern(path.name, case_sensitive) if path.name else ANY_PATTERN
|
|
53
52
|
|
|
54
53
|
name_is_pattern = WILCARD_PATTERN.match(path.name) != None
|
|
55
|
-
wildcard_in_path = name_is_pattern
|
|
54
|
+
wildcard_in_path = name_is_pattern or path.has_glob_pattern()
|
|
56
55
|
parent = next(iter(path.parents), None)
|
|
57
|
-
for segment in path.segments:
|
|
58
|
-
if WILCARD_PATTERN.match(segment) != None:
|
|
59
|
-
wildcard_in_path = True
|
|
60
|
-
break
|
|
61
56
|
|
|
62
57
|
root: _Globable = (
|
|
63
58
|
(root_dir or parent) if not root_dir or not parent else (root_dir / parent)
|
|
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
|
|
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
|