sms-toolkit
A collection of tools used to send SMS messages.
Tools
Message Profiling
Accepts a raw SMS message string and determines its most efficient encoding, then determines how many segments would be used to send it.
Largely based on this tool (code found here).
The segmenting logic for GSM-7 and UCS-2 encoding follows these standards
Here is an example with simple ascii input, which will be profiled as GSM-7 format:
from sms_toolkit.messages.profiling import profile_message
profile_message("Sup chonus")
'''
# Outputs -
{
"num_segments": 1,
"segments": [
{
"message": "Sup chonus",
"total_segment_length": 10,
"unicode_character_list": [
"S", "u", "p", " ", "c", "h", "o", "n", "u", "s"
],
"byte_groups": [
[83], [117], [112], [32], [99], [104], [111], [110], [117], [115]
]
}
],
"message_length": 10,
"max_segment_size": 160
}
'''
Here is an example with non-ascii input, containing characters from BMP (represented as 2 bytes byte-group) and non-BMP (representing as 4 bytes in the byte-group) ranges which will be profiled as UCS-2 format:
from sms_toolkit.messages.profiling import profile_message
profile_message("fuel ⛽ fiⓇe 🔥 emojis 😉")
'''
# Outputs -
{
'num_segments': 1,
'segments': [
{
'message': 'fuel ⛽ fiⓇe 🔥 emojis 😉',
'unicode_character_list': [
'f', 'u', 'e', 'l', ' ', '⛽', ' ', 'f', 'i', 'Ⓡ', 'e', ' ', '🔥', ' ', 'e', 'm', 'o', 'j', 'i', 's', ' ', '😉'
],
'byte_groups': [
[0, 102], [0, 117], [0, 101], [0, 108], [0, 32], [38, 253], [0, 32], [0, 102], [0, 105], [36, 199], [0, 101], [0, 32], [216, 61, 221, 37], [0, 32], [0, 101], [0, 109], [0, 111], [0, 106], [0, 105], [0, 115], [0, 32], [216, 61, 222, 9]
],
'total_segment_length': 24
}
],
'message_length': 24,
'max_segment_size': 70
}
'''
Message Truncating
Accepts a raw SMS message string, and the maximum length and truncates it. This also detects the right encoding and adjusts the character length accordingly.
from sms_toolkit import truncate_message
truncate_message("fuel ⛽ fiⓇe 🔥 emojis 😉", 22)
'''
# Outputs -
'fuel ⛽ fiⓇe 🔥 emojis '
'''
Testing
This library needs is tested against python 2 and 3. Both interpreters need to be available to tox
pyenv versions # shows all versions available pyenv local 2.7.* 3.7.*
Run tests:
tox .
Acknowledgements
Klaviyo has adapted the original vobject packaged in to this package. We have only kept the vcard class from the original package, removing calendar functionality, etc.
Metadata
Release files for sms-toolkit 1.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sms-toolkit-1.0.9.tar.gz | 25.3 kB | Without provenance | Details for sms-toolkit-1.0.9.tar.gz |
Release files / sms-toolkit-1.0.9.tar.gz
| Download URL | sms-toolkit-1.0.9.tar.gz |
|---|---|
| Size | 25.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bc41d2a98e242a481088a26ebfa790c53b00904a24041703af48522e1a8a6c66
|
|
BLAKE2b-256 checksum How to use checksums |
a590a7fbf7aa49d19f722ef3e37dbba99d305a2ec370f11068cb2cd8cad778b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.8.2 requests/2.27.1 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/2.7.15
|
Security for sms-toolkit 1.0.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.