Proper __eq__ logic for Characters - we'll need this to find WorkOrders belonging to Bob.

pull/133/head
jMyles 2017-12-05 12:48:40 -08:00
parent 97a97c6b5c
commit 074788f10f
1 changed files with 8 additions and 3 deletions

View File

@ -4,13 +4,12 @@ from binascii import hexlify
from logging import getLogger
import msgpack
from apistar.http import Response
from sqlalchemy.exc import IntegrityError
from apistar import http
from apistar.core import Route
from apistar.frameworks.wsgi import WSGIApp as App
from sqlalchemy.exc import IntegrityError
from apistar.http import Response
from kademlia.network import Server
from kademlia.utils import digest
from nkms.crypto import api as API
@ -73,6 +72,12 @@ class Character(object):
else:
self._seal = StrangerSeal(self)
def __eq__(self, other):
return bytes(self.seal) == bytes(other.seal)
def __hash__(self):
return int.from_bytes(self.seal, byteorder="big")
class NotFound(KeyError):
"""raised when we try to interact with an actor of whom we haven't learned yet."""