From aa5034f89f921ba13b320716aea5ebe2b6ea594a Mon Sep 17 00:00:00 2001 From: Matthew Watkins Date: Tue, 16 Jan 2024 20:16:17 +0000 Subject: [PATCH] Chore: Repo updates Signed-off-by: Matthew Watkins --- .pre-commit-config.yaml | 8 +++++--- docs/conf.py | 4 ++-- pyproject.toml | 2 +- scripts/template-to-repo.sh | 16 +++++++++++----- .../__init__.py | 0 .../skeleton.py | 8 ++++---- tests/conftest.py | 2 +- ..._test.py => test_osc_rule_based_extractor.py} | 1 - 8 files changed, 24 insertions(+), 17 deletions(-) rename src/{osc_data_extractor => osc_rule_based_extractor}/__init__.py (100%) rename src/{osc_data_extractor => osc_rule_based_extractor}/skeleton.py (94%) rename tests/{osc_data_extractor_test.py => test_osc_rule_based_extractor.py} (99%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 349dca5..2d63b0e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -51,6 +51,7 @@ repos: - id: mixed-line-ending args: ["--fix=lf"] - id: name-tests-test + args: ["--pytest-test-first"] # Do not allow direct push to main/master branches - id: no-commit-to-branch # - id: pretty-format-json @@ -63,7 +64,7 @@ repos: hooks: - id: prettier args: - ['--ignore-unknown', '--no-error-on-unmatched-pattern', '!chart/**'] + ['--ignore-unknown'] # Lint: Markdown - repo: https://github.com/igorshubovych/markdownlint-cli @@ -97,7 +98,7 @@ repos: rev: 2.1.1 hooks: - id: bashate - args: ["--ignore=E006"] + args: ["--ignore=E006,E011"] - repo: https://github.com/shellcheck-py/shellcheck-py rev: v0.9.0.6 @@ -121,6 +122,7 @@ repos: rev: 5.13.2 hooks: - id: isort + args: ["--profile", "black"] - repo: https://github.com/adrienverge/yamllint.git rev: v1.33.0 @@ -159,4 +161,4 @@ repos: - id: mypy verbose: true args: [--show-error-codes] - additional_dependencies: ["types-requests"] + additional_dependencies: ["pytest", "types-requests"] diff --git a/docs/conf.py b/docs/conf.py index ef395b4..7e0e3b8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -34,7 +34,7 @@ from sphinx import apidoc output_dir = os.path.join(__location__, "api") -module_dir = os.path.join(__location__, "../src/osc_data_extractor") +module_dir = os.path.join(__location__, "../src/osc-rule-based-extractor") try: shutil.rmtree(output_dir) except FileNotFoundError: @@ -99,7 +99,7 @@ # If you don’t need the separation provided between version and release, # just set them both to the same value. try: - from osc_data_extractor import __version__ as version + from osc-rule-based-extractor import __version__ as version except ImportError: version = "" diff --git a/pyproject.toml b/pyproject.toml index e7c4c5c..010f791 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,7 @@ build-backend = "pdm.backend" license-files = ["LICENSES.txt"] [project.scripts] -osc-data-extractor = "osc_data_extractor.skeleton:run" +osc-data-extractor = "osc-rule-based-extractor.skeleton:run" [project.optional-dependencies] dev = [ diff --git a/scripts/template-to-repo.sh b/scripts/template-to-repo.sh index 21c975c..fd9fb7d 100755 --- a/scripts/template-to-repo.sh +++ b/scripts/template-to-repo.sh @@ -48,29 +48,35 @@ file_content_substitution() { else FILENAME="$1" fi + COUNT=0 if (grep "$TEMPLATE_NAME" "$FILENAME" > /dev/null 2>&1); then MATCHES=$(grep -c "$TEMPLATE_NAME" "$FILENAME") if [ "$MATCHES" -eq 1 ]; then - echo "1 content substitution required: $FILENAME" + echo "1 content substitution required: $FILENAME (dashes)" + COUNT=$((COUNT++)) else - echo "$MATCHES content substitutions required: $FILENAME" + echo "$MATCHES content substitutions required: $FILENAME (dashes)" + COUNT=$((COUNT+MATCHES)) fi sed -i "s/$TEMPLATE_NAME/$REPO_NAME/g" "$FILENAME" fi if (grep "$ALT_TEMPLATE_NAME" "$FILENAME" > /dev/null 2>&1); then MATCHES=$(grep -c "$ALT_TEMPLATE_NAME" "$FILENAME") if [ "$MATCHES" -eq 1 ]; then - echo "1 content substitution required: $FILENAME" + echo "1 content substitution required: $FILENAME (underscores)" + COUNT=$((COUNT++)) else - echo "$MATCHES content substitutions required: $FILENAME" + echo "$MATCHES content substitutions required: $FILENAME (underscores)" + COUNT=$((COUNT+MATCHES)) fi sed -i "s/$ALT_TEMPLATE_NAME/$ALT_REPO_NAME/g" "$FILENAME" fi + echo "$COUNT total substitution(s) made in file: $FILENAME" } ### Main script entry point -TEMPLATE_NAME=osc-python-template +TEMPLATE_NAME=osc-rule-based-extractor ALT_TEMPLATE_NAME="${TEMPLATE_NAME//-/_}" if ! (git rev-parse --show-toplevel > /dev/null); then diff --git a/src/osc_data_extractor/__init__.py b/src/osc_rule_based_extractor/__init__.py similarity index 100% rename from src/osc_data_extractor/__init__.py rename to src/osc_rule_based_extractor/__init__.py diff --git a/src/osc_data_extractor/skeleton.py b/src/osc_rule_based_extractor/skeleton.py similarity index 94% rename from src/osc_data_extractor/skeleton.py rename to src/osc_rule_based_extractor/skeleton.py index 03b4206..a845528 100644 --- a/src/osc_data_extractor/skeleton.py +++ b/src/osc_rule_based_extractor/skeleton.py @@ -4,7 +4,7 @@ ``[options.entry_points]`` section in ``setup.cfg``:: console_scripts = - fibonacci = osc_data_extractor.skeleton:run + fibonacci = osc_rule_based_extractor.skeleton:run Then run ``pip install .`` (or ``pip install -e .`` for editable mode) which will install the command ``fibonacci`` inside your current environment. @@ -24,7 +24,7 @@ import logging import sys -from osc_data_extractor import __version__ +from osc_rule_based_extractor import __version__ __author__ = "Matthew Watkins" __copyright__ = "Matthew Watkins" @@ -36,7 +36,7 @@ # ---- Python API ---- # The functions defined in this section can be imported by users in their # Python scripts/interactive interpreter, e.g. via -# `from osc_data_extractor.skeleton import fib`, +# `from osc_rule_based_extractor.skeleton import fib`, # when using this Python module as a library. @@ -142,6 +142,6 @@ def run(): # After installing your project with pip, users can also run your Python # modules as scripts via the ``-m`` flag, as defined in PEP 338:: # - # python -m osc_data_extractor.skeleton 42 + # python -m osc_rule_based_extractor.skeleton 42 # run() diff --git a/tests/conftest.py b/tests/conftest.py index 7a41d0d..df8010b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,5 @@ """ - Dummy conftest.py for osc_data_extractor. + Dummy conftest.py for osc-rule-based-extractor. If you don't know what this is for, just leave it empty. Read more about conftest.py under: diff --git a/tests/osc_data_extractor_test.py b/tests/test_osc_rule_based_extractor.py similarity index 99% rename from tests/osc_data_extractor_test.py rename to tests/test_osc_rule_based_extractor.py index c39011f..e588107 100644 --- a/tests/osc_data_extractor_test.py +++ b/tests/test_osc_rule_based_extractor.py @@ -1,5 +1,4 @@ import pytest - from osc_data_extractor.skeleton import fib, main __author__ = "Matthew Watkins"