ingabotool 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 Developer
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,82 @@
1
+ Metadata-Version: 2.4
2
+ Name: ingabotool
3
+ Version: 0.1.0
4
+ Summary: A small, professional Python package for developer utilities.
5
+ Author: Developer
6
+ License: MIT License
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Dynamic: license-file
14
+
15
+ # ingabotool
16
+
17
+ A small, professional Python package that provides a set of reusable developer utilities for common text manipulation and validation tasks.
18
+
19
+ ## Features
20
+
21
+ - **`slugify`**: Convert text into URL-friendly strings.
22
+ - **`truncate`**: Safely truncate strings and append a suffix if they exceed a maximum length.
23
+ - **`is_valid_email`**: Perform practical validation of email formats.
24
+ - **`mask_email`**: Obfuscate email usernames while preserving the domain for privacy.
25
+ - **`generate_id`**: Generate short, unique alphanumeric identifiers with an optional prefix.
26
+
27
+ ## Installation for Local Development
28
+
29
+ You can install this package locally in editable mode. Navigate to the root directory of the package (where `pyproject.toml` is located) and run:
30
+
31
+ ```bash
32
+ pip install -e .
33
+ ```
34
+
35
+ To build the package distribution files:
36
+
37
+ ```bash
38
+ python -m build
39
+ ```
40
+ *(If `build` is not installed, install it via: `pip install build`)*
41
+
42
+ To run the test suite:
43
+
44
+ ```bash
45
+ python -m unittest discover -s tests
46
+ ```
47
+ *Note: Make sure your `PYTHONPATH` includes the `src` directory if not installing first, or run from the root directory.*
48
+
49
+
50
+ ## Usage Examples
51
+
52
+ ```python
53
+ from ingabotool import slugify, truncate, is_valid_email, mask_email, generate_id
54
+
55
+ # 1. slugify
56
+ print(slugify("Hello, World!"))
57
+ # Output: "hello-world"
58
+
59
+ # 2. truncate
60
+ print(truncate("This is a long sentence", 10))
61
+ # Output: "This is..."
62
+
63
+ # 3. is_valid_email
64
+ print(is_valid_email("user@example.com"))
65
+ # Output: True
66
+
67
+ # 4. mask_email
68
+ print(mask_email("john.doe@gmail.com"))
69
+ # Output: "j*******@gmail.com"
70
+
71
+ # 5. generate_id
72
+ print(generate_id("user"))
73
+ # Output: "user_a8f31c4b" (random)
74
+ ```
75
+
76
+ ## Available Functions
77
+
78
+ - `slugify(text: str) -> str`
79
+ - `truncate(text: str, max_length: int, suffix: str = "...") -> str`
80
+ - `is_valid_email(email: str) -> bool`
81
+ - `mask_email(email: str) -> str`
82
+ - `generate_id(prefix: str = "id") -> str`
@@ -0,0 +1,68 @@
1
+ # ingabotool
2
+
3
+ A small, professional Python package that provides a set of reusable developer utilities for common text manipulation and validation tasks.
4
+
5
+ ## Features
6
+
7
+ - **`slugify`**: Convert text into URL-friendly strings.
8
+ - **`truncate`**: Safely truncate strings and append a suffix if they exceed a maximum length.
9
+ - **`is_valid_email`**: Perform practical validation of email formats.
10
+ - **`mask_email`**: Obfuscate email usernames while preserving the domain for privacy.
11
+ - **`generate_id`**: Generate short, unique alphanumeric identifiers with an optional prefix.
12
+
13
+ ## Installation for Local Development
14
+
15
+ You can install this package locally in editable mode. Navigate to the root directory of the package (where `pyproject.toml` is located) and run:
16
+
17
+ ```bash
18
+ pip install -e .
19
+ ```
20
+
21
+ To build the package distribution files:
22
+
23
+ ```bash
24
+ python -m build
25
+ ```
26
+ *(If `build` is not installed, install it via: `pip install build`)*
27
+
28
+ To run the test suite:
29
+
30
+ ```bash
31
+ python -m unittest discover -s tests
32
+ ```
33
+ *Note: Make sure your `PYTHONPATH` includes the `src` directory if not installing first, or run from the root directory.*
34
+
35
+
36
+ ## Usage Examples
37
+
38
+ ```python
39
+ from ingabotool import slugify, truncate, is_valid_email, mask_email, generate_id
40
+
41
+ # 1. slugify
42
+ print(slugify("Hello, World!"))
43
+ # Output: "hello-world"
44
+
45
+ # 2. truncate
46
+ print(truncate("This is a long sentence", 10))
47
+ # Output: "This is..."
48
+
49
+ # 3. is_valid_email
50
+ print(is_valid_email("user@example.com"))
51
+ # Output: True
52
+
53
+ # 4. mask_email
54
+ print(mask_email("john.doe@gmail.com"))
55
+ # Output: "j*******@gmail.com"
56
+
57
+ # 5. generate_id
58
+ print(generate_id("user"))
59
+ # Output: "user_a8f31c4b" (random)
60
+ ```
61
+
62
+ ## Available Functions
63
+
64
+ - `slugify(text: str) -> str`
65
+ - `truncate(text: str, max_length: int, suffix: str = "...") -> str`
66
+ - `is_valid_email(email: str) -> bool`
67
+ - `mask_email(email: str) -> str`
68
+ - `generate_id(prefix: str = "id") -> str`
@@ -0,0 +1,19 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ingabotool"
7
+ version = "0.1.0"
8
+ description = "A small, professional Python package for developer utilities."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = {text = "MIT License"}
12
+ authors = [
13
+ {name = "Developer"}
14
+ ]
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,4 @@
1
+ from .text_utils import slugify, truncate, is_valid_email, mask_email, generate_id
2
+
3
+ __version__ = "0.1.0"
4
+ __all__ = ["slugify", "truncate", "is_valid_email", "mask_email", "generate_id"]
@@ -0,0 +1,86 @@
1
+ import re
2
+ import uuid
3
+
4
+ def slugify(text: str) -> str:
5
+ """
6
+ Convert text to lowercase, remove unnecessary punctuation,
7
+ and replace spaces and repeated separators with a single hyphen.
8
+ """
9
+ if not isinstance(text, str):
10
+ raise TypeError("Input must be a string")
11
+
12
+ text = text.lower()
13
+ # Remove punctuation except spaces and hyphens
14
+ text = re.sub(r'[^\w\s-]', '', text)
15
+ # Replace spaces and repeated hyphens with a single hyphen
16
+ text = re.sub(r'[\s-]+', '-', text)
17
+ # Strip leading/trailing hyphens
18
+ return text.strip('-')
19
+
20
+
21
+ def truncate(text: str, max_length: int, suffix: str = "...") -> str:
22
+ """
23
+ Return the original text if it fits within max_length.
24
+ Otherwise truncate it and append the suffix.
25
+ The final result will not exceed max_length.
26
+ """
27
+ if not isinstance(text, str):
28
+ raise TypeError("Text must be a string")
29
+ if not isinstance(max_length, int) or max_length < 0:
30
+ raise ValueError("max_length must be a non-negative integer")
31
+ if len(suffix) > max_length:
32
+ raise ValueError("suffix length cannot be greater than max_length")
33
+
34
+ if len(text) <= max_length:
35
+ return text
36
+
37
+ return text[:max_length - len(suffix)] + suffix
38
+
39
+
40
+ def is_valid_email(email: str) -> bool:
41
+ """
42
+ Perform a simple practical email-format validation.
43
+ """
44
+ if not isinstance(email, str):
45
+ return False
46
+ # Simple regex for practical validation: something@something.something
47
+ pattern = r'^[^@\s]+@[^@\s]+\.[^@\s]+$'
48
+ return bool(re.match(pattern, email))
49
+
50
+
51
+ def mask_email(email: str) -> str:
52
+ """
53
+ Hide part of the username while keeping the domain visible.
54
+ """
55
+ if not isinstance(email, str) or '@' not in email:
56
+ return email
57
+
58
+ parts = email.split('@')
59
+ if len(parts) != 2:
60
+ return email
61
+
62
+ username, domain = parts
63
+
64
+ # Handle empty username
65
+ if not username:
66
+ return f"@{domain}"
67
+
68
+ if len(username) > 1:
69
+ masked_username = username[0] + "*" * (len(username) - 1)
70
+ else:
71
+ masked_username = "*" * len(username)
72
+
73
+ return f"{masked_username}@{domain}"
74
+
75
+
76
+ def generate_id(prefix: str = "id") -> str:
77
+ """
78
+ Generate a short unique identifier using Python's standard library.
79
+ """
80
+ if not isinstance(prefix, str):
81
+ raise TypeError("Prefix must be a string")
82
+
83
+ unique_part = uuid.uuid4().hex[:8]
84
+ if prefix:
85
+ return f"{prefix}_{unique_part}"
86
+ return unique_part
@@ -0,0 +1,82 @@
1
+ Metadata-Version: 2.4
2
+ Name: ingabotool
3
+ Version: 0.1.0
4
+ Summary: A small, professional Python package for developer utilities.
5
+ Author: Developer
6
+ License: MIT License
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Dynamic: license-file
14
+
15
+ # ingabotool
16
+
17
+ A small, professional Python package that provides a set of reusable developer utilities for common text manipulation and validation tasks.
18
+
19
+ ## Features
20
+
21
+ - **`slugify`**: Convert text into URL-friendly strings.
22
+ - **`truncate`**: Safely truncate strings and append a suffix if they exceed a maximum length.
23
+ - **`is_valid_email`**: Perform practical validation of email formats.
24
+ - **`mask_email`**: Obfuscate email usernames while preserving the domain for privacy.
25
+ - **`generate_id`**: Generate short, unique alphanumeric identifiers with an optional prefix.
26
+
27
+ ## Installation for Local Development
28
+
29
+ You can install this package locally in editable mode. Navigate to the root directory of the package (where `pyproject.toml` is located) and run:
30
+
31
+ ```bash
32
+ pip install -e .
33
+ ```
34
+
35
+ To build the package distribution files:
36
+
37
+ ```bash
38
+ python -m build
39
+ ```
40
+ *(If `build` is not installed, install it via: `pip install build`)*
41
+
42
+ To run the test suite:
43
+
44
+ ```bash
45
+ python -m unittest discover -s tests
46
+ ```
47
+ *Note: Make sure your `PYTHONPATH` includes the `src` directory if not installing first, or run from the root directory.*
48
+
49
+
50
+ ## Usage Examples
51
+
52
+ ```python
53
+ from ingabotool import slugify, truncate, is_valid_email, mask_email, generate_id
54
+
55
+ # 1. slugify
56
+ print(slugify("Hello, World!"))
57
+ # Output: "hello-world"
58
+
59
+ # 2. truncate
60
+ print(truncate("This is a long sentence", 10))
61
+ # Output: "This is..."
62
+
63
+ # 3. is_valid_email
64
+ print(is_valid_email("user@example.com"))
65
+ # Output: True
66
+
67
+ # 4. mask_email
68
+ print(mask_email("john.doe@gmail.com"))
69
+ # Output: "j*******@gmail.com"
70
+
71
+ # 5. generate_id
72
+ print(generate_id("user"))
73
+ # Output: "user_a8f31c4b" (random)
74
+ ```
75
+
76
+ ## Available Functions
77
+
78
+ - `slugify(text: str) -> str`
79
+ - `truncate(text: str, max_length: int, suffix: str = "...") -> str`
80
+ - `is_valid_email(email: str) -> bool`
81
+ - `mask_email(email: str) -> str`
82
+ - `generate_id(prefix: str = "id") -> str`
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/ingabotool/__init__.py
5
+ src/ingabotool/text_utils.py
6
+ src/ingabotool.egg-info/PKG-INFO
7
+ src/ingabotool.egg-info/SOURCES.txt
8
+ src/ingabotool.egg-info/dependency_links.txt
9
+ src/ingabotool.egg-info/top_level.txt
10
+ tests/test_text_utils.py
@@ -0,0 +1 @@
1
+ ingabotool
@@ -0,0 +1,54 @@
1
+ import unittest
2
+ from ingabotool import slugify, truncate, is_valid_email, mask_email, generate_id
3
+
4
+ class TestTextUtils(unittest.TestCase):
5
+
6
+ def test_slugify(self):
7
+ self.assertEqual(slugify("Hello, World!"), "hello-world")
8
+ self.assertEqual(slugify(" Spaces and-hyphens "), "spaces-and-hyphens")
9
+ self.assertEqual(slugify("multiple---hyphens"), "multiple-hyphens")
10
+ self.assertEqual(slugify(""), "")
11
+ with self.assertRaises(TypeError):
12
+ slugify(123)
13
+
14
+ def test_truncate(self):
15
+ self.assertEqual(truncate("hello world", 8), "hello...")
16
+ self.assertEqual(truncate("hello world", 15), "hello world")
17
+ self.assertEqual(truncate("hello", 10), "hello")
18
+ self.assertEqual(truncate("hello world", 7, ".."), "hello..")
19
+ with self.assertRaises(ValueError):
20
+ truncate("hello", 2, "...")
21
+ with self.assertRaises(ValueError):
22
+ truncate("hello", -1)
23
+
24
+ def test_is_valid_email(self):
25
+ self.assertTrue(is_valid_email("john.doe@gmail.com"))
26
+ self.assertTrue(is_valid_email("user.name+tag@example.co.uk"))
27
+ self.assertFalse(is_valid_email("invalid-email"))
28
+ self.assertFalse(is_valid_email("missing@domain"))
29
+ self.assertFalse(is_valid_email("@domain.com"))
30
+ self.assertFalse(is_valid_email(""))
31
+ self.assertFalse(is_valid_email(None))
32
+
33
+ def test_mask_email(self):
34
+ self.assertEqual(mask_email("john.doe@gmail.com"), "j*******@gmail.com")
35
+ self.assertEqual(mask_email("a@b.com"), "*@b.com")
36
+ self.assertEqual(mask_email("invalid"), "invalid")
37
+ self.assertEqual(mask_email(""), "")
38
+ self.assertEqual(mask_email("@b.com"), "@b.com")
39
+
40
+ def test_generate_id(self):
41
+ id1 = generate_id("user")
42
+ id2 = generate_id("user")
43
+ self.assertTrue(id1.startswith("user_"))
44
+ self.assertNotEqual(id1, id2)
45
+
46
+ id3 = generate_id()
47
+ self.assertTrue(id3.startswith("id_"))
48
+
49
+ id4 = generate_id("")
50
+ self.assertTrue(len(id4) == 8)
51
+ self.assertNotIn("_", id4)
52
+
53
+ if __name__ == "__main__":
54
+ unittest.main()