hidetext


Namehidetext JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/jaume-ferrarons/hidetext
SummaryHides non-desired text
upload_time2022-12-08 13:38:43
maintainer
docs_urlNone
authorJaume Ferrarons
requires_python>=3.8.1,<4.0.0
licenseMIT
keywords text filter word pattern
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Hidetext

Extensible Python library to hide fragments of text.

[![version](https://img.shields.io/pypi/v/hidetext?logo=pypi&logoColor=white)](https://pypi.org/project/hidetext/)
[![build](https://github.com/jaume-ferrarons/hidetext/actions/workflows/push-event.yml/badge.svg)](https://github.com/jaume-ferrarons/hidetext/actions/workflows/push-event.yml)
[![codecov](https://codecov.io/github/jaume-ferrarons/hidetext/branch/main/graph/badge.svg?token=MZQOAFBQ5I)](https://codecov.io/github/jaume-ferrarons/hidetext)

## Installation
**Requirements**: python >= 3.8

It can be easily installed with:
```bash
pip install -U hidetext
```

## Basic usage


```python
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: ****************
    



```python
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`:


```python
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>."



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jaume-ferrarons/hidetext",
    "name": "hidetext",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.1,<4.0.0",
    "maintainer_email": "",
    "keywords": "text,filter,word,pattern",
    "author": "Jaume Ferrarons",
    "author_email": "jaume.ferrarons@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f2/1f/6f8e48309081a0ee8b08938d4b9be9ea64a9a5302a58e2ee1c1353cbf296/hidetext-0.1.1.tar.gz",
    "platform": null,
    "description": "# Hidetext\n\nExtensible Python library to hide fragments of text.\n\n[![version](https://img.shields.io/pypi/v/hidetext?logo=pypi&logoColor=white)](https://pypi.org/project/hidetext/)\n[![build](https://github.com/jaume-ferrarons/hidetext/actions/workflows/push-event.yml/badge.svg)](https://github.com/jaume-ferrarons/hidetext/actions/workflows/push-event.yml)\n[![codecov](https://codecov.io/github/jaume-ferrarons/hidetext/branch/main/graph/badge.svg?token=MZQOAFBQ5I)](https://codecov.io/github/jaume-ferrarons/hidetext)\n\n## Installation\n**Requirements**: python >= 3.8\n\nIt can be easily installed with:\n```bash\npip install -U hidetext\n```\n\n## Basic usage\n\n\n```python\nfrom hidetext import Hidetext\n\nhide = Hidetext()\n\nprint(hide.character(\"\"\"\nDear Mr Robinson,\n\nI'm contacting you regarding \nMy DNI is 43244328J.\n\nEmail: fdsfsd@gmail.com\n\"\"\"))\n```\n\n    \n    Dear Mr Robinson,\n    \n    I'm contacting you regarding \n    My DNI is *********.\n    \n    Email: ****************\n    \n\n\n\n```python\nprint(hide.kind(\"\"\"\nDear Mr Robinson,\n\nI'm contacting you regarding \nMy DNI is 43244328J.\n\nEmail: fdsfsd@gmail.com\n\"\"\"))\n```\n\n    \n    Dear Mr Robinson,\n    \n    I'm contacting you regarding \n    My DNI is <ID_CARD>.\n    \n    Email: <EMAIL>\n    \n\n\n## Creating custom filters\n\nIt's easy to create custom filters to remove undesired text using `PatternFilter`:\n\n\n```python\nfrom typing import Dict\n\nfrom hidetext import Hidetext\nfrom hidetext.filters import PatternFilter\n\nclass HourFilter(PatternFilter):\n    name: str = \"HOUR\"\n\n    patterns: Dict[str, str] = {\n        \"digital_hour\": r\"\\d{2}(:\\d{2}){1,2}\",\n        \"hour\": \"\\d{1,2}\\s?(am|pm)\"\n    }\n\nhide = Hidetext(filters=[HourFilter()])\n\nhide.kind(\"The train departs at 15:45 and arrives at 19:35, therefore I'll be at the party at 8pm.\")\n```\n\n\n\n\n    \"The train departs at <HOUR> and arrives at <HOUR>, therefore I'll be at the party at <HOUR>.\"\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Hides non-desired text",
    "version": "0.1.1",
    "split_keywords": [
        "text",
        "filter",
        "word",
        "pattern"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "c110af409e287de7d246baf09ab30004",
                "sha256": "9c7282d6682783bdb6ea4d2951e8bd15a1357aca568703839a67b796cb6cf724"
            },
            "downloads": -1,
            "filename": "hidetext-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c110af409e287de7d246baf09ab30004",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.1,<4.0.0",
            "size": 10291,
            "upload_time": "2022-12-08T13:38:41",
            "upload_time_iso_8601": "2022-12-08T13:38:41.330269Z",
            "url": "https://files.pythonhosted.org/packages/c3/26/cd0b29395652caeb770c03e9c68ebfe052fe278c991219b9ea6729119543/hidetext-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "f09a44785d425bee7ec78304937ddc12",
                "sha256": "805d9f47797db0013cea09c090d07b85c1c3fde70777f2c88c23fd13e855245d"
            },
            "downloads": -1,
            "filename": "hidetext-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "f09a44785d425bee7ec78304937ddc12",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.1,<4.0.0",
            "size": 7330,
            "upload_time": "2022-12-08T13:38:43",
            "upload_time_iso_8601": "2022-12-08T13:38:43.215656Z",
            "url": "https://files.pythonhosted.org/packages/f2/1f/6f8e48309081a0ee8b08938d4b9be9ea64a9a5302a58e2ee1c1353cbf296/hidetext-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-08 13:38:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "jaume-ferrarons",
    "github_project": "hidetext",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "hidetext"
}
        
Elapsed time: 0.01789s