From 08b4e06f100f76d83f0b792281cf098452ebb118 Mon Sep 17 00:00:00 2001 From: Thor77 Date: Sun, 23 Jul 2017 17:31:45 +0200 Subject: [PATCH] Refactor and simplify log-parsing * _parse_line parses one line at a time for simplified testing and return a list of event.Event's instead of applying changes directly to a Clients-obj * parse_log just bundles the logs (using _bundle_logs), opens them, parses them (using _parse_line) and applies returned events to a Clients-obj in the correct order With these changes some sort of caching is possible because events are not bound to a specific client-object and are easily sortable due to their attached timestamp. --- tsstats/log.py | 177 ++++++++++++++++++------------------------------- 1 file changed, 63 insertions(+), 114 deletions(-) diff --git a/tsstats/log.py b/tsstats/log.py index ca28156..5e605ad 100644 --- a/tsstats/log.py +++ b/tsstats/log.py @@ -1,16 +1,17 @@ # -*- coding: utf-8 -*- - +# TODO: Implemented online_dc again +import itertools import logging import re from codecs import open from collections import namedtuple from glob import glob from os.path import basename -from time import time import pendulum -from tsstats.client import Client, Clients +from tsstats import events +from tsstats.client import Clients re_log_filename = re.compile(r'ts3server_(?P\d{4}-\d\d-\d\d)' '__(?P