Skip to content

Commit

Permalink
Merge pull request #8 from plasticuproject/dev
Browse files Browse the repository at this point in the history
Refactor/re-write of the module to be more pythonic. Migrated from tr…
  • Loading branch information
plasticuproject committed Jan 27, 2022
2 parents 8ed761d + 903aa6f commit 447fb4f
Show file tree
Hide file tree
Showing 11 changed files with 538 additions and 279 deletions.
1 change: 0 additions & 1 deletion .coveragerc
Expand Up @@ -2,4 +2,3 @@
omit =
*/site-packages/*
*/distutils/*
test.py
28 changes: 28 additions & 0 deletions .github/workflows/python-publish.yml
@@ -0,0 +1,28 @@
name: Upload Python Package

on:
push:
branches: [ master ]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python setup.py sdist
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
40 changes: 40 additions & 0 deletions .github/workflows/tests.yml
@@ -0,0 +1,40 @@
name: build

on: ["push", "pull_request"]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install flake8 coverage>=6.3 mypy types-requests
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Static type checking with mypy
run: |
python -m mypy --strict .
- name: Unit tests
run: |
python -m unittest -v
- name: Generate code coverage reports
run: |
python -m coverage run test.py -v
python -m coverage lcov -o ./coverage/lcov.info
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
141 changes: 140 additions & 1 deletion .gitignore
@@ -1,3 +1,142 @@
# Byte-compiled / optimized / DLL files
__pycache__/
htmlcov/*
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

.idea/

docs/_build
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

38 changes: 19 additions & 19 deletions README.md
@@ -1,5 +1,5 @@
[![Build Status](https://travis-ci.org/plasticuproject/hibpwned.svg?branch=master)](https://travis-ci.org/plasticuproject/hibpwned)
[![Python 3.7](https://img.shields.io/badge/python-3.6+-blue.svg)](https://www.python.org/downloads/release/python-370/)
[![build](https://github.com/plasticuproject/hibpwned/actions/workflows/tests.yml/badge.svg)](https://github.com/plasticuproject/hibpwned/actions/workflows/tests.yml)
[![Python 3.8](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/release/python-380/)
[![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)
[![PyPI version](https://badge.fury.io/py/hibpwned.svg)](https://badge.fury.io/py/hibpwned)
[![Downloads](https://pepy.tech/badge/hibpwned)](https://pepy.tech/project/hibpwned)
Expand All @@ -25,16 +25,16 @@ https://haveibeenpwned.com/API/Key
## Usage
This module contains the class Pwned with functions: <br/>

searchAllBreaches <br/>
allBreaches <br/>
singleBreach <br/>
dataClasses <br/>
searchPastes <br/>
searchPassword <br/>
searchHashes <br/>
search_all_breaches <br/>
all_breaches <br/>
single_breach <br/>
data_classes <br/>
search_pastes <br/>
search_password <br/>
search_hashes <br/>

All functions return a JSON object containing relevent data, with the exception <br/>
of searchPassword and searchHashes, which returns an integer and a string object, <br/>
All functions return a JSON objects containing relevent data, with the exception <br/>
of search_password and search_hashes, which returns an integer and a string object, <br/>
respectively. <br/>

See module DocStrings for function descriptions and parameters <br/>
Expand All @@ -44,14 +44,14 @@ See module DocStrings for function descriptions and parameters <br/>
```python
import hibpwned

myApp = hibpwned.Pwned('test@example.com', 'My_App', 'My_API_Key')
my_app = hibpwned.Pwned("test@example.com", "My_App", "My_API_Key")

myBreaches = myApp.searchAllBreaches()
Breaches = myApp.allBreaches()
adobe = myApp.singleBreach('adobe')
data = myApp.dataClasses()
myPastes = myApp.searchPastes()
password = myApp.searchPassword('BadPassword')
myHashes = myApp.searchHashes('21BD1')
my_breaches = my_app.search_all_breaches()
breaches = my_app.all_breaches()
adobe = my_app.single_breach("adobe")
data = my_app.data_classes()
my_pastes = my_app.search_pastes()
password = my_app.search_password("BadPassword")
my_hashes = my_app.search_hashes("21BD1")
```

0 comments on commit 447fb4f

Please sign in to comment.