improve CLI output
This commit is contained in:
@@ -96,15 +96,15 @@ def list_quarantines(quarantines, args):
|
|||||||
else:
|
else:
|
||||||
qlist = []
|
qlist = []
|
||||||
for q in quarantines:
|
for q in quarantines:
|
||||||
storage_type = type(q.storage).__name__
|
storage_type = q.storage.type
|
||||||
|
|
||||||
if q.notification:
|
if q.notification:
|
||||||
notification_type = type(q.notification).__name__
|
notification_type = q.notification.type
|
||||||
else:
|
else:
|
||||||
notification_type = "NONE"
|
notification_type = "NONE"
|
||||||
|
|
||||||
if q.whitelist:
|
if q.whitelist:
|
||||||
whitelist_type = type(q.whitelist).__name__
|
whitelist_type = q.whitelist.type
|
||||||
else:
|
else:
|
||||||
whitelist_type = "NONE"
|
whitelist_type = "NONE"
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ class BaseNotification:
|
|||||||
def __init__(self, pretend=False):
|
def __init__(self, pretend=False):
|
||||||
self.pretend = pretend
|
self.pretend = pretend
|
||||||
|
|
||||||
|
@property
|
||||||
|
def type(self):
|
||||||
|
return "Base"
|
||||||
|
|
||||||
def execute(self, milter, logger):
|
def execute(self, milter, logger):
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -143,6 +147,10 @@ class EMailNotification(BaseNotification):
|
|||||||
|
|
||||||
self.parser_lib = parser_lib
|
self.parser_lib = parser_lib
|
||||||
|
|
||||||
|
@property
|
||||||
|
def type(self):
|
||||||
|
return "E-Mail"
|
||||||
|
|
||||||
def get_email_body_soup(self, msg, logger):
|
def get_email_body_soup(self, msg, logger):
|
||||||
"Extract and decode email body and return it as BeautifulSoup object."
|
"Extract and decode email body and return it as BeautifulSoup object."
|
||||||
# try to find the body part
|
# try to find the body part
|
||||||
|
|||||||
@@ -47,6 +47,10 @@ class BaseMailStorage:
|
|||||||
self.metavar = metavar
|
self.metavar = metavar
|
||||||
self.pretend = False
|
self.pretend = False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def type(self):
|
||||||
|
return "Base"
|
||||||
|
|
||||||
def add(self, data, qid, mailfrom, recipients, subject, variables):
|
def add(self, data, qid, mailfrom, recipients, subject, variables):
|
||||||
"Add email to storage."
|
"Add email to storage."
|
||||||
return ("", "")
|
return ("", "")
|
||||||
@@ -103,6 +107,10 @@ class FileMailStorage(BaseMailStorage):
|
|||||||
cfg.append(f"original={self.original}")
|
cfg.append(f"original={self.original}")
|
||||||
return "FileMailStorage(" + ", ".join(cfg) + ")"
|
return "FileMailStorage(" + ", ".join(cfg) + ")"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def type(self):
|
||||||
|
return "File"
|
||||||
|
|
||||||
def get_storageid(self, qid):
|
def get_storageid(self, qid):
|
||||||
timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
|
timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
|
||||||
return f"{timestamp}_{qid}"
|
return f"{timestamp}_{qid}"
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ class WhitelistBase:
|
|||||||
self.batv_regex = re.compile(
|
self.batv_regex = re.compile(
|
||||||
r"^prvs=[0-9]{4}[0-9A-Fa-f]{6}=(?P<LEFT_PART>.+?)@")
|
r"^prvs=[0-9]{4}[0-9A-Fa-f]{6}=(?P<LEFT_PART>.+?)@")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def type(self):
|
||||||
|
return "Base"
|
||||||
|
|
||||||
def remove_batv(self, addr):
|
def remove_batv(self, addr):
|
||||||
return self.batv_regex.sub(r"\g<LEFT_PART>", addr, count=1)
|
return self.batv_regex.sub(r"\g<LEFT_PART>", addr, count=1)
|
||||||
|
|
||||||
@@ -137,6 +141,10 @@ class DatabaseWhitelist(WhitelistBase):
|
|||||||
cfg.append(f"{arg}={self.cfg[arg]}")
|
cfg.append(f"{arg}={self.cfg[arg]}")
|
||||||
return "DatabaseWhitelist(" + ", ".join(cfg) + ")"
|
return "DatabaseWhitelist(" + ", ".join(cfg) + ")"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def type(self):
|
||||||
|
return "DB"
|
||||||
|
|
||||||
def _entry_to_dict(self, entry):
|
def _entry_to_dict(self, entry):
|
||||||
result = {}
|
result = {}
|
||||||
result[entry.id] = {
|
result[entry.id] = {
|
||||||
|
|||||||
Reference in New Issue
Block a user