diff options
author | Aineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi> | 2024-02-19 00:18:40 +0200 |
---|---|---|
committer | Aineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi> | 2024-02-19 00:18:40 +0200 |
commit | 949f0e39838fac49a48a00548a833c8b47593139 (patch) | |
tree | 1ac90c784d5d614a450680607c3df378fcd2bfbc | |
parent | 854e8468ea035b7d588ca7cc26a96f8f700541e7 (diff) |
Package can be installed. Light ./dev.sh for running dev scripts.
-rw-r--r-- | README.md | 2 | ||||
-rwxr-xr-x | dev.sh | 32 | ||||
-rw-r--r-- | dev/README.md | 18 | ||||
-rw-r--r-- | dev/__init__.py | 1 | ||||
-rw-r--r-- | dev/commands.py | 66 | ||||
-rw-r--r-- | pyproject.toml | 4 | ||||
-rw-r--r-- | src/miinaharava/main.py | 11 |
7 files changed, 46 insertions, 88 deletions
@@ -34,4 +34,4 @@ Miinaharava ratkaisijalla - [käyttöohje](doc/käyttöohje.pdf) ### Ohjeita kehitykseen -- [dev/](dev/) +- `./dev.sh` @@ -0,0 +1,32 @@ +#!/bin/sh +[ x$1 = x ] && echo "\ +Pieni ja kevyt skripti helppoa kehitystyökalujen ajoa varten. + +Käyttö: $0 <komento> + +Komennot: + +pytest Aja yksikkötestit pytestillä +pylint Tarkista muotoilu pylintillä +covhtml Tee haarakattavuus raportti html muodossa +covxml Sama mutta xml muoto (codecov tarvitsee tämän) +covff Tee html haarakattavuusraportti ja avaa se firefoxissa +all Sama kuin '$0 covff && $0 pylint' +" + +[ $1 = pytest ] && poetry run pytest -v + +[ $1 = pylint ] && poetry run python3 -m pylint src/miinaharava/ + +[ $1 = covhtml ] && poetry run python3 -m coverage run --branch -m pytest -v \ + && poetry run python3 -m coverage html + +[ $1 = covhtml ] && poetry run python3 -m coverage run --branch -m pytest -v \ + && poetry run python3 -m coverage xml + +[ $1 = covff ] && poetry run python3 -m coverage run --branch -m pytest -v \ + && poetry run python3 -m coverage html && firefox htmlcov/index.html + +[ $1 = all ] && poetry run python3 -m coverage run --branch -m pytest -v \ + && poetry run python3 -m coverage html && firefox htmlcov/index.html \ + && poetry run python3 -m pylint src/miinaharava/ diff --git a/dev/README.md b/dev/README.md deleted file mode 100644 index dd0b2dc..0000000 --- a/dev/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# Ohjeita kehitykseen -## Riippuvuuksien asennus: -`PYTHON_KEYRING_BACKEND=keyring.backends.fail.Keyring poetry install` - -## Aja pytest: -`poetry run pytest` - -## Generoi haarakattavuusraportti: -`poetry run covhtml` - -## Avaa haarakattavuusraportti Firefoxilla: -`poetry run covff` - -## Linttaus: -`poetry run pylint` - -## Kaikki -`poetry run all` diff --git a/dev/__init__.py b/dev/__init__.py deleted file mode 100644 index 796c8ef..0000000 --- a/dev/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .commands import dev_command diff --git a/dev/commands.py b/dev/commands.py deleted file mode 100644 index ff94eb2..0000000 --- a/dev/commands.py +++ /dev/null @@ -1,66 +0,0 @@ -from subprocess import run -from sys import argv - -usage = """ -Komentoja kehitykseen: - -poetry run dev <komento> - -Komennot: - pytest Ajaa yksikkötestit - pylint Tarkistaa koodin ulkoasun - coverage Tutkii haarakattavuuden - covhtml Tekee coverage haarakattavuusraportin HTML muodossa - covxml Tekee coverage haarakattavuusraportin XML muodossa - covff Tekee haarakattavuusraportin ja avaa sen firefoxilla - all Sama kuin <covff> + <pylint> -""" - -def dev_command(): - if len(argv)==2: - match argv[1]: - case "pytest": - import pytest - return pytest.main(["-v"]) - case "pylint": - return run_pylint() - case "coverage": - return run_coverage() - case "covhtml": - return run_covhtml() - case "covxml": - return run_covxml() - case "covff": - return run_covff() - case "all": - if e := run_covff(): return e - return run_pylint() - print(usage) - return 0 - -def run_pylint(): - import pylint - return pylint.run_pylint(argv=["-v", "src/miinaharava"]) - -def run_coverage(): - return run( - "poetry run python3 -m coverage run --branch -m pytest -v ".split() - ).returncode - -def run_covhtml(): - if e := run_coverage(): return e - return run( - "poetry run python3 -m coverage html".split() - ).returncode - -def run_covxml(): - if e := run_coverage(): return e - return run( - "poetry run python3 -m coverage xml".split() - ).returncode - -def run_covff(): - if e := run_covhtml(): return e - return run( - "firefox htmlcov/index.html".split() - ).returncode diff --git a/pyproject.toml b/pyproject.toml index a14ef19..e6637b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "miinaharava" -version = "0.2-alpha" +version = "0.2" description = "Miinaharava ratkaisijalla" authors = ["Aineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi>"] readme = "README.md" @@ -15,7 +15,7 @@ coverage = "^7.4.0" pylint = "^3.0.3" [tool.poetry.scripts] -dev = "dev:dev_command" +miinaharava = 'miinaharava.main:main' [build-system] requires = ["poetry-core"] diff --git a/src/miinaharava/main.py b/src/miinaharava/main.py new file mode 100644 index 0000000..7c44f70 --- /dev/null +++ b/src/miinaharava/main.py @@ -0,0 +1,11 @@ +""" main.py """ +from runpy import run_path +from pathlib import Path + +def main(): + """ Ajaa moduulin hakemistossa jossa tämä tiedosto on """ + my_path = Path(__file__).parent.resolve() + run_path(f"{my_path}", run_name="miinaharava") + +if __name__ == "__main__": + main() |