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