PurgoMalum Client
This is a Python client for the PurgoMalum web service.
Installation
pip install purgomalum
or
python setup.py install
Usage
To use the basic filtering you can call the contains_profanity or the retrieve_filtered_text methods from the client:
>>> from purgo_malum import client
>>> client.contains_profanity('You are an @a$$hole')
True
>>> client.retrieve_filtered_text('You are an @a$$hole')
u'You are an ********'
The client functions also support adding words to the profanity list, setting your own filter text, and setting your own filter characters:
>>> from purgo_malum import client
>>> client.contains_profanity('You are a good friend', add='you')
True
>>> client.retrieve_filtered_text('You are a good friend', add='you,are', fill_text='[filtered]')
u'[filtered] [filtered] a good friend'
>>> client.retrieve_filtered_text('You are a good friend', add='you,are', fill_char='|')
u'||| ||| a good friend'
You can also get the raw data that the PurgoMalum API returns by calling the raw version of the APIs:
>>> from purgo_malum import client
>>> client.retrieve_filtered_text_raw('You are an @a$$hole', 'json')
{u'result': u'You are an ********'}
>>> client.retrieve_filtered_text_raw('You are an @a$$hole', 'plain')
u'You are an ********'
>>> client.retrieve_filtered_text_raw('You are an @a$$hole', 'xml')
u'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><PurgoMalum xmlns="http://www.purgomalum.com"><result>You are an ********</result></PurgoMalum>'
This can be helpful in the event that the API changes and/or you feel you can use the raw data in some manner.
You can also see the URL that is created for a specific request by using the build_url method (mainly helpful for testing):
>>> client.build_url('test text', 'json', add='test', fill_text='[filtered]')
u'https://www.purgomalum.com/service/json?text=test+text&add=test&fill_text=%5Bfiltered%5D'
Testing
Tests have been for python 2.7 and python 3 using pytest. The unit tests do call the actual PurgoMalum production API in order to test against potential API changes.
Before running tests make sure to install pytest, pytest-cov, pytest-mock, and mock (already included in requirements.txt).
To execute the tests and generate a code coverage report run the following:
pytest --cov-report term-missing --cov=purgo_malum/
You should see:
Name Stmts Miss Cover Missing ------------------------------------------------------- purgo_malum/__init__.py 0 0 100% purgo_malum/client.py 54 0 100% ------------------------------------------------------- TOTAL 54 0 100%
Miscellaneous
This is my first offering to the open source community. If you see any issues with this client library and/or potential improvements please let me know and I will make the necessary updates.
Donation
If this is helpful to you in any please consider a small donation.
Metadata
Release files for PurgoMalum 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| PurgoMalum-1.0.3.tar.gz | 5.3 kB | Without provenance | Details for PurgoMalum-1.0.3.tar.gz |
Release files / PurgoMalum-1.0.3.tar.gz
| Download URL | PurgoMalum-1.0.3.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0addb2d753f2f5af0a1d73578ccbe049a176bc1d96e3c21877dba96df86fbc5d
|
|
BLAKE2b-256 checksum How to use checksums |
bab69feb9f7101509b8aae0ec928bd5de0534ce591a1fd87b2851152a50f03fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.6.5
|
Security for PurgoMalum 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.