textutils-strickerman 0.2.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.
- casing/__init__.py +4 -0
- casing/_capitalize_words.py +28 -0
- casing/_kebab_case.py +24 -0
- textutils_strickerman-0.2.0.dist-info/METADATA +99 -0
- textutils_strickerman-0.2.0.dist-info/RECORD +12 -0
- textutils_strickerman-0.2.0.dist-info/WHEEL +5 -0
- textutils_strickerman-0.2.0.dist-info/licenses/LICENSE +21 -0
- textutils_strickerman-0.2.0.dist-info/top_level.txt +2 -0
- transform/__init__.py +5 -0
- transform/_character_count.py +25 -0
- transform/_reverse.py +22 -0
- transform/_word_count.py +25 -0
casing/__init__.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
def capitalize_words(text: str) -> str:
|
|
2
|
+
"""Capitalize the first letter of each word in a string.
|
|
3
|
+
|
|
4
|
+
Parameters
|
|
5
|
+
----------
|
|
6
|
+
text : str
|
|
7
|
+
The input string to transform.
|
|
8
|
+
|
|
9
|
+
Returns
|
|
10
|
+
-------
|
|
11
|
+
str
|
|
12
|
+
The string with each word capitalized.
|
|
13
|
+
|
|
14
|
+
Raises
|
|
15
|
+
------
|
|
16
|
+
TypeError
|
|
17
|
+
If text is not a string.
|
|
18
|
+
"""
|
|
19
|
+
if not isinstance(text, str):
|
|
20
|
+
raise TypeError("text must be a string")
|
|
21
|
+
|
|
22
|
+
words = text.split(" ")
|
|
23
|
+
words_capitalised = []
|
|
24
|
+
|
|
25
|
+
for word in words:
|
|
26
|
+
words_capitalised.append(word.capitalize())
|
|
27
|
+
|
|
28
|
+
return " ".join(words_capitalised)
|
casing/_kebab_case.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
def kebab_case(text: str) -> str:
|
|
2
|
+
"""Convert a string to kebab-case format.
|
|
3
|
+
|
|
4
|
+
Parameters
|
|
5
|
+
----------
|
|
6
|
+
text : str
|
|
7
|
+
The input string to transform.
|
|
8
|
+
|
|
9
|
+
Returns
|
|
10
|
+
-------
|
|
11
|
+
str
|
|
12
|
+
The input string converted to kebab-case.
|
|
13
|
+
|
|
14
|
+
Raises
|
|
15
|
+
------
|
|
16
|
+
TypeError
|
|
17
|
+
If text is not a string.
|
|
18
|
+
"""
|
|
19
|
+
if not isinstance(text, str):
|
|
20
|
+
raise TypeError("text must be a string")
|
|
21
|
+
|
|
22
|
+
clean_text = text.replace("_", " ").strip()
|
|
23
|
+
words = clean_text.split()
|
|
24
|
+
return "-".join(words).lower()
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: textutils-strickerman
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: A utility package for text manipulation and analysis.
|
|
5
|
+
Author: Esteban Stricker
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Provides-Extra: dev
|
|
10
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
11
|
+
Requires-Dist: pytest-cov>=5.0; extra == "dev"
|
|
12
|
+
Requires-Dist: black>=24.0; extra == "dev"
|
|
13
|
+
Requires-Dist: ruff>=0.3.0; extra == "dev"
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# textutils
|
|
17
|
+
|
|
18
|
+
A lightweight Python library providing common text-processing and manipulation utilities.
|
|
19
|
+
Developed as part of the *Open Source Development* course at ENSISA, Université de Haute-Alsace.
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
This initial version provides essential string manipulation tools:
|
|
24
|
+
* `word_count(text)`: Counts the number of words in a given text string.
|
|
25
|
+
* `character_count(text)`: Returns the total number of characters in the string.
|
|
26
|
+
* `reverse(text)`: Returns the string reversed character by character.
|
|
27
|
+
* `capitalize_words(text)`: Capitalizes the first letter of each word in the string.
|
|
28
|
+
|
|
29
|
+
*(Planned features for upcoming versions: `snake_case()`, `camel_case()`, and `slugify()`)*
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
### For Users
|
|
34
|
+
Install the package directly via `pip`:
|
|
35
|
+
```bash
|
|
36
|
+
pip install textutils
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### For Development / Contributors
|
|
40
|
+
Clone the repository and install it in editable mode with development dependencies:
|
|
41
|
+
```bash
|
|
42
|
+
git clone https://github.com/<your-username>/textutils.git
|
|
43
|
+
cd textutils
|
|
44
|
+
pip install -e .[dev]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
Here is a quick example demonstrating how to import and use the functions:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from textutils import (
|
|
53
|
+
capitalize_words,
|
|
54
|
+
character_count,
|
|
55
|
+
reverse,
|
|
56
|
+
word_count,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
sample_text = "hello open source world"
|
|
60
|
+
|
|
61
|
+
# 1. Count words
|
|
62
|
+
print(word_count(sample_text)) # Output: 4
|
|
63
|
+
|
|
64
|
+
# 2. Count characters
|
|
65
|
+
print(character_count(sample_text)) # Output: 23
|
|
66
|
+
|
|
67
|
+
# 3. Capitalize words
|
|
68
|
+
print(capitalize_words(sample_text)) # Output: "Hello Open Source World"
|
|
69
|
+
|
|
70
|
+
# 4. Reverse text
|
|
71
|
+
print(reverse(sample_text)) # Output: "dlrow ecruos nepo olleh"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Contributing
|
|
75
|
+
|
|
76
|
+
Contributions are welcome! To contribute to this project, please follow these steps:
|
|
77
|
+
|
|
78
|
+
1. Fork the repository.
|
|
79
|
+
2. Create a dedicated branch for your feature or fix:
|
|
80
|
+
```bash
|
|
81
|
+
git switch -c feature/my-new-feature
|
|
82
|
+
```
|
|
83
|
+
3. Commit your changes with clear, descriptive commit messages:
|
|
84
|
+
```bash
|
|
85
|
+
git commit -m "Add unit tests for capitalize_words"
|
|
86
|
+
```
|
|
87
|
+
4. Push your branch to your fork:
|
|
88
|
+
```bash
|
|
89
|
+
git push origin feature/my-new-feature
|
|
90
|
+
```
|
|
91
|
+
5. Open a Pull Request on GitHub describing your modifications.
|
|
92
|
+
|
|
93
|
+
## Author
|
|
94
|
+
|
|
95
|
+
**Esteban Stricker**
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
This project is licensed under the MIT License.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
casing/__init__.py,sha256=cYCnCYIbtbsLbs5_60e-owLJVUNaeI3mOuS-3h7whyU,129
|
|
2
|
+
casing/_capitalize_words.py,sha256=gYBrxOLDNQDQZzLjtpHvq_J6QDWoQOlv_BOZLxl81gw,598
|
|
3
|
+
casing/_kebab_case.py,sha256=yq9Pjj_NX0eqBwRfIr2tcsORZj9kyLl3kWi9-HDsFeY,523
|
|
4
|
+
textutils_strickerman-0.2.0.dist-info/licenses/LICENSE,sha256=GQyykhDrWjVzg8DPEAYRefggkUgk7-dNwEEF6GDUJco,1073
|
|
5
|
+
transform/__init__.py,sha256=ln29mb82KJDkaeqd40g4VKr2jiNvp2pBcZQX0YWl03E,168
|
|
6
|
+
transform/_character_count.py,sha256=5Y9-8wrQ1rSGzGTuehJ88d4pzY_Nnxx9zDx5W8p8z3I,478
|
|
7
|
+
transform/_reverse.py,sha256=TA2OE7xdZqQXeXNS43KgubKPWmS4wfwsr3Q9uMbpWW4,385
|
|
8
|
+
transform/_word_count.py,sha256=8wVCDyttLq1jJKm6VnWqE9gHPseddPE4AJfYKVZpuM0,471
|
|
9
|
+
textutils_strickerman-0.2.0.dist-info/METADATA,sha256=jeyAs0CrB2SbL3dEhQ5gw9Qbv0DAZA4RpqKKxRXvo_8,2680
|
|
10
|
+
textutils_strickerman-0.2.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
11
|
+
textutils_strickerman-0.2.0.dist-info/top_level.txt,sha256=uz71-K1n4QmBG7-KLtqa0D5OLjrITLttjVLidw10kH8,17
|
|
12
|
+
textutils_strickerman-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Esteban Stricker
|
|
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.
|
transform/__init__.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
def character_count(text: str) -> int:
|
|
2
|
+
"""Count the total number of characters in a string.
|
|
3
|
+
|
|
4
|
+
Parameters
|
|
5
|
+
----------
|
|
6
|
+
text : str
|
|
7
|
+
The input string to analyze.
|
|
8
|
+
|
|
9
|
+
Returns
|
|
10
|
+
-------
|
|
11
|
+
int
|
|
12
|
+
The number of characters in the string.
|
|
13
|
+
|
|
14
|
+
Raises
|
|
15
|
+
------
|
|
16
|
+
TypeError
|
|
17
|
+
If text is not a string.
|
|
18
|
+
"""
|
|
19
|
+
if not isinstance(text, str):
|
|
20
|
+
raise TypeError("text must be a string")
|
|
21
|
+
|
|
22
|
+
if not text:
|
|
23
|
+
return 0
|
|
24
|
+
|
|
25
|
+
return len(text)
|
transform/_reverse.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
def reverse(text: str) -> str:
|
|
2
|
+
"""Reverse a string.
|
|
3
|
+
|
|
4
|
+
Parameters
|
|
5
|
+
----------
|
|
6
|
+
text : str
|
|
7
|
+
The input string to reverse.
|
|
8
|
+
|
|
9
|
+
Returns
|
|
10
|
+
-------
|
|
11
|
+
str
|
|
12
|
+
The string reversed.
|
|
13
|
+
|
|
14
|
+
Raises
|
|
15
|
+
------
|
|
16
|
+
TypeError
|
|
17
|
+
If text is not a string.
|
|
18
|
+
"""
|
|
19
|
+
if not isinstance(text, str):
|
|
20
|
+
raise TypeError("text must be a string")
|
|
21
|
+
|
|
22
|
+
return text[::-1]
|
transform/_word_count.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
def word_count(text: str) -> int:
|
|
2
|
+
"""Count the total number of words in a string.
|
|
3
|
+
|
|
4
|
+
Parameters
|
|
5
|
+
----------
|
|
6
|
+
text : str
|
|
7
|
+
The input string to analyze.
|
|
8
|
+
|
|
9
|
+
Returns
|
|
10
|
+
-------
|
|
11
|
+
int
|
|
12
|
+
The number of words in the string.
|
|
13
|
+
|
|
14
|
+
Raises
|
|
15
|
+
------
|
|
16
|
+
TypeError
|
|
17
|
+
If text is not a string.
|
|
18
|
+
"""
|
|
19
|
+
if not isinstance(text, str):
|
|
20
|
+
raise TypeError("text must be a string")
|
|
21
|
+
|
|
22
|
+
if not text:
|
|
23
|
+
return 0
|
|
24
|
+
|
|
25
|
+
return len(text.split())
|