Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,57 @@ | ||
# turboguard | ||
|
||
[![Build](https://github.com/pylover/turboguard/actions/workflows/build.yml/badge.svg)](https://github.com/pylover/turboguard/actions/workflows/build.yml) | ||
[![Coverage Status](https://coveralls.io/repos/github/pylover/turboguard/badge.svg?branch=master)](https://coveralls.io/github/pylover/turboguard?branch=master) | ||
|
||
Python C extension to validate and sanitize the user input using blacklist | ||
and character map. | ||
|
||
## Install | ||
|
||
```bash | ||
pip install turboguard | ||
``` | ||
|
||
|
||
### Quickstart. | ||
|
||
Create an instance of the `Sanitizer` class as the below. | ||
|
||
The `Sanitizer.__enter__` method returns a `callable(str) -> str` which let | ||
you to call it many times without worring about performance and memory leak. | ||
|
||
```python | ||
from turboguard import Sanitizer, BlacklistedError | ||
|
||
|
||
blacklist = [ | ||
('\u1d100', '\u1d1ff'), # Blacklist Unicode range | ||
'\u0635', # Blacklist single character | ||
... | ||
] | ||
|
||
replace = [ | ||
('\u0636', '\u0637'), # Replace \u0636 by \u0637 | ||
... | ||
] | ||
|
||
with Sanitizer(blacklist, replace) as sanitize: # Loading(Slow) part | ||
try: | ||
print(sanitize('foo bar baz')) # Fast call! | ||
except BlacklistedError: | ||
print('Validation failed!') | ||
``` | ||
|
||
## Contribution | ||
|
||
```bash | ||
make env | ||
make build | ||
make cover | ||
``` | ||
|
||
Afterward, for development sycle: | ||
|
||
```bash | ||
make clean build cover | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from . import core | ||
from .core import BlacklistedError | ||
|
||
|
||
__version__ = '0.1.0' | ||
|