minimindslab-header-normalize 0.1.0__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.
@@ -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,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,37 @@
1
+ # MiniMindsLab Header Normalize
2
+
3
+ Normalize messy text header labels into stable lowercase `snake_case` field names.
4
+
5
+ ## Features
6
+
7
+ - Converts mixed case and separators to lowercase snake_case
8
+ - Removes unsupported punctuation deterministically
9
+ - Collapses repeated separators to a single underscore
10
+ - Trims leading/trailing underscores
11
+ - Pure Python (standard library only)
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pip install minimindslab-header-normalize
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```python
22
+ from minimindslab_header_normalize import normalize_header
23
+
24
+ print(normalize_header(" Customer Name ")) # customer_name
25
+ print(normalize_header("Order-ID###")) # order_id
26
+ print(normalize_header("Total Amount ($)")) # total_amount
27
+ print(normalize_header("___Already__snake___")) # already_snake
28
+ ```
29
+
30
+ ## API
31
+
32
+ ### `normalize_header(value: str) -> str`
33
+
34
+ Normalize a single header string to lowercase snake_case.
35
+
36
+ Raises:
37
+ - `TypeError` if `value` is not a string.
@@ -0,0 +1,21 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0.3"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "minimindslab-header-normalize"
7
+ version = "0.1.0"
8
+ description = "Normalize text header names into stable machine-friendly field names."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "MiniMindsLab" }
14
+ ]
15
+ dependencies = []
16
+
17
+ [tool.setuptools]
18
+ package-dir = {"" = "src"}
19
+
20
+ [tool.setuptools.packages.find]
21
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -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,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/minimindslab_header_normalize/__init__.py
5
+ src/minimindslab_header_normalize.egg-info/PKG-INFO
6
+ src/minimindslab_header_normalize.egg-info/SOURCES.txt
7
+ src/minimindslab_header_normalize.egg-info/dependency_links.txt
8
+ src/minimindslab_header_normalize.egg-info/top_level.txt
9
+ tests/test_normalize_header.py
@@ -0,0 +1,48 @@
1
+ import pathlib
2
+ import unittest
3
+
4
+ from minimindslab_header_normalize import normalize_header
5
+
6
+
7
+ class NormalizeHeaderTests(unittest.TestCase):
8
+ def test_mixed_case_spaces_punctuation_and_repeated_separators(self):
9
+ self.assertEqual(normalize_header(" First Name "), "first_name")
10
+ self.assertEqual(normalize_header("Order---ID"), "order_id")
11
+ self.assertEqual(normalize_header("TOTAL.amount"), "total_amount")
12
+ self.assertEqual(normalize_header("A__B C"), "a_b_c")
13
+
14
+ def test_collapse_and_trim_underscores(self):
15
+ self.assertEqual(normalize_header("___alpha___beta___"), "alpha_beta")
16
+ self.assertEqual(normalize_header("__x__"), "x")
17
+
18
+ def test_preserve_alphanumeric_remove_other_punctuation(self):
19
+ self.assertEqual(normalize_header("Field#1 (v2)!"), "field_1_v2")
20
+ self.assertEqual(normalize_header("R2D2*&^%$Unit"), "r2d2_unit")
21
+
22
+ def test_empty_result_when_no_alphanumeric(self):
23
+ self.assertEqual(normalize_header("---***___"), "")
24
+
25
+ def test_type_error_for_non_string(self):
26
+ with self.assertRaises(TypeError):
27
+ normalize_header(None) # type: ignore[arg-type]
28
+ with self.assertRaises(TypeError):
29
+ normalize_header(123) # type: ignore[arg-type]
30
+
31
+ def test_security_no_forbidden_tokens_in_core_source(self):
32
+ forbidden = [
33
+ "sub" + "process",
34
+ "re" + "quests",
35
+ "ht" + "tpx",
36
+ "aio" + "http",
37
+ "urllib" + ".request",
38
+ ]
39
+ source_path = pathlib.Path(__file__).resolve().parents[1] / "src" / "minimindslab_header_normalize" / "__init__.py"
40
+ content = source_path.read_text(encoding="utf-8")
41
+ self.assertNotIn("ev" + "al(", content)
42
+ self.assertNotIn("ex" + "ec(", content)
43
+ for token in forbidden:
44
+ self.assertNotIn(token, content)
45
+
46
+
47
+ if __name__ == "__main__":
48
+ unittest.main()