Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from KPrasch/superman
Browse files Browse the repository at this point in the history
Use super for splittable baseclasses
  • Loading branch information
vepkenez authored Apr 30, 2020
2 parents 841e54e + 2bb8cac commit 41970de
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions bytestring_splitter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def produce_value(message_class, message_name, bytes_for_this_object, kwargs):
return value


class BytestringSplitter(object):
class BytestringSplitter:
Message = namedtuple("Message", ("name", "message_class", "length", "kwargs"))
processed_objects_container = list
partial_receiver = PartiallySplitBytes
Expand Down Expand Up @@ -347,14 +347,13 @@ def repeat(self, splittable, as_set=False):
class BytestringKwargifier(BytestringSplitter):
processed_objects_container = dict
partial_receiver = PartiallyKwargifiedBytes
__splitterbaseclass = BytestringSplitter

def __init__(self, _receiver=None, _partial_receiver=None, _additional_kwargs=None, **parameter_pairs):
self.receiver = _receiver
if _partial_receiver is not None:
self.partial_receiver = _partial_receiver
self._additional_kwargs = _additional_kwargs or {}
self.__splitterbaseclass.__init__(self, *parameter_pairs.items())
super().__init__(*parameter_pairs.items())

def __call__(self, splittable, receiver=None, partial=False, *args, **kwargs):
receiver = receiver or self.receiver
Expand All @@ -363,7 +362,7 @@ def __call__(self, splittable, receiver=None, partial=False, *args, **kwargs):
raise TypeError(
"Can't fabricate without a receiver. You can either pass one when calling or pass one when init'ing.")

result = self.__splitterbaseclass.__call__(self, splittable, partial=partial, *args, **kwargs)
result = super().__call__(splittable, partial=partial, *args, **kwargs)
if partial:
result.set_receiver(receiver)
result.set_additional_kwargs(self._additional_kwargs)
Expand Down Expand Up @@ -549,7 +548,6 @@ class VersionedBytestringKwargifier(VersionedBytestringSplitter, BytestringKwarg
"""
A BytestringKwargifier which is versioned.
"""
__splitterbaseclass = VersionedBytestringSplitter

def __init__(self, *args, **kwargs):
self._input_version = kwargs.pop('version')
Expand Down

0 comments on commit 41970de

Please sign in to comment.