
Xc           @   s0  d  Z  d Z d d l Z d d l Z d d l Z e j rB e Z n  d d l m	 Z	 d d l
 m Z d d l
 m Z d d d	 d
 d g Z e	 j   e	 j   e	 j   e	 j   f Z e j d e j  Z e j d e j  Z e e j j e j j g  Z d e f d     YZ d e f d     YZ d e f d     YZ  e! e! e! e! e" d  Z# d   Z$ d e! e! e! e! e" d  Z% d e! e! e! e! e" d  Z& d e! e! e! e! e" d  Z' d   Z( d   Z) d   Z* d   Z+ d   Z, d   Z- d    Z. d! e f d"     YZ/ e! e! d#  Z0 d$   Z1 d%   Z2 d&   Z3 d S('   sb  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())
s    kenton@google.com (Kenton Varda)iN(   t   type_checkers(   t
   descriptor(   t   text_encodingt   MessageToStringt   PrintMessaget
   PrintFieldt   PrintFieldValuet   Merges   -?inf(?:inity)?f?s   nanf?t   Errorc           B   s   e  Z d  Z RS(   s'   Top-level module error for text_format.(   t   __name__t
   __module__t   __doc__(    (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR   G   s   t
   ParseErrorc           B   s   e  Z d  Z RS(   s&   Thrown in case of ASCII parsing error.(   R	   R
   R   (    (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR   K   s   t
   TextWriterc           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   s.   t  j r t j   |  _ n t j   |  _ d  S(   N(   t   sixt   PY2t   iot   BytesIOt   _writert   StringIO(   t   selft   as_utf8(    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyt   __init__O   s    	c         C   s@   t  j r0 t | t  j  r0 | j d  } q0 n  |  j j |  S(   Ns   utf-8(   R   R   t
   isinstancet	   text_typet   encodeR   t   write(   R   t   val(    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR   U   s    	c         C   s   |  j  j   S(   N(   R   t   close(   R   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR   [   s    c         C   s   |  j  j   S(   N(   R   t   getvalue(   R   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR   ^   s    (   R	   R
   R   R   R   R   (    (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR   N   s   			c         C   sa   t  |  } t |  | d | d | d | d | d | | j   } | j   | r] | j   S| S(   sk  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'.

  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.

  Returns:
    A string of the text formatted protocol buffer message.
  R   t   as_one_linet   pointy_bracketst   use_index_ordert   float_format(   R   R   R   R   t   rstrip(   t   messageR   R   R   R    R!   t   outt   result(    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR   b   s    

c         C   s1   |  j  t j j k o0 |  j j o0 |  j j   j S(   N(   t   typeR   t   FieldDescriptort   TYPE_MESSAGEt   message_typet   has_optionst
   GetOptionst	   map_entry(   t   field(    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyt   _IsMapEntry   s    i    c         C   s2  |  j    } | r( | j d d    n  x| D] \ }	 }
 t |	  r x t |
  D]P } |	 j j d | d |
 |  } t |	 | | | | | d | d | d | qT Wq/ |	 j t j	 j
 k r xg |
 D]1 } t |	 | | | | | d | d | d | q Wq/ t |	 |
 | | | | d | d | d | q/ Wd  S(   Nt   keyc         S   s   |  d j  S(   Ni    (   t   index(   t   x(    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyt   <lambda>   s    t   valueR   R    R!   (   t
   ListFieldst   sortR.   t   sortedR)   t   _concrete_classR   t   labelR   R'   t   LABEL_REPEATED(   R#   R$   t   indentR   R   R   R    R!   t   fieldsR-   R3   R/   t   entry_submsgt   element(    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR      s*    c	   	      C   s]  | j  d |  |  j r | j  d  |  j j   j r |  j t j j k r |  j	 |  j
 k r |  j t j j k r | j  |  j	 j  n | j  |  j  | j  d  n; |  j t j j k r | j  |  j	 j  n | j  |  j  |  j t j j k r| j  d  n  t |  | | | | | d | d | d | | rL| j  d  n | j  d  d	 S(
   sc   Print a single field name/value pair.  For repeated fields, the value
  should be a single element.t    t   [t   ]s   : R   R    R!   s   
N(   R   t   is_extensiont   containing_typeR+   t   message_set_wire_formatR&   R   R'   R(   R)   t   extension_scopeR8   t   LABEL_OPTIONALt	   full_namet
   TYPE_GROUPt   namet   cpp_typet   CPPTYPE_MESSAGER   (	   R-   R3   R$   R:   R   R   R   R    R!   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR      s,    	c	         C   s^  | r d }	 d }
 n d }	 d }
 |  j  t j j k r | r | j d |	  t | | | | | d | d | d | | j |
  qZ| j d	 |	  t | | | d
 | | d | d | d | | j d | |
  n|  j  t j j k r<|  j j j	 | d  } | d k	 r&| j | j  qZ| j t |   n|  j  t j j k r| j d  t | t j  r| j d  } n | } |  j t j j k rt } n | } | j t j | |   | j d  n |  j  t j j k r| r | j d  qZ| j d  nJ |  j  t k rG| d k	 rG| j d j | |   n | j t |   d S(   sn   Print a single field value (not including name).  For repeated fields,
  the value should be a single element.t   <t   >t   {t   }s    %s R   R    R!   s    %s
i   R>   s   "s   utf-8t   truet   falses   {1:{0}}N(   RI   R   R'   RJ   R   R   t   CPPTYPE_ENUMt	   enum_typet   values_by_numbert   gett   NoneRH   t   strt   CPPTYPE_STRINGR   R   R   R   R&   t
   TYPE_BYTESt   FalseR   t   CEscapet   CPPTYPE_BOOLt   _FLOAT_TYPESt   format(   R-   R3   R$   R:   R   R   R   R    R!   t   openbt   closebt
   enum_valuet	   out_valuet   out_as_utf8(    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR      sR    		c         C   s7   t  |  t  s! |  j d  }  n  t |  j d  |  S(   s  Parses an ASCII representation of a protocol message into a message.

  Args:
    text: Message ASCII representation.
    message: A protocol buffer message to merge into.

  Returns:
    The same message passed as argument.

  Raises:
    ParseError: On ASCII parsing problems.
  s   utf-8s   
(   R   RV   t   decodet
   ParseLinest   split(   t   textR#   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyt   Parse	  s     c         C   s   t  |  j d  |  S(   sx  Parses an ASCII representation of a protocol message into a message.

  Like Parse(), but allows repeated values for a non-repeated field, and uses
  the last one.

  Args:
    text: Message ASCII representation.
    message: A protocol buffer message to merge into.

  Returns:
    The same message passed as argument.

  Raises:
    ParseError: On ASCII parsing problems.
  s   
(   t
   MergeLinesRe   (   Rf   R#   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR     s    c         C   s   t  |  | t  | S(   s6  Parses an ASCII representation of a protocol message into a message.

  Args:
    lines: An iterable of lines of a message's ASCII representation.
    message: A protocol buffer message to merge into.

  Returns:
    The same message passed as argument.

  Raises:
    ParseError: On ASCII parsing problems.
  (   t   _ParseOrMergeRY   (   t   linesR#   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyRd   -  s    c         C   s   t  |  | t  | S(   s6  Parses an ASCII representation of a protocol message into a message.

  Args:
    lines: An iterable of lines of a message's ASCII representation.
    message: A protocol buffer message to merge into.

  Returns:
    The same message passed as argument.

  Raises:
    ParseError: On ASCII parsing problems.
  (   Ri   t   True(   Rj   R#   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyRh   >  s    c         C   s3   t  |   } x  | j   s. t | | |  q Wd S(   s  Converts an ASCII representation of a protocol message into a message.

  Args:
    lines: Lines of a message's ASCII representation.
    message: A protocol buffer message to merge into.
    allow_multiple_scalars: Determines if repeated values for a non-repeated
      field are permitted, e.g., the string "foo: 1 foo: 2" for a
      required/optional field named "foo".

  Raises:
    ParseError: On ASCII parsing problems.
  N(   t
   _Tokenizert   AtEndt   _MergeField(   Rj   R#   t   allow_multiple_scalarst	   tokenizer(    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyRi   O  s    c         C   s  | j  } t | d  r0 | j d k r0 t } n  |  j d  r|  j   g } x& |  j d  rv | j |  j    qQ Wd j |  } | j s |  j	 d | j
   n  | j j |  } | s |  j	 d |   n. | | j k r|  j	 d | | j
 f   n  |  j d  n |  j   } | j j | d  } | s}| j j | j   d  } | r}| j t j j k r}d } q}n  | r| j t j j k r| j j | k rd } n  | s|  j	 d	 | j
 | f   n  | j t j j k rt |  } |  j d
  |  j d  rd } n |  j d  d } | j t j j k r| j re| j | j   } q| r}| j j    } qt! | | j  j   } n5 | j r| j | } n t! | | j  } | j"   xE |  j |  s|  j#   r|  j	 d |   n  t$ |  | |  qW| r| j j d j }	 |	 t j j k rlt! | | j  | j% }
 |
 j& | j'  q| j' t! | | j  | j% <qn t( |  | | |  |  j d  s|  j d  n  d S(   s  Merges a single protocol message field into a message.

  Args:
    tokenizer: A tokenizer to parse the field name and values.
    message: A protocol message to record the data.
    allow_multiple_scalars: Determines if repeated values for a non-repeated
      field are permitted, e.g., the string "foo: 1 foo: 2" for a
      required/optional field named "foo".

  Raises:
    ParseError: In case of ASCII parsing problems.
  t   syntaxt   proto3R?   t   .s+   Message type "%s" does not have extensions.s   Extension "%s" not registered.s1   Extension "%s" does not extend message type "%s".R@   s*   Message type "%s" has no field named "%s".t   :RK   RL   RM   RN   s   Expected "%s".R3   t   ,t   ;N()   t
   DESCRIPTORt   hasattrRq   Rk   t
   TryConsumet   ConsumeIdentifiert   appendt   joint   is_extendablet   ParseErrorPreviousTokenRF   t
   Extensionst   _FindExtensionByNameRB   t   Consumet   fields_by_nameRT   RU   t   lowerR&   R   R'   RG   R)   RH   RI   RJ   R.   R8   R9   RA   t   addR7   t   getattrt   SetInParentRm   Rn   R/   t	   MergeFromR3   t   _MergeScalarField(   Rp   R#   Ro   t   message_descriptorRH   R-   t   is_map_entryt	   end_tokent   sub_messaget   value_cpptypeR3   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyRn   a  s    							
"c         C   s  |  j  d  d } | j t j j t j j t j j f k rL |  j   } no| j t j j	 t j j
 t j j f k r |  j   } n6| j t j j t j j f k r |  j   } n| j t j j t j j f k r |  j   } n | j t j j t j j f k r|  j   } n | j t j j k r9|  j   } n | j t j j k r]|  j   } n^ | j t j j k r|  j   } n: | j t j j k r|  j |  } n t d | j   | j t j j  k r| j! r| j" | j# |  qt$ | | j%  j# |  n | j! r`| rP| j& |  rP|  j' d | j( j) | j) f   q| | j" | <nQ | r| j* | j%  r|  j' d | j( j) | j% f   n t+ | | j% |  d S(   s  Merges a single protocol message scalar field into a message.

  Args:
    tokenizer: A tokenizer to parse the field value.
    message: A protocol message to record the data.
    field: The descriptor of the field to be merged.
    allow_multiple_scalars: Determines if repeated values for a non-repeated
      field are permitted, e.g., the string "foo: 1 foo: 2" for a
      required/optional field named "foo".

  Raises:
    ParseError: In case of ASCII parsing problems.
    RuntimeError: On runtime errors.
  Rt   s   Unknown field type %ds;   Message type "%s" should not have multiple "%s" extensions.s7   Message type "%s" should not have multiple "%s" fields.N(,   R   RU   R&   R   R'   t
   TYPE_INT32t   TYPE_SINT32t   TYPE_SFIXED32t   ConsumeInt32t
   TYPE_INT64t   TYPE_SINT64t   TYPE_SFIXED64t   ConsumeInt64t   TYPE_UINT32t   TYPE_FIXED32t   ConsumeUint32t   TYPE_UINT64t   TYPE_FIXED64t   ConsumeUint64t
   TYPE_FLOATt   TYPE_DOUBLEt   ConsumeFloatt	   TYPE_BOOLt   ConsumeBoolt   TYPE_STRINGt   ConsumeStringRX   t   ConsumeByteStringt	   TYPE_ENUMt   ConsumeEnumt   RuntimeErrorR8   R9   RA   R   R{   R   RH   t   HasExtensionR~   Rw   RF   t   HasFieldt   setattr(   Rp   R#   R-   Ro   R3   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR     sV    				Rl   c           B   s   e  Z d  Z e j d e j  Z e j d  Z e j d  Z d   Z	 d   Z
 d   Z d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s   Protocol buffer ASCII representation tokenizer.

  This class handles the lower level string parsing by splitting it into
  meaningful tokens.

  It was directly ported from the Java protocol buffer API.
  s   (\s|(#.*$))+s`   [a-zA-Z_][0-9a-zA-Z_+-]*|[0-9+-][0-9a-zA-Z_.+-]*|"([^"
\\]|\\.)*("|\\?$)|'([^'
\\]|\\.)*('|\\?$)s   \w+c         C   sx   d |  _  d |  _ d |  _ d  |  _ d |  _ t |  |  _ d |  _ d |  _	 d |  _
 t |  _ |  j   |  j   d  S(   Ni    it    (   t	   _positiont   _linet   _columnRU   t   _token_startt   tokent   itert   _linest   _current_linet   _previous_linet   _previous_columnRk   t   _more_linest   _SkipWhitespacet	   NextToken(   R   Rj   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR      s    									
c         C   s   |  j  S(   s^   Checks the end of the text was reached.

    Returns:
      True iff the end was reached.
    (   R   (   R   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyRm   .  s    c         C   sx   xq t  |  j  |  j k rs y t |  j  |  _ Wn$ t k
 rW d |  _ t |  _ d  SX|  j d 7_ d |  _ q Wd  S(   NR   i   i    (	   t   lenR   R   t   nextR   t   StopIterationRY   R   R   (   R   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyt   _PopLine6  s    		c         C   sd   x] t  r_ |  j   |  j j |  j |  j  } | s8 Pn  t | j d   } |  j | 7_ q Wd  S(   Ni    (   Rk   R   t   _WHITESPACEt   matchR   R   R   t   group(   R   R   t   length(    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR   B  s    	
c         C   s!   |  j  | k r |  j   t St S(   s   Tries to consume a given piece of text.

    Args:
      token: Text to consume.

    Returns:
      True iff the text was consumed.
    (   R   R   Rk   RY   (   R   R   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyRy   K  s    	
c         C   s)   |  j  |  s% |  j d |   n  d S(   s   Consumes a piece of text.

    Args:
      token: Text to consume.

    Raises:
      ParseError: If the text couldn't be consumed.
    s   Expected "%s".N(   Ry   t   _ParseError(   R   R   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR   Y  s    	c         C   s;   |  j  } |  j j |  s- |  j d   n  |  j   | S(   s   Consumes protocol message field identifier.

    Returns:
      Identifier string.

    Raises:
      ParseError: If an identifier couldn't be consumed.
    s   Expected identifier.(   R   t   _IDENTIFIERR   R   R   (   R   R%   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyRz   e  s
    		
c         C   sX   y t  |  j d t d t } Wn( t k
 rI } |  j t |    n X|  j   | S(   s   Consumes a signed 32bit integer number.

    Returns:
      The integer parsed.

    Raises:
      ParseError: If a signed 32bit integer couldn't be consumed.
    t	   is_signedt   is_long(   t   ParseIntegerR   Rk   RY   t
   ValueErrorR   RV   R   (   R   R%   t   e(    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR   t  s    	
c         C   sX   y t  |  j d t d t } Wn( t k
 rI } |  j t |    n X|  j   | S(   s   Consumes an unsigned 32bit integer number.

    Returns:
      The integer parsed.

    Raises:
      ParseError: If an unsigned 32bit integer couldn't be consumed.
    R   R   (   R   R   RY   R   R   RV   R   (   R   R%   R   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR     s    	
c         C   sX   y t  |  j d t d t } Wn( t k
 rI } |  j t |    n X|  j   | S(   s   Consumes a signed 64bit integer number.

    Returns:
      The integer parsed.

    Raises:
      ParseError: If a signed 64bit integer couldn't be consumed.
    R   R   (   R   R   Rk   R   R   RV   R   (   R   R%   R   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR     s    	
c         C   sX   y t  |  j d t d t } Wn( t k
 rI } |  j t |    n X|  j   | S(   s   Consumes an unsigned 64bit integer number.

    Returns:
      The integer parsed.

    Raises:
      ParseError: If an unsigned 64bit integer couldn't be consumed.
    R   R   (   R   R   RY   Rk   R   R   RV   R   (   R   R%   R   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR     s    	
c         C   sL   y t  |  j  } Wn( t k
 r= } |  j t |    n X|  j   | S(   s   Consumes an floating point number.

    Returns:
      The number parsed.

    Raises:
      ParseError: If a floating point number couldn't be consumed.
    (   t
   ParseFloatR   R   R   RV   R   (   R   R%   R   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR     s    	
c         C   sL   y t  |  j  } Wn( t k
 r= } |  j t |    n X|  j   | S(   s   Consumes a boolean value.

    Returns:
      The bool parsed.

    Raises:
      ParseError: If a boolean value couldn't be consumed.
    (   t	   ParseBoolR   R   R   RV   R   (   R   R%   R   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR     s    	
c         C   sI   |  j    } y t j | d  SWn" t k
 rD } |  j |   n Xd S(   s   Consumes a string value.

    Returns:
      The string parsed.

    Raises:
      ParseError: If a string value couldn't be consumed.
    s   utf-8N(   R   R   R   t   UnicodeDecodeErrort   _StringParseError(   R   t	   the_bytesR   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR     s
    	c         C   sR   |  j    g } x3 |  j rD |  j d d k rD | j |  j     q Wd j |  S(   s   Consumes a byte array value.

    Returns:
      The array parsed (as a string).

    Raises:
      ParseError: If a byte array value couldn't be consumed.
    i    s   't   "R   (   s   'R   (   t   _ConsumeSingleByteStringR   R{   R|   (   R   t   the_list(    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR     s    	c         C   s   |  j  } t |  d k  s+ | d d	 k rD |  j d | f   n  t |  d k  sj | d | d k r |  j d | f   n  y t j | d d ! } Wn( t k
 r } |  j t |    n X|  j   | S(
   s*  Consume one token of a string literal.

    String literals (whether bytes or text) can come in multiple adjacent
    tokens which are automatically concatenated, like in C or Python.  This
    method only consumes one token.

    Raises:
      ParseError: When the wrong format data is found.
    i   i    s   'R   s   Expected string but found: %ri   is   String missing ending quote: %r(   s   'R   (   R   R   R   R   t	   CUnescapeR   RV   R   (   R   Rf   R%   R   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR     s    
	"&
c         C   sO   y t  | |  j  } Wn( t k
 r@ } |  j t |    n X|  j   | S(   N(   t	   ParseEnumR   R   R   RV   R   (   R   R-   R%   R   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR   	  s    
c         C   s%   t  d |  j d |  j d | f  S(   s   Creates and *returns* a ParseError for the previously read token.

    Args:
      message: A message to set for the exception.

    Returns:
      A ParseError instance.
    s
   %d:%d : %si   (   R   R   R   (   R   R#   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR~     s    	c         C   s%   t  d |  j d |  j d | f  S(   s9   Creates and *returns* a ParseError for the current token.s
   %d:%d : %si   (   R   R   R   (   R   R#   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR     s    c         C   s   |  j  d t |   S(   Ns   Couldn't parse string: (   R   RV   (   R   R   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR   "  s    c         C   s   |  j  |  _ |  j |  _ |  j t |  j  7_ |  j   |  j sP d |  _ d S|  j j	 |  j
 |  j  } | r | j d  } | |  _ n |  j
 |  j |  _ d S(   s    Reads the next meaningful token.R   Ni    (   R   R   R   R   R   R   R   R   t   _TOKENR   R   R   (   R   R   R   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR   %  s    
		(   R	   R
   R   t   ret   compilet	   MULTILINER   R   R   R   Rm   R   R   Ry   R   Rz   R   R   R   R   R   R   R   R   R   R   R~   R   R   R   (    (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyRl     s4   																						c         C   s~   y+ | r t  |  d  } n t |  d  } Wn! t k
 rN t d |    n Xt d t |  t |  } | j |  | S(   s  Parses an integer.

  Args:
    text: The text to parse.
    is_signed: True if a signed integer must be parsed.
    is_long: True if a long integer must be parsed.

  Returns:
    The integer value.

  Raises:
    ValueError: Thrown Iff the text is not a valid integer.
  i    s   Couldn't parse integer: %si   (   t   longt   intR   t   _INTEGER_CHECKERSt
   CheckValue(   Rf   R   R   R%   t   checker(    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR   9  s    c         C   s   y t  |   SWn t k
 r t j |   rT |  d d k rG t  d  St  d  Sq t j |   rm t  d  Sy t  |  j d   SWq t k
 r t d |    q Xn Xd S(	   s   Parse a floating point number.

  Args:
    text: Text to parse.

  Returns:
    The number parsed.

  Raises:
    ValueError: If a floating point number couldn't be parsed.
  i    t   -s   -inft   inft   nant   fs   Couldn't parse float: %sN(   t   floatR   t   _FLOAT_INFINITYR   t
   _FLOAT_NANR"   (   Rf   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR   Y  s    

c         C   s0   |  d	 k r t  S|  d
 k r  t St d   d S(   s   Parse a boolean value.

  Args:
    text: Text to parse.

  Returns:
    Boolean values parsed

  Raises:
    ValueError: If text is not a valid boolean.
  RO   t   tt   1RP   R   t   0s   Expected "true" or "false".N(   s   trueR   R   (   s   falseR   R   (   Rk   RY   R   (   Rf   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR   y  s
    c         C   s   |  j  } y t | d  } WnN t k
 rl | j j | d  } | d k r t d | j | f   q n> X| j j | d  } | d k r t d | j | f   n  | j S(   s&  Parse an enum value.

  The value can be specified by a number (the enum value), or by
  a string literal (the enum name).

  Args:
    field: Enum field descriptor.
    value: String value.

  Returns:
    Enum value number.

  Raises:
    ValueError: If the enum value could not be parsed.
  i    s%   Enum type "%s" has no value named %s.s+   Enum type "%s" has no value with number %d.N(	   RR   R   R   t   values_by_nameRT   RU   RF   RS   t   number(   R-   R3   t   enum_descriptorR   R`   (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyR     s    	(4   R   t
   __author__R   R   R   t   PY3R   R   t   google.protobuf.internalR    t   google.protobufR   R   t   __all__t   Uint32ValueCheckert   Int32ValueCheckert   Uint64ValueCheckert   Int64ValueCheckerR   R   t
   IGNORECASER   R   t	   frozensetR'   t   CPPTYPE_FLOATt   CPPTYPE_DOUBLER\   t	   ExceptionR   R   t   objectR   RY   RU   R   R.   R   R   R   Rg   R   Rd   Rh   Ri   Rn   R   Rl   R   R   R   R   (    (    (    s]   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/google/protobuf/text_format.pyt   <module>)   s`   						!			$8						j	D + 	 	