Name | traisms JSON |
Version |
0.1.0
JSON |
| download |
home_page | None |
Summary | This package to replace content in the TRAI SMS template |
upload_time | 2024-04-03 05:29:00 |
maintainer | None |
docs_url | None |
author | Deepak Pant |
requires_python | >=3.7 |
license | None |
keywords |
python
trai
sms
replace
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# TRAI SMS Template Replacer
Replace content in the TRAI SMS template with ease using this Python package. This library is designed to simplify the process of replacing placeholders in a TRAI SMS template with actual values. It's particularly useful for bulk SMS generation where you need to personalize messages based on dynamic data.
## Installation
You can install the `traisms` library using pip:
```bash
pip install traisms
```
## Usage
To get started, import the library and create an instance of the `SMSTemplate` class:
```python
from traisms import SMSTemplate
template = 'Hi, %%|name^{"inputtype" : "text", "maxlength" : "8"}%% has checked out at %%|time^{"inputtype" : "number", "maxlength" : "6"}%% PM from %%|place^{"inputtype" : "text", "maxlength" : "64"}%%'
values = ["Alice", "2", "Taj Hotel"]
```
Then, simply replace the placeholders in the template with the provided values using the `replace` method:
```python
try:
result = SMSTemplate.replace(template, values)
print(result)
except Exception as e:
print(e)
```
The `replace` method will return the updated template with the values substituted in place of the placeholders. If there are any validation errors, the library will raise relevant exceptions:
- **Invalid Template Error**: This error is raised if a placeholder in the template is not valid.
- **Invalid Number Found**: This error is raised if a placeholder expects a numeric value but a non-numeric value is provided.
- **Exceeded Max Length**: This error is raised if a placeholder value exceeds its specified maximum length.
Example Error Handling:
```python
# Output:
# Invalid Number Found: Can not replace "1233" expecting numeric value
# or
# Output:
# Exceeded Max Length: Can not replace "Alice" exceeding max length of 8
```
## Template Syntax
The template follows a specific syntax for placeholders, which are enclosed within double percentage signs (e.g., `%%`). Each placeholder should have the following format:
```
%%|name^{"inputtype" : "text", "maxlength" : "8"}%%
```
- `name`: Placeholder ID
- `{"inputtype" : "text", "maxlength" : "8"}`: Placeholder attributes (optional)
You can customize the placeholder attributes as needed.
## Features
- Easy replacement of placeholders in TRAI SMS templates.
- Support for dynamic values provided in a list.
- Customizable placeholder attributes for flexibility.
- Validation and error handling for template placeholders.
- Suitable for bulk SMS generation and personalization.
## License
This library is provided under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).
## Contributions
Contributions and feedback are welcome! If you encounter any issues or have suggestions for improvements, please [open an issue](https://github.com/DeepakPant93/trai-sms-template-replacer/issues) or submit a pull request.
---
**Note**: This library is not affiliated with TRAI (Telecom Regulatory Authority of India) but is designed to assist in formatting SMS messages according to TRAI guidelines.
Happy SMS templating! 📱✉️
Raw data
{
"_id": null,
"home_page": null,
"name": "traisms",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "python, trai, sms, replace",
"author": "Deepak Pant",
"author_email": "<deepak.93p@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/ed/4f/24ae353c329dd1a3665dedce6a74877db3ed3ac0b16c502b9f662f4b0127/traisms-0.1.0.tar.gz",
"platform": null,
"description": "\n# TRAI SMS Template Replacer\n\nReplace content in the TRAI SMS template with ease using this Python package. This library is designed to simplify the process of replacing placeholders in a TRAI SMS template with actual values. It's particularly useful for bulk SMS generation where you need to personalize messages based on dynamic data.\n\n## Installation\n\nYou can install the `traisms` library using pip: \n\n```bash\npip install traisms\n```\n\n## Usage\n\nTo get started, import the library and create an instance of the `SMSTemplate` class:\n\n```python\nfrom traisms import SMSTemplate\n\ntemplate = 'Hi, %%|name^{\"inputtype\" : \"text\", \"maxlength\" : \"8\"}%% has checked out at %%|time^{\"inputtype\" : \"number\", \"maxlength\" : \"6\"}%% PM from %%|place^{\"inputtype\" : \"text\", \"maxlength\" : \"64\"}%%'\nvalues = [\"Alice\", \"2\", \"Taj Hotel\"]\n\n```\n\nThen, simply replace the placeholders in the template with the provided values using the `replace` method:\n\n```python\ntry:\n result = SMSTemplate.replace(template, values)\n print(result)\nexcept Exception as e:\n print(e)\n```\n\nThe `replace` method will return the updated template with the values substituted in place of the placeholders. If there are any validation errors, the library will raise relevant exceptions:\n\n- **Invalid Template Error**: This error is raised if a placeholder in the template is not valid.\n\n- **Invalid Number Found**: This error is raised if a placeholder expects a numeric value but a non-numeric value is provided.\n\n- **Exceeded Max Length**: This error is raised if a placeholder value exceeds its specified maximum length.\n\nExample Error Handling:\n\n```python\n# Output:\n# Invalid Number Found: Can not replace \"1233\" expecting numeric value\n\n# or\n\n# Output:\n# Exceeded Max Length: Can not replace \"Alice\" exceeding max length of 8\n```\n\n## Template Syntax\n\nThe template follows a specific syntax for placeholders, which are enclosed within double percentage signs (e.g., `%%`). Each placeholder should have the following format:\n\n```\n%%|name^{\"inputtype\" : \"text\", \"maxlength\" : \"8\"}%%\n```\n\n- `name`: Placeholder ID\n- `{\"inputtype\" : \"text\", \"maxlength\" : \"8\"}`: Placeholder attributes (optional)\n\nYou can customize the placeholder attributes as needed.\n\n## Features\n\n- Easy replacement of placeholders in TRAI SMS templates.\n- Support for dynamic values provided in a list.\n- Customizable placeholder attributes for flexibility.\n- Validation and error handling for template placeholders.\n- Suitable for bulk SMS generation and personalization.\n\n## License\n\nThis library is provided under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).\n\n## Contributions\n\nContributions and feedback are welcome! If you encounter any issues or have suggestions for improvements, please [open an issue](https://github.com/DeepakPant93/trai-sms-template-replacer/issues) or submit a pull request.\n\n---\n\n**Note**: This library is not affiliated with TRAI (Telecom Regulatory Authority of India) but is designed to assist in formatting SMS messages according to TRAI guidelines.\n\nHappy SMS templating! \ud83d\udcf1\u2709\ufe0f\n",
"bugtrack_url": null,
"license": null,
"summary": "This package to replace content in the TRAI SMS template",
"version": "0.1.0",
"project_urls": null,
"split_keywords": [
"python",
" trai",
" sms",
" replace"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "98cb7870f51261e8d0cfcd63ebe0677828d390d73ba1252658c5a226752f7e3f",
"md5": "4a3e486085fcac645b359eb0e8039f88",
"sha256": "3f206657890e45d43665b94b89efdd093f3bdc28949159154b4a33e41f252530"
},
"downloads": -1,
"filename": "traisms-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4a3e486085fcac645b359eb0e8039f88",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 7884,
"upload_time": "2024-04-03T05:28:58",
"upload_time_iso_8601": "2024-04-03T05:28:58.522692Z",
"url": "https://files.pythonhosted.org/packages/98/cb/7870f51261e8d0cfcd63ebe0677828d390d73ba1252658c5a226752f7e3f/traisms-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ed4f24ae353c329dd1a3665dedce6a74877db3ed3ac0b16c502b9f662f4b0127",
"md5": "c5a13604a36d45cb838f8bb885f70cd7",
"sha256": "ea3bbaf71dc3a96e5713dd3f7fb9486d5cd425a1757513875f8c608e5f553616"
},
"downloads": -1,
"filename": "traisms-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "c5a13604a36d45cb838f8bb885f70cd7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 7353,
"upload_time": "2024-04-03T05:29:00",
"upload_time_iso_8601": "2024-04-03T05:29:00.076045Z",
"url": "https://files.pythonhosted.org/packages/ed/4f/24ae353c329dd1a3665dedce6a74877db3ed3ac0b16c502b9f662f4b0127/traisms-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-03 05:29:00",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "traisms"
}