コード例 #1
0
def from_decimal(decimal):

    if decimal.HasField("u_int_32"):
        return int(decimal.u_int_32)
    elif decimal.HasField("s_int_32"):
        return int(decimal.s_int_32)
    elif decimal.HasField("u_int_64"):
        return int(decimal.u_int_64)
    elif decimal.HasField("s_int_64"):
        return int(decimal.s_int_64)
    elif decimal.HasField("floating"):
        return float(decimal.floating)
    elif decimal.HasField("string_sequence"):
        raise MishmashNotImplementedYetException("string_sequence not implemented yet")
    elif decimal.HasField("big_decimal"):
        raise MishmashNotImplementedYetException("big_decimal not implemented yet")
    else:
        raise MishmashNotImplementedYetException("wrong decimal value")
コード例 #2
0
    def __getitem__(self, name):

        new_mishmash = self.__intersection(name)

        if self.is_async:
            raise MishmashNotImplementedYetException(
                "not implemented async __getitem__ logic")

        return new_mishmash
コード例 #3
0
def to_value(arg):
    if isinstance(arg, int):
        return mishmash_rpc_pb2.Value(decimal=to_decimal(arg))
    elif isinstance(arg, bool):
        return mishmash_rpc_pb2.Value(boolean=mishmash_rpc_pb2.BooleanValue(boolean=arg))
    elif arg is None:
        return mishmash_rpc_pb2.Value(null=mishmash_rpc_pb2.NullValue())
    elif isinstance(arg, float):
        return mishmash_rpc_pb2.Value(decimal=to_decimal(arg))
    elif isinstance(arg, str):
        return mishmash_rpc_pb2.Value(string=mishmash_rpc_pb2.StringValue(sequence=arg))
    elif utils.isinstance_datetime(arg):
        return mishmash_rpc_pb2.Value(date=mishmash_rpc_pb2.DateValue(iso8601=arg.isoformat()))
    else:
        raise MishmashNotImplementedYetException(f"value with type {type(arg)} is not implemented yet")
コード例 #4
0
def from_value(value):
    if value.HasField("boolean"):
        return from_boolean(value.boolean)
    elif value.HasField("decimal"):
        return from_decimal(value.decimal)
    elif value.HasField("string"):
        return from_string(value.string)
    elif value.HasField("date"):
        return datetime.strptime(value.date.iso8601, "%Y-%m-%dT%H:%M:%SZ")
    elif value.HasField("buffer"):
        raise MishmashNotImplementedYetException("get buffer not implemented yet")
    elif value.HasField("null"):
        return None
    else:
        raise MishmashInvalidMessageException(
            "wrong value = {} with type = {}".format(value, type(value)))
コード例 #5
0
 def __union_lambda(self, v):
     raise MishmashNotImplementedYetException(
         "union with lambda function are not implemented yet")
コード例 #6
0
 def __union_memoryview(self, v):
     raise MishmashNotImplementedYetException(
         "union with memoryview object are not implemented yet")
コード例 #7
0
 def __union_slice(self, v):
     raise MishmashNotImplementedYetException(
         "union with slice are not implemented yet")
コード例 #8
0
 def __union_namedtuple(self, v):
     raise MishmashNotImplementedYetException(
         "union with namedtuple are not implemented yet")
コード例 #9
0
 def __union_bytes(self, v):
     raise MishmashNotImplementedYetException(
         "union with bytes object are not implemented yet")
コード例 #10
0
 def __intersect_generator(self, v):
     raise MishmashNotImplementedYetException("intersect with generator")
コード例 #11
0
 def __intersect_namedtuple(self, v):
     raise MishmashNotImplementedYetException("intersect with namedtuple")
コード例 #12
0
 def __intersect_memoryview(self, v):
     raise MishmashNotImplementedYetException("intersect with memoryview")
コード例 #13
0
 def __intersect_bytearray(self, v):
     raise MishmashNotImplementedYetException("intersect with bytearray")
コード例 #14
0
 def __intersect_slice(self, v):
     raise MishmashNotImplementedYetException("intersection with slice")
コード例 #15
0
 def __intersect_range(self, v):
     raise MishmashNotImplementedYetException("intersection with range")
コード例 #16
0
 def __union_generator(self, v):
     raise MishmashNotImplementedYetException(
         "union with generator are not implemented yet")
コード例 #17
0
 def __union_method(self, v):
     raise MishmashNotImplementedYetException(
         "union with method are not implemented yet")
コード例 #18
0
 def __intersect_method(self, v):
     raise MishmashNotImplementedYetException("intersect with method")
コード例 #19
0
 async def __anext__(self):
     raise MishmashNotImplementedYetException("__anext__ not implemented next")
コード例 #20
0
 def __intersect_lambda(self, v):
     raise MishmashNotImplementedYetException("intersect with lambda")
コード例 #21
0
 def __xor__(self, y):
     raise MishmashNotImplementedYetException(
         " xor logic not implemented yet")
コード例 #22
0
 def __union_complex(self, v):
     raise MishmashNotImplementedYetException(
         "complex number are not implemented yet")