-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 94f96ba
Showing
24 changed files
with
414 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
root = True | ||
|
||
[*] | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = True | ||
trim_trailing_whitespace = True | ||
|
||
[*.py] | ||
charset = utf-8 | ||
|
||
[*.{js,json}] | ||
charset = utf-8 | ||
indent_size = 2 | ||
|
||
[*.{yml,yaml,md,rb}] | ||
indent_size = 2 | ||
|
||
[Makefile,*.mk] | ||
indent_style = tab |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: PDF Scrub CI Lint | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.10"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Pip | ||
run: | | ||
python -m pip install --upgrade pip | ||
- name: Run Lint | ||
run: | | ||
make tests |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Package | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*" | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.10"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Pip | ||
run: | | ||
python -m pip install --upgrade pip | ||
- name: Make package | ||
run: | | ||
pip install wheel | ||
make package | ||
- name: Publish package | ||
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.PYPI_API_TOKEN }} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: PDF Scrub CI Tests | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.10"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Pip | ||
run: python -m pip install --upgrade pip | ||
- name: Run Tests | ||
run: make test |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
bin | ||
include | ||
lib | ||
lib64 | ||
pyvenv.cfg | ||
tags | ||
|
||
.eggs: | ||
pytest_runner-5.3.1-py3.9.egg | ||
README.txt | ||
|
||
src/pdf_scrub.egg-info: | ||
dependency_links.txt | ||
entry_points.txt | ||
PKG-INFO | ||
requires.txt | ||
src/pdf_scrub/version.py | ||
SOURCES.txt | ||
top_level.txt | ||
__pycache__/ | ||
.coverage | ||
coverage.xml | ||
htmlcov | ||
.idea | ||
.cache/ |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
### Cross platform development | ||
|
||
By installing `make` you can do the following: | ||
|
||
```sh | ||
$ make help | ||
make install | ||
- Installs pdf_scrub. | ||
make install-all | ||
- Install pdf_scrub, all development and tests dependencies. | ||
make test | ||
- Runs integration tests and unit tests | ||
make unit-test | ||
- Runs integration tests | ||
make integration-tests | ||
- Runs unit tests | ||
make lint | ||
- Lints your code (black, flake8 and mypy). | ||
make fix | ||
- Autofixes imports and some formatting. | ||
``` | ||
|
||
### Developing on Linux | ||
|
||
#### Run helping tools automatically on file change | ||
|
||
While the `make` targets is an okay way to run things, I find it helpful to have my tests and linter running in separate terminal windows to get continous quick feedback. | ||
|
||
The command `ag` is from The Silver Searcher program which can be found [here](https://archlinux.org/packages/community/x86_64/the_silver_searcher/). And the `entr` program can be found [here](https://archlinux.org/packages/community/x86_64/entr/). | ||
|
||
###### Run `unit tests` on file change automatically | ||
|
||
```sh | ||
alias unit="ag -l | entr -c pytest --durations=0 tests/unit_tests" | ||
``` | ||
|
||
###### Run `flake8` on file change automatically | ||
|
||
```sh | ||
alias flakeit="ag -l | entr -c flake8 tests src" | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
graft src | ||
global-exclude *.pyc |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
COMPONENT?=pdf_scrub | ||
VERSION:=src/${COMPONENT}/version.py | ||
.DEFAULT:help | ||
include make/help.mk | ||
include make/common.mk | ||
include make/install.mk | ||
include make/test.mk | ||
include make/lint.mk | ||
include make/ci.mk | ||
|
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# PDF Scrub | ||
|
||
## Development | ||
|
||
For help getting started developing check [DEVELOPMENT.md](DEVELOPMENT.md) |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package: ${VERSION} setup.py | ||
@python setup.py sdist bdist_wheel | ||
|
||
.PHONY:package |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
${VERSION}: | ||
@echo "__version__ = \"$(shell git describe --tag --always | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' || echo "0.0.0")\"" > ${VERSION} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
help: | ||
@printf "\e[92m%s\e[0m\n" "make install" | ||
@echo " - Installs ${COMPONENT}." | ||
@printf "\e[92m%s\e[0m\n" "make install-all" | ||
@echo " - Install ${COMPONENT}, all development and tests dependencies in editable mode." | ||
@printf "\e[92m%s\e[0m\n" "make test" | ||
@echo " - Runs unit tests" | ||
@printf "\e[92m%s\e[0m\n" "make lint" | ||
@echo " - Lints your code (black, flake8 and mypy)." | ||
@printf "\e[92m%s\e[0m\n" "make fix" | ||
@echo " - Autofixes imports and some formatting." | ||
|
||
.PHONY: help | ||
.DEFAULT: help |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
install: ${VERSION} | ||
@pip install . | ||
|
||
install-all: ${VERSION} | ||
@pip install -e '.[all]' | ||
|
||
install-dev: ${VERSION} | ||
@pip install -e '.[dev]' | ||
|
||
install-tests: ${VERSION} | ||
@pip install -e '.[tests]' |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ensure-lint-dependencies: | ||
command -v black flake8 mypy 2>/dev/null || make install-dev | ||
|
||
ensure-fix-dependencies: | ||
command -v black isort 2>/dev/null || make install-dev | ||
|
||
|
||
lint: ensure-lint-dependencies $(VERSION) | ||
black --check -q src tests | ||
flake8 src tests | ||
mypy src tests | ||
|
||
fix: ensure-fix-dependencies $(VERSION) | ||
black src tests | ||
isort src tests |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ensure-test-dependencies: | ||
command -v pytest 2>/dev/null || make install-tests | ||
|
||
test: ${VERSION} ensure-test-dependencies | ||
pytest tests/unit_tests |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[tool.black] | ||
line-length = 120 | ||
|
||
[tool.nitpick] | ||
style = "https://raw.githubusercontent.com/nymann/python-styleguide/master/styles/nitpick-style.toml" | ||
cache = "never" |
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 |
---|---|---|
@@ -0,0 +1,112 @@ | ||
[metadata] | ||
name = pdf_scrub | ||
url = "https://github.com/nymann/pdf-scrub" | ||
maintainer = Kristian Nymann Jakobsen | ||
maintainer_email = [email protected] | ||
description = PDF Scrub | ||
long_description = file: README.md | ||
long_description_content_type = text/markdown | ||
|
||
[options] | ||
packages = find: | ||
include_package_data = true | ||
package_dir = = src | ||
python_requires = >= 3.9 | ||
setup_requires = | ||
pytest-runner | ||
install_requires = | ||
typer >= 0.4.1 | ||
|
||
[options.extras_require] | ||
all = | ||
%(dev)s | ||
%(tests)s | ||
dev = | ||
isort | ||
wemake-python-styleguide | ||
mypy | ||
black | ||
nitpick | ||
add-trailing-comma | ||
tests = | ||
pytest | ||
pytest-cov | ||
pytest-mock | ||
|
||
[options.packages.find] | ||
where = src | ||
|
||
[options.entry_points] | ||
console_scripts = | ||
pdf_scrub = pdf_scrub.main:app | ||
|
||
|
||
[tool:pytest] | ||
testpaths = tests | ||
addopts = | ||
--color=yes | ||
--cov-report=xml | ||
--cov-report=html | ||
--cov=src | ||
--cov-report=term-missing | ||
|
||
[coverage:run] | ||
branch = true | ||
omit = src/pdf_scrub/version.py | ||
source = | ||
src | ||
tests | ||
|
||
[coverage:paths] | ||
source = | ||
src | ||
|
||
[aliases] | ||
test=pytest | ||
|
||
[pydocstyle] | ||
convention=google | ||
|
||
[flake8] | ||
docstring-style = google | ||
format = wemake | ||
ignore = WPS305,D100,D101,D102,D103,D104,D107,H601,WPS306 | ||
max-complexity = 6 | ||
max-line-length = 120 | ||
show-source = True | ||
strictness = long | ||
inline-quotes = double | ||
per-file-ignores = | ||
tests/**.py:WPS218,WPS432,WPS442,S101,src/**/version.py:WPS410 | ||
|
||
[isort] | ||
combine_as_imports = True | ||
force_grid_wrap = 0 | ||
force_single_line = True | ||
force_sort_within_sections = True | ||
include_trailing_comma = True | ||
lexicographical = True | ||
line_length = 120 | ||
multi_line_output = 3 | ||
single_line_exclusions = typing | ||
src_paths = src,tests | ||
|
||
[mypy] | ||
allow_redefinition = False | ||
check_untyped_defs = True | ||
disallow_incomplete_defs = True | ||
disallow_untyped_calls = True | ||
disallow_untyped_decorators = False | ||
disallow_untyped_defs = True | ||
ignore_errors = False | ||
ignore_missing_imports = True | ||
implicit_reexport = False | ||
local_partial_types = True | ||
no_implicit_optional = True | ||
strict_equality = True | ||
strict_optional = True | ||
warn_no_return = True | ||
warn_redundant_casts = True | ||
warn_unreachable = True | ||
warn_unused_configs = True | ||
warn_unused_ignores = True |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from distutils import util | ||
from typing import Dict | ||
|
||
import setuptools | ||
|
||
version: Dict[str, str] = {} | ||
path = util.convert_path("src/pdf_scrub/version.py") | ||
with open(path) as version_file: | ||
exec(version_file.read(), version) # noqa: S102 DUO105, WPS421 | ||
|
||
setuptools.setup(version=version["__version__"]) |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import typer | ||
|
||
app = typer.Typer() | ||
|
||
|
||
@app.command() | ||
def welcome(name: str) -> None: | ||
typer.echo(f"Welcome {name}!") | ||
|
||
|
||
if __name__ == "__main__": | ||
app() |
Empty file.
Empty file.
Oops, something went wrong.