kisstdlib 0.0.1__tar.gz → 0.0.3__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.
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/PKG-INFO +1 -1
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/kisstdlib/__init__.py +2 -6
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/kisstdlib/argparse/__init__.py +2 -6
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/kisstdlib/argparse/better.py +6 -6
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/kisstdlib/exceptions.py +2 -6
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/kisstdlib/io/__init__.py +2 -6
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/kisstdlib/io/base.py +2 -6
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/kisstdlib/io/encoder/__init__.py +2 -6
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/kisstdlib/io/encoder/base.py +2 -6
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/kisstdlib/io/encoder/pyrepr.py +2 -6
- kisstdlib-0.0.3/kisstdlib/io/stdio.py +30 -0
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/kisstdlib/io/wrapper.py +25 -16
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/kisstdlib/logging.py +2 -6
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/kisstdlib/path.py +13 -10
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/kisstdlib.egg-info/PKG-INFO +1 -1
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/kisstdlib.egg-info/SOURCES.txt +1 -0
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/pyproject.toml +1 -1
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/README.md +0 -0
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/kisstdlib/py.typed +0 -0
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/kisstdlib.egg-info/dependency_links.txt +0 -0
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/kisstdlib.egg-info/top_level.txt +0 -0
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/setup.cfg +0 -0
- {kisstdlib-0.0.1 → kisstdlib-0.0.3}/setup.py +0 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Copyright (c) 2018-2023 Jan Malakhovski <oxij@oxij.org>
|
|
2
2
|
#
|
|
3
|
+
# This file is a part of kisstdlib project.
|
|
4
|
+
#
|
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
6
|
# of this software and associated documentation files (the "Software"), to deal
|
|
5
7
|
# in the Software without restriction, including without limitation the rights
|
|
@@ -17,9 +19,3 @@
|
|
|
17
19
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
21
|
# SOFTWARE.
|
|
20
|
-
#
|
|
21
|
-
# This file is a part of kisstdlib project.
|
|
22
|
-
#
|
|
23
|
-
# This file can be distributed under the terms of the above MIT license or
|
|
24
|
-
# Python Software Foundation License version 2 (PSF-2.0) as published by Python
|
|
25
|
-
# Software Foundation.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Copyright (c) 2023 Jan Malakhovski <oxij@oxij.org>
|
|
2
2
|
#
|
|
3
|
+
# This file is a part of kisstdlib project.
|
|
4
|
+
#
|
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
6
|
# of this software and associated documentation files (the "Software"), to deal
|
|
5
7
|
# in the Software without restriction, including without limitation the rights
|
|
@@ -17,11 +19,5 @@
|
|
|
17
19
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
21
|
# SOFTWARE.
|
|
20
|
-
#
|
|
21
|
-
# This file is a part of kisstdlib project.
|
|
22
|
-
#
|
|
23
|
-
# This file can be distributed under the terms of the above MIT license or
|
|
24
|
-
# Python Software Foundation License version 2 (PSF-2.0) as published by Python
|
|
25
|
-
# Software Foundation.
|
|
26
22
|
|
|
27
23
|
from .better import *
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Copyright (c) 2022-2023 Jan Malakhovski <oxij@oxij.org>
|
|
2
2
|
#
|
|
3
|
+
# This file is a part of kisstdlib project.
|
|
4
|
+
#
|
|
5
|
+
# This file can be distributed under the terms of the MIT-style license given
|
|
6
|
+
# below or Python Software Foundation License version 2 (PSF-2.0) as published
|
|
7
|
+
# by Python Software Foundation.
|
|
8
|
+
#
|
|
3
9
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
10
|
# of this software and associated documentation files (the "Software"), to deal
|
|
5
11
|
# in the Software without restriction, including without limitation the rights
|
|
@@ -17,12 +23,6 @@
|
|
|
17
23
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
24
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
25
|
# SOFTWARE.
|
|
20
|
-
#
|
|
21
|
-
# This file is a part of kisstdlib project.
|
|
22
|
-
#
|
|
23
|
-
# This file can be distributed under the terms of the above MIT license or
|
|
24
|
-
# Python Software Foundation License version 2 (PSF-2.0) as published by Python
|
|
25
|
-
# Software Foundation.
|
|
26
26
|
|
|
27
27
|
import typing as _t
|
|
28
28
|
from argparse import *
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Copyright (c) 2023 Jan Malakhovski <oxij@oxij.org>
|
|
2
2
|
#
|
|
3
|
+
# This file is a part of kisstdlib project.
|
|
4
|
+
#
|
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
6
|
# of this software and associated documentation files (the "Software"), to deal
|
|
5
7
|
# in the Software without restriction, including without limitation the rights
|
|
@@ -17,12 +19,6 @@
|
|
|
17
19
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
21
|
# SOFTWARE.
|
|
20
|
-
#
|
|
21
|
-
# This file is a part of kisstdlib project.
|
|
22
|
-
#
|
|
23
|
-
# This file can be distributed under the terms of the above MIT license or
|
|
24
|
-
# Python Software Foundation License version 2 (PSF-2.0) as published by Python
|
|
25
|
-
# Software Foundation.
|
|
26
22
|
|
|
27
23
|
"""Exceptions with printable descriptions.
|
|
28
24
|
"""
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Copyright (c) 2018-2023 Jan Malakhovski <oxij@oxij.org>
|
|
2
2
|
#
|
|
3
|
+
# This file is a part of kisstdlib project.
|
|
4
|
+
#
|
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
6
|
# of this software and associated documentation files (the "Software"), to deal
|
|
5
7
|
# in the Software without restriction, including without limitation the rights
|
|
@@ -17,12 +19,6 @@
|
|
|
17
19
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
21
|
# SOFTWARE.
|
|
20
|
-
#
|
|
21
|
-
# This file is a part of kisstdlib project.
|
|
22
|
-
#
|
|
23
|
-
# This file can be distributed under the terms of the above MIT license or
|
|
24
|
-
# Python Software Foundation License version 2 (PSF-2.0) as published by Python
|
|
25
|
-
# Software Foundation.
|
|
26
22
|
|
|
27
23
|
"""KISS IO File Object hierarchy.
|
|
28
24
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Copyright (c) 2018-2023 Jan Malakhovski <oxij@oxij.org>
|
|
2
2
|
#
|
|
3
|
+
# This file is a part of kisstdlib project.
|
|
4
|
+
#
|
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
6
|
# of this software and associated documentation files (the "Software"), to deal
|
|
5
7
|
# in the Software without restriction, including without limitation the rights
|
|
@@ -17,12 +19,6 @@
|
|
|
17
19
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
21
|
# SOFTWARE.
|
|
20
|
-
#
|
|
21
|
-
# This file is a part of kisstdlib project.
|
|
22
|
-
#
|
|
23
|
-
# This file can be distributed under the terms of the above MIT license or
|
|
24
|
-
# Python Software Foundation License version 2 (PSF-2.0) as published by Python
|
|
25
|
-
# Software Foundation.
|
|
26
22
|
|
|
27
23
|
import abc as _abc
|
|
28
24
|
import sys as _sys
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Copyright (c) 2023 Jan Malakhovski <oxij@oxij.org>
|
|
2
2
|
#
|
|
3
|
+
# This file is a part of kisstdlib project.
|
|
4
|
+
#
|
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
6
|
# of this software and associated documentation files (the "Software"), to deal
|
|
5
7
|
# in the Software without restriction, including without limitation the rights
|
|
@@ -17,12 +19,6 @@
|
|
|
17
19
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
21
|
# SOFTWARE.
|
|
20
|
-
#
|
|
21
|
-
# This file is a part of kisstdlib project.
|
|
22
|
-
#
|
|
23
|
-
# This file can be distributed under the terms of the above MIT license or
|
|
24
|
-
# Python Software Foundation License version 2 (PSF-2.0) as published by Python
|
|
25
|
-
# Software Foundation.
|
|
26
22
|
|
|
27
23
|
from .base import *
|
|
28
24
|
from .pyrepr import *
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Copyright (c) 2023 Jan Malakhovski <oxij@oxij.org>
|
|
2
2
|
#
|
|
3
|
+
# This file is a part of kisstdlib project.
|
|
4
|
+
#
|
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
6
|
# of this software and associated documentation files (the "Software"), to deal
|
|
5
7
|
# in the Software without restriction, including without limitation the rights
|
|
@@ -17,12 +19,6 @@
|
|
|
17
19
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
21
|
# SOFTWARE.
|
|
20
|
-
#
|
|
21
|
-
# This file is a part of kisstdlib project.
|
|
22
|
-
#
|
|
23
|
-
# This file can be distributed under the terms of the above MIT license or
|
|
24
|
-
# Python Software Foundation License version 2 (PSF-2.0) as published by Python
|
|
25
|
-
# Software Foundation.
|
|
26
22
|
|
|
27
23
|
import sys as _sys
|
|
28
24
|
import typing as _t
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Copyright (c) 2023 Jan Malakhovski <oxij@oxij.org>
|
|
2
2
|
#
|
|
3
|
+
# This file is a part of kisstdlib project.
|
|
4
|
+
#
|
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
6
|
# of this software and associated documentation files (the "Software"), to deal
|
|
5
7
|
# in the Software without restriction, including without limitation the rights
|
|
@@ -17,12 +19,6 @@
|
|
|
17
19
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
21
|
# SOFTWARE.
|
|
20
|
-
#
|
|
21
|
-
# This file is a part of kisstdlib project.
|
|
22
|
-
#
|
|
23
|
-
# This file can be distributed under the terms of the above MIT license or
|
|
24
|
-
# Python Software Foundation License version 2 (PSF-2.0) as published by Python
|
|
25
|
-
# Software Foundation.
|
|
26
22
|
|
|
27
23
|
"""cbor2-style encoder for Pythonic Object Representation (repr)
|
|
28
24
|
"""
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Copyright (c) 2018-2024 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
|
+
import os as _os
|
|
24
|
+
import sys as _sys
|
|
25
|
+
|
|
26
|
+
from .wrapper import *
|
|
27
|
+
|
|
28
|
+
stdin = TIOWrappedReader(_os.fdopen(_sys.stdin.fileno(), "rb"))
|
|
29
|
+
stdout = TIOWrappedWriter(_os.fdopen(_sys.stdout.fileno(), "wb"))
|
|
30
|
+
stderr = TIOWrappedWriter(_os.fdopen(_sys.stderr.fileno(), "wb"))
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
# Copyright (c) 2018-
|
|
1
|
+
# Copyright (c) 2018-2024 Jan Malakhovski <oxij@oxij.org>
|
|
2
|
+
#
|
|
3
|
+
# This file is a part of kisstdlib project.
|
|
2
4
|
#
|
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
6
|
# of this software and associated documentation files (the "Software"), to deal
|
|
@@ -17,12 +19,6 @@
|
|
|
17
19
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
21
|
# SOFTWARE.
|
|
20
|
-
#
|
|
21
|
-
# This file is a part of kisstdlib project.
|
|
22
|
-
#
|
|
23
|
-
# This file can be distributed under the terms of the above MIT license or
|
|
24
|
-
# Python Software Foundation License version 2 (PSF-2.0) as published by Python
|
|
25
|
-
# Software Foundation.
|
|
26
22
|
|
|
27
23
|
import logging as _logging
|
|
28
24
|
import os as _os
|
|
@@ -31,28 +27,37 @@ import typing as _t
|
|
|
31
27
|
|
|
32
28
|
from .base import *
|
|
33
29
|
|
|
30
|
+
_logger = _logging.getLogger("kisstd")
|
|
31
|
+
|
|
34
32
|
class MinimalIOWrapper(MinimalIO):
|
|
33
|
+
fobj : _t.Any
|
|
34
|
+
fileno : int | None
|
|
35
|
+
|
|
35
36
|
def __init__(self, fobj : _t.Any) -> None:
|
|
36
37
|
self.fobj = fobj
|
|
37
38
|
# _socket.socket's fileno() will return -1 after
|
|
38
39
|
# .close() and poll needs an actual value to unsubscribe
|
|
39
40
|
# properly so we have to keep a copy here
|
|
40
41
|
try:
|
|
41
|
-
self.
|
|
42
|
+
self.fileno = fobj.fileno()
|
|
42
43
|
except OSError:
|
|
43
|
-
self.
|
|
44
|
-
|
|
44
|
+
self.fileno = None
|
|
45
|
+
_logger.debug("init %s", self)
|
|
45
46
|
|
|
46
47
|
def __del__(self) -> None:
|
|
47
|
-
|
|
48
|
+
_logger.debug("del %s", self)
|
|
48
49
|
|
|
49
50
|
def __repr__(self) -> str:
|
|
50
|
-
if self.
|
|
51
|
-
desc = "fd=" + str(self.
|
|
51
|
+
if self.fileno is not None:
|
|
52
|
+
desc = "fd=" + str(self.fileno)
|
|
52
53
|
else:
|
|
53
54
|
desc = "obj=" + str(id(self.fobj))
|
|
54
55
|
return "<%s %s %s closed=%s>" % (self.__class__.__name__, hex(id(self)), desc, self.closed)
|
|
55
56
|
|
|
57
|
+
@property
|
|
58
|
+
def isatty(self) -> bool:
|
|
59
|
+
return self.fobj.isatty() # type: ignore
|
|
60
|
+
|
|
56
61
|
def close(self) -> None:
|
|
57
62
|
self.fobj.close()
|
|
58
63
|
|
|
@@ -118,6 +123,10 @@ class TIOWrappedWriter(TIOWrapper, MinimalIOWriter):
|
|
|
118
123
|
else:
|
|
119
124
|
self.write_bytes(data)
|
|
120
125
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
126
|
+
def write_ln(self, data : str | ByteString) -> None:
|
|
127
|
+
self.write(data)
|
|
128
|
+
self.write_bytes(self.eol)
|
|
129
|
+
|
|
130
|
+
def __exit__(self, exc_type : _t.Any, exc_value : _t.Any, exc_tb : _t.Any) -> None:
|
|
131
|
+
self.flush()
|
|
132
|
+
self.close()
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Copyright (c) 2023 Jan Malakhovski <oxij@oxij.org>
|
|
2
2
|
#
|
|
3
|
+
# This file is a part of kisstdlib project.
|
|
4
|
+
#
|
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
6
|
# of this software and associated documentation files (the "Software"), to deal
|
|
5
7
|
# in the Software without restriction, including without limitation the rights
|
|
@@ -17,12 +19,6 @@
|
|
|
17
19
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
21
|
# SOFTWARE.
|
|
20
|
-
#
|
|
21
|
-
# This file is a part of kisstdlib project.
|
|
22
|
-
#
|
|
23
|
-
# This file can be distributed under the terms of the above MIT license or
|
|
24
|
-
# Python Software Foundation License version 2 (PSF-2.0) as published by Python
|
|
25
|
-
# Software Foundation.
|
|
26
22
|
|
|
27
23
|
import logging as _logging
|
|
28
24
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
# Copyright (c) 2018-
|
|
1
|
+
# Copyright (c) 2018-2024 Jan Malakhovski <oxij@oxij.org>
|
|
2
|
+
#
|
|
3
|
+
# This file is a part of kisstdlib project.
|
|
2
4
|
#
|
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
6
|
# of this software and associated documentation files (the "Software"), to deal
|
|
@@ -17,12 +19,6 @@
|
|
|
17
19
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
21
|
# SOFTWARE.
|
|
20
|
-
#
|
|
21
|
-
# This file is a part of kisstdlib project.
|
|
22
|
-
#
|
|
23
|
-
# This file can be distributed under the terms of the above MIT license or
|
|
24
|
-
# Python Software Foundation License version 2 (PSF-2.0) as published by Python
|
|
25
|
-
# Software Foundation.
|
|
26
22
|
|
|
27
23
|
import logging as _logging
|
|
28
24
|
import os as _os
|
|
@@ -30,12 +26,14 @@ import stat as _stat
|
|
|
30
26
|
import typing as _t
|
|
31
27
|
|
|
32
28
|
def walk_orderly(path : _t.AnyStr,
|
|
29
|
+
*,
|
|
33
30
|
include_directories : bool = True,
|
|
34
31
|
follow_symlinks : bool = True,
|
|
32
|
+
ordering : bool | None = True,
|
|
35
33
|
handle_error : _t.Callable[..., None] | None = _logging.error) -> _t.Iterable[_t.AnyStr]:
|
|
36
34
|
"""Similar to os.walk, but produces an iterator over plain file paths, allows
|
|
37
35
|
non-directories as input (which will just output a single element), and
|
|
38
|
-
the output is guaranteed to be ordered
|
|
36
|
+
the output is guaranteed to be ordered if `ordering` is not `None`.
|
|
39
37
|
"""
|
|
40
38
|
|
|
41
39
|
try:
|
|
@@ -88,13 +86,18 @@ def walk_orderly(path : _t.AnyStr,
|
|
|
88
86
|
else:
|
|
89
87
|
elements.append(entry.path)
|
|
90
88
|
|
|
91
|
-
|
|
89
|
+
if ordering is not None:
|
|
90
|
+
elements.sort(reverse=not ordering)
|
|
92
91
|
|
|
93
92
|
for path in elements:
|
|
94
93
|
lchar : _t.AnyStr = path[-1:]
|
|
95
94
|
if lchar == "/" or lchar == b"/":
|
|
96
95
|
if include_directories:
|
|
97
96
|
yield path
|
|
98
|
-
yield from walk_orderly(path,
|
|
97
|
+
yield from walk_orderly(path,
|
|
98
|
+
include_directories=include_directories,
|
|
99
|
+
follow_symlinks=follow_symlinks,
|
|
100
|
+
ordering=ordering,
|
|
101
|
+
handle_error=handle_error)
|
|
99
102
|
else:
|
|
100
103
|
yield path
|
|
@@ -3,7 +3,7 @@ requires = ["setuptools"]
|
|
|
3
3
|
build-backend = "setuptools.build_meta"
|
|
4
4
|
[project]
|
|
5
5
|
name = "kisstdlib"
|
|
6
|
-
version = "0.0.
|
|
6
|
+
version = "0.0.3"
|
|
7
7
|
authors = [{ name = "Jan Malakhovski", email = "oxij@oxij.org" }]
|
|
8
8
|
description = "Keep It Simple STandarD LIBraries set for Python"
|
|
9
9
|
readme = "README.md"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|