superpathlib 2.0.7__tar.gz → 2.0.9__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 (30) hide show
  1. {superpathlib-2.0.7/src/superpathlib.egg-info → superpathlib-2.0.9}/PKG-INFO +21 -8
  2. {superpathlib-2.0.7 → superpathlib-2.0.9}/README.md +20 -7
  3. {superpathlib-2.0.7 → superpathlib-2.0.9}/pyproject.toml +1 -4
  4. {superpathlib-2.0.7 → superpathlib-2.0.9}/src/superpathlib/base.py +1 -1
  5. {superpathlib-2.0.7 → superpathlib-2.0.9}/src/superpathlib/common_folders.py +25 -2
  6. {superpathlib-2.0.7 → superpathlib-2.0.9}/src/superpathlib/extra_functionality.py +1 -1
  7. {superpathlib-2.0.7 → superpathlib-2.0.9}/src/superpathlib/override.py +2 -2
  8. {superpathlib-2.0.7 → superpathlib-2.0.9/src/superpathlib.egg-info}/PKG-INFO +21 -8
  9. {superpathlib-2.0.7 → superpathlib-2.0.9}/src/superpathlib.egg-info/SOURCES.txt +1 -0
  10. {superpathlib-2.0.7 → superpathlib-2.0.9}/tests/test_cached_content.py +3 -3
  11. {superpathlib-2.0.7 → superpathlib-2.0.9}/tests/test_common_folders.py +0 -1
  12. {superpathlib-2.0.7 → superpathlib-2.0.9}/tests/test_functionality.py +5 -4
  13. superpathlib-2.0.9/tests/test_inheritance.py +14 -0
  14. {superpathlib-2.0.7 → superpathlib-2.0.9}/tests/test_metadata.py +3 -2
  15. {superpathlib-2.0.7 → superpathlib-2.0.9}/LICENSE +0 -0
  16. {superpathlib-2.0.7 → superpathlib-2.0.9}/setup.cfg +0 -0
  17. {superpathlib-2.0.7 → superpathlib-2.0.9}/src/superpathlib/__init__.py +0 -0
  18. {superpathlib-2.0.7 → superpathlib-2.0.9}/src/superpathlib/cached_content.py +0 -0
  19. {superpathlib-2.0.7 → superpathlib-2.0.9}/src/superpathlib/content_properties.py +0 -0
  20. {superpathlib-2.0.7 → superpathlib-2.0.9}/src/superpathlib/encryption.py +0 -0
  21. {superpathlib-2.0.7 → superpathlib-2.0.9}/src/superpathlib/metadata_properties.py +0 -0
  22. {superpathlib-2.0.7 → superpathlib-2.0.9}/src/superpathlib/path.py +0 -0
  23. {superpathlib-2.0.7 → superpathlib-2.0.9}/src/superpathlib/py.typed +0 -0
  24. {superpathlib-2.0.7 → superpathlib-2.0.9}/src/superpathlib/tags.py +0 -0
  25. {superpathlib-2.0.7 → superpathlib-2.0.9}/src/superpathlib/utils.py +0 -0
  26. {superpathlib-2.0.7 → superpathlib-2.0.9}/src/superpathlib.egg-info/dependency_links.txt +0 -0
  27. {superpathlib-2.0.7 → superpathlib-2.0.9}/src/superpathlib.egg-info/requires.txt +0 -0
  28. {superpathlib-2.0.7 → superpathlib-2.0.9}/src/superpathlib.egg-info/top_level.txt +0 -0
  29. {superpathlib-2.0.7 → superpathlib-2.0.9}/tests/test_content.py +1 -1
  30. {superpathlib-2.0.7 → superpathlib-2.0.9}/tests/test_encrypted_content.py +1 -1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: superpathlib
3
- Version: 2.0.7
3
+ Version: 2.0.9
4
4
  Summary: Extended Pathlib
5
5
  Author-email: Quinten Roets <qdr2104@columbia.edu>
6
6
  License: MIT
@@ -27,14 +27,26 @@ Requires-Dist: xattr<2,>=0.10.1; extra == "dev"
27
27
 
28
28
  # Superpathlib
29
29
  [![PyPI version](https://badge.fury.io/py/superpathlib.svg)](https://badge.fury.io/py/superpathlib)
30
+ ![PyPI downloads](https://img.shields.io/pypi/dm/superpathlib)
30
31
  ![Python version](https://img.shields.io/badge/python-3.10+-brightgreen)
31
32
  ![Operating system](https://img.shields.io/badge/os-linux%20%7c%20macOS-brightgreen)
32
33
  ![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)
33
34
 
34
- Maximize your productivity using minimal code!
35
+ Maximize your productivity with minimal code!
35
36
 
36
- Superpathlib enhances file operations, making them more intuitive and easy to implement.
37
- This library extends Python's standard library [pathlib](https://docs.python.org/3/library/pathlib.html) module, offering an expansive range of added features without compromising performance.
37
+ Superpathlib is an enhanced version of Python's standard [pathlib](https://docs.python.org/3/library/pathlib.html), designed to make file operations more intuitive and extend functionality without compromising performance. It builds on pathlib by introducing additional properties, methods, and shortcuts that simplify common file manipulations and reduce boilerplate code.
38
+
39
+ For custom operations, the package supports subclassing, which has been added to the standard library in [python3.12](https://docs.python.org/3/whatsnew/3.12.html).
40
+
41
+ ## Key features:
42
+ * Read and write content in various formats such as text, bytes, YAML, JSON, and even NumPy arrays
43
+ * Access and modify file metadata like file size, modification time, and custom tags
44
+ * Utility methods:
45
+ * `rmtree` to remove directories recursively
46
+ * `copy_to` to copy content
47
+ * `tempfile` to create and use temporary files
48
+ * `find` for recursive search
49
+ * `unpack` for unpacking archives
38
50
 
39
51
  ## Usage
40
52
 
@@ -131,8 +143,7 @@ class Path(superpathlib.Path):
131
143
  return sum(1 for _ in self.iterdir())
132
144
  ```
133
145
 
134
- This only works if you inherit from superpathlib Path, not pathlib Path
135
-
146
+ The standard pathlib library supports this for Python versions starting from [python3.12](https://docs.python.org/3/whatsnew/3.12.html).
136
147
 
137
148
  ## Installation
138
149
 
@@ -143,7 +154,9 @@ or
143
154
  ```shell
144
155
  pip install superpathlib[full]
145
156
  ```
157
+ to include additional dependencies like PyYAML for handling YAML files
158
+
159
+ or
146
160
 
147
- Install the packages corresponding with the properties you want to use:
148
- * e.g. PyYaml for yaml property
161
+ Manually install the packages corresponding with the features you want to use:
149
162
  * Packages listed in pyproject.toml
@@ -1,13 +1,25 @@
1
1
  # Superpathlib
2
2
  [![PyPI version](https://badge.fury.io/py/superpathlib.svg)](https://badge.fury.io/py/superpathlib)
3
+ ![PyPI downloads](https://img.shields.io/pypi/dm/superpathlib)
3
4
  ![Python version](https://img.shields.io/badge/python-3.10+-brightgreen)
4
5
  ![Operating system](https://img.shields.io/badge/os-linux%20%7c%20macOS-brightgreen)
5
6
  ![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)
6
7
 
7
- Maximize your productivity using minimal code!
8
+ Maximize your productivity with minimal code!
8
9
 
9
- Superpathlib enhances file operations, making them more intuitive and easy to implement.
10
- This library extends Python's standard library [pathlib](https://docs.python.org/3/library/pathlib.html) module, offering an expansive range of added features without compromising performance.
10
+ Superpathlib is an enhanced version of Python's standard [pathlib](https://docs.python.org/3/library/pathlib.html), designed to make file operations more intuitive and extend functionality without compromising performance. It builds on pathlib by introducing additional properties, methods, and shortcuts that simplify common file manipulations and reduce boilerplate code.
11
+
12
+ For custom operations, the package supports subclassing, which has been added to the standard library in [python3.12](https://docs.python.org/3/whatsnew/3.12.html).
13
+
14
+ ## Key features:
15
+ * Read and write content in various formats such as text, bytes, YAML, JSON, and even NumPy arrays
16
+ * Access and modify file metadata like file size, modification time, and custom tags
17
+ * Utility methods:
18
+ * `rmtree` to remove directories recursively
19
+ * `copy_to` to copy content
20
+ * `tempfile` to create and use temporary files
21
+ * `find` for recursive search
22
+ * `unpack` for unpacking archives
11
23
 
12
24
  ## Usage
13
25
 
@@ -104,8 +116,7 @@ class Path(superpathlib.Path):
104
116
  return sum(1 for _ in self.iterdir())
105
117
  ```
106
118
 
107
- This only works if you inherit from superpathlib Path, not pathlib Path
108
-
119
+ The standard pathlib library supports this for Python versions starting from [python3.12](https://docs.python.org/3/whatsnew/3.12.html).
109
120
 
110
121
  ## Installation
111
122
 
@@ -116,7 +127,9 @@ or
116
127
  ```shell
117
128
  pip install superpathlib[full]
118
129
  ```
130
+ to include additional dependencies like PyYAML for handling YAML files
131
+
132
+ or
119
133
 
120
- Install the packages corresponding with the properties you want to use:
121
- * e.g. PyYaml for yaml property
134
+ Manually install the packages corresponding with the features you want to use:
122
135
  * Packages listed in pyproject.toml
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "superpathlib"
3
- version = "2.0.7"
3
+ version = "2.0.9"
4
4
  description = "Extended Pathlib"
5
5
  authors = [{name = "Quinten Roets", email = "qdr2104@columbia.edu"}]
6
6
  license = {text = "MIT"}
@@ -76,9 +76,6 @@ ignore = [
76
76
  "G004", # logging f-string
77
77
  ]
78
78
 
79
- [tool.ruff.lint.isort]
80
- known-first-party = ["src"]
81
-
82
79
  [tool.ruff.lint.per-file-ignores]
83
80
  "__init__.py" = [
84
81
  "F401" # unused import
@@ -15,7 +15,7 @@ class Path(pathlib.Path): # pragma: nocover
15
15
  if os.name == "nt"
16
16
  else pathlib._posix_flavour # type: ignore[attr-defined] # noqa: SLF001
17
17
  )
18
- else:
18
+ elif sys.version_info < (3, 13):
19
19
  _flavour = (
20
20
  pathlib.ntpath # type: ignore[attr-defined]
21
21
  if os.name == "nt"
@@ -1,5 +1,7 @@
1
+ import abc
2
+ import sys
1
3
  import typing
2
- from typing import TypeVar
4
+ from typing import Any, TypeVar
3
5
 
4
6
  from simple_classproperty import classproperty
5
7
 
@@ -8,7 +10,28 @@ from . import base
8
10
  T = TypeVar("T", bound="Path")
9
11
 
10
12
 
11
- class Path(base.Path):
13
+ def enable_classproperties(cls: type[T]) -> None: # pragma: nocover
14
+ for name, method in vars(cls).items():
15
+ if isinstance(method, classmethod):
16
+ wrapped_method = method.__func__
17
+ if isinstance(wrapped_method, classproperty):
18
+ setattr(cls, name, wrapped_method)
19
+
20
+
21
+ class PropertyMeta(abc.ABCMeta):
22
+ def __new__(
23
+ cls: type["PropertyMeta"],
24
+ name: str,
25
+ bases: tuple[type, ...],
26
+ attributes: dict[str, Any],
27
+ ) -> "PropertyMeta":
28
+ meta_class = super().__new__(cls, name, bases, attributes)
29
+ if sys.version_info >= (3, 13):
30
+ enable_classproperties(meta_class) # pragma: nocover
31
+ return meta_class
32
+
33
+
34
+ class Path(base.Path, metaclass=PropertyMeta):
12
35
  """Expose common folders as attributes.
13
36
 
14
37
  Use classmethod properties to ensure child classes return instance
@@ -261,7 +261,7 @@ class Path(cached_content.Path):
261
261
 
262
262
  def subpath(self: PathType, *parts: str) -> PathType:
263
263
  path = self
264
- tokens_to_replace = self._flavour.sep, "."
264
+ tokens_to_replace = os.sep, "."
265
265
  for part in parts:
266
266
  for token in tokens_to_replace:
267
267
  part = part.replace(token, "_") # noqa: PLW2901
@@ -3,7 +3,7 @@ import shutil
3
3
  import typing
4
4
  from collections.abc import Callable, Generator
5
5
  from functools import wraps
6
- from pathlib import PurePath
6
+ from os import PathLike
7
7
  from typing import IO, Any, TypeVar
8
8
 
9
9
  from . import encryption
@@ -80,7 +80,7 @@ class Path(encryption.Path):
80
80
  raise
81
81
  return target_path
82
82
 
83
- def replace(self: T, target: str | PurePath) -> T:
83
+ def replace(self: T, target: str | PathLike[str]) -> T:
84
84
  path = self.rename(target, exist_ok=True)
85
85
  return typing.cast(T, path)
86
86
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: superpathlib
3
- Version: 2.0.7
3
+ Version: 2.0.9
4
4
  Summary: Extended Pathlib
5
5
  Author-email: Quinten Roets <qdr2104@columbia.edu>
6
6
  License: MIT
@@ -27,14 +27,26 @@ Requires-Dist: xattr<2,>=0.10.1; extra == "dev"
27
27
 
28
28
  # Superpathlib
29
29
  [![PyPI version](https://badge.fury.io/py/superpathlib.svg)](https://badge.fury.io/py/superpathlib)
30
+ ![PyPI downloads](https://img.shields.io/pypi/dm/superpathlib)
30
31
  ![Python version](https://img.shields.io/badge/python-3.10+-brightgreen)
31
32
  ![Operating system](https://img.shields.io/badge/os-linux%20%7c%20macOS-brightgreen)
32
33
  ![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)
33
34
 
34
- Maximize your productivity using minimal code!
35
+ Maximize your productivity with minimal code!
35
36
 
36
- Superpathlib enhances file operations, making them more intuitive and easy to implement.
37
- This library extends Python's standard library [pathlib](https://docs.python.org/3/library/pathlib.html) module, offering an expansive range of added features without compromising performance.
37
+ Superpathlib is an enhanced version of Python's standard [pathlib](https://docs.python.org/3/library/pathlib.html), designed to make file operations more intuitive and extend functionality without compromising performance. It builds on pathlib by introducing additional properties, methods, and shortcuts that simplify common file manipulations and reduce boilerplate code.
38
+
39
+ For custom operations, the package supports subclassing, which has been added to the standard library in [python3.12](https://docs.python.org/3/whatsnew/3.12.html).
40
+
41
+ ## Key features:
42
+ * Read and write content in various formats such as text, bytes, YAML, JSON, and even NumPy arrays
43
+ * Access and modify file metadata like file size, modification time, and custom tags
44
+ * Utility methods:
45
+ * `rmtree` to remove directories recursively
46
+ * `copy_to` to copy content
47
+ * `tempfile` to create and use temporary files
48
+ * `find` for recursive search
49
+ * `unpack` for unpacking archives
38
50
 
39
51
  ## Usage
40
52
 
@@ -131,8 +143,7 @@ class Path(superpathlib.Path):
131
143
  return sum(1 for _ in self.iterdir())
132
144
  ```
133
145
 
134
- This only works if you inherit from superpathlib Path, not pathlib Path
135
-
146
+ The standard pathlib library supports this for Python versions starting from [python3.12](https://docs.python.org/3/whatsnew/3.12.html).
136
147
 
137
148
  ## Installation
138
149
 
@@ -143,7 +154,9 @@ or
143
154
  ```shell
144
155
  pip install superpathlib[full]
145
156
  ```
157
+ to include additional dependencies like PyYAML for handling YAML files
158
+
159
+ or
146
160
 
147
- Install the packages corresponding with the properties you want to use:
148
- * e.g. PyYaml for yaml property
161
+ Manually install the packages corresponding with the features you want to use:
149
162
  * Packages listed in pyproject.toml
@@ -24,4 +24,5 @@ tests/test_common_folders.py
24
24
  tests/test_content.py
25
25
  tests/test_encrypted_content.py
26
26
  tests/test_functionality.py
27
+ tests/test_inheritance.py
27
28
  tests/test_metadata.py
@@ -2,9 +2,9 @@ import typing
2
2
  from typing import Any
3
3
 
4
4
  from package_utils.storage import CachedFileContent
5
- from superpathlib import Path
6
5
 
7
- from tests.content import byte_content, text_content
6
+ from superpathlib import Path
7
+ from tests.content import byte_content, slower_test_settings, text_content
8
8
  from tests.utils import ignore_fixture_warning
9
9
 
10
10
 
@@ -39,7 +39,7 @@ def test_content(path: Path, content: dict[str, dict[str, str]]) -> None:
39
39
  verify_storage(Storage, content)
40
40
 
41
41
 
42
- @ignore_fixture_warning
42
+ @slower_test_settings
43
43
  @text_content
44
44
  def test_created_content(path: Path, content: dict[str, dict[str, str]]) -> None:
45
45
  class Storage:
@@ -1,5 +1,4 @@
1
1
  from superpathlib import Path
2
-
3
2
  from tests.content import byte_content
4
3
  from tests.utils import ignore_fixture_warning
5
4
 
@@ -1,8 +1,8 @@
1
1
  from collections.abc import Callable
2
2
 
3
3
  import pytest
4
- from superpathlib import Path
5
4
 
5
+ from superpathlib import Path
6
6
  from tests.content import (
7
7
  byte_content,
8
8
  dictionary_content,
@@ -65,7 +65,7 @@ def test_copy(path: Path, path2: Path, content: bytes) -> None:
65
65
  assert path2.byte_content == content
66
66
 
67
67
 
68
- @ignore_fixture_warning
68
+ @slower_test_settings
69
69
  @byte_content
70
70
  def test_copy_if_newer_copies(path: Path, path2: Path, content: bytes) -> None:
71
71
  path.byte_content = content
@@ -74,7 +74,7 @@ def test_copy_if_newer_copies(path: Path, path2: Path, content: bytes) -> None:
74
74
  assert path2.byte_content == content
75
75
 
76
76
 
77
- @ignore_fixture_warning
77
+ @slower_test_settings
78
78
  @byte_content
79
79
  def test_copy_if_newer_skips(path: Path, path2: Path, content: bytes) -> None:
80
80
  path.byte_content = content
@@ -83,7 +83,7 @@ def test_copy_if_newer_skips(path: Path, path2: Path, content: bytes) -> None:
83
83
  assert path2.byte_content == b""
84
84
 
85
85
 
86
- @ignore_fixture_warning
86
+ @slower_test_settings
87
87
  @byte_content
88
88
  def test_move(path: Path, path2: Path, content: bytes) -> None:
89
89
  path.byte_content = content
@@ -269,6 +269,7 @@ def test_rmtree_preserve_root(directory: Path) -> None:
269
269
  directory.rmtree(remove_root=False)
270
270
 
271
271
 
272
+ @slower_test_settings
272
273
  @dictionary_content
273
274
  def test_yaml_update(content: dict[str, str]) -> None:
274
275
  with Path.tempfile() as path:
@@ -0,0 +1,14 @@
1
+ from simple_classproperty import classproperty
2
+
3
+ import superpathlib
4
+ from superpathlib.common_folders import T
5
+
6
+
7
+ def test_inheritance() -> None:
8
+ class Path(superpathlib.Path):
9
+ @classmethod
10
+ @classproperty
11
+ def HOME(cls: type[T]) -> T: # noqa: N802
12
+ return cls("HOME")
13
+
14
+ assert Path.docs.is_relative_to(Path.HOME)
@@ -4,14 +4,15 @@ import time
4
4
 
5
5
  from hypothesis import given, strategies
6
6
  from hypothesis.strategies import lists
7
- from superpathlib import Path
8
7
 
8
+ from superpathlib import Path
9
9
  from tests.content import byte_content, text_strategy
10
10
  from tests.utils import ignore_fixture_warning
11
11
 
12
12
 
13
13
  @ignore_fixture_warning
14
- @given(mtime=strategies.floats(min_value=0, max_value=time.time()))
14
+ # avoid small numbers
15
+ @given(mtime=strategies.floats(min_value=0.1, max_value=time.time()))
15
16
  def test_mtime(path: Path, mtime: float) -> None:
16
17
  assert isinstance(Path.mtime, property)
17
18
  path.mtime = mtime
File without changes
File without changes
@@ -1,6 +1,6 @@
1
1
  import numpy as np
2
- from superpathlib import Path
3
2
 
3
+ from superpathlib import Path
4
4
  from tests.content import (
5
5
  byte_content,
6
6
  dictionary_content,
@@ -1,6 +1,6 @@
1
1
  from hypothesis import HealthCheck, settings
2
- from superpathlib import Path
3
2
 
3
+ from superpathlib import Path
4
4
  from tests.content import byte_content, text_content
5
5
 
6
6
  slow_test_settings = settings(