Skip to content

Commit

Permalink
Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pylover committed Dec 6, 2021
1 parent acc1fe1 commit 750ab12
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
55 changes: 55 additions & 0 deletions README.md
@@ -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
```
3 changes: 1 addition & 2 deletions tests/test_pipeline.py
@@ -1,7 +1,6 @@
import pytest

from turboguard import Sanitizer
from turboguard.core import BlacklistedError
from turboguard import Sanitizer, BlacklistedError


def test_blacklist():
Expand Down
1 change: 1 addition & 0 deletions turboguard/__init__.py
@@ -1,4 +1,5 @@
from . import core
from .core import BlacklistedError


__version__ = '0.1.0'
Expand Down

0 comments on commit 750ab12

Please sign in to comment.