From 2b4b95a42ffabeb650484b1319ae599831dbd899 Mon Sep 17 00:00:00 2001 From: nico Date: Fri, 8 Nov 2019 16:28:57 +0100 Subject: * minor restructuring --- ingest.py | 16 ++++++---------- main.py | 7 ++++--- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/ingest.py b/ingest.py index dc8cf21..0c762c8 100644 --- a/ingest.py +++ b/ingest.py @@ -7,30 +7,26 @@ import sys from defusedxml import ElementTree -class Ingest: +class IngestLogfile: """log ingestion class""" - def __init__(self, conn, infile: list = None): + def __init__(self, conn): """ :param conn: sqlite connection object - :param infile: list containing log filenames to be ingested """ self.conn = conn - self.infile = infile self.jid_pattern = re.compile("^(?:([^\"&'/:<>@]{1,1023})@)?([^/@]{1,1023})(?:/(.{1,1023}))?$") self.message_pattern = re.compile(r'', re.DOTALL) - self.ingest() - - def ingest(self): + def read(self, infile: list = None): """ - ingest method to split up the ingest file list - if necessary decompression and decoding are applied + ingest method to split up the ingest file list, if necessary decompression and decoding are applied + :param infile: list containing log filenames to be ingested """ magic_number = b"\x1f\x8b\x08" # iterate over all infile elements - for element in self.infile: + for element in infile: try: # open file in binary mode diff --git a/main.py b/main.py index cf417d5..e528d3b 100755 --- a/main.py +++ b/main.py @@ -8,7 +8,7 @@ import sys import tabulate -from ingest import Ingest +from ingest import IngestLogfile from report import ReportDomain @@ -25,6 +25,7 @@ class AbuseReport: self.conn = sqlite3.connect("/".join([self.path, "spam.db"])) self.Report = ReportDomain(self.conn) + self.Ingest = IngestLogfile(self.conn) def main(self): """main method guiding the actions to take""" @@ -37,10 +38,10 @@ class AbuseReport: elif self.infile: # infile set -> ingest - Ingest(self.conn, self.infile) + self.Ingest.read(self.infile) # close sqlite connection - self.conn.close() + self.conn.close() def check(self): # check if the minimum requirements are met -- cgit v1.2.3-54-g00ecf