comb-utils 0.0.2__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.
- comb_utils/__init__.py +12 -0
- comb_utils/api/__init__.py +1 -0
- comb_utils/api/internal.py +25 -0
- comb_utils/api/public.py +21 -0
- comb_utils/lib/__init__.py +1 -0
- comb_utils/lib/example.py +16 -0
- comb_utils-0.0.2.dist-info/LICENSE +21 -0
- comb_utils-0.0.2.dist-info/METADATA +142 -0
- comb_utils-0.0.2.dist-info/RECORD +11 -0
- comb_utils-0.0.2.dist-info/WHEEL +5 -0
- comb_utils-0.0.2.dist-info/top_level.txt +1 -0
comb_utils/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Do not define in API, only import."""
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""Internal functions overlay library and are typically wrapped by public functions.
|
|
2
|
+
|
|
3
|
+
This allows us to maintain a separation of API from implementation.
|
|
4
|
+
Internal functions may come with extra options that public functions don't have, say for
|
|
5
|
+
power users and developers who may want to use an existing DB session or something.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typeguard import typechecked
|
|
9
|
+
|
|
10
|
+
from comb_utils.lib import example
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@typechecked
|
|
14
|
+
def wait_a_second(
|
|
15
|
+
secs: int = 1, extra_string: str = "Fancy me, calling internal functions."
|
|
16
|
+
) -> None:
|
|
17
|
+
"""Just wait a second, or however many seconds you want.
|
|
18
|
+
|
|
19
|
+
Also prints a message with the number you passed, along with any extra message you want.
|
|
20
|
+
|
|
21
|
+
Arguments:
|
|
22
|
+
secs: How many seconds to wait.
|
|
23
|
+
extra_string: Extra message to add on tail of existing message.
|
|
24
|
+
"""
|
|
25
|
+
example.wait_a_second(secs=secs, extra_string=extra_string)
|
comb_utils/api/public.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""Public functions wrap internal functions which wrap library functions.
|
|
2
|
+
|
|
3
|
+
This allows separation of API from implementation. It also allows a simplified public API
|
|
4
|
+
separate from a more complex internal API with more options for power users.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typeguard import typechecked
|
|
8
|
+
|
|
9
|
+
from comb_utils.api.internal import example
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@typechecked
|
|
13
|
+
def wait_a_second(secs: int = 1) -> None:
|
|
14
|
+
"""Just wait a second, or however many seconds you want.
|
|
15
|
+
|
|
16
|
+
Also prints a message with the number you passed.
|
|
17
|
+
|
|
18
|
+
Arguments:
|
|
19
|
+
secs: How many seconds to wait.
|
|
20
|
+
"""
|
|
21
|
+
example.wait_a_second(secs=secs)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""lib init."""
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""This is an example module."""
|
|
2
|
+
|
|
3
|
+
import time
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def wait_a_second(secs: int = 1, extra_string: str = "") -> None:
|
|
7
|
+
"""Just wait a second, or however many seconds you want.
|
|
8
|
+
|
|
9
|
+
Also prints a message with the number you passed, along with any extra message you want.
|
|
10
|
+
|
|
11
|
+
Arguments:
|
|
12
|
+
secs: How many seconds to wait.
|
|
13
|
+
extra_string: Extra message to add on tail of existing message.
|
|
14
|
+
"""
|
|
15
|
+
print(f"Waiting {secs} seconds.{' ' + extra_string if extra_string else ''}")
|
|
16
|
+
time.sleep(secs)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Kaleb Coberly
|
|
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.
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: comb_utils
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: Handy utils for Python projects.
|
|
5
|
+
Author: Kaleb Coberly
|
|
6
|
+
Maintainer-email: kaleb.coberly@gmail.com
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: typeguard
|
|
11
|
+
Provides-Extra: dev
|
|
12
|
+
Requires-Dist: comb_utils[build]; extra == "dev"
|
|
13
|
+
Requires-Dist: comb_utils[doc]; extra == "dev"
|
|
14
|
+
Requires-Dist: comb_utils[qc]; extra == "dev"
|
|
15
|
+
Requires-Dist: comb_utils[test]; extra == "dev"
|
|
16
|
+
Provides-Extra: build
|
|
17
|
+
Requires-Dist: build; extra == "build"
|
|
18
|
+
Requires-Dist: twine; extra == "build"
|
|
19
|
+
Provides-Extra: doc
|
|
20
|
+
Requires-Dist: furo; extra == "doc"
|
|
21
|
+
Requires-Dist: sphinx; extra == "doc"
|
|
22
|
+
Requires-Dist: sphinx-autodoc-typehints; extra == "doc"
|
|
23
|
+
Provides-Extra: qc
|
|
24
|
+
Requires-Dist: bandit; extra == "qc"
|
|
25
|
+
Requires-Dist: black; extra == "qc"
|
|
26
|
+
Requires-Dist: black[jupyter]; extra == "qc"
|
|
27
|
+
Requires-Dist: flake8; extra == "qc"
|
|
28
|
+
Requires-Dist: flake8-annotations; extra == "qc"
|
|
29
|
+
Requires-Dist: flake8-bandit; extra == "qc"
|
|
30
|
+
Requires-Dist: flake8-black; extra == "qc"
|
|
31
|
+
Requires-Dist: flake8-bugbear; extra == "qc"
|
|
32
|
+
Requires-Dist: flake8-docstrings; extra == "qc"
|
|
33
|
+
Requires-Dist: flake8-isort; extra == "qc"
|
|
34
|
+
Requires-Dist: isort; extra == "qc"
|
|
35
|
+
Requires-Dist: jake; extra == "qc"
|
|
36
|
+
Requires-Dist: pytype; extra == "qc"
|
|
37
|
+
Requires-Dist: comb_utils[test]; extra == "qc"
|
|
38
|
+
Requires-Dist: safety; extra == "qc"
|
|
39
|
+
Provides-Extra: test
|
|
40
|
+
Requires-Dist: coverage[toml]; extra == "test"
|
|
41
|
+
Requires-Dist: pytest; extra == "test"
|
|
42
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
43
|
+
|
|
44
|
+
# Basic package template
|
|
45
|
+
|
|
46
|
+
## Summary
|
|
47
|
+
|
|
48
|
+
Some handy utils for Python projects. Repo is made from the `reference_package` template repo: https://github.com/crickets-and-comb/reference_package. See the docs: https://crickets-and-comb.github.io/shared_utils/.
|
|
49
|
+
|
|
50
|
+
## Structure
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
.github/workflows GitHub Actions CI/CD workflows.
|
|
54
|
+
docs RST docs and doc build staging.
|
|
55
|
+
Makefile Dev tools and params. (includes shared/Makefile)
|
|
56
|
+
src/comb_utils/api Public and internal API.
|
|
57
|
+
setup.cfg Metadata and dependencies.
|
|
58
|
+
shared Shared dev tools Git submodule.
|
|
59
|
+
src/comb_utils/lib Implementation.
|
|
60
|
+
tests/e2e End-to-end tests.
|
|
61
|
+
test/integration Integration tests.
|
|
62
|
+
tests/unit Unit tests.
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
To install the package, run:
|
|
68
|
+
|
|
69
|
+
$ pip install comb_utils
|
|
70
|
+
|
|
71
|
+
See https://pypi.org/project/comb-utils/.
|
|
72
|
+
|
|
73
|
+
## Library functions
|
|
74
|
+
|
|
75
|
+
`comb_utils` is a library from which you can import functions. Import the public example function like this: `from comb_utils import wait_a_second`. Or, import the internal version like a power user like this: `from comb_utils.api.internal import wait_a_second`.
|
|
76
|
+
|
|
77
|
+
Unless you're developing, avoid importing directly from library, like `from comb_utils.lib.example import wait_a_second`.
|
|
78
|
+
|
|
79
|
+
## Dev workflow
|
|
80
|
+
|
|
81
|
+
There are a number of dev tools in the `Makefile`. You can list all the make tools you might want to use:
|
|
82
|
+
|
|
83
|
+
$ make list-targets
|
|
84
|
+
|
|
85
|
+
Go check them out in `Makefile`.
|
|
86
|
+
|
|
87
|
+
*Note: The dev tools are built around developing on a Mac, so they may not all work on Windows without some modifications.*
|
|
88
|
+
|
|
89
|
+
### Shared tools setup
|
|
90
|
+
|
|
91
|
+
When you first clone this repo, you'll need to set up the shared tools Git submodule. Follow the setup directions on that repo's README: https://github.com/crickets-and-comb/shared
|
|
92
|
+
|
|
93
|
+
#### Updating shared tools
|
|
94
|
+
|
|
95
|
+
Once you've set up the shared dev tools submodule, you'll want to periodically update it to get updates to the shared tools:
|
|
96
|
+
|
|
97
|
+
$ make update-shared
|
|
98
|
+
|
|
99
|
+
Note that, while you'll be able to run with this updated shared submodule, you'll still want to commit that update to your consuming repo to track that update.
|
|
100
|
+
|
|
101
|
+
#### Setting Personal Access Token
|
|
102
|
+
|
|
103
|
+
The shared workflows rely on a Personal Access Token (PAT) (to checkout the submodule so they can use the make targets). You need to create a PAT with repo access and add it to the consuming repo's (`comb_utils` in this case) action secrets as `CHECKOUT_SHARED`. See GitHub for how to set up PATs (hint: check the developer settings on your personal account) and how to add secrets to a repo's actions (hint: check the repo's settings).
|
|
104
|
+
|
|
105
|
+
Note: Using a PAT tied to a single user like this is less than ideal. Figuring out how to get around this is a welcome security upgrade.
|
|
106
|
+
|
|
107
|
+
### Dev installation
|
|
108
|
+
|
|
109
|
+
You'll want this package's site-package files to be the source files in this repo so you can test your changes without having to reinstall. We've got some tools for that.
|
|
110
|
+
|
|
111
|
+
First build and activate the env before installing this package:
|
|
112
|
+
|
|
113
|
+
$ make build-env
|
|
114
|
+
$ conda activate comb_utils_py3.12
|
|
115
|
+
|
|
116
|
+
Note, if you don't have Python installed, you need to pass the package name directly when you build the env: `make build-env PACKAGE_NAME=comb_utils`. If you have Python installed (e.g., this conda env already activated), then you don't need to because it uses Python to grab the package name from the `setup.cfg` file.
|
|
117
|
+
|
|
118
|
+
Then, install this package and its dev dependencies:
|
|
119
|
+
|
|
120
|
+
$ make install
|
|
121
|
+
|
|
122
|
+
This installs all the dependencies in your conda env site-packages, but the files for this package's installation are now your source files in this repo.
|
|
123
|
+
|
|
124
|
+
### QC and testing
|
|
125
|
+
|
|
126
|
+
Before pushing commits, you'll usually want to rebuild the env and run all the QC and testing:
|
|
127
|
+
|
|
128
|
+
$ make clean format full
|
|
129
|
+
|
|
130
|
+
When making smaller commits, you might just want to run some of the smaller commands:
|
|
131
|
+
|
|
132
|
+
$ make clean format full-qc full-test
|
|
133
|
+
|
|
134
|
+
As a final step, it's good practice to test run the workflow before opening a PR or pushing to an open PR. We don't want to waste GitHub runtime on a glitch that we could have caught before. You can use a make target for that:
|
|
135
|
+
|
|
136
|
+
$ make run-act
|
|
137
|
+
|
|
138
|
+
That will run `.github/workflows/CI_CD.yml`. But, you can also run any workflow you'd like by using `act` directly. See https://nektosact.com.
|
|
139
|
+
|
|
140
|
+
To use this tool, you'll need to have Docker installed and running on your machine: https://www.docker.com/. You'll also need to install `act` in your terminal:
|
|
141
|
+
|
|
142
|
+
$ brew install act
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
comb_utils/__init__.py,sha256=He_mrvOz82NvEXxin1KsDQFqEFehEsWbHRzGAH7JMNE,229
|
|
2
|
+
comb_utils/api/__init__.py,sha256=VskpwBKQUkO7pLLZrWvJngWwPVx72vx0xPSCfxKAr3g,41
|
|
3
|
+
comb_utils/api/internal.py,sha256=-N9lH06EjHSoPkeQ_Tz_a2XzqJ3PYyAhhXa93glzutE,906
|
|
4
|
+
comb_utils/api/public.py,sha256=Y0BsLAX8df-B4W87lcFuctNH8wtALQwcWxvHy6WzI-A,621
|
|
5
|
+
comb_utils/lib/__init__.py,sha256=c-kh18Hkn-n2YGFLrJTxjv38h5KH9WmV1x4M5OBjKPY,16
|
|
6
|
+
comb_utils/lib/example.py,sha256=qq3ZfrY1BEByapTjrEng0xkqXN7y9kpkAqgcLQn33uM,524
|
|
7
|
+
comb_utils-0.0.2.dist-info/LICENSE,sha256=RbOwAEE8wb02qCx9uWRXbBUb0oAtrdZFvZFO9jARIdg,1070
|
|
8
|
+
comb_utils-0.0.2.dist-info/METADATA,sha256=6g0WTZnmXkdSFBct-2q3x38sf_UjPTWRohAfnFyrvzs,6136
|
|
9
|
+
comb_utils-0.0.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
10
|
+
comb_utils-0.0.2.dist-info/top_level.txt,sha256=bHRllaHFjJ1buzSdn8p1-7PeCC-QrCMCvhyapa7ND_k,11
|
|
11
|
+
comb_utils-0.0.2.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
comb_utils
|