j8yte-toolbox 1.0.0.dev0__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.

Potentially problematic release.


This version of j8yte-toolbox might be problematic. Click here for more details.

@@ -0,0 +1,83 @@
1
+ include:
2
+ - project: 'lab-semifer/templates/gitlab-ci'
3
+ file: '.python-vault.yml'
4
+
5
+ stages:
6
+ - linting
7
+ - testing
8
+ - build
9
+ - deploy
10
+
11
+ variables:
12
+ UV_LINK_MODE: "copy"
13
+ GIT_DEPTH: "0"
14
+
15
+ ruff:
16
+ stage: linting
17
+ script:
18
+ - uv run --group dev ruff check .
19
+ rules:
20
+ - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
21
+ when: always
22
+ - if: $CI_COMMIT_BRANCH != "main"
23
+
24
+ pytest:
25
+ stage: testing
26
+ script:
27
+ - uv run --group dev pytest --cov=src --cov-report=term-missing --cov-report=html:htmlcov
28
+ coverage: '/TOTAL.*\s+(\d+)\%/'
29
+ artifacts:
30
+ paths:
31
+ - htmlcov/
32
+ expire_in: 1 week
33
+ rules:
34
+ - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
35
+ when: always
36
+ - if: '$CI_COMMIT_BRANCH == "main"'
37
+ when: always
38
+
39
+ build-package:
40
+ stage: build
41
+ script:
42
+ - uv build
43
+ artifacts:
44
+ paths:
45
+ - dist/
46
+ expire_in: 1 week
47
+ rules:
48
+ - if: '$CI_COMMIT_TAG'
49
+
50
+ pages:
51
+ stage: deploy
52
+ image: alpine:latest
53
+ script:
54
+ - mkdir -p public
55
+ - cp -r htmlcov/* public/
56
+ artifacts:
57
+ paths:
58
+ - public/
59
+ expire_in: 30 days
60
+ rules:
61
+ - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
62
+ when: always
63
+
64
+ pypi-publish:
65
+ stage: deploy
66
+ needs:
67
+ - job: vault
68
+ - job: build-package
69
+ script:
70
+ - |
71
+ VAULT_CLIENT_TOKEN=$(uv run python -c "
72
+ import urllib.request, json
73
+ req = urllib.request.Request('${VAULT_SERVER_URL}/v1/auth/jwt/login', data=json.dumps({'jwt': '${VAULT_ID_TOKEN}', 'role': '${VAULT_AUTH_ROLE}'}).encode())
74
+ print(json.loads(urllib.request.urlopen(req).read())['auth']['client_token'])
75
+ ")
76
+ export UV_PUBLISH_TOKEN=$(uv run python -c "
77
+ import urllib.request, json
78
+ req = urllib.request.Request('${VAULT_SERVER_URL}/v1/kv/data/pypi', headers={'X-Vault-Token': '${VAULT_CLIENT_TOKEN}'})
79
+ print(json.loads(urllib.request.urlopen(req).read())['data']['data']['token'])
80
+ ")
81
+ - uv publish
82
+ rules:
83
+ - if: '$CI_COMMIT_TAG'
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2026 j8yte
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,148 @@
1
+ Metadata-Version: 2.5
2
+ Name: j8yte-toolbox
3
+ Version: 1.0.0-dev
4
+ Summary: A Python module that provides static methods designed to simplify the export of Excel files, communication on Slack, sending emails, executing HTTP requests, creating HTML documents, and more.
5
+ Project-URL: Homepage, https://github.com/j8yte/j8yte-toolbox
6
+ Project-URL: Bug-Tracker, https://github.com/j8yte/j8yte-toolbox/issues
7
+ Author-email: j8yte <j8ytes@gmail.com>
8
+ License-File: LICENSE.txt
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
14
+ Classifier: Topic :: Utilities
15
+ Requires-Python: >=3.13
16
+ Requires-Dist: hvac~=2.4
17
+ Requires-Dist: mailgun~=1.10
18
+ Requires-Dist: openpyxl~=3.1
19
+ Requires-Dist: pandas~=3.1
20
+ Requires-Dist: requests~=2.34
21
+ Requires-Dist: tzdata~=2026.6
22
+ Requires-Dist: xhtml2pdf~=0.2
23
+ Requires-Dist: xlsxwriter~=3.3
24
+ Description-Content-Type: text/markdown
25
+
26
+ # j8yte-toolbox
27
+
28
+ A general-purpose and modern Python toolkit designed to simplify common API interactions, file manipulation (Excel, PDF, Base64), notification delivery (Slack, Mail, Mailgun), and secure infrastructure secret management via HashiCorp Vault.
29
+
30
+ ---
31
+
32
+ ## 🚀 Installation & Integration
33
+
34
+ Add the module to your project managed with **uv**:
35
+
36
+ ```bash
37
+ uv add j8yte-toolbox
38
+ ```
39
+
40
+ ---
41
+
42
+ ## 🛠️ Classes & Features Reference
43
+
44
+ ### 1. `Api` (HTTP Requests)
45
+ Provides a robust wrapper over `requests` featuring a native automatic retry strategy in case of infrastructure issues (HTTP codes 429, 500, 502, 503, 504).
46
+
47
+ * **`basic_auth_header(user, password)`**: Generates a Basic HTTP authentication token encoded in Base64.
48
+ * **`request(method, host, entry_point, ...)`**: Executes a secure HTTP request using reusable custom sessions.
49
+
50
+ ```python
51
+ from j8yte_toolbox import Api
52
+
53
+ # Example of a secure GET request
54
+ response = Api.request(
55
+ method="GET",
56
+ host="example.com",
57
+ entry_point="/api/something",
58
+ headers={"Accept": "application/json"}
59
+ )
60
+ ```
61
+
62
+ ### 2. `Base` (Low-Level Utilities)
63
+ Utility functions for type conversion, timezones, and physical files.
64
+
65
+ * **`str2bool(value)`**: Converts a string value (`"true"`, `"yes"`, `"1"`) into a native boolean.
66
+ * **`get_iso_8601(date, timezone)`**: Computes the dynamic daylight saving offset (summer/winter) for a given UTC date.
67
+ * **`bin_to_base64(src, dest)`** / **`base64_to_bin(text, dest)`**: Bidirectional conversion of binary files.
68
+
69
+ ### 3. `Excel` (XLSX Manipulation)
70
+ Facilitates stylized exportation and reading of spreadsheets using `xlsxwriter` and `pandas`.
71
+
72
+ * **`export(file, data)`**: Exports a list of dictionaries into a pre-formatted Excel spreadsheet (blue headers, automatic filters, and auto-adjusted columns).
73
+ * **`read(file, sheet, no_headers)`**: Reads an Excel file and returns its content as a clean Python `list[dict]`.
74
+
75
+ ```python
76
+ from j8yte_toolbox import Excel
77
+
78
+ data = [{"Key1": "abc", "Key2": "123"}, {"Key1": "def", "Key2": "456"}]
79
+ Excel.export("report.xlsx", data)
80
+ ```
81
+
82
+ ### 4. `Html` (Document & Chart Generation)
83
+ Allows the dynamic generation of lightweight HTML documents for emails or document conversion. Features a semantic CSS mapping system that automatically applies visual classes (`ok`, `warn`, `crit`, `ongoing`) based on text status keywords or numeric thresholds.
84
+
85
+ * **`create_doc(body, layout, font_size)`**: Generates a complete HTML5 document integrating a stylesheet compatible with demanding email clients.
86
+ * **`create_table(data, empty_blank)`**: Automatically converts dictionaries into dynamically colored HTML tables.
87
+ * **`create_separator()`**: Creates an HTML separator compatible with legacy Outlook desktop clients.
88
+ * **`create_pie_chart(...)`** / **`create_bar_chart(...)`**: Generates chart image tags pointing to the remote QuickChart API.
89
+ * **`color_class(value, invert, empty_blank)`**: Evaluates string or numeric values to return the appropriate CSS class.
90
+ * **`create_label(title, value)`**: Generates a formatted HTML stat box with a title and a value.
91
+
92
+ ### 5. `Jsm` (Atlassian Jira Service Management Integration)
93
+ Utilities dedicated to manipulating complex structures for Jira forms and injecting formatted comments using the Atlassian Document Format (ADF) schema.
94
+
95
+ * **`form_select(field, data, return_unknown_if_empty)`**: Parses and cleans choice-based text answers from Jira forms.
96
+ * **`create_table(headers, data, text, colwidth)`**: Generates the structural JSON dictionary representing a data table, ready to be sent via the JSM Comment API.
97
+
98
+ ### 6. `Mail` & `Mailgun` (Email Services)
99
+ Two messaging alternatives tailored to your infrastructure delivery requirements.
100
+
101
+ * **`Mail.send(...)`**: Dispatches HTML emails via a standard SMTP server relay (supports TLS encryption and authentication). Supports file attachments.
102
+ * **`Mailgun.send(...)`**: Dispatches transactional messages via the high-availability Mailgun REST API, supporting dynamic lists of file attachments.
103
+
104
+ ### 7. `Pdf` (Document Export)
105
+ Provides straightforward exporting tools to save HTML content directly into portable documents.
106
+
107
+ * **`export(file, html_doc)`**: Converted raw HTML structures into a physical formatted PDF binary file using `xhtml2pdf`.
108
+
109
+ ### 8. `Slack` (Communications & Block Kit)
110
+ Complete management of interactions with the Slack collaboration platform.
111
+
112
+ * **`send(host, token, channel, blocks, text)`**: Sends a simple text message or a complex layout interface using Slack Block Kit structures.
113
+ * **`delete(host, token, channel, timestamp)`**: Deletes a specific message in a Slack channel using its unique timestamp identifier.
114
+ * **`send_attachment(host, token, channel, filepath, blocks)`**: Handles Slack's 3-step file upload workflow to securely upload local attachments directly into a channel.
115
+ * **`delete_attachment(host, token, file_id)`**: Programmatically removes an uploaded attachment from Slack using its file identifier.
116
+ * **`create_table(data)`**: Translates a 2-column Python dataset into structural Slack Markdown table blocks.
117
+ * **`create_list(data, simple)`**: Transforms data into a structural Slack list layout (either bulleted rich text blocks or simple markdown rows).
118
+
119
+ ### 9. `Vault` (Secure Secrets Management)
120
+ Seamlessly interfaces with **HashiCorp Vault** within automated tasks, eliminating hardcoded passwords and tokens from your repository.
121
+
122
+ * **`get(reqs, url, role, token, mount_point)`**: Authenticates the client and batch-extracts secrets from the Vault KV v2 secret engine.
123
+
124
+ ```python
125
+ from j8yte_toolbox import Vault
126
+
127
+ # Automatic secret retrieval
128
+ my_requests = [{"path": "my-project/tokens", "key": "slack_api_token"}]
129
+ retrieved_secrets = Vault.get(my_requests)
130
+ ```
131
+
132
+ ---
133
+
134
+ ## 🔒 Pipeline Environment Variables
135
+
136
+ To operate seamlessly within your CI/CD automated jobs (specifically GitLab CI), the `Vault` class listens to the following standardized environment variables:
137
+
138
+ | Variable Name | Description | Example |
139
+ | :--- | :--- | :--- |
140
+ | `VAULT_SERVER_URL` | The network URL of your secure HashiCorp Vault instance. | `https://company.com` |
141
+ | `VAULT_AUTH_ROLE` | The authentication role name configured in Vault for GitLab CI. | `gitlab-ci-read-role` |
142
+ | `VAULT_ID_TOKEN` | The temporary OIDC JWT token automatically supplied by the GitLab Runner. | *(Generated by GitLab)* |
143
+
144
+ ---
145
+
146
+ ## 📝 License
147
+
148
+ This project is licensed under the **MIT** License. See the `LICENSE` file for more details.
@@ -0,0 +1,123 @@
1
+ # j8yte-toolbox
2
+
3
+ A general-purpose and modern Python toolkit designed to simplify common API interactions, file manipulation (Excel, PDF, Base64), notification delivery (Slack, Mail, Mailgun), and secure infrastructure secret management via HashiCorp Vault.
4
+
5
+ ---
6
+
7
+ ## 🚀 Installation & Integration
8
+
9
+ Add the module to your project managed with **uv**:
10
+
11
+ ```bash
12
+ uv add j8yte-toolbox
13
+ ```
14
+
15
+ ---
16
+
17
+ ## 🛠️ Classes & Features Reference
18
+
19
+ ### 1. `Api` (HTTP Requests)
20
+ Provides a robust wrapper over `requests` featuring a native automatic retry strategy in case of infrastructure issues (HTTP codes 429, 500, 502, 503, 504).
21
+
22
+ * **`basic_auth_header(user, password)`**: Generates a Basic HTTP authentication token encoded in Base64.
23
+ * **`request(method, host, entry_point, ...)`**: Executes a secure HTTP request using reusable custom sessions.
24
+
25
+ ```python
26
+ from j8yte_toolbox import Api
27
+
28
+ # Example of a secure GET request
29
+ response = Api.request(
30
+ method="GET",
31
+ host="example.com",
32
+ entry_point="/api/something",
33
+ headers={"Accept": "application/json"}
34
+ )
35
+ ```
36
+
37
+ ### 2. `Base` (Low-Level Utilities)
38
+ Utility functions for type conversion, timezones, and physical files.
39
+
40
+ * **`str2bool(value)`**: Converts a string value (`"true"`, `"yes"`, `"1"`) into a native boolean.
41
+ * **`get_iso_8601(date, timezone)`**: Computes the dynamic daylight saving offset (summer/winter) for a given UTC date.
42
+ * **`bin_to_base64(src, dest)`** / **`base64_to_bin(text, dest)`**: Bidirectional conversion of binary files.
43
+
44
+ ### 3. `Excel` (XLSX Manipulation)
45
+ Facilitates stylized exportation and reading of spreadsheets using `xlsxwriter` and `pandas`.
46
+
47
+ * **`export(file, data)`**: Exports a list of dictionaries into a pre-formatted Excel spreadsheet (blue headers, automatic filters, and auto-adjusted columns).
48
+ * **`read(file, sheet, no_headers)`**: Reads an Excel file and returns its content as a clean Python `list[dict]`.
49
+
50
+ ```python
51
+ from j8yte_toolbox import Excel
52
+
53
+ data = [{"Key1": "abc", "Key2": "123"}, {"Key1": "def", "Key2": "456"}]
54
+ Excel.export("report.xlsx", data)
55
+ ```
56
+
57
+ ### 4. `Html` (Document & Chart Generation)
58
+ Allows the dynamic generation of lightweight HTML documents for emails or document conversion. Features a semantic CSS mapping system that automatically applies visual classes (`ok`, `warn`, `crit`, `ongoing`) based on text status keywords or numeric thresholds.
59
+
60
+ * **`create_doc(body, layout, font_size)`**: Generates a complete HTML5 document integrating a stylesheet compatible with demanding email clients.
61
+ * **`create_table(data, empty_blank)`**: Automatically converts dictionaries into dynamically colored HTML tables.
62
+ * **`create_separator()`**: Creates an HTML separator compatible with legacy Outlook desktop clients.
63
+ * **`create_pie_chart(...)`** / **`create_bar_chart(...)`**: Generates chart image tags pointing to the remote QuickChart API.
64
+ * **`color_class(value, invert, empty_blank)`**: Evaluates string or numeric values to return the appropriate CSS class.
65
+ * **`create_label(title, value)`**: Generates a formatted HTML stat box with a title and a value.
66
+
67
+ ### 5. `Jsm` (Atlassian Jira Service Management Integration)
68
+ Utilities dedicated to manipulating complex structures for Jira forms and injecting formatted comments using the Atlassian Document Format (ADF) schema.
69
+
70
+ * **`form_select(field, data, return_unknown_if_empty)`**: Parses and cleans choice-based text answers from Jira forms.
71
+ * **`create_table(headers, data, text, colwidth)`**: Generates the structural JSON dictionary representing a data table, ready to be sent via the JSM Comment API.
72
+
73
+ ### 6. `Mail` & `Mailgun` (Email Services)
74
+ Two messaging alternatives tailored to your infrastructure delivery requirements.
75
+
76
+ * **`Mail.send(...)`**: Dispatches HTML emails via a standard SMTP server relay (supports TLS encryption and authentication). Supports file attachments.
77
+ * **`Mailgun.send(...)`**: Dispatches transactional messages via the high-availability Mailgun REST API, supporting dynamic lists of file attachments.
78
+
79
+ ### 7. `Pdf` (Document Export)
80
+ Provides straightforward exporting tools to save HTML content directly into portable documents.
81
+
82
+ * **`export(file, html_doc)`**: Converted raw HTML structures into a physical formatted PDF binary file using `xhtml2pdf`.
83
+
84
+ ### 8. `Slack` (Communications & Block Kit)
85
+ Complete management of interactions with the Slack collaboration platform.
86
+
87
+ * **`send(host, token, channel, blocks, text)`**: Sends a simple text message or a complex layout interface using Slack Block Kit structures.
88
+ * **`delete(host, token, channel, timestamp)`**: Deletes a specific message in a Slack channel using its unique timestamp identifier.
89
+ * **`send_attachment(host, token, channel, filepath, blocks)`**: Handles Slack's 3-step file upload workflow to securely upload local attachments directly into a channel.
90
+ * **`delete_attachment(host, token, file_id)`**: Programmatically removes an uploaded attachment from Slack using its file identifier.
91
+ * **`create_table(data)`**: Translates a 2-column Python dataset into structural Slack Markdown table blocks.
92
+ * **`create_list(data, simple)`**: Transforms data into a structural Slack list layout (either bulleted rich text blocks or simple markdown rows).
93
+
94
+ ### 9. `Vault` (Secure Secrets Management)
95
+ Seamlessly interfaces with **HashiCorp Vault** within automated tasks, eliminating hardcoded passwords and tokens from your repository.
96
+
97
+ * **`get(reqs, url, role, token, mount_point)`**: Authenticates the client and batch-extracts secrets from the Vault KV v2 secret engine.
98
+
99
+ ```python
100
+ from j8yte_toolbox import Vault
101
+
102
+ # Automatic secret retrieval
103
+ my_requests = [{"path": "my-project/tokens", "key": "slack_api_token"}]
104
+ retrieved_secrets = Vault.get(my_requests)
105
+ ```
106
+
107
+ ---
108
+
109
+ ## 🔒 Pipeline Environment Variables
110
+
111
+ To operate seamlessly within your CI/CD automated jobs (specifically GitLab CI), the `Vault` class listens to the following standardized environment variables:
112
+
113
+ | Variable Name | Description | Example |
114
+ | :--- | :--- | :--- |
115
+ | `VAULT_SERVER_URL` | The network URL of your secure HashiCorp Vault instance. | `https://company.com` |
116
+ | `VAULT_AUTH_ROLE` | The authentication role name configured in Vault for GitLab CI. | `gitlab-ci-read-role` |
117
+ | `VAULT_ID_TOKEN` | The temporary OIDC JWT token automatically supplied by the GitLab Runner. | *(Generated by GitLab)* |
118
+
119
+ ---
120
+
121
+ ## 📝 License
122
+
123
+ This project is licensed under the **MIT** License. See the `LICENSE` file for more details.
@@ -0,0 +1,63 @@
1
+ [build-system]
2
+ requires = ["hatchling", "hatch-vcs"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [tool.hatch.version]
6
+ source = "vcs"
7
+ fallback-version = "1.0.0-dev"
8
+
9
+ [tool.hatch.build.targets.wheel]
10
+ packages = ["src/j8yte_toolbox"]
11
+
12
+ [project]
13
+ name = "j8yte-toolbox"
14
+ dynamic = ["version"]
15
+ description = "A Python module that provides static methods designed to simplify the export of Excel files, communication on Slack, sending emails, executing HTTP requests, creating HTML documents, and more."
16
+ readme = "README.md"
17
+ requires-python = ">=3.13"
18
+ authors = [
19
+ { name = "j8yte", email = "j8ytes@gmail.com" }
20
+ ]
21
+ classifiers = [
22
+ "Programming Language :: Python :: 3",
23
+ "License :: OSI Approved :: MIT License",
24
+ "Operating System :: OS Independent",
25
+ "Intended Audience :: Developers",
26
+ "Topic :: Utilities",
27
+ "Topic :: Software Development :: Libraries :: Python Modules"
28
+ ]
29
+ dependencies = [
30
+ "mailgun~=1.10",
31
+ "requests~=2.34",
32
+ "tzdata~=2026.6",
33
+ "xlsxwriter~=3.3",
34
+ "pandas~=3.1",
35
+ "openpyxl~=3.1",
36
+ "hvac~=2.4",
37
+ "xhtml2pdf~=0.2"
38
+ ]
39
+
40
+ [project.urls]
41
+ Homepage = "https://github.com/j8yte/j8yte-toolbox"
42
+ Bug-Tracker = "https://github.com/j8yte/j8yte-toolbox/issues"
43
+
44
+ [dependency-groups]
45
+ # Dépendances de développement
46
+ dev = [
47
+ "pytest~=9.2",
48
+ "pytest-cov~=7.1",
49
+ "ruff~=0.17",
50
+ ]
51
+
52
+ [tool.ruff]
53
+ target-version = "py313"
54
+ line-length = 88
55
+ exclude = ["tests"]
56
+
57
+ [tool.ruff.lint]
58
+ # E/W (Pycodestyle), F (Pyflakes), I (Isort), UP (Pyupgrade), B (Bugbear)
59
+ select = ["E", "W", "F", "I", "UP", "B"]
60
+ ignore = []
61
+
62
+ [tool.ruff.lint.isort]
63
+ known-first-party = ["j8yte_toolbox"]
@@ -0,0 +1,14 @@
1
+ from .core import Api, Base, Excel, Html, Jsm, Mail, Mailgun, Pdf, Slack, Vault
2
+
3
+ __all__ = [
4
+ "Api",
5
+ "Base",
6
+ "Excel",
7
+ "Html",
8
+ "Jsm",
9
+ "Mail",
10
+ "Mailgun",
11
+ "Pdf",
12
+ "Slack",
13
+ "Vault"
14
+ ]