From 1c70be079e042fe386df8268ca8a492e73c199fe Mon Sep 17 00:00:00 2001 From: Gabor Guzmics Date: Fri, 14 Apr 2017 18:44:32 +0200 Subject: [PATCH] ?? they were missing, what? --- logs/base.py | 7 +++++++ logs/combat.py | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/logs/base.py b/logs/base.py index 6a4cc93..8415e91 100644 --- a/logs/base.py +++ b/logs/base.py @@ -17,6 +17,13 @@ import logging reviewed is an internal boolean, which supposed to be saved on successful unpack, unpack should ignore already unpacked logs. matcher is a regex object to match, or a list of them. trash is a boolean flag to indicate, this log is possibly unknown information or unneeded, and should be removed or ignored. + + -> Note for anyone creating new subclasses for parsing: + All classes are to be __slot__-ed so they can be created more efficiently by python. + A class without __slot__ will slow down parsing exponentially in CPython. + __slots__ hinder you to add new properties on the fly in the code, but having this immutable class optimizes memory allocation. + + This is the reason, the base layout of the log object is explained here. """ diff --git a/logs/combat.py b/logs/combat.py index f2445f7..d39c450 100644 --- a/logs/combat.py +++ b/logs/combat.py @@ -116,6 +116,23 @@ class Participant(CombatLog): __slots__ = CombatLog.__slots__ matcher = re.compile(r"^\s+Participant\s+(?P[^\s]+)(?:\s+(?P\w+)|\s{30,})\s+(?:totalDamage\s(?P(?:\d+|\d+\.\d+));\s+|\s+)(?:mostDamageWith\s'(?P[^']+)';\s*(?P.*)|<(?P\w+)>)") +""" +2017-03-29 13:25:49 - Unknown Packet for Rocket: +Rocket launch 18912, owner 'LOSNAR', def 'SpaceMissile_Barrage_T5_Mk3', target 'white213mouse' (17894) +2017-03-29 13:25:49 - Unknown Packet for Rocket: +Rocket detonation 18912, owner 'LOSNAR', def 'SpaceMissile_Barrage_T5_Mk3', reason 'auto_detonate', directHit 'white213mouse' +2017-03-29 13:25:49 - Unknown Packet for Rocket: +Rocket launch 18966, owner 'LOSNAR', def 'SpaceMissile_Barrage_T5_Mk3', target 'white213mouse' (17894) +2017-03-29 13:25:49 - Unknown Packet for Rocket: +Rocket detonation 18966, owner 'LOSNAR', def 'SpaceMissile_Barrage_T5_Mk3', reason 'auto_detonate', directHit 'white213mouse' +2017-03-29 13:25:49 - Unknown Packet for Rocket: +Rocket detonation 18892, owner 'LOSNAR', def 'SpaceMissile_Barrage_T5_Mk3', reason 'ttl' +2017-03-29 13:25:49 - Unknown Packet for Rocket: +Rocket detonation 18931, owner 'optimistik', def 'Weapon_Railgun_Heavy_T5_Epic', reason 'hit' +2017-03-29 13:25:49 - Unknown Packet for Participant: + Participant white213mouse Ship_Race5_M_ATTACK_Rank15 +""" + class Rocket(CombatLog): __slots__ = CombatLog.__slots__ matcher = re.compile(r"^Rocket\s(?Plaunch|detonation)\.\sowner\s'(?P[^']+)'(?:,\s(?:def\s'(?P\w+)'|target\s'(?P[^']+)'|reason\s'(?P\w+)'|directHit\s'(?P[^']+)'))+")