From 513c68ca081dc9409df932ad86c66100164380a6 Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Wed, 16 Nov 2016 10:48:23 +0200 Subject: [PATCH] added StructReader --- docs/api/steam.util.rst | 6 ++++++ steam/core/msg/structs.py | 39 +++++++++++++++------------------- steam/util/binary.py | 44 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 22 deletions(-) create mode 100644 steam/util/binary.py diff --git a/docs/api/steam.util.rst b/docs/api/steam.util.rst index 46e73b2..a2585f3 100644 --- a/docs/api/steam.util.rst +++ b/docs/api/steam.util.rst @@ -22,4 +22,10 @@ util.web :undoc-members: :show-inheritance: +util.binary +----------- +.. automodule:: steam.util.binary + :members: + :undoc-members: + :show-inheritance: diff --git a/steam/core/msg/structs.py b/steam/core/msg/structs.py index ef19a00..9a88655 100644 --- a/steam/core/msg/structs.py +++ b/steam/core/msg/structs.py @@ -1,8 +1,10 @@ """Classes to (de)serialize various struct messages""" import struct import six +from six.moves import range from steam.enums import EResult, EUniverse from steam.enums.emsg import EMsg +from steam.util.binary import StructReader _emsg_map = {} @@ -136,19 +138,18 @@ class ClientVACBanStatus(StructMessage): StructMessage.__init__(self, data) def load(self, data): - numBans, = struct.unpack_from(" m.end: m.start, m.end = m.end, m.start - offset += 4 + 4 + 4 - def __str__(self): text = ["numBans: %d" % self.numBans] @@ -179,12 +180,9 @@ class ClientChatMsg(StructMessage): return rbytes def load(self, data): - (self.steamIdChatter, - self.steamIdChatRoom, - self.ChatMsgType, - ) = struct.unpack_from("