# Path: utils.py
# class ProtocolViolation(Exception):
#     """Indicates that the communication protocol between this and a remote
#     client has been violated. In this case we abort from the communication."""
#     def __init__(self, reason="unknown"):
#         self.reason = reason
#     def __repr__(self):
#         return "ProtocolViolation(%s)"%self.reason
# 
# def constructor(func):
#     @classmethod
#     def f(cls, *args, **kwargs):
#         self = cls.__new__(cls)
#         func(self, *args, **kwargs)
#         return self
#     return f


import binascii
from utils import ProtocolViolation, constructor
Float = alreadyjson(float)
Bool = alreadyjson(bool)

def List(type):
    class _List():
        @staticmethod
        def tojson(self):
            return [type.tojson(x) for x in self]
        @staticmethod
        def fromjson(json):
            return [type.fromjson(x) for x in json]
    return _List

def Dict(ktype, vtype):
    class _Dict():
        def tojson(self):
            return dict(((ktype.tojson(k), vtype.tojson(v)) for (k, v) in self.items()))
        @staticmethod
        def fromjson(json):
            return dict(((ktype.fromjson(k), vtype.fromjson(v)) for (k, v) in json.items()))
    return _Dict

# Serialization for various types in stdlib modules

#This isn't technically a stdlib module
class IPv4():
    @staticmethod
    def tojson(obj):
        return str(obj)
    @staticmethod

# Path: utils.py
# class ProtocolViolation(Exception):
#     """Indicates that the communication protocol between this and a remote
#     client has been violated. In this case we abort from the communication."""
#     def __init__(self, reason="unknown"):
#         self.reason = reason
#     def __repr__(self):
#         return "ProtocolViolation(%s)"%self.reason
# 
# def constructor(func):
#     @classmethod
#     def f(cls, *args, **kwargs):
#         self = cls.__new__(cls)
#         func(self, *args, **kwargs)
#         return self
#     return f


# Path: jserialize.py
import binascii
from utils import ProtocolViolation, constructor

Float = alreadyjson(float)
Bool = alreadyjson(bool)

def List(type):
    class _List():
        @staticmethod
        def tojson(self):
            return [type.tojson(x) for x in self]
        @staticmethod
        def fromjson(json):
            return [type.fromjson(x) for x in json]
    return _List

def Dict(ktype, vtype):
    class _Dict():
        def tojson(self):
            return dict(((ktype.tojson(k), vtype.tojson(v)) for (k, v) in self.items()))
        @staticmethod
        def fromjson(json):
            return dict(((ktype.fromjson(k), vtype.fromjson(v)) for (k, v) in json.items()))
    return _Dict

# Serialization for various types in stdlib modules

#This isn't technically a stdlib module
class IPv4():
    @staticmethod
    def tojson(obj):
        return str(obj)
    @staticmethod

    def fromjson(object):