From fdbde18856e93e618e28b4fc51aada804d421b35 Mon Sep 17 00:00:00 2001 From: Thor77 Date: Sat, 19 Nov 2016 22:25:57 +0100 Subject: [PATCH] parse_logs: Return Server instead of dict because it's easier to iterate and access contained information --- tsstats/log.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tsstats/log.py b/tsstats/log.py index c58532a..2db8873 100644 --- a/tsstats/log.py +++ b/tsstats/log.py @@ -24,6 +24,7 @@ re_disconnect_invoker = re.compile( log_timestamp_format = '%Y-%m-%d %H:%M:%S.%f' TimedLog = namedtuple('TimedLog', ['path', 'timestamp']) +Server = namedtuple('Server', ['sid', 'clients']) logger = logging.getLogger('tsstats') @@ -40,9 +41,9 @@ def parse_logs(log_glob, ident_map=None, online_dc=True, *args, **kwargs): :type ident_map: dict :return: clients bundled by virtual-server - :rtype: dict + :rtype: tsstats.log.Server ''' - vserver_clients = {} + server = [] for virtualserver_id, logs in\ _bundle_logs(glob(log_glob)).items(): clients = Clients(ident_map) @@ -56,8 +57,8 @@ def parse_logs(log_glob, ident_map=None, online_dc=True, *args, **kwargs): _parse_details(logs[-1].path, clients=clients, online_dc=online_dc, *args, **kwargs) if len(clients) >= 1: - vserver_clients[virtualserver_id] = clients - return vserver_clients + server.append(Server(virtualserver_id, clients)) + return server def _bundle_logs(logs):