Hides non-desired text
Project description
Hidetext
Extensible Python library to hide fragments of text.
Installation
Requirements: python >= 3.8
It can be easily installed with:
pip install -U hidetext
Basic usage
from hidetext import Hidetext
hide = Hidetext()
print(hide.character("""
Dear Mr Robinson,
I'm contacting you regarding
My DNI is 43244328J.
Email: fdsfsd@gmail.com
"""))
Dear Mr Robinson,
I'm contacting you regarding
My DNI is *********.
Email: ****************
print(hide.kind("""
Dear Mr Robinson,
I'm contacting you regarding
My DNI is 43244328J.
Email: fdsfsd@gmail.com
"""))
Dear Mr Robinson,
I'm contacting you regarding
My DNI is <ID_CARD>.
Email: <EMAIL>
Creating custom filters
It's easy to create custom filters to remove undesired text using PatternFilter
:
from typing import Dict
from hidetext import Hidetext
from hidetext.filters import PatternFilter
class HourFilter(PatternFilter):
name: str = "HOUR"
patterns: Dict[str, str] = {
"digital_hour": r"\d{2}(:\d{2}){1,2}",
"hour": "\d{1,2}\s?(am|pm)"
}
hide = Hidetext(filters=[HourFilter()])
hide.kind("The train departs at 15:45 and arrives at 19:35, therefore I'll be at the party at 8pm.")
"The train departs at <HOUR> and arrives at <HOUR>, therefore I'll be at the party at <HOUR>."
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hidetext-0.1.1.tar.gz
(7.3 kB
view details)
Built Distribution
hidetext-0.1.1-py3-none-any.whl
(10.3 kB
view details)
File details
Details for the file hidetext-0.1.1.tar.gz
.
File metadata
- Download URL: hidetext-0.1.1.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.14 CPython/3.8.10 Darwin/22.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 805d9f47797db0013cea09c090d07b85c1c3fde70777f2c88c23fd13e855245d |
|
MD5 | f09a44785d425bee7ec78304937ddc12 |
|
BLAKE2b-256 | f21f6f8e48309081a0ee8b08938d4b9be9ea64a9a5302a58e2ee1c1353cbf296 |
File details
Details for the file hidetext-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: hidetext-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.14 CPython/3.8.10 Darwin/22.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c7282d6682783bdb6ea4d2951e8bd15a1357aca568703839a67b796cb6cf724 |
|
MD5 | c110af409e287de7d246baf09ab30004 |
|
BLAKE2b-256 | c326cd0b29395652caeb770c03e9c68ebfe052fe278c991219b9ea6729119543 |