diff --git a/.github/workflows/python-publish-stag.yml b/.github/workflows/python-publish-stag.yml new file mode 100644 index 0000000..abef659 --- /dev/null +++ b/.github/workflows/python-publish-stag.yml @@ -0,0 +1,38 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Upload Python Package [Staging] + +on: + push: + branches: + - main + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.11' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.STAG_PYPI_TOKEN }} + repository_url: https://test.pypi.org/legacy/ diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..d0c5c1f --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,36 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Upload Python Package + +on: + release: + types: [published] + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.11' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PROD_PYPI_TOKEN }} diff --git a/pfe/comparison.py b/pfe/comparison.py index aa52a0b..7af8784 100755 --- a/pfe/comparison.py +++ b/pfe/comparison.py @@ -15,16 +15,7 @@ from pfe import PFE -def Comparison(object, - mtype, - ctype, - csubtype, - mvalue, - ccomplex=None, - ccomplex_value=False, - exemptfail=False, - comparison_name="unnamed", - **kwargs): +class Comparison(): def __init__(self, object, @@ -32,7 +23,8 @@ def __init__(self, mvalue=None, ccomplex=None, exemptfail=False, - comparison_name="unnamed", **kwargs): + comparison_name="unnamed", + **kwargs): ''' @@ -75,13 +67,12 @@ def __init__(self, if isinstance(mtype, str): # Expand mtype to length of comparisons - self.mtype = [mtype for x in range(self.length) ] + self.mtype = [mtype for x in range(self.length)] elif isinstance(mtype, list): if len(mtype) != self.length: raise ValueError("Custom list of mtypes doesn't match length fo values and complexes") self.mtype = mtype - self.id_field = self.kwargs.get("id_field", None) self.data_field = self.kwargs.get("data_field", None) @@ -132,7 +123,6 @@ def big_loop(self): this_mvalue = self.mvalue[ti] - try: this_cvalue = pyjq.one(self.ccomplex[ti], x) @@ -151,7 +141,7 @@ def big_loop(self): this_pfe = self.is_check(this_mvalue, this_cvalue) elif this_mtype in ("match", "matchne"): match_args = {"ne": False} - if "ne" in mvalue: + if "ne" in this_mtype: match_args["ne"] = True this_pfe = self.match_check(this_mvalue, this_cvalue, **match_args) @@ -186,7 +176,6 @@ def big_loop(self): else: results.append(this_pfe) - if PFE.EXEMPT in results: exempt_list.append(object_name) elif PFE.FAIL in results: @@ -306,7 +295,6 @@ def ver_check(self, mvalue, cvalue, **chargs): mvalue_ver = len(mvalue) cvalue_ver = len(cvalue) - if direction == "eq": if cvalue_ver == mvalue_ver: pfe = PFE.PASS @@ -336,5 +324,4 @@ def ver_check(self, mvalue, cvalue, **chargs): self.logger.warning("Unknown version direction {}".format(direction)) pfe = PFE.EXEMPT - - return pfe \ No newline at end of file + return pfe diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..35702e3 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,28 @@ +[build-system] +requires = [ + "twine", + "setuptools" +] +build-backend = "setuptools.build_meta" + +[project] +name = "pfelogic" +version = "2023.05.05.0" +authors = [ + {name = "Chris Halbersma", email = "chalbersma@halbersma.us"}, +] +description = "An opinionated pass fail exempt library that I wanted to stop making in every project." +readme = "README.md" +requires-python = ">=3.10" +keywords = ["manowar"] +license = {text = "BSD-2-Clause"} +classifiers = [ + "Programming Language :: Python :: 3", +] +dependencies = [ + "packaging", + "pyjq", +] + +[options] +packages = ["pfe"] \ No newline at end of file