def deserialize_reply(xml, update_time=False):
if not xml:<EOL><INDENT>return EmptyReply()<EOL><DEDENT>try:<EOL><INDENT>reply_dict = xmltodict.parse(xml)["<STR_LIT>"]<EOL>msg_type = reply_dict["<STR_LIT>"]<EOL><DEDENT>except (xmltodict.expat.ExpatError, KeyError):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if msg_type not in REPLY_TYPES:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>cls = REPLY_TYPES[msg_type]<EOL>kwargs = dict()<EOL>for attr, field in cls._fields.items():<EOL><INDENT>if field.name in reply_dict:<EOL><INDENT>str_value = reply_dict[field.name]<EOL>kwargs[attr] = field.from_xml(str_value)<EOL><DEDENT><DEDENT>if update_time:<EOL><INDENT>kwargs["<STR_LIT:time>"] = time.time()<EOL><DEDENT>return cls(**kwargs)<EOL>
反序列化被动回复
:param xml: 待反序列化的xml
:param update_time: 是否用当前时间替换xml中的时间
:raises ValueError: 不能辨识的reply xml
:rtype: wechatpy.replies.BaseReply