def _bufferize_arg(worker: AbstractWorker, arg: object) -> ArgPB: protobuf_arg = ArgPB() try: setattr(protobuf_arg, "arg_" + type(arg).__name__, arg) except: getattr(protobuf_arg, "arg_" + type(arg).__name__).CopyFrom( sy.serde.protobuf.serde._bufferize(worker, arg)) return protobuf_arg
def bufferize_arg(worker: AbstractWorker, arg: object) -> ArgPB: protobuf_arg = ArgPB() try: setattr(protobuf_arg, "arg_" + type(arg).__name__.lower(), arg) except: getattr(protobuf_arg, "arg_" + type(arg).__name__.lower()).CopyFrom( _bufferize(worker, arg)) return protobuf_arg
def bufferize_arg(worker: AbstractWorker, arg: object) -> ArgPB: protobuf_arg = ArgPB() attr_name = "arg_" + _camel2snake(type(arg).__name__) try: setattr(protobuf_arg, attr_name, arg) except: getattr(protobuf_arg, attr_name).CopyFrom(_bufferize(worker, arg)) return protobuf_arg
def bufferize_arg(worker: AbstractWorker, arg: object) -> ArgPB: protobuf_arg = ArgPB() if isinstance(arg, list): protobuf_arg_list = ArgListPB() arg_list = [bufferize_arg(worker, i) for i in arg] protobuf_arg_list.args.extend(arg_list) protobuf_arg.arg_list.CopyFrom(protobuf_arg_list) else: attr_name = "arg_" + _camel2snake(type(arg).__name__) try: setattr(protobuf_arg, attr_name, arg) except: getattr(protobuf_arg, attr_name).CopyFrom(_bufferize(worker, arg)) return protobuf_arg