refactory

This commit is contained in:
2025-04-28 22:29:35 +02:00
parent 40ef173694
commit cc7a136cf3
26 changed files with 372 additions and 433 deletions

View File

@@ -2,9 +2,8 @@
"""
from configparser import ConfigParser
import json
class config:
class Config:
def __init__(self):
c = ConfigParser()
c.read(["/etc/aseftp/ftpcsvreceiver.ini", "./ftpcsvreceiver.ini",

12
utils/config/parser.py Normal file
View File

@@ -0,0 +1,12 @@
import re
def extract_value(patterns, primary_source, secondary_source, default='Not Defined'):
"""Extracts the first match for a list of patterns from the primary source.
Falls back to the secondary source if no match is found.
"""
for source in (primary_source, secondary_source):
for pattern in patterns:
matches = re.findall(pattern, source, re.IGNORECASE)
if matches:
return matches[0] # Return the first match immediately
return default # Return default if no matches are found