reach_commons 0.15.6__py3-none-any.whl → 0.15.7__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,40 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from math import ceil
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class MessageSmartEncoding:
|
|
7
|
+
"""
|
|
8
|
+
Sms Message Representation
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
replacements = {
|
|
12
|
+
"“": '"',
|
|
13
|
+
"”": '"',
|
|
14
|
+
"‘": "'",
|
|
15
|
+
"’": "'",
|
|
16
|
+
"–": "-",
|
|
17
|
+
"—": "-",
|
|
18
|
+
"…": "...",
|
|
19
|
+
"•": "-",
|
|
20
|
+
"€": "EUR",
|
|
21
|
+
"™": "",
|
|
22
|
+
"©": "",
|
|
23
|
+
"®": "",
|
|
24
|
+
"\u0002": "",
|
|
25
|
+
"\u001b": "",
|
|
26
|
+
}
|
|
27
|
+
body: str
|
|
28
|
+
normalized_text: str = field(init=False)
|
|
29
|
+
length: int = field(init=False)
|
|
30
|
+
segments: int = field(init=False)
|
|
31
|
+
|
|
32
|
+
def __post_init__(self):
|
|
33
|
+
self.normalized_text = self.normalize(self.body)
|
|
34
|
+
self.length = len(self.normalized_text)
|
|
35
|
+
self.segments = ceil(self.length / 160)
|
|
36
|
+
|
|
37
|
+
def normalize(self, text: str) -> str:
|
|
38
|
+
for char, replacement in self.replacements.items():
|
|
39
|
+
text = text.replace(char, replacement)
|
|
40
|
+
return text
|
|
@@ -24,8 +24,9 @@ reach_commons/reach_aws/s3.py,sha256=KLWvlQVakaaGfFg3110QHc1PlxCb1pUhmJQ-VggLEj4
|
|
|
24
24
|
reach_commons/reach_aws/sqs.py,sha256=Xm4JzYX76NJmAFhHFA4cKyRVpXCkuFFWZIqsbDnkeKI,15420
|
|
25
25
|
reach_commons/reach_base_model.py,sha256=uMmDGjwKTZ3h7f8Pfvc99FCsAt5eZNlUJnLLbB5EqGY,2907
|
|
26
26
|
reach_commons/redis_manager.py,sha256=_4FOYPMapwRmWU-5SO1Bm0Cb__Ngkx2hrOPlrJETzX0,1896
|
|
27
|
+
reach_commons/sms_smart_encoding.py,sha256=81byimk8zydNsj1wYdYsF4n96Lw4GQOBmKOu-GiYY9s,993
|
|
27
28
|
reach_commons/utils.py,sha256=dMgKIGqTgoSItuBI8oz81gKtW3qi21Jkljv9leS_V88,8475
|
|
28
29
|
reach_commons/validations.py,sha256=jc78boM62S9Z0Ip_nV1z7I983gGpW2Y7vOCQtmia8OU,964
|
|
29
|
-
reach_commons-0.15.
|
|
30
|
-
reach_commons-0.15.
|
|
31
|
-
reach_commons-0.15.
|
|
30
|
+
reach_commons-0.15.7.dist-info/METADATA,sha256=EpIypPocnOxwXnljNfUOipEluFKIHIY-SDZgCAKG70U,1860
|
|
31
|
+
reach_commons-0.15.7.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
32
|
+
reach_commons-0.15.7.dist-info/RECORD,,
|
|
File without changes
|