Skip to content

Commit

Permalink
Updates (#10)
Browse files Browse the repository at this point in the history
* Consistently wrap exceptions in ItemActionError

* Support `NOOP` as a response type in config files

* Upgrade PyYAML; update poetry.lock and lock-version

* Log NOOP actions
  • Loading branch information
rschmitt authored Feb 8, 2025
1 parent 5019902 commit fb07df2
Show file tree
Hide file tree
Showing 5 changed files with 592 additions and 527 deletions.
4 changes: 2 additions & 2 deletions calrules/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ def main():
break

for i in items:
LOG.info(f"Item: {i.subject} is marked for {i.action}")

if i.action is Response.NOOP:
continue

LOG.info(f"Item: {i.subject} is marked for {i.action}")

try:
if i.action is Response.ACCEPT:
i.accept()
Expand Down
2 changes: 1 addition & 1 deletion calrules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
rule:
pattern: str()
description: str()
response: enum('ACCEPT', 'MAYBE', 'DECLINE', 'DELETE', required=False, none='DECLINE')
response: enum('ACCEPT', 'MAYBE', 'DECLINE', 'DELETE', 'NOOP', required=False, none='NOOP')
message: str(required=False)
"""

Expand Down
6 changes: 3 additions & 3 deletions calrules/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ def delete(self):

self.item.delete(affected_task_occurrences='AllOccurrences')
except Exception as e:
raise ItemError(e)
raise ItemActionError(e)

def accept(self):
try:
self.item.accept()
except Exception as e:
raise ItemError(e)
raise ItemActionError(e)

def decline(self):
try:
Expand All @@ -121,4 +121,4 @@ def maybe(self):
def thread_index(self) -> str:
for h in self.item.headers:
if h.name == "Thread-Index":
return h.value
return h.value
Loading

0 comments on commit fb07df2

Please sign in to comment.