holytext-lib 0.0.3__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.
- holytext/__init__.py +13 -0
- holytext/analyze.py +23 -0
- holytext/format.py +35 -0
- holytext/transform.py +23 -0
- holytext_lib-0.0.3.dist-info/METADATA +45 -0
- holytext_lib-0.0.3.dist-info/RECORD +9 -0
- holytext_lib-0.0.3.dist-info/WHEEL +5 -0
- holytext_lib-0.0.3.dist-info/licenses/LICENSE +21 -0
- holytext_lib-0.0.3.dist-info/top_level.txt +1 -0
holytext/__init__.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
__version__ = "0.0.3"
|
|
2
|
+
__all__ = [
|
|
3
|
+
"reverse",
|
|
4
|
+
"upper_first",
|
|
5
|
+
"count_words",
|
|
6
|
+
"is_palindrome",
|
|
7
|
+
"truncate",
|
|
8
|
+
"slugify"
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
from .transform import reverse, upper_first
|
|
12
|
+
from .analyze import count_words, is_palindrome
|
|
13
|
+
from .format import truncate, slugify
|
holytext/analyze.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
def count_words(text):
|
|
2
|
+
"""
|
|
3
|
+
Возвращает количество слов в строке.
|
|
4
|
+
"""
|
|
5
|
+
if isinstance(text, str):
|
|
6
|
+
words = text.split()
|
|
7
|
+
return len(words)
|
|
8
|
+
else:
|
|
9
|
+
text_type = type(text).__name__
|
|
10
|
+
raise TypeError(f"count_words() expected str, got {text_type}")
|
|
11
|
+
|
|
12
|
+
def is_palindrome(text):
|
|
13
|
+
"""
|
|
14
|
+
Проверяет, является ли строка палиндромом.
|
|
15
|
+
"""
|
|
16
|
+
if isinstance(text, str):
|
|
17
|
+
r = text[::-1].lower()
|
|
18
|
+
if r == text.lower():
|
|
19
|
+
return True
|
|
20
|
+
else: return False
|
|
21
|
+
else:
|
|
22
|
+
text_type = type(text).__name__
|
|
23
|
+
raise TypeError(f"is_palindrome() expected str, got {text_type}")
|
holytext/format.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
def truncate(text, num):
|
|
2
|
+
"""
|
|
3
|
+
Возвращает строку, ограниченную указанным количеством символов.
|
|
4
|
+
"""
|
|
5
|
+
if isinstance(text, str) and isinstance(num, int) and num>0:
|
|
6
|
+
if len(text) > num:
|
|
7
|
+
return text[:num] + "..."
|
|
8
|
+
else:
|
|
9
|
+
return text[:num]
|
|
10
|
+
elif isinstance(num, int) and num <= 0:
|
|
11
|
+
raise ValueError("truncate() expected truncate(str, num) num>0")
|
|
12
|
+
else:
|
|
13
|
+
text_type = type(text).__name__
|
|
14
|
+
num_type = type(num).__name__
|
|
15
|
+
raise TypeError(f"truncate() expected truncate(str, int), got truncate({text_type}, {num_type})")
|
|
16
|
+
|
|
17
|
+
def slugify(text):
|
|
18
|
+
"""
|
|
19
|
+
Возвращает строку в формате slug для использования в URL.
|
|
20
|
+
"""
|
|
21
|
+
if isinstance(text, str):
|
|
22
|
+
r0 = text.lower()
|
|
23
|
+
r1 = r0.split()
|
|
24
|
+
cw = []
|
|
25
|
+
for word in r1:
|
|
26
|
+
clean_word = ''
|
|
27
|
+
for ch in word:
|
|
28
|
+
if ch.isalnum():
|
|
29
|
+
clean_word += ch
|
|
30
|
+
if clean_word != '':
|
|
31
|
+
cw.append(clean_word)
|
|
32
|
+
return "-".join(cw)
|
|
33
|
+
else:
|
|
34
|
+
text_type = type(text).__name__
|
|
35
|
+
raise TypeError(f"slugify() expected str, got {text_type}")
|
holytext/transform.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
def reverse(text):
|
|
2
|
+
"""
|
|
3
|
+
Возвращает перевёрнутую версиб текста иои целого числа.
|
|
4
|
+
"""
|
|
5
|
+
if isinstance(text, str):
|
|
6
|
+
return text[::-1]
|
|
7
|
+
elif isinstance(text, int):
|
|
8
|
+
sign = -1 if text < 0 else 1
|
|
9
|
+
return sign * int(str(abs(text))[::-1])
|
|
10
|
+
else:
|
|
11
|
+
text_type = type(text).__name__
|
|
12
|
+
raise TypeError(f"reverse() expected str or int, got {text_type}")
|
|
13
|
+
|
|
14
|
+
def upper_first(text):
|
|
15
|
+
"""
|
|
16
|
+
Влзвращает строку с заглавным первым символом.
|
|
17
|
+
"""
|
|
18
|
+
if isinstance(text, str):
|
|
19
|
+
if text == "": return ""
|
|
20
|
+
else: return text[0].upper() + text[1:]
|
|
21
|
+
else:
|
|
22
|
+
text_type = type(text).__name__
|
|
23
|
+
raise TypeError(f"upper_first() expected str, got {text_type}")
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: holytext-lib
|
|
3
|
+
Version: 0.0.3
|
|
4
|
+
Summary: A simple Python library.
|
|
5
|
+
Author: German Stroheim
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 German Stroheim
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Requires-Python: >=3.10
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# HolyText
|
|
34
|
+
|
|
35
|
+
A simple Python library.
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
pip install holytext
|
|
40
|
+
|
|
41
|
+
## Example
|
|
42
|
+
|
|
43
|
+
from holytext import reverse
|
|
44
|
+
|
|
45
|
+
print(reverse("Hello"))
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
holytext/__init__.py,sha256=N9jwfbDqtXJUQgFkGOUfCxLjtF2JOwK8-e-8WlC5jNs,271
|
|
2
|
+
holytext/analyze.py,sha256=PMvJxAySSvIGpnNiplH2_zo-XPpQ3x9Q3m8FXx3giFg,717
|
|
3
|
+
holytext/format.py,sha256=XHAjPVfq5w5-bU2UkVYh-puZH1Yp_C3yCaP8IAkrYvw,1253
|
|
4
|
+
holytext/transform.py,sha256=sC7Dr5gjM9L3KXN-rBEefpCDecfOo4wLUf7h1aUFIzo,805
|
|
5
|
+
holytext_lib-0.0.3.dist-info/licenses/LICENSE,sha256=dAqALDuHGAQo9NU5toNNZBDhLddmDFaZrAv047jB3V0,1072
|
|
6
|
+
holytext_lib-0.0.3.dist-info/METADATA,sha256=cK4WMu4pRJU4AQNBhvsDrBNKikfJ764t6RgMUhRihdI,1616
|
|
7
|
+
holytext_lib-0.0.3.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
8
|
+
holytext_lib-0.0.3.dist-info/top_level.txt,sha256=6FZNkEyrRxYTUMlSKetZ28VRIfVJW9Yunl_tfdR4eZI,9
|
|
9
|
+
holytext_lib-0.0.3.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 German Stroheim
|
|
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
|
+
holytext
|