✏️ 正在编辑: text_format.cpython-36.pyc
路径:
/lib/python3.6/site-packages/google/protobuf/__pycache__/text_format.cpython-36.pyc
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
3 ���h�� � @ s d Z dZddlZddlZddlZejr*eZddlm Z ddl mZ ddl mZ ddd d dgZ e j� e j� e j� e j� fZejdej�Zejd ej�Zeejjejjg�ZedO�ZdZG dd� de�ZG dd� de�Z G dd� de!�Z"dPdd�Z#dd� Z$dQdd�Z%dRdd �Z&dSdd �Z'dd� Z(G d d!� d!e!�Z)dTd"d#�Z*dUd$d�Z+dVd%d&�Z,dWd'd(�Z-G d)d*� d*e!�Z.d+d,� Z/d-d.� Z0d/d0� Z1d1d2� Z2G d3d4� d4e!�Z3e3Z4d5d6� Z5d7d8� Z6d9d:� Z7d;d<� Z8d=d>� Z9d?d@� Z:dXdAdB�Z;dYdCdD�Z<dZdEdF�Z=d[dGdH�Z>dIdJ� Z?dKdL� Z@dMdN� ZAdS )\ab Contains routines for printing protocol messages in text format. Simple usage example: # Create a proto object and serialize it to a text proto string. message = my_proto_pb2.MyMessage(foo='bar') text_proto = text_format.MessageToString(message) # Parse a text proto string. message = text_format.Parse(text_proto, my_proto_pb2.MyMessage()) z kenton@google.com (Kenton Varda)� N)� type_checkers)� descriptor)� text_encoding�MessageToString�PrintMessage� PrintField�PrintFieldValue�Mergez-?inf(?:inity)?f?znanf?�'�"zgoogle.protobuf.Anyc @ s e Zd ZdZdS )�Errorz'Top-level module error for text_format.N)�__name__� __module__�__qualname__�__doc__� r r �!/usr/lib/python3.6/text_format.pyr I s r c s2 e Zd ZdZd � fdd� Zdd� Zdd� Z� ZS ) � ParseErrorz3Thrown in case of text parsing or tokenizing error.Nc sr |d k r:|d k r:t |�}|d k r.|dj|�7 }dj||�}|d k rTtt| �j|� ntt| �j� || _|| _d S )Nz:{0}z {0} : {1})�str�format�superr �__init__�_line�_column)�self�message�line�column�loc)� __class__r r r P s zParseError.__init__c C s | j S )N)r )r r r r �GetLine] s zParseError.GetLinec C s | j S )N)r )r r r r � GetColumn` s zParseError.GetColumn)NNN)r r r r r r r! � __classcell__r r )r r r M s r c @ s, e Zd Zdd� Zdd� Zdd� Zdd� Zd S ) � TextWriterc C s t jrtj� | _n tj� | _d S )N)�six�PY2�io�BytesIO�_writer�StringIO)r �as_utf8r r r r f s zTextWriter.__init__c C s( t jrt|t j�r|jd�}| jj|�S )Nzutf-8)r$ r% � isinstance� text_type�encoder( �write)r �valr r r r. l s zTextWriter.writec C s | j j� S )N)r( �close)r r r r r0 r s zTextWriter.closec C s | j j� S )N)r( �getvalue)r r r r r1 u s zTextWriter.getvalueN)r r r r r. r0 r1 r r r r r# d s r# Fc C sL t |�} t| ||||||||| � }|j| � | j� }| j� |rH|j� S |S )a� Convert protobuf message to text format. Floating point values can be formatted compactly with 15 digits of precision (which is the most that IEEE 754 "double" can guarantee) using float_format='.15g'. To ensure that converting to text and back to a proto will result in an identical value, float_format='.17g' should be used. Args: message: The protocol buffers message. as_utf8: Produce text output in UTF8 format. as_one_line: Don't introduce newlines between fields. pointy_brackets: If True, use angle brackets instead of curly braces for nesting. use_index_order: If True, print fields of a proto message using the order defined in source code instead of the field number. By default, use the field number order. float_format: If set, use this to specify floating point number formatting (per the "Format Specification Mini-Language"); otherwise, str() is used. use_field_number: If True, print field numbers instead of names. descriptor_pool: A DescriptorPool used to resolve Any types. indent: The indent level, in terms of spaces, for pretty print. message_formatter: A function(message, indent, as_one_line): unicode|None to custom format selected sub-messages (usually based on message type). Use to pretty print parts of the protobuf for easier diffing. Returns: A string of the text formatted protocol buffer message. )r# �_Printerr r1 r0 �rstrip) r r* �as_one_line�pointy_brackets�use_index_order�float_format�use_field_number�descriptor_pool�indent�message_formatter�out�printer�resultr r r r y s & c C s"