How to use the s2protocol.encoders.IncompleteError function in s2protocol

To help you get started, we’ve selected a few s2protocol examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Blizzard / s2protocol / s2protocol / encoders.py View on Github external
def _choice(self, value, bounds, fields):
        #assert isinstance(value, dict)
        assert len(value) == 1
        for tag, field in fields.items():
            if field[0] in value:
                self._int(tag, bounds)
                self.instance(value[field[0]], field[1])
                break
        else:
            raise IncompleteError(self) # unknown choice field name
github Blizzard / s2protocol / s2protocol / encoders.py View on Github external
def _struct(self, value, fields):
        #assert isinstance(value, dict)
        # encode each field
        for field_name, field_type, _ in fields:
            if field_name == '__parent':
                # if there is a parent its fields are in the same value dict
                self.instance(value, field_type)
            elif field_name in value:
                self.instance(value[field_name], field_type)
            else:
                raise IncompleteError(self) # missing field_name
github Blizzard / s2protocol / s2protocol / encoders.py View on Github external
def _choice(self, value, bounds, fields):
        #assert isinstance(value, dict)
        assert len(value) == 1
        self._write_skip(3)
        for tag, field in fields.items():
            if field[0] in value:
                self._vint(tag)
                self.instance(value[field[0]], field[1])
                break
        else:
            raise IncompleteError(self) # unknown choice field name