kisstdlib 0.0.6__tar.gz → 0.0.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.
Files changed (38) hide show
  1. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/PKG-INFO +2 -2
  2. kisstdlib-0.0.8/kisstdlib/compression.py +56 -0
  3. kisstdlib-0.0.8/kisstdlib/fs.py +974 -0
  4. kisstdlib-0.0.8/kisstdlib/io/base.py +258 -0
  5. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib/io/wrapper.py +8 -8
  6. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib/sorted.py +0 -13
  7. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib/time.py +0 -128
  8. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib/util.py +46 -3
  9. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib.egg-info/PKG-INFO +2 -2
  10. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib.egg-info/SOURCES.txt +6 -2
  11. kisstdlib-0.0.8/kisstdlib_bin/describe_dir.py +73 -0
  12. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/pyproject.toml +4 -3
  13. kisstdlib-0.0.8/test/test_fs.py +317 -0
  14. kisstdlib-0.0.8/test/test_sorted.py +39 -0
  15. kisstdlib-0.0.8/test/test_time.py +154 -0
  16. kisstdlib-0.0.6/kisstdlib/io/base.py +0 -142
  17. kisstdlib-0.0.6/kisstdlib/os.py +0 -531
  18. kisstdlib-0.0.6/kisstdlib_bin/describe_dir.py +0 -157
  19. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/LICENSE.txt +0 -0
  20. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/README.md +0 -0
  21. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib/__init__.py +0 -0
  22. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib/argparse/__init__.py +0 -0
  23. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib/argparse/better.py +0 -0
  24. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib/failure.py +0 -0
  25. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib/io/__init__.py +0 -0
  26. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib/io/encoder.py +0 -0
  27. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib/io/stdio.py +0 -0
  28. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib/logging.py +0 -0
  29. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib/parsing.py +0 -0
  30. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib/py.typed +0 -0
  31. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib/pyrepr.py +0 -0
  32. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib/tariter.py +0 -0
  33. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib.egg-info/dependency_links.txt +0 -0
  34. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib.egg-info/entry_points.txt +0 -0
  35. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib.egg-info/requires.txt +0 -0
  36. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/kisstdlib.egg-info/top_level.txt +0 -0
  37. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/setup.cfg +0 -0
  38. {kisstdlib-0.0.6 → kisstdlib-0.0.8}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kisstdlib
3
- Version: 0.0.6
3
+ Version: 0.0.8
4
4
  Summary: Keep It Simple STandarD LIBraries set for Python
5
5
  Author-email: Jan Malakhovski <oxij@oxij.org>
6
6
  Project-URL: Homepage, https://oxij.org/software/kisstdlib/
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3
12
12
  Classifier: License :: OSI Approved :: MIT License
13
13
  Classifier: License :: OSI Approved :: Python Software Foundation License
14
14
  Classifier: License :: OSI Approved :: BSD License
15
- Requires-Python: >=3.10
15
+ Requires-Python: >=3.11
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE.txt
18
18
  Requires-Dist: sortedcontainers==2.4.*
@@ -0,0 +1,56 @@
1
+ # Copyright (c) 2024-2025 Jan Malakhovski <oxij@oxij.org>
2
+ #
3
+ # This file is a part of `kisstdlib` project.
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ """Simple compression and decompression."""
24
+
25
+ import gzip as _gzip
26
+ import io as _io
27
+ import typing as _t
28
+
29
+
30
+ def gzip_maybe(data: bytes) -> bytes:
31
+ """Given some bytes, return their GZipped version if they compress, return the original otherwise."""
32
+ buf = _io.BytesIO()
33
+ with _gzip.GzipFile(fileobj=buf, filename="", mtime=0, mode="wb", compresslevel=9) as gz:
34
+ gz.write(data)
35
+ compressed_data = buf.getvalue()
36
+
37
+ if len(compressed_data) < len(data):
38
+ return compressed_data
39
+ return data
40
+
41
+
42
+ def ungzip_maybe(data: bytes) -> bytes:
43
+ """UnGZip a `bytes` object if it appears to be GZipped."""
44
+ if data[:2] != b"\037\213":
45
+ return data
46
+
47
+ with _gzip.GzipFile(fileobj=_io.BytesIO(data), mode="rb") as ungz:
48
+ return ungz.read()
49
+
50
+
51
+ def ungzip_fileobj_maybe(fobj: _io.BufferedReader) -> _io.BufferedReader:
52
+ """UnGZip a file-like object if it appears to be GZipped."""
53
+ head = fobj.peek(2)[:2]
54
+ if head == b"\037\213":
55
+ fobj = _t.cast(_io.BufferedReader, _gzip.GzipFile(fileobj=fobj, mode="rb"))
56
+ return fobj