evilutils 0.1.0__tar.gz → 0.1.2__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 (25) hide show
  1. {evilutils-0.1.0/src/evilutils.egg-info → evilutils-0.1.2}/PKG-INFO +1 -1
  2. {evilutils-0.1.0 → evilutils-0.1.2}/src/evilfunctools/__init__.py +1 -2
  3. evilutils-0.1.2/src/evilfunctools/decorators.py +23 -0
  4. evilutils-0.1.2/src/evilpath/__init__.py +3 -0
  5. evilutils-0.1.2/src/evilpath/path.py +36 -0
  6. {evilutils-0.1.0 → evilutils-0.1.2}/src/evilutils/info.py +1 -1
  7. evilutils-0.1.2/src/evilutils/py.typed +0 -0
  8. {evilutils-0.1.0 → evilutils-0.1.2/src/evilutils.egg-info}/PKG-INFO +1 -1
  9. {evilutils-0.1.0 → evilutils-0.1.2}/src/evilutils.egg-info/SOURCES.txt +5 -1
  10. {evilutils-0.1.0 → evilutils-0.1.2}/src/evilutils.egg-info/top_level.txt +1 -0
  11. evilutils-0.1.2/tests/test_evilpath.py +35 -0
  12. evilutils-0.1.0/src/evilfunctools/decorators.py +0 -44
  13. {evilutils-0.1.0 → evilutils-0.1.2}/LICENSE +0 -0
  14. {evilutils-0.1.0 → evilutils-0.1.2}/MANIFEST.in +0 -0
  15. {evilutils-0.1.0 → evilutils-0.1.2}/README.md +0 -0
  16. {evilutils-0.1.0 → evilutils-0.1.2}/pyproject.toml +0 -0
  17. {evilutils-0.1.0 → evilutils-0.1.2}/requirements.txt +0 -0
  18. {evilutils-0.1.0 → evilutils-0.1.2}/setup.cfg +0 -0
  19. {evilutils-0.1.0 → evilutils-0.1.2}/src/evilfunctools/compose.py +0 -0
  20. {evilutils-0.1.0 → evilutils-0.1.2}/src/evilfunctools/py.typed +0 -0
  21. {evilutils-0.1.0/src/evilutils → evilutils-0.1.2/src/evilpath}/py.typed +0 -0
  22. {evilutils-0.1.0 → evilutils-0.1.2}/src/evilutils/__init__.py +0 -0
  23. {evilutils-0.1.0 → evilutils-0.1.2}/src/evilutils/__main__.py +0 -0
  24. {evilutils-0.1.0 → evilutils-0.1.2}/src/evilutils.egg-info/dependency_links.txt +0 -0
  25. {evilutils-0.1.0 → evilutils-0.1.2}/src/evilutils.egg-info/requires.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: evilutils
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: All of the utils I don't want to write twice.
5
5
  Author-email: Ernest Izdebski <44341687+ernieIzde8ski@users.noreply.github.com>
6
6
  License: Copyright 2025-present Ernest Izdebski
@@ -3,7 +3,7 @@
3
3
  from functools import cache, cached_property, partial, partialmethod, wraps
4
4
 
5
5
  from .compose import compose
6
- from .decorators import immediate, map_result
6
+ from .decorators import immediate
7
7
 
8
8
  __all__ = [
9
9
  "partial",
@@ -13,5 +13,4 @@ __all__ = [
13
13
  "compose",
14
14
  "wraps",
15
15
  "immediate",
16
- "map_result",
17
16
  ]
@@ -0,0 +1,23 @@
1
+ from collections.abc import Callable
2
+ from typing import ParamSpec, TypeVar
3
+
4
+ __all__ = ["immediate"]
5
+
6
+ P = ParamSpec("P")
7
+ RT = TypeVar("RT")
8
+ MT = TypeVar("MT")
9
+
10
+ TT = TypeVar("TT", bound=type)
11
+
12
+
13
+ def immediate(func: Callable[[], RT]) -> RT:
14
+ """Immediately evaluate the given function, returning its output.
15
+
16
+ >>> @immediate
17
+ ... def VALUES():
18
+ ... return (0, 1)
19
+ >>>
20
+ >>> VALUES
21
+ (0, 1)
22
+ """
23
+ return func()
@@ -0,0 +1,3 @@
1
+ __all__ = ["Path"]
2
+
3
+ from .path import Path
@@ -0,0 +1,36 @@
1
+ import pathlib
2
+ from datetime import datetime
3
+ from typing import Literal, overload
4
+
5
+ __all__ = ["Path"]
6
+
7
+
8
+ class Path(pathlib.Path):
9
+ """Evil extensions to `pathlib`'s `Path` class."""
10
+
11
+ @overload
12
+ def atime(self, *, form: Literal["datetime"]) -> datetime: ...
13
+ @overload
14
+ def atime(self, *, form: Literal["float"] = "float") -> float: ...
15
+ def atime(self, *, form: Literal["float", "datetime"] = "float"):
16
+ """Time of last access."""
17
+ res = self.stat().st_atime
18
+ return res if form == "float" else datetime.fromtimestamp(res)
19
+
20
+ @overload
21
+ def mtime(self, *, form: Literal["datetime"]) -> datetime: ...
22
+ @overload
23
+ def mtime(self, *, form: Literal["float"] = "float") -> float: ...
24
+ def mtime(self, *, form: Literal["float", "datetime"] = "float"):
25
+ """Time of last modification."""
26
+ res = self.stat().st_mtime
27
+ return res if form == "float" else datetime.fromtimestamp(res)
28
+
29
+ @overload
30
+ def ctime(self, *, form: Literal["datetime"]) -> datetime: ...
31
+ @overload
32
+ def ctime(self, *, form: Literal["float"] = "float") -> float: ...
33
+ def ctime(self, *, form: Literal["float", "datetime"] = "float"):
34
+ """Time of last change."""
35
+ res = self.stat().st_ctime
36
+ return res if form == "float" else datetime.fromtimestamp(res)
@@ -2,5 +2,5 @@ __author__ = "Ernest Izdebski"
2
2
  __copyright__ = "Copyright 2025-present, Ernest Izdebski"
3
3
  __credits__ = ["Ernest Izdebski"]
4
4
  __license__ = "MIT"
5
- __version__ = "0.1.0"
5
+ __version__ = "0.1.2"
6
6
  __maintainer__ = "Ernest Izdebski"
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: evilutils
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: All of the utils I don't want to write twice.
5
5
  Author-email: Ernest Izdebski <44341687+ernieIzde8ski@users.noreply.github.com>
6
6
  License: Copyright 2025-present Ernest Izdebski
@@ -7,6 +7,9 @@ src/evilfunctools/__init__.py
7
7
  src/evilfunctools/compose.py
8
8
  src/evilfunctools/decorators.py
9
9
  src/evilfunctools/py.typed
10
+ src/evilpath/__init__.py
11
+ src/evilpath/path.py
12
+ src/evilpath/py.typed
10
13
  src/evilutils/__init__.py
11
14
  src/evilutils/__main__.py
12
15
  src/evilutils/info.py
@@ -15,4 +18,5 @@ src/evilutils.egg-info/PKG-INFO
15
18
  src/evilutils.egg-info/SOURCES.txt
16
19
  src/evilutils.egg-info/dependency_links.txt
17
20
  src/evilutils.egg-info/requires.txt
18
- src/evilutils.egg-info/top_level.txt
21
+ src/evilutils.egg-info/top_level.txt
22
+ tests/test_evilpath.py
@@ -1,2 +1,3 @@
1
1
  evilfunctools
2
+ evilpath
2
3
  evilutils
@@ -0,0 +1,35 @@
1
+ from . import _ensure as _ # noqa: F401
2
+
3
+ # isort: split
4
+
5
+ from datetime import datetime
6
+
7
+ import pytest
8
+
9
+ from evilpath import Path
10
+
11
+
12
+ @pytest.fixture
13
+ def this():
14
+ return Path(__file__)
15
+
16
+
17
+ def test_can_get_default_float_times(this: Path) -> None:
18
+ """
19
+ The no-parameter behavior of [amc]time should be
20
+ """
21
+ assert isinstance(this.atime(), float)
22
+ assert isinstance(this.mtime(), float)
23
+ assert isinstance(this.ctime(), float)
24
+
25
+
26
+ def test_can_get_float_times(this: Path) -> None:
27
+ assert isinstance(this.atime(form="float"), float)
28
+ assert isinstance(this.mtime(form="float"), float)
29
+ assert isinstance(this.ctime(form="float"), float)
30
+
31
+
32
+ def test_can_get_datetimes(this: Path) -> None:
33
+ assert isinstance(this.atime(form="datetime"), datetime)
34
+ assert isinstance(this.mtime(form="datetime"), datetime)
35
+ assert isinstance(this.ctime(form="datetime"), datetime)
@@ -1,44 +0,0 @@
1
- from collections.abc import Callable
2
- from functools import partial
3
- from typing import ParamSpec, TypeVar
4
-
5
- from .compose import compose
6
-
7
- __all__ = ["immediate", "map_result"]
8
-
9
- P = ParamSpec("P")
10
- RT = TypeVar("RT")
11
- MT = TypeVar("MT")
12
-
13
- TT = TypeVar("TT", bound=type)
14
-
15
-
16
- def immediate(func: Callable[[], RT]) -> RT:
17
- """Immediately evaluate the given function, returning its output.
18
-
19
- >>> @immediate
20
- ... def VALUES():
21
- ... return (0, 1)
22
- >>>
23
- >>> VALUES
24
- (0, 1)
25
- """
26
- return func()
27
-
28
-
29
- def map_result(
30
- mapper: Callable[[RT], MT],
31
- ) -> Callable[[Callable[P, RT]], Callable[P, MT]]:
32
- """Map the returned value of a function using another function.
33
-
34
- This is especially designed with generators in mind, though one
35
- could easily find other uses.
36
-
37
- >>> @map_result(tuple)
38
- ... def __generate_values(a: int):
39
- ... yield from (a, 1)
40
- >>>
41
- >>> __generate_values(0)
42
- (0, 1)
43
- """
44
- return partial(compose, mapper)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes