Exemple #1
0
class ParkingRequestMessage:
    location: Location = attr.ib(converter=ensure(Location))
    # TODO: Maybe make a preferences class so that we can validate the content
    # of preferences.
    preferences: dict = attr.ib(validator=enforce_type, factory=dict)
    _type: int = attr.ib(default=WebSocketMessageType.PARKING_REQUEST.value,
                         init=False)
Exemple #2
0
class ParkingLot:
    capacity: int = attr.ib(validator=[enforce_type, validate_pos])
    name: str = attr.ib(validator=enforce_type)
    price: float = attr.ib(converter=float, validator=validate_non_neg)
    location: Location = attr.ib(
        converter=ensure(Location),
        validator=attr.validators.instance_of(Location))
    id: int = attr.ib(validator=enforce_type, default=0)
Exemple #3
0
class ParkingLot:
    capacity: int = attr.ib(
        validator=[attr.validators.instance_of(int), validate_pos])
    name: str = attr.ib(validator=attr.validators.instance_of(str))
    price: float = attr.ib(
        validator=[attr.validators.instance_of(float), validate_non_neg])
    location: Location = attr.ib(
        converter=ensure(Location),
        validator=attr.validators.instance_of(Location))
    id: int = attr.ib(validator=attr.validators.instance_of(int), default=0)
Exemple #4
0
class ParkingAllocationMessage:
    # TODO: Maybe have an error class to validate the error.
    lot: ParkingLot = attr.ib(converter=ensure(ParkingLot), validator=attr.validators.instance_of(ParkingLot))
    error: dict = attr.ib(validator=attr.validators.instance_of(dict), factory=dict)
    _type: int = attr.ib(default=WebSocketMessageType.PARKING_ALLOCATION.value, init=False)
Exemple #5
0
class LocationUpdateMessage:
    location: Location = attr.ib(converter=ensure(Location), validator=attr.validators.instance_of(Location))
    _type: int = attr.ib(default=WebSocketMessageType.LOCATION_UPDATE.value, init=False)
Exemple #6
0
class ParkingAllocationMessage:
    # TODO: Maybe have an error class to validate the error.
    lot: ParkingLotAllocation = attr.ib(converter=ensure(ParkingLotAllocation))
    _type: int = attr.ib(default=WebSocketMessageType.PARKING_ALLOCATION.value, init=False)
Exemple #7
0
class ErrorMessage:
    error: WsError = attr.ib(converter=ensure(WsError))
    _type: int = attr.ib(default=WebSocketMessageType.ERROR.value, init=False)