Skip to content

Commit 6a98962

Browse files
author
João Guerreiro
committed
feat(py-gitguardian): initial commit
0 parents  commit 6a98962

21 files changed

+1080
-0
lines changed

.github/workflows/test-lint.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Package Test
5+
6+
on: [push, pull_request]
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Set up Python 3.8
14+
uses: actions/setup-python@v1
15+
with:
16+
python-version: 3.8
17+
- name: Install dependencies
18+
run: |
19+
python -m pip install --upgrade pip
20+
python -m pip install --upgrade pipenv
21+
pipenv install --dev --system --skip-lock
22+
- name: Lint with flake8
23+
run: |
24+
pipenv run flake8
25+
- name: Lint with black
26+
run: |
27+
pipenv run black .
28+
29+
build:
30+
runs-on: ubuntu-latest
31+
strategy:
32+
matrix:
33+
python-version: [3.5, 3.6, 3.7, 3.8]
34+
35+
steps:
36+
- uses: actions/checkout@v2
37+
- name: Set up Python ${{ matrix.python-version }}
38+
uses: actions/setup-python@v1
39+
with:
40+
python-version: ${{ matrix.python-version }}
41+
- name: Install dependencies
42+
run: |
43+
python -m pip install --upgrade pip
44+
python -m pip install --upgrade pipenv
45+
pipenv install --system --skip-lock
46+
pip install nose coverage
47+
- name: Test with pytest
48+
run: |
49+
pipenv run coverage run --source pygitguardian -m nose tests
50+
pipenv run coverage report --fail-under=80

.gitignore

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
*.py[cod]
2+
3+
# C extensions
4+
*.so
5+
6+
# Packages
7+
*.egg
8+
*.egg-info
9+
build
10+
eggs
11+
parts
12+
bin
13+
var
14+
sdist
15+
develop-eggs
16+
.installed.cfg
17+
lib
18+
lib64
19+
20+
# Installer logs
21+
pip-log.txt
22+
23+
# Unit test / coverage reports
24+
.coverage
25+
.tox
26+
nosetests.xml
27+
28+
# Translations
29+
*.mo
30+
31+
# Mr Developer
32+
.mr.developer.cfg
33+
.project
34+
.pydevproject
35+
36+
# Complexity
37+
output/*.html
38+
output/*/index.html
39+
40+
# Sphinx
41+
docs/_build
42+
43+
.webassets-cache
44+
45+
# Virtualenvs
46+
env/
47+
48+
# npm
49+
/node_modules/
50+
51+
# webpack-built files
52+
/pygitguardian/static/build/
53+
/pygitguardian/webpack/manifest.json
54+
55+
56+
# IntelliJ
57+
*.iml
58+
59+
.pytest_cache
60+
61+
# Pycharm
62+
.idea/*
63+
64+
# Sublime text
65+
*.sublime-project
66+
*.sublime-workspace
67+
68+
# Ipython notebook
69+
*.ipynb_checkpoints
70+
71+
# Mac
72+
# General
73+
.DS_Store
74+
.AppleDouble
75+
.LSOverride
76+
77+
# Icon must end with two \r
78+
Icon
79+
80+
81+
# Thumbnails
82+
._*
83+
84+
# Files that might appear in the root of a volume
85+
.DocumentRevisions-V100
86+
.fseventsd
87+
.Spotlight-V100
88+
.TemporaryItems
89+
.Trashes
90+
.VolumeIcon.icns
91+
.com.apple.timemachine.donotpresent
92+
93+
# Directories potentially created on remote AFP share
94+
.AppleDB
95+
.AppleDesktop
96+
Network Trash Folder
97+
Temporary Items
98+
.apdisk
99+
100+
101+
# Installer logs
102+
pip-log.txt
103+
pip-delete-this-directory.txt
104+
105+
# Unit test / coverage reports
106+
htmlcov/
107+
.tox/
108+
.coverage
109+
.coverage.*
110+
.cache
111+
nosetests.xml
112+
coverage.xml
113+
*.cover
114+
.hypothesis/
115+
.pytest_cache/
116+
117+
# Catch sensitive files
118+
.env
119+
secrets.py
120+
secret.py
121+
secrets
122+
123+
Pipfile.lock

.gitlab-ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include:
2+
- project: "gg-code/sre/gitguardian-oss"
3+
file: "/pygitguardian.yml"

.pre-commit-config.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
default_stages: [commit]
2+
repos:
3+
- repo: https://github.com/ambv/black
4+
rev: stable
5+
hooks:
6+
- id: black
7+
language_version: python3.8
8+
- repo: https://github.com/asottile/seed-isort-config
9+
rev: v1.9.1
10+
hooks:
11+
- id: seed-isort-config
12+
- repo: https://github.com/pre-commit/mirrors-isort
13+
rev: v4.3.20
14+
hooks:
15+
- id: isort
16+
- repo: https://github.com/pre-commit/pre-commit-hooks
17+
rev: v2.5.0
18+
hooks:
19+
- id: check-json
20+
- id: check-added-large-files
21+
- id: check-yaml
22+
- repo: https://gitlab.com/pycqa/flake8
23+
rev: 3.7.9
24+
hooks:
25+
- id: flake8
26+
- repo: https://github.com/Woile/commitizen
27+
rev: master
28+
hooks:
29+
- id: commitizen
30+
# don't forget to run pre-commit install --hook-type commit-msg for this hook to run
31+
stages: [commit-msg]
32+
- repo: https://github.com/prettier/prettier # to format JSON, YAML and markdown files among others
33+
rev: master
34+
hooks:
35+
- id: prettier

CONTRIBUTING.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
## Contributing to pygitguardian
2+
3+
## Getting involved
4+
5+
Development is coordinated via the issue tracker exclusively.
6+
7+
If you want to propose large changes be sure to communicate with other contributors
8+
through an issue tagged as `feature request` about the design and the benefits of such change.
9+
10+
## Bug Reporting
11+
12+
When submitting a bug report be sure that:
13+
14+
- You are using the latest version of the package
15+
- There are no issues describing the same behaviour on the issue tracker
16+
17+
## Dev environment
18+
19+
```bash
20+
pipenv install --dev
21+
pipenv run pre-commit install -f --hook-type commit-msg --hook-type pre-commit
22+
```
23+
24+
## Testing
25+
26+
Pygitguardian testing is done with `nosetest`. You should make sure your changes don't report any error on
27+
28+
```
29+
make test
30+
```
31+
32+
## Conventions
33+
34+
pygitguardian follows conventional commit messages [link](https://www.conventionalcommits.org/).
35+
36+
### Line length
37+
38+
Line length in the one enforced by Black: 88 characters.
39+
40+
### DocString
41+
42+
- Use sphinx style docstrings
43+
- There are never too many docstrings
44+
- If the docstring will take more than 1 line, start directly below """
45+
- The first sentence starts with a capital letter and ends with a point. This sentence is separated from the others by a blank line
46+
- Docstrings must have :params: if the function has 2 or more arguments.
47+
- All docstrings must state the return object and raised exception with :return: and :raise:

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 gg-code / prm
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include README.md
2+
include LICENSE

Makefile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
SHELL :=/bin/bash
2+
.PHONY: all test coverage black flake8
3+
.SILENT:
4+
5+
test ?= tests
6+
7+
all:
8+
echo "Usage :"
9+
echo " make test" # Run tests
10+
echo " make coverage" # Run tests and coverage
11+
echo " make black" # Run black formatter on python code
12+
echo " make flake8" # Run flake8 linter on python code
13+
echo " make isort" # Run isort linter on python code
14+
15+
test:
16+
pipenv run nosetests $(test)
17+
18+
coverage:
19+
pipenv run coverage run --source pygitguardian -m nose tests && pipenv run coverage report --fail-under=80
20+
21+
black:
22+
pipenv run black --config black.toml .
23+
24+
flake8:
25+
pipenv run flake8
26+
27+
isort:
28+
pipenv run isort **/*.py

Pipfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[[source]]
2+
url = "https://pypi.python.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
pygitguardian = {editable = true,path = "."}
8+
marshmallow = "~=3.5"
9+
requests = ">=2.21.0"
10+
11+
[dev-packages]
12+
black = "==19.10b0"
13+
flake8 = "*"
14+
ipython = "*"
15+
pre-commit = "*"
16+
coverage = "*"
17+
flake8-isort = "*"
18+
isort = "*"
19+
nose = "*"

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<img src="./doc/logo.svg">
2+
3+
# GitGuardian API Client
4+
5+
API client library for the GitGuardian API.
6+
7+
You can check API details [here](https://api.gitguardian.com/doc)
8+
with all the response codes and expected structures on each method.
9+
10+
## Requirements
11+
12+
Python 3.5+
13+
14+
## Getting started
15+
16+
You can obtain tokens for API usage on your [dashboard](https://dashboard.gitguardian.com/api).
17+
18+
**pip**
19+
20+
```bash
21+
pip3 install --upgrade pygitguardian
22+
```
23+
24+
**pipenv**
25+
26+
```bash
27+
pipenv install pygitguardian
28+
```
29+
30+
**poetry**
31+
32+
```bash
33+
poetry add pygitguardian
34+
```
35+
36+
Check [examples/content_scan.py](examples/content_scan.py) for an example usage of the API.
37+
38+
### Dependencies
39+
40+
Py-gitguardian depends on these excelent libraries:
41+
42+
- `requests` - HTTP client
43+
- `marshmallow` - Request (de)serialization and input validation

0 commit comments

Comments
 (0)