roundlet 0.2.4__py3-none-any.whl

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.
roundlet/__init__.py ADDED
@@ -0,0 +1,12 @@
1
+ # SPDX-FileCopyrightText: Peter Pentchev <roam@ringlet.net>
2
+ # SPDX-License-Identifier: BSD-2-Clause
3
+ """Random collection of helper libraries used by Ringlet software."""
4
+
5
+ from __future__ import annotations
6
+
7
+ from .defs import VERSION
8
+
9
+
10
+ __all__ = [
11
+ "VERSION",
12
+ ]
roundlet/cli_basic.py ADDED
@@ -0,0 +1,54 @@
1
+ # SPDX-FileCopyrightText: Peter Pentchev <roam@ringlet.net>
2
+ # SPDX-License-Identifier: BSD-2-Clause
3
+ """Helpers for parsing some very basic command-line options."""
4
+
5
+ from __future__ import annotations
6
+
7
+ import sys
8
+
9
+
10
+ def handle_basic_options(
11
+ prog: str,
12
+ version: str,
13
+ features: list[tuple[str, str]],
14
+ help: str, # ruff: ignore[builtin-argument-shadowing]
15
+ ) -> bool:
16
+ """Try to process some very basic command-line options.
17
+
18
+ If any of the `-h` / `--help`, `-V` / `--version`, or `--features`
19
+ command-line options are specified, display the requested information and
20
+ return true.
21
+
22
+ If any command-line options other than these are specified, return false.
23
+ """
24
+ version_flag = False
25
+ features_flag = False
26
+ help_flag = False
27
+ for arg in sys.argv[1:]:
28
+ match arg:
29
+ case "-h" | "--help":
30
+ help_flag = True
31
+
32
+ case "-V" | "--version":
33
+ version_flag = True
34
+
35
+ case "--features":
36
+ features_flag = True
37
+
38
+ case "--":
39
+ break
40
+
41
+ case _:
42
+ return False
43
+
44
+ if version_flag:
45
+ print(f"{prog} {version}") # ruff: ignore[print] # this is the whole point
46
+
47
+ if features_flag:
48
+ # ruff: ignore[print] # this is the whole point
49
+ print(f"Features: {' '.join(f'{name}={value}' for name, value in features)}")
50
+
51
+ if help_flag:
52
+ print(help) # ruff: ignore[print] # this is the whole point
53
+
54
+ return version_flag or features_flag or help_flag
roundlet/defs.py ADDED
@@ -0,0 +1,15 @@
1
+ # SPDX-FileCopyrightText: Peter Pentchev <roam@ringlet.net>
2
+ # SPDX-License-Identifier: BSD-2-Clause
3
+ """Common definitions for the roundlet utilities."""
4
+
5
+ from __future__ import annotations
6
+
7
+ import typing
8
+
9
+
10
+ if typing.TYPE_CHECKING:
11
+ from typing import Final
12
+
13
+
14
+ VERSION: Final = "0.2.4"
15
+ """The project version, semver-like."""
roundlet/env.py ADDED
@@ -0,0 +1,23 @@
1
+ # SPDX-FileCopyrightText: Peter Pentchev <roam@ringlet.net>
2
+ # SPDX-License-Identifier: BSD-2-Clause
3
+ """Helpers for running programs in UTF-8-compatible environments."""
4
+
5
+ from __future__ import annotations
6
+
7
+ import typing
8
+
9
+
10
+ if typing.TYPE_CHECKING:
11
+ from typing import Final
12
+
13
+
14
+ UTF8_VARS: Final = {
15
+ "LC_ALL": "C.UTF-8",
16
+ "LANGUAGE": "",
17
+ }
18
+ """Environment settings for requesting a UTF-8 environment on most modern systems.
19
+
20
+ There are still some systems out there that do not know about the POSIX C.UTF-8 locale.
21
+ For them, the `utf8-locale` Python library would be a better choice.
22
+ For most modern systems though, these settings will suffice.
23
+ """
roundlet/logging.py ADDED
@@ -0,0 +1,41 @@
1
+ # SPDX-FileCopyrightText: Peter Pentchev <roam@ringlet.net>
2
+ # SPDX-License-Identifier: BSD-2-Clause
3
+ """Helper utilities for logging."""
4
+
5
+ from __future__ import annotations
6
+
7
+ import functools
8
+ import logging
9
+ import sys
10
+ import typing
11
+
12
+
13
+ if typing.TYPE_CHECKING:
14
+ from typing import Final
15
+
16
+
17
+ @functools.lru_cache
18
+ def build_logger(*, name: str, quiet: bool = False, verbose: bool = False) -> logging.Logger:
19
+ """Build a logger that outputs to the standard output and error streams.
20
+
21
+ Messages of level `WARNING` and higher go to the standard error stream.
22
+ If `quiet` is false, messages of level `INFO` also go to the standard error stream.
23
+ If `verbose` is true, messages of level `DEBUG` also go to the standard error stream.
24
+ """
25
+ logger: Final = logging.getLogger(name)
26
+ logger.setLevel(logging.DEBUG if verbose else logging.WARNING if quiet else logging.INFO)
27
+ logger.propagate = False
28
+
29
+ diag_handler: Final = logging.StreamHandler(sys.stderr)
30
+ diag_handler.setLevel(logging.DEBUG if verbose else logging.WARNING)
31
+ if not quiet:
32
+ diag_handler.addFilter(lambda rec: rec.levelno != logging.INFO)
33
+ logger.addHandler(diag_handler)
34
+
35
+ if not quiet:
36
+ info_handler: Final = logging.StreamHandler(sys.stderr)
37
+ info_handler.setLevel(logging.INFO)
38
+ info_handler.addFilter(lambda rec: rec.levelno == logging.INFO)
39
+ logger.addHandler(info_handler)
40
+
41
+ return logger
roundlet/py.typed ADDED
File without changes
@@ -0,0 +1,48 @@
1
+ Metadata-Version: 2.5
2
+ Name: roundlet
3
+ Version: 0.2.4
4
+ Summary: Random collection of helper libraries used by Ringlet software
5
+ License-Expression: BSD-2-Clause
6
+ License-File: LICENSES/BSD-2-Clause.txt
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Programming Language :: Python
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Programming Language :: Python :: 3.15
18
+ Classifier: Programming Language :: Python :: 3.16
19
+ Classifier: Topic :: Software Development :: Libraries
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.11
23
+ Description-Content-Type: text/markdown
24
+
25
+ <!--
26
+ SPDX-FileCopyrightText: Peter Pentchev <roam@ringlet.net>
27
+ SPDX-License-Identifier: BSD-2-Clause
28
+ -->
29
+
30
+ # roundlet - a random collection of helper libraries used by Ringlet software
31
+
32
+ \[[Home][ringlet-home] | [sourcehut][sourcehut] | [crates.io][crates-io] | [ReadTheDocs][readthedocs]\]
33
+
34
+ ## Overview
35
+
36
+ A couple of helper functions for Rust programs developed at Ringlet.
37
+
38
+ ## Contact
39
+
40
+ The `roundlet` library was written by [Peter Pentchev][roam].
41
+ It is developed in [a Sourcehut repository][sourcehut]. This documentation is
42
+ hosted at [Ringlet][ringlet-home] with a copy at [ReadTheDocs][readthedocs].
43
+
44
+ [roam]: mailto:roam@ringlet.net "Peter Pentchev"
45
+ [sourcehut]: https://git.sr.ht/~ppentchev/roundlet "The roundlet Sourcehut repository"
46
+ [crates-io]: https://crates.io/crates/roundlet "The roundlet crate on crates.io"
47
+ [readthedocs]: https://roundlet.readthedocs.io/ "The roundlet ReadTheDocs page"
48
+ [ringlet-home]: https://devel.ringlet.net/devel/roundlet/ "The Ringlet roundlet homepage"
@@ -0,0 +1,10 @@
1
+ roundlet/__init__.py,sha256=ra8j-slrQUeV_2SmIEmi2PT7MoYGp5PgCjI7HQVxSng,264
2
+ roundlet/cli_basic.py,sha256=lC-DmMkWJOquMLq_Kj9dFunvStWYBrzh6f5cn9l7mY8,1538
3
+ roundlet/defs.py,sha256=YwAgjA_HStM7-1uwVUA0DFWfTHs-MzubLiAJQjyWVxM,327
4
+ roundlet/env.py,sha256=140ZpPqXzAi1_QABhwQqHyiUUsHnyT9eZd1dkUfuakw,652
5
+ roundlet/logging.py,sha256=8nJDTfQ-teLA3shsseRyRQyNystn1D0QIkVLLyw-xN4,1428
6
+ roundlet/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ roundlet-0.2.4.dist-info/METADATA,sha256=UiSiFsS-GUgiQRC7_vgNiU99tqQNoIpeCwaVt016zo0,1995
8
+ roundlet-0.2.4.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
9
+ roundlet-0.2.4.dist-info/licenses/LICENSES/BSD-2-Clause.txt,sha256=8y-ztBehlBZ8-tBoIj_JdbqWxZYFE6EPZqPChyCuwd8,1267
10
+ roundlet-0.2.4.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,9 @@
1
+ Copyright (c) <year> <owner>
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+
7
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+
9
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.