From d5dff9b9bc4d928a9ff787ef0dcf32cdd34be623 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Tue, 19 Mar 2024 07:55:04 +0100 Subject: [PATCH] Fixing class PostfixLogchainInfo. --- lib/pp_admintools/postfix_chain.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/pp_admintools/postfix_chain.py b/lib/pp_admintools/postfix_chain.py index 5bbbd2f..e394ec5 100644 --- a/lib/pp_admintools/postfix_chain.py +++ b/lib/pp_admintools/postfix_chain.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -@summary: A class for encapsulating the information from a chain of Postfix log entries +@summary: A class for encapsulating the information from a chain of Postfix log entries. @author: Frank Brehm @contact: frank.brehm@pixelpark.com @@ -14,7 +14,6 @@ import logging import re # Third party modules -from from fb_tools.obj import FbGenericBaseObject __version__ = '0.1.0' @@ -28,11 +27,19 @@ UTC = utc = datetime.timezone(0, 'UTC') class PostfixLogchainInfo(FbGenericBaseObject): """A class for encapsulating the information from a chain of Postfix log entries.""" + pattern_isodate = r'(?P\d{4})-?(?P[01]\d)-?(?P[0-3]\d)' + pattern_isotime = ( + r'(?P[0-2]\d):?(?P[0-5]\d)(?::?(?P[0-5]\d)(\.(?P\d+))?)?') + pattern_isotimezone = r'((?PZ)|(?P[+-][01]\d)(?::?(?P[0-5]\d))?)?' + + re_isodatetime = re.compile( + pattern_isodate + r'[T\s]' + pattern_isotime + pattern_isotimezone) + # ------------------------------------------------------------------------- def __init__( - self, client_host=None, client_addr=None, start=None, end=None, message_id=None, postfix_pid=None, - ehlo=None, starttls=None, quit=None, auth=None, commands=None, rcpt=None, data=None, - mail=None, from_address=None, to_address=None): + self, client_host=None, client_addr=None, start=None, end=None, message_id=None, + postfix_pid=None, ehlo=None, starttls=None, sent_quit=None, auth=None, commands=None, + rcpt=None, data=None, mail=None, from_address=None, to_address=None): """Initialize this object.""" self._auth = None self._client_addr = None @@ -45,8 +52,8 @@ class PostfixLogchainInfo(FbGenericBaseObject): self._mail = None self._message_id = None self._postfix_pid = None - self._quit = None self._rcpt = None + self._sent_quit = None self._start = None self._starttls = None self._to_address = None @@ -64,14 +71,13 @@ class PostfixLogchainInfo(FbGenericBaseObject): if value is None: self._auth = None return - + val = str(value).strip() if val == '': self._auth = None else: self._auth = val - # ------------------------------------------------------------------------- def __repr__(self): """Typecast into a string for reproduction.""" @@ -103,7 +109,6 @@ class PostfixLogchainInfo(FbGenericBaseObject): return res - # ============================================================================= if __name__ == '__main__': @@ -112,4 +117,4 @@ if __name__ == '__main__': # ============================================================================= -# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 list -- 2.39.5