hive-common 0.0.1__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.
- hive/common/__init__.py +1 -0
- hive/common/__version__.py +1 -0
- hive/common/argument_parser.py +17 -0
- hive/common/logging.py +13 -0
- hive/common/testing.py +16 -0
- hive/common/units.py +12 -0
- hive_common-0.0.1.dist-info/METADATA +37 -0
- hive_common-0.0.1.dist-info/RECORD +10 -0
- hive_common-0.0.1.dist-info/WHEEL +5 -0
- hive_common-0.0.1.dist-info/top_level.txt +1 -0
hive/common/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .argument_parser import HiveArgumentParser as ArgumentParser
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.1"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from argparse import ArgumentParser
|
|
4
|
+
|
|
5
|
+
from .logging import getenv_log_level
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger(__name__)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class HiveArgumentParser(ArgumentParser):
|
|
11
|
+
def parse_args(self, *args, **kwargs):
|
|
12
|
+
if (log_level := getenv_log_level()):
|
|
13
|
+
try:
|
|
14
|
+
logging.basicConfig(level=log_level)
|
|
15
|
+
except ValueError:
|
|
16
|
+
logger.warning(f"Ignoring LL={log_level!r}")
|
|
17
|
+
return super().parse_args(*args, *kwargs)
|
hive/common/logging.py
ADDED
hive/common/testing.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
try:
|
|
2
|
+
from pep440_version_utils import Version
|
|
3
|
+
except ImportError:
|
|
4
|
+
pass
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def assert_is_valid_version(version: str):
|
|
8
|
+
try:
|
|
9
|
+
assert str(Version(version)) == version
|
|
10
|
+
except Exception as e:
|
|
11
|
+
raise AssertionError(f"Invalid version {version!r}") from e
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def want_to_see(caplog, msg):
|
|
15
|
+
failure_detail = f"didn't see: {msg}"
|
|
16
|
+
assert any(r.getMessage() == msg for r in caplog.records), failure_detail
|
hive/common/units.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
BYTE = BYTES = 1
|
|
2
|
+
KiB = BYTE << 10
|
|
3
|
+
MiB = KiB << 10
|
|
4
|
+
GiB = MiB << 10
|
|
5
|
+
TiB = GiB << 10
|
|
6
|
+
|
|
7
|
+
SECOND = SECONDS = 1
|
|
8
|
+
MINUTE = MINUTES = 60 * SECONDS
|
|
9
|
+
HOUR = HOURS = 60 * MINUTES
|
|
10
|
+
|
|
11
|
+
MILLISECOND = MILLISECONDS = SECOND / 1000
|
|
12
|
+
MICROSECOND = MICROSECONDS = MILLISECOND / 1000
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: hive-common
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Common code for Hive libraries and services
|
|
5
|
+
Author-email: Gary Benson <gary@gbenson.net>
|
|
6
|
+
Project-URL: Homepage, https://github.com/gbenson/hive/tree/main/libs/common
|
|
7
|
+
Project-URL: Source, https://github.com/gbenson/hive
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
|
|
10
|
+
[![version badge]](https://pypi.org/project/hive-common/)
|
|
11
|
+
|
|
12
|
+
[version badge]: https://img.shields.io/pypi/v/hive-common?color=limegreen
|
|
13
|
+
|
|
14
|
+
# hive-common
|
|
15
|
+
|
|
16
|
+
Common code for Hive libraries and services
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
### With PIP
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
pip install hive-common
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### From source
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
git clone https://github.com/gbenson/hive.git
|
|
30
|
+
cd hive/libs/common
|
|
31
|
+
python3 -m venv .venv
|
|
32
|
+
. .venv/bin/activate
|
|
33
|
+
pip install --upgrade pip
|
|
34
|
+
pip install -r requirements.txt
|
|
35
|
+
pip install -e .
|
|
36
|
+
flake8 && pytest
|
|
37
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
hive/common/__init__.py,sha256=0PQvzFq0-j33-Ci3mmlmrl3fgXNa82zlQSoimHzzd_o,66
|
|
2
|
+
hive/common/__version__.py,sha256=sXLh7g3KC4QCFxcZGBTpG2scR7hmmBsMjq6LqRptkRg,22
|
|
3
|
+
hive/common/argument_parser.py,sha256=EW4Sr0inuwDMj4hmC07anlNjACUDvVjfQFzXPfAJynI,474
|
|
4
|
+
hive/common/logging.py,sha256=NvPi5B7WHMq_kYZ7kNLz00_FHQbACoOIpTKpp4oHnek,252
|
|
5
|
+
hive/common/testing.py,sha256=DIHirggpsadwRFgwf8yEW_ddudRVzK9acfJHY_b5718,428
|
|
6
|
+
hive/common/units.py,sha256=ua82W_1gVoFYuSJYea7smautXz_zOYcYQKEsuMtie6I,256
|
|
7
|
+
hive_common-0.0.1.dist-info/METADATA,sha256=Z34YIGQUGxaLBp30TVDIuQaln9f5-krcR6nNJGOnbhA,813
|
|
8
|
+
hive_common-0.0.1.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
9
|
+
hive_common-0.0.1.dist-info/top_level.txt,sha256=pLpVAuviHGk3pzaFXU-4GKttxGTGAbFoWK8JvUl1jHQ,5
|
|
10
|
+
hive_common-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
hive
|