Skip to content

Commit

Permalink
Bugfixes and publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
chalbersma committed May 6, 2023
1 parent b3887aa commit 1bdd0b8
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 19 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/python-publish-stag.yml
Original file line number Diff line number Diff line change
@@ -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/
36 changes: 36 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
25 changes: 6 additions & 19 deletions pfe/comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,16 @@
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,
mtype="is",
mvalue=None,
ccomplex=None,
exemptfail=False,
comparison_name="unnamed", **kwargs):
comparison_name="unnamed",
**kwargs):

'''
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -132,7 +123,6 @@ def big_loop(self):

this_mvalue = self.mvalue[ti]


try:
this_cvalue = pyjq.one(self.ccomplex[ti], x)

Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -336,5 +324,4 @@ def ver_check(self, mvalue, cvalue, **chargs):
self.logger.warning("Unknown version direction {}".format(direction))
pfe = PFE.EXEMPT


return pfe
return pfe
28 changes: 28 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"},
]
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"]

0 comments on commit 1bdd0b8

Please sign in to comment.