mirror of
https://github.com/davegallant/rfd-notify.git
synced 2025-08-06 00:33:39 +00:00
Migrate to python (#265)
* Add initial python migration * Add pylint * Add pre-commit * Add Dockerfile * Add expression matching * Use shelve to store previous matches * Add notifications * Calculate post age * Update README.md
This commit is contained in:
19
rfd_notify/config.py
Normal file
19
rfd_notify/config.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import yaml
|
||||
from loguru import logger
|
||||
|
||||
|
||||
class Config:
|
||||
def __init__(self, expressions):
|
||||
self.expressions = expressions
|
||||
|
||||
def __repr__(self):
|
||||
return f"Config(expressions={self.expressions})"
|
||||
|
||||
|
||||
def load_yaml_file(filename: str) -> Config:
|
||||
with open(filename, "r", encoding="utf-8") as file:
|
||||
try:
|
||||
data = yaml.safe_load(file)
|
||||
except yaml.YAMLError as err:
|
||||
logger.error(f"Error loading config file: {err}")
|
||||
return Config(**data)
|
Reference in New Issue
Block a user