minimindslab-header-normalize 0.1.0__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.
@@ -0,0 +1,47 @@
1
+ """MiniMindsLab Header Normalize.
2
+
3
+ Utilities to normalize messy header names into stable lowercase snake_case.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ import re
9
+
10
+ __all__ = ["normalize_header"]
11
+
12
+ _SEP_RE = re.compile(r"[^a-zA-Z0-9]+")
13
+ _MULTI_UNDERSCORE_RE = re.compile(r"_+")
14
+
15
+
16
+ def normalize_header(value: str) -> str:
17
+ """Normalize a header string into lowercase snake_case.
18
+
19
+ Rules:
20
+ - Convert non-alphanumeric runs into underscores.
21
+ - Collapse repeated underscores.
22
+ - Strip leading and trailing underscores.
23
+ - Lowercase final output.
24
+
25
+ Parameters
26
+ ----------
27
+ value:
28
+ Input header text.
29
+
30
+ Returns
31
+ -------
32
+ str
33
+ Normalized snake_case name. May be empty for inputs with no
34
+ alphanumeric characters.
35
+
36
+ Raises
37
+ ------
38
+ TypeError
39
+ If `value` is not a string.
40
+ """
41
+ if not isinstance(value, str):
42
+ raise TypeError("value must be a string")
43
+
44
+ normalized = _SEP_RE.sub("_", value)
45
+ normalized = _MULTI_UNDERSCORE_RE.sub("_", normalized)
46
+ normalized = normalized.strip("_")
47
+ return normalized.lower()
@@ -0,0 +1,48 @@
1
+ Metadata-Version: 2.4
2
+ Name: minimindslab-header-normalize
3
+ Version: 0.1.0
4
+ Summary: Normalize text header names into stable machine-friendly field names.
5
+ Author: MiniMindsLab
6
+ License: MIT
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Dynamic: license-file
11
+
12
+ # MiniMindsLab Header Normalize
13
+
14
+ Normalize messy text header labels into stable lowercase `snake_case` field names.
15
+
16
+ ## Features
17
+
18
+ - Converts mixed case and separators to lowercase snake_case
19
+ - Removes unsupported punctuation deterministically
20
+ - Collapses repeated separators to a single underscore
21
+ - Trims leading/trailing underscores
22
+ - Pure Python (standard library only)
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ pip install minimindslab-header-normalize
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ ```python
33
+ from minimindslab_header_normalize import normalize_header
34
+
35
+ print(normalize_header(" Customer Name ")) # customer_name
36
+ print(normalize_header("Order-ID###")) # order_id
37
+ print(normalize_header("Total Amount ($)")) # total_amount
38
+ print(normalize_header("___Already__snake___")) # already_snake
39
+ ```
40
+
41
+ ## API
42
+
43
+ ### `normalize_header(value: str) -> str`
44
+
45
+ Normalize a single header string to lowercase snake_case.
46
+
47
+ Raises:
48
+ - `TypeError` if `value` is not a string.
@@ -0,0 +1,6 @@
1
+ minimindslab_header_normalize/__init__.py,sha256=OwhLD66IDOPX0cGuy7MGPfjIEkmn_vkL26A_coiHApc,1096
2
+ minimindslab_header_normalize-0.1.0.dist-info/licenses/LICENSE,sha256=9SsHAp-rmsco8evLbp-_802okWchTYdG-RZx5d3yddM,1069
3
+ minimindslab_header_normalize-0.1.0.dist-info/METADATA,sha256=UME-I12cxIlKvXi8DL6Dcn3V3EsOwRIdN35gFZolFtc,1253
4
+ minimindslab_header_normalize-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
5
+ minimindslab_header_normalize-0.1.0.dist-info/top_level.txt,sha256=JF5_PHHAHP1cpOmcWIRmkcWmZhGefMlfpaErfHx0wM0,30
6
+ minimindslab_header_normalize-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MiniMindsLab
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 @@
1
+ minimindslab_header_normalize