Skip to content

Commit

Permalink
All set for first release!
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Del Fante committed Apr 11, 2022
1 parent ae4690f commit 2e4c806
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
1 change: 0 additions & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
pip install pylint
- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py')
7 changes: 4 additions & 3 deletions hlpy_business_rule_engine/rule.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import re
from typing import List

INDENTATION_PATTERN = re.compile(r"([\t ]+).+")

Expand All @@ -11,9 +12,9 @@ def __repr__(self) -> str:

DEFAULT_PRIORITY = 10000

def __init__(self, rule_name: str, conditions=[], actions="", priority=DEFAULT_PRIORITY) -> None:
def __init__(self, rule_name: str, conditions: List[str] = [], actions="", priority=DEFAULT_PRIORITY) -> None:
self.rule_name: str = rule_name
self.conditions: list[str] = conditions
self.conditions: List[str] = conditions
self.actions: str = RuleParser.normalize_indentation(actions)
self.priority: int = priority

Expand Down Expand Up @@ -65,7 +66,7 @@ def parsestr(self, text: str) -> Rule:
is_action = False
if line.lower().strip().startswith('then'):
if is_then:
#TODO change this exception
# TODO change this exception
raise Exception('using multiple "then" in one rule is not allowed')
is_then = True
ignore_line = True
Expand Down
7 changes: 3 additions & 4 deletions hlpy_business_rule_engine/rule_engine.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import os
import logging
from .rule import Rule, RuleParser
import os
import re

from .rule import Rule, RuleParser


class RuleEngine:

CUSTOM_FUNCTIONS = {}

def __init__(self):
Expand Down Expand Up @@ -133,4 +132,4 @@ def register_function(cls, function, function_name: str = None) -> None:
@classmethod
def unregister_function(cls, function, function_name: str = None) -> None:
custom_function_name = function_name or function.__name__
del(cls.CUSTOM_FUNCTIONS[custom_function_name])
del (cls.CUSTOM_FUNCTIONS[custom_function_name])
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
-e .

# Testing
pylint
pytest
coverage

# Packaging
twine
build
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
description-file = README.md
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
setuptools.setup(
name="hlpy_business_rule_engine",
version=version,
author="hlpy",
author_email="[email protected]",
license='MIT',
description="The hlpy business rule engine.",
author="hlpy",
author_email="[email protected]",
url='https://github.com/hlpy-co/business-rule-engine',
download_url=f'https://github.com/hlpy-co/business-rule-engine/archive/{version}.tar.gz',
packages=setuptools.find_packages(exclude=['tests/']),
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Operating System :: OS Independent",
],
python_requires='>=3.8',
Expand Down

0 comments on commit 2e4c806

Please sign in to comment.