Browse Source

updated project to latest cookiecutter

main
Holger Frey 3 years ago
parent
commit
55b05596b6
  1. 2
      .flake8
  2. 3
      .gitignore
  3. 8
      CONTRIBUTING.md
  4. 12
      Makefile
  5. 61
      pyproject.toml
  6. 6
      requirements.txt
  7. 2
      superx_budget/pyramid/__init__.py
  8. 6
      tests/test_budget_parser.py
  9. 14
      tests/test_overview.py
  10. 6
      tests/test_superx_parser.py

2
.flake8

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
[flake8]
per-file-ignores = tests/*:S101

3
.gitignore vendored

@ -45,7 +45,6 @@ htmlcov/ @@ -45,7 +45,6 @@ htmlcov/
nosetests.xml
coverage.xml
*,cover
mail/
# Translations
*.mo
@ -63,5 +62,3 @@ target/ @@ -63,5 +62,3 @@ target/
# Mac Stuff
.DS_Store
# Pyramid
production.ini

8
CONTRIBUTING.md

@ -11,7 +11,7 @@ Types of Contributions @@ -11,7 +11,7 @@ Types of Contributions
### Report Bugs
Report bugs at https://github.com/holgi/superx_budget/issues.
Report bugs at https://git.cpi.imtek.uni-freiburg.de/CPI/superx-budget-overview.git/issues.
If you are reporting a bug, please include:
@ -31,13 +31,13 @@ and "help wanted" is open to whoever wants to implement it. @@ -31,13 +31,13 @@ and "help wanted" is open to whoever wants to implement it.
### Write Documentation
superx_budget could always use more documentation, whether as part of the
official superx_budget docs, in docstrings, or even on the web in blog posts,
SuperX Budget could always use more documentation, whether as part of the
official SuperX Budget docs, in docstrings, or even on the web in blog posts,
articles, and such.
### Submit Feedback
The best way to send feedback is to file an issue at https://github.com/holgi/superx_budget/issues.
The best way to send feedback is to file an issue at https://git.cpi.imtek.uni-freiburg.de/CPI/superx-budget-overview.git/issues.
If you are proposing a feature:

12
Makefile

@ -57,10 +57,13 @@ lint: ## reformat with black and check style with flake8 @@ -57,10 +57,13 @@ lint: ## reformat with black and check style with flake8
flake8 superx_budget tests
test: lint ## run tests quickly with the default Python
pytest tests -x --disable-warnings -m "not app"
pytest tests -x --disable-warnings -m "not fun"
testall: lint ## run tests quickly with the default Python
pytest tests
coverage: lint ## full test suite, check code coverage and open coverage report
pytest tests --cov=superx_budget
pytest tests --cov=superx_budget -m "fun"
coverage html
$(BROWSER) htmlcov/index.html
@ -73,12 +76,15 @@ install: ## install updated project.toml with flint @@ -73,12 +76,15 @@ install: ## install updated project.toml with flint
devenv: ## setup development environment
python3 -m venv --prompt superx_budget .venv
.venv/bin/pip3 install --upgrade pip
.venv/bin/pip3 install flit
.venv/bin/pip3 install "flit>3.2"
.venv/bin/flit install --pth-file
repo: devenv ## complete project setup with development environment and git repo
git init .
git branch -m main
git add .
git commit -m "import of project template"
git remote add origin https://git.cpi.imtek.uni-freiburg.de/CPI/superx-budget-overview.git
git push -u origin main --no-verify
.venv/bin/pre-commit install --install-hooks

61
pyproject.toml

@ -4,14 +4,17 @@ @@ -4,14 +4,17 @@
requires = ["flit"]
build-backend = "flit.buildapi"
[tool.flit.metadata]
module = "superx_budget"
dist-name = "superx_budget"
author = "Holger Frey"
author-email = "frey@imtek.de"
home-page = "https://github.com/holgi/superx_budget"
description-file = "README.md"
license = "Beerware"
[project]
name = "superx_budget"
readme = "README.md"
description = "Creating a budget overview from a SuperX export."
license = { file = "LICENSE" }
requires-python = ">=3.7"
dynamic = ["version"]
authors = [
{name = "Holger Frey", email = "frey@imtek.de"},
]
# see https://pypi.org/classifiers/
classifiers = [
@ -23,7 +26,7 @@ classifiers = [ @@ -23,7 +26,7 @@ classifiers = [
"License :: Freely Distributable",
]
requires = [
dependencies = [
"openpyxl >= 3.0.0",
"pyramid >= 1.10",
"pyramid_jinja2 >= 2.7",
@ -31,39 +34,43 @@ requires = [ @@ -31,39 +34,43 @@ requires = [
"waitress >= 1.4.3",
"passlib[argon2] >= 1.7.2",
]
requires-python = ">=3.7"
[tool.flit.metadata.requires-extra]
[project.entrypoints."paste.app_factory"]
main = "superx_budget:main"
[project.urls]
Source = "https://git.cpi.imtek.uni-freiburg.de/CPI/superx-budget-overview.git"
[project.optional-dependencies]
test = [
"pytest >=4.0.0",
"pytest-cov",
"pytest-mock",
"pytest-randomly",
"tox",
]
dev = [
"black",
"flake8",
"flake8-comprehensions",
"flake8-bandit",
"isort >= 5.0.0",
"keyring",
"pre-commit",
]
[tool.flit.entrypoints."paste.app_factory"]
main = "superx_budget:main"
[tool.black]
line-length = 79
py37 = true
target-version = ['py37','py38', 'py39']
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.tox
| \.venv
| build
| dist
)/
extend-exclude = '''
# A regex preceded with ^/ will apply only to files and directories
# in the root of the project.
^/.git
^/.tox
^/.venv
^/.build
^/.dist
'''
[tool.isort]
@ -71,3 +78,11 @@ line_length=79 @@ -71,3 +78,11 @@ line_length=79
multi_line_output=3
length_sort="True"
include_trailing_comma="True"
[tool.pytest.ini_options]
markers = [
"fun: marks tests as functional (deselect with '-m \"not fun\"')",
]
addopts = [
"--strict-markers",
]

6
requirements.txt

@ -1,6 +0,0 @@ @@ -1,6 +0,0 @@
openpyxl==3.0.5
pyramid==1.10.4
pyramid-jinja2==2.8
pyramid-mailer==0.15.1
waitress==1.4.4
passlib==1.7.2

2
superx_budget/pyramid/__init__.py

@ -5,7 +5,7 @@ from pathlib import Path @@ -5,7 +5,7 @@ from pathlib import Path
from pyramid.view import notfound_view_config
from pyramid.config import Configurator
from pyramid.session import JSONSerializer, SignedCookieSessionFactory
from pyramid.security import Allow, Everyone, Authenticated
from pyramid.authorization import Allow, Everyone, Authenticated
from pyramid.httpexceptions import HTTPFound
from ..overview import create_overview # noqa: F401

6
tests/test_budget_parser.py

@ -2,7 +2,7 @@ import pytest @@ -2,7 +2,7 @@ import pytest
def test_check_table_header_raises_error():
from superx_budget.budget import _check_table_header, ExcelRow
from superx_budget.budget import ExcelRow, _check_table_header
from superx_budget.exceptions import BudgetParserError
row = ExcelRow(None, ["not", "the", "expected", "row", None, 0])
@ -12,7 +12,7 @@ def test_check_table_header_raises_error(): @@ -12,7 +12,7 @@ def test_check_table_header_raises_error():
def test_skip_empty_lines():
from superx_budget.budget import _skip_empty_lines, ExcelRow
from superx_budget.budget import ExcelRow, _skip_empty_lines
rows = [
ExcelRow(0, [""]),
@ -29,7 +29,7 @@ def test_skip_empty_lines(): @@ -29,7 +29,7 @@ def test_skip_empty_lines():
def test_parse_data_table():
from superx_budget.budget import _parse_data_table, ExcelRow
from superx_budget.budget import ExcelRow, _parse_data_table
rows = [
ExcelRow(2, list("ABCDEFG")),

14
tests/test_overview.py

@ -79,8 +79,8 @@ def test_project_overview_available_property(example_budget_data): @@ -79,8 +79,8 @@ def test_project_overview_available_property(example_budget_data):
def test_create_overview_map(budget_example_file):
from superx_budget.overview import _create_overview_map
from superx_budget.budget import parse_budget_file
from superx_budget.overview import _create_overview_map
budget_data = parse_budget_file(budget_example_file)
result = _create_overview_map(budget_data)
@ -92,12 +92,12 @@ def test_create_overview_map(budget_example_file): @@ -92,12 +92,12 @@ def test_create_overview_map(budget_example_file):
def test_create_entries_from_export(budget_example_file, superx_example_file):
from superx_budget.budget import parse_budget_file
from superx_budget.superx import parse_exported_file
from superx_budget.overview import (
_create_entries_from_superx,
_create_overview_map,
_create_entries_from_superx,
)
from superx_budget.budget import parse_budget_file
from superx_budget.superx import parse_exported_file
superx_data = parse_exported_file(superx_example_file)
budget_data = parse_budget_file(budget_example_file)
@ -109,11 +109,11 @@ def test_create_entries_from_export(budget_example_file, superx_example_file): @@ -109,11 +109,11 @@ def test_create_entries_from_export(budget_example_file, superx_example_file):
def test_filter_superx_material_expenses(superx_example_file):
from superx_budget.superx import parse_exported_file
from superx_budget.overview import (
_filter_superx_material_expenses,
VALID_MATERIAL_IDS,
_filter_superx_material_expenses,
)
from superx_budget.superx import parse_exported_file
superx_data = parse_exported_file(superx_example_file)
result = list(_filter_superx_material_expenses(superx_data))
@ -124,9 +124,9 @@ def test_filter_superx_material_expenses(superx_example_file): @@ -124,9 +124,9 @@ def test_filter_superx_material_expenses(superx_example_file):
def test_create_overview(budget_example_file, superx_example_file):
from superx_budget.overview import create_overview
from superx_budget.budget import parse_budget_file
from superx_budget.superx import parse_exported_file
from superx_budget.overview import create_overview
superx_data = parse_exported_file(superx_example_file)
budget_data = parse_budget_file(budget_example_file)

6
tests/test_superx_parser.py

@ -15,9 +15,10 @@ def test_check_export_headline(): @@ -15,9 +15,10 @@ def test_check_export_headline():
def test_get_export_metadata_ok():
from superx_budget.superx import _get_export_metadata
from datetime import datetime
from superx_budget.superx import _get_export_metadata
value = "Haushaltsjahr: XXX;Stand:31.12.2020;Gruppierung:automatisch"
row = [value]
metadata = _get_export_metadata(row)
@ -88,9 +89,10 @@ def test_parse_data_table(): @@ -88,9 +89,10 @@ def test_parse_data_table():
def test_parse_export_data(superx_example_workbook):
from superx_budget.superx import parse_export_data
from datetime import datetime
from superx_budget.superx import parse_export_data
result = parse_export_data(superx_example_workbook.active)
assert result.account_year == "2020"

Loading…
Cancel
Save