pathlib-next 0.1.3__tar.gz → 0.1.4__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.3 → pathlib_next-0.1.4}/PKG-INFO +1 -1
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/pyproject.toml +1 -1
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/src/example.py +1 -1
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/src/pathlib_next/mempath.py +25 -3
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/.gitignore +0 -0
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/LICENSE +0 -0
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/README.md +0 -0
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/src/pathlib_next/__init__.py +0 -0
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/src/pathlib_next/fspath.py +0 -0
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/src/pathlib_next/path.py +0 -0
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/src/pathlib_next/uri/__init__.py +0 -0
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/src/pathlib_next/uri/query.py +0 -0
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/src/pathlib_next/uri/schemes/__init__.py +0 -0
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/src/pathlib_next/uri/schemes/file.py +0 -0
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/src/pathlib_next/uri/schemes/http.py +0 -0
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/src/pathlib_next/uri/schemes/sftp.py +0 -0
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/src/pathlib_next/uri/source.py +0 -0
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/src/pathlib_next/utils/__init__.py +0 -0
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/src/pathlib_next/utils/glob.py +0 -0
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/src/pathlib_next/utils/stat.py +0 -0
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/src/pathlib_next/utils/sync.py +0 -0
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/tests/test_local.py +0 -0
- {pathlib_next-0.1.3 → pathlib_next-0.1.4}/tests/test_uri.py +0 -0
|
@@ -4,7 +4,7 @@ from pathlib_next.uri import Query, Source, UriPath
|
|
|
4
4
|
from pathlib_next.uri.schemes import *
|
|
5
5
|
from pathlib_next.utils.sync import PathSyncer
|
|
6
6
|
|
|
7
|
-
mempath = MemPath("test/test3")
|
|
7
|
+
mempath = MemPath("test/test3") / "subpath"
|
|
8
8
|
mempath.parent.mkdir(parents=True, exist_ok=True)
|
|
9
9
|
mempath.write_text("test")
|
|
10
10
|
check = mempath.read_text()
|
|
@@ -3,7 +3,7 @@ import posixpath as _posix
|
|
|
3
3
|
from io import IOBase
|
|
4
4
|
from urllib.parse import quote as _urlquote
|
|
5
5
|
|
|
6
|
-
from .path import Path
|
|
6
|
+
from .path import Path, Pathname
|
|
7
7
|
from .utils.stat import FileStat, FileStatLike
|
|
8
8
|
|
|
9
9
|
|
|
@@ -26,11 +26,33 @@ class MemPath(Path):
|
|
|
26
26
|
|
|
27
27
|
__slots__ = ("_backend", "_segments", "_normalized")
|
|
28
28
|
|
|
29
|
-
def __init__(
|
|
30
|
-
self
|
|
29
|
+
def __init__(
|
|
30
|
+
self, *segments: str | Pathname | Path, backend: MemPathBackend = None, **kwargs
|
|
31
|
+
):
|
|
32
|
+
_segments = []
|
|
33
|
+
_backend = None
|
|
34
|
+
for segment in segments:
|
|
35
|
+
if isinstance(segment, MemPath):
|
|
36
|
+
_segments.extend(segment.segments)
|
|
37
|
+
_backend = segment.backend
|
|
38
|
+
elif isinstance(segment, Path):
|
|
39
|
+
raise NotImplementedError()
|
|
40
|
+
elif isinstance(segment, Pathname):
|
|
41
|
+
_segments.extend(segment.segments)
|
|
42
|
+
else:
|
|
43
|
+
_segments.append(segment)
|
|
44
|
+
self._segments = "/".join(_segments).split("/")
|
|
45
|
+
if _backend and backend is None:
|
|
46
|
+
backend = _backend
|
|
31
47
|
self._backend = backend if backend is not None else MemPathBackend()
|
|
32
48
|
self._normalized = None
|
|
33
49
|
|
|
50
|
+
def __repr__(self):
|
|
51
|
+
return "{}({!r})".format(type(self).__name__, self.as_uri())
|
|
52
|
+
|
|
53
|
+
def __str__(self) -> str:
|
|
54
|
+
return self.as_uri()
|
|
55
|
+
|
|
34
56
|
@property
|
|
35
57
|
def backend(self):
|
|
36
58
|
return self._backend
|
|
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
|
|
File without changes
|