o
    ÞË·eƒ†  ã                   @   sÎ   d Z dZddlZddlZddlZddlmZ ddlmZ ze	 W n e
y+   eZ	Y nw dd„ Zdd	„ Zd
d„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZG dd„ dejƒZdS ) zpUtilities for Python proto2 tests.

This is intentionally modeled on C++ code in
//google/protobuf/test_util.*.
z#robinson@google.com (Will Robinson)é    N)Úunittest_import_pb2)Úunittest_pb2c                 C   s   | j jdkS )NÚproto2)Ú
DESCRIPTORÚsyntax©Úmessage© r	   úY/var/www/ideatree/venv/lib/python3.10/site-packages/google/protobuf/internal/test_util.pyÚIsProto27   s   r   c                 C   s  d| _ d| _d| _d| _d| _d| _d| _d| _d	| _d
| _	d| _
d| _d| _d| _d| _t| ƒr5d| j_d| j_d| j_d| j_d| j_tjj| _tj| _t| ƒrVt j!| _"d| _#d| _$| j% &d¡ | j' &d¡ | j( &d¡ | j) &d¡ | j* &d¡ | j+ &d¡ | j, &d¡ | j- &d¡ | j. &d¡ | j/ &d ¡ | j0 &d!¡ | j1 &d"¡ | j2 &d¡ | j3 &d#¡ | j4 &d$¡ t| ƒrÀd%| j5 6¡ _d&| j7 6¡ _d'| j8 6¡ _d(| j9 6¡ _d)| j: 6¡ _| j; &tjj<¡ | j= &tj>¡ t| ƒrò| j? &t j@¡ | jA &d*¡ | jB &d+¡ | j% &d,¡ | j' &d,¡ | j( &d,¡ | j) &d,¡ | j* &d,¡ | j+ &d,¡ | j, &d,¡ | j- &d,¡ | j. &d,¡ | j/ &d,¡ | j0 &d,¡ | j1 &d,¡ | j2 &d¡ | j3 &d-¡ | j4 &d.¡ d/| j%d0< d1| j'd0< d2| j(d0< d3| j)d0< d4| j*d0< d5| j+d0< d6| j,d0< d7| j-d0< d8| j.d0< d9| j/d0< d:| j0d0< d;| j1d0< d<| j2d0< d=| j3d0< d>| j4d0< t| ƒr®d?| j5 6¡ _d@| j7 6¡ _dA| j8 6¡ _dB| j9 6¡ _dC| j: 6¡ _| j; &tjj<¡ tjj| j;d0< | j= &tj¡ t| ƒrè| j? &t j!¡ | jA &dD¡ | jB &dE¡ t| ƒr9dF| _CdG| _DdH| _EdI| _FdJ| _GdK| _HdL| _IdM| _JdN| _KdO| _LdP| _MdQ| _Nd<| _OdR| _PdS| _QtjjR| _StjT| _Ut jV| _WdT| _XdU| _YdV| _ZdW| j[_dX| _\dY| _]dZS )[zmSets every non-lazy field in the message to a unique value.

  Args:
    message: A TestAllTypes instance.
  ée   éf   ég   éh   éi   éj   ék   él   ém   én   éo   ép   TÚ115ó   116éu   év   éw   éx   é~   Ú124Ú125éÉ   éÊ   éË   éÌ   éÍ   éÎ   éÏ   éÐ   éÑ   éÒ   éÓ   éÔ   Ú215ó   216éÙ   éÚ   éÛ   éÜ   éã   Ú224Ú225r   Ú0ó   0é-  é   é.  é/  é0  é1  é2  é3  é4  é5  é6  é7  é8  FÚ315ó   316é=  é>  é?  é@  éG  Ú324Ú325é‘  é’  é“  é”  é•  é–  é—  é˜  é™  éš  é›  éœ  Ú415ó   416Ú424Ú425éY  éZ  Ú603ó   604N)^Úoptional_int32Úoptional_int64Úoptional_uint32Úoptional_uint64Úoptional_sint32Úoptional_sint64Úoptional_fixed32Úoptional_fixed64Úoptional_sfixed32Úoptional_sfixed64Úoptional_floatÚoptional_doubleÚoptional_boolÚoptional_stringÚoptional_bytesr   ÚoptionalgroupÚaÚoptional_nested_messageÚbbÚoptional_foreign_messageÚcÚoptional_import_messageÚdÚoptional_public_import_messageÚer   ÚTestAllTypesÚBAZÚoptional_nested_enumÚFOREIGN_BAZÚoptional_foreign_enumr   Ú
IMPORT_BAZÚoptional_import_enumÚoptional_string_pieceÚoptional_cordÚrepeated_int32ÚappendÚrepeated_int64Úrepeated_uint32Úrepeated_uint64Úrepeated_sint32Úrepeated_sint64Úrepeated_fixed32Úrepeated_fixed64Úrepeated_sfixed32Úrepeated_sfixed64Úrepeated_floatÚrepeated_doubleÚrepeated_boolÚrepeated_stringÚrepeated_bytesÚrepeatedgroupÚaddÚrepeated_nested_messageÚrepeated_foreign_messageÚrepeated_import_messageÚrepeated_lazy_messageÚrepeated_nested_enumÚBARÚrepeated_foreign_enumÚFOREIGN_BARÚrepeated_import_enumÚ
IMPORT_BARÚrepeated_string_pieceÚrepeated_cordÚdefault_int32Údefault_int64Údefault_uint32Údefault_uint64Údefault_sint32Údefault_sint64Údefault_fixed32Údefault_fixed64Údefault_sfixed32Údefault_sfixed64Údefault_floatÚdefault_doubleÚdefault_boolÚdefault_stringÚdefault_bytesÚFOOÚdefault_nested_enumÚFOREIGN_FOOÚdefault_foreign_enumÚ
IMPORT_FOOÚdefault_import_enumÚdefault_string_pieceÚdefault_cordÚoneof_uint32Úoneof_nested_messageÚoneof_stringÚoneof_bytesr   r	   r	   r
   ÚSetAllNonLazyFields;   sô   




















r½   c                 C   s   t | ƒ d| j_d| j_d S )Né   é€   )r½   Úoptional_lazy_messagert   Ú optional_unverified_lazy_messager   r	   r	   r
   ÚSetAllFieldsÚ   s   rÂ   c                 C   sn  | j }t}t}d||j< d||j< d||j< d||j< d||j< d||j< d||j	< d||j
< d	||j< d
||j< d||j< d||j< d||j< d||j< d||j< d||j _d||j _d||j _d||j _d||j _d||j _d||j _|jj||j < |jj||j < |j!||j"< |j#||j$< d||j%< d||j&< ||j'  (d¡ ||j)  (d¡ ||j*  (d¡ ||j+  (d¡ ||j,  (d¡ ||j-  (d¡ ||j.  (d¡ ||j/  (d ¡ ||j0  (d!¡ ||j1  (d"¡ ||j2  (d#¡ ||j3  (d$¡ ||j4  (d¡ ||j5  (d%¡ ||j6  (d&¡ d'||j7  8¡ _d(||j9  8¡ _d)||j:  8¡ _d*||j;  8¡ _d+||j<  8¡ _||j=  (|jj>¡ ||j?  (|j@¡ ||jA  (|jB¡ ||jC  (d,¡ ||jD  (d-¡ ||j'  (d.¡ ||j)  (d/¡ ||j*  (d0¡ ||j+  (d1¡ ||j,  (d2¡ ||j-  (d3¡ ||j.  (d4¡ ||j/  (d5¡ ||j0  (d6¡ ||j1  (d7¡ ||j2  (d8¡ ||j3  (d9¡ ||j4  (d:¡ ||j5  (d;¡ ||j6  (d<¡ d=||j7  8¡ _d>||j9  8¡ _d?||j:  8¡ _d@||j;  8¡ _dA||j<  8¡ _||j=  (|jj¡ ||j?  (|j!¡ ||jA  (|j#¡ ||jC  (dB¡ ||jD  (dC¡ dD||jE< dE||jF< dF||jG< dG||jH< dH||jI< dI||jJ< dJ||jK< dK||jL< dL||jM< dM||jN< dN||jO< dO||jP< d:||jQ< dP||jR< dQ||jS< |jjT||jU< |jV||jW< |jX||jY< dR||jZ< dS||j[< dT||j\< dU||j] _dV||j^< dW||j_< dXS )YzzSets every extension in the message to a unique value.

  Args:
    message: A unittest_pb2.TestAllExtensions instance.
  r   r   r   r   r   r   r   r   r   r   r   r   Tr   r   r   r   r   r   r   r¾   r¿   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r8   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   FrE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   N)`Ú
Extensionsr   r   Úoptional_int32_extensionÚoptional_int64_extensionÚoptional_uint32_extensionÚoptional_uint64_extensionÚoptional_sint32_extensionÚoptional_sint64_extensionÚoptional_fixed32_extensionÚoptional_fixed64_extensionÚoptional_sfixed32_extensionÚoptional_sfixed64_extensionÚoptional_float_extensionÚoptional_double_extensionÚoptional_bool_extensionÚoptional_string_extensionÚoptional_bytes_extensionÚoptionalgroup_extensionrr   Ú!optional_nested_message_extensionrt   Ú"optional_foreign_message_extensionrv   Ú!optional_import_message_extensionrx   Ú(optional_public_import_message_extensionrz   Úoptional_lazy_message_extensionÚ*optional_unverified_lazy_message_extensionr{   r|   Úoptional_nested_enum_extensionr~   Úoptional_foreign_enum_extensionr€   Úoptional_import_enum_extensionÚoptional_string_piece_extensionÚoptional_cord_extensionÚrepeated_int32_extensionr…   Úrepeated_int64_extensionÚrepeated_uint32_extensionÚrepeated_uint64_extensionÚrepeated_sint32_extensionÚrepeated_sint64_extensionÚrepeated_fixed32_extensionÚrepeated_fixed64_extensionÚrepeated_sfixed32_extensionÚrepeated_sfixed64_extensionÚrepeated_float_extensionÚrepeated_double_extensionÚrepeated_bool_extensionÚrepeated_string_extensionÚrepeated_bytes_extensionÚrepeatedgroup_extensionr•   Ú!repeated_nested_message_extensionÚ"repeated_foreign_message_extensionÚ!repeated_import_message_extensionÚrepeated_lazy_message_extensionÚrepeated_nested_enum_extensionr›   Úrepeated_foreign_enum_extensionr   Úrepeated_import_enum_extensionrŸ   Úrepeated_string_piece_extensionÚrepeated_cord_extensionÚdefault_int32_extensionÚdefault_int64_extensionÚdefault_uint32_extensionÚdefault_uint64_extensionÚdefault_sint32_extensionÚdefault_sint64_extensionÚdefault_fixed32_extensionÚdefault_fixed64_extensionÚdefault_sfixed32_extensionÚdefault_sfixed64_extensionÚdefault_float_extensionÚdefault_double_extensionÚdefault_bool_extensionÚdefault_string_extensionÚdefault_bytes_extensionr±   Údefault_nested_enum_extensionr³   Údefault_foreign_enum_extensionrµ   Údefault_import_enum_extensionÚdefault_string_piece_extensionÚdefault_cord_extensionÚoneof_uint32_extensionÚoneof_nested_message_extensionÚoneof_string_extensionÚoneof_bytes_extension)r   Ú
extensionsÚpb2Ú
import_pb2r	   r	   r
   ÚSetAllExtensionsà   sÒ   



































r  c                 C   s.   d| _ d| _d| _d| jtj< d| jtj< dS )zƒSets every field and extension in the message to a unique value.

  Args:
    message: A unittest_pb2.TestAllExtensions message.
  r9   Úfooç      ð?é   ÚbarN)Úmy_intÚ	my_stringÚmy_floatrÃ   r   Úmy_extension_intÚmy_extension_stringr   r	   r	   r
   ÚSetAllFieldsAndExtensionso  s
   r  c                 C   sÒ   t j}t j}g }t  ¡ }d|_| | ¡ ¡ | ¡  d|j|< | | ¡ ¡ | ¡  d|_	| | ¡ ¡ | ¡  d|j|< | | ¡ ¡ | ¡  d|_
| | ¡ ¡ | ¡  d |¡}|| krgtd|| f ƒ‚dS )	zÇEnsures that serialized is the serialization we expect for a message
  filled with SetAllFieldsAndExtensions().  (Specifically, ensures that the
  serialization is in canonical, tag-number order).
  r9   r  r  r  r  ó    zExpected %r, found %rN)r   r  r  ÚTestFieldOrderingsr  r…   ÚSerializeToStringÚClearrÃ   r  r  ÚjoinÚ
ValueError)Ú
serializedr  r  Úexpected_stringsr   Úexpectedr	   r	   r
   Ú#ExpectAllFieldsAndExtensionsInOrder|  s.   


ÿr'  c                 C   sâ
  |   | d¡¡ |   | d¡¡ |   | d¡¡ |   | d¡¡ |   | d¡¡ |   | d¡¡ |   | d¡¡ |   | d¡¡ |   | d	¡¡ |   | d
¡¡ |   | d¡¡ |   | d¡¡ |   | d¡¡ |   | d¡¡ |   | d¡¡ t|ƒr„|   | d¡¡ |   | d¡¡ |   | d¡¡ |   | d¡¡ |   |j d¡¡ |   |j d¡¡ |   |j d¡¡ |   |j d¡¡ |   | d¡¡ |   | d¡¡ t|ƒrÜ|   | d¡¡ |   | d¡¡ |   | d¡¡ |  d|j¡ |  d|j	¡ |  d|j
¡ |  d |j¡ |  d!|j¡ |  d"|j¡ |  d#|j¡ |  d$|j¡ |  d%|j¡ |  d&|j¡ |  d'|j¡ |  d(|j¡ |  d)|j¡ |  d*|j¡ |  d+|j¡ t|ƒrb|  d,|jj¡ |  d-|jj¡ |  d.|jj¡ |  d/|jj¡ |  d0|jj¡ |  d1|jj¡ |  d2|jj¡ |  tj j!|j"¡ |  tj#|j$¡ t|ƒr°|  t%j&|j'¡ |  d3t(|j)ƒ¡ |  d3t(|j*ƒ¡ |  d3t(|j+ƒ¡ |  d3t(|j,ƒ¡ |  d3t(|j-ƒ¡ |  d3t(|j.ƒ¡ |  d3t(|j/ƒ¡ |  d3t(|j0ƒ¡ |  d3t(|j1ƒ¡ |  d3t(|j2ƒ¡ |  d3t(|j3ƒ¡ |  d3t(|j4ƒ¡ |  d3t(|j5ƒ¡ |  d3t(|j6ƒ¡ |  d3t(|j7ƒ¡ t|ƒrE|  d3t(|j8ƒ¡ |  d3t(|j9ƒ¡ |  d3t(|j:ƒ¡ |  d3t(|j;ƒ¡ |  d3t(|j<ƒ¡ |  d3t(|j=ƒ¡ t|ƒr€|  d3t(|j>ƒ¡ |  d3t(|j?ƒ¡ |  d3t(|j@ƒ¡ |  d4|j)d5 ¡ |  d6|j*d5 ¡ |  d7|j+d5 ¡ |  d8|j,d5 ¡ |  d9|j-d5 ¡ |  d:|j.d5 ¡ |  d;|j/d5 ¡ |  d<|j0d5 ¡ |  d=|j1d5 ¡ |  d>|j2d5 ¡ |  d?|j3d5 ¡ |  d@|j4d5 ¡ |  d)|j5d5 ¡ |  dA|j6d5 ¡ |  dB|j7d5 ¡ t|ƒr(|  dC|j8d5 j¡ |  dD|j9d5 j¡ |  dE|j:d5 j¡ |  dF|j;d5 j¡ |  dG|jAd5 j¡ |  tj jB|j<d5 ¡ |  tjC|j=d5 ¡ t|ƒrt|  t%jD|j>d5 ¡ |  dH|j)dI ¡ |  dJ|j*dI ¡ |  dK|j+dI ¡ |  dL|j,dI ¡ |  dM|j-dI ¡ |  dN|j.dI ¡ |  dO|j/dI ¡ |  dP|j0dI ¡ |  dQ|j1dI ¡ |  dR|j2dI ¡ |  dS|j3dI ¡ |  dT|j4dI ¡ |  dU|j5dI ¡ |  dV|j6dI ¡ |  dW|j7dI ¡ t|ƒr
|  dX|j8dI j¡ |  dY|j9dI j¡ |  dZ|j:dI j¡ |  d[|j;dI j¡ |  d\|jAdI j¡ |  tj j!|j<dI ¡ |  tj#|j=dI ¡ t|ƒrV|  t%j&|j>dI ¡ t|ƒro|   | d]¡¡ |   | d^¡¡ |   | d_¡¡ |   | d`¡¡ |   | da¡¡ |   | db¡¡ |   | dc¡¡ |   | dd¡¡ |   | de¡¡ |   | df¡¡ |   | dg¡¡ |   | dh¡¡ |   | di¡¡ |   | dj¡¡ |   | dk¡¡ |   | dl¡¡ |   | dm¡¡ |   | dn¡¡ |  do|jE¡ |  dp|jF¡ |  dq|jG¡ |  dr|jH¡ |  ds|jI¡ |  dt|jJ¡ |  du|jK¡ |  dv|jL¡ |  dw|jM¡ |  dx|jN¡ |  dy|jO¡ |  dz|jP¡ |  dU|jQ¡ |  d{|jR¡ |  d||jS¡ |  tj jT|jU¡ |  tjV|jW¡ |  t%jX|jY¡ d}S d}S )~zFCheck all fields for correct values have after Set*Fields() is called.rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   rs   ru   rw   rr   rt   rv   rx   r}   r   r   r‚   rƒ   r   r   r   r   r   r   r   r   r   r   r   r   Tr   r   r   r   r   r   r   r¾   r¿   é   r!   r   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   FrE   rF   rG   rH   rI   rJ   rK   r¢   r£   r¤   r¥   r¦   r§   r¨   r©   rª   r«   r¬   r­   r®   r¯   r°   r²   r´   r¶   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   N)ZÚ
assertTrueÚHasFieldr   rq   rs   ru   rw   ÚassertEqualrb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rr   rt   rv   rx   ry   rz   rÀ   rÁ   r   r{   r|   r}   r~   r   r   r€   r   Úlenr„   r†   r‡   rˆ   r‰   rŠ   r‹   rŒ   r   rŽ   r   r   r‘   r’   r“   r”   r–   r—   r˜   rš   rœ   rž   r    r¡   r™   r›   r   rŸ   r¢   r£   r¤   r¥   r¦   r§   r¨   r©   rª   r«   r¬   r­   r®   r¯   r°   r±   r²   r³   r´   rµ   r¶   )Ú	test_caser   r	   r	   r
   ÚExpectAllFieldsSetš  s†  

ÿÿ
ÿ



ÿÿ
ÿ

ÿÿ
ÿ

ÿÿÿ×r.  c                 C   s°   d}t j |¡r-t j t j |d¡¡r t j |d| ¡}t|dƒS t j |d¡}t j |¡sd}t j |d| ¡}t j |¡rBt|dƒS t j d| ¡}t j |¡rTt|dƒS tdƒ‚)	zFFinds the given golden file and returns a file object representing it.Ú.zsrc/google/protobufzsrc/google/protobuf/testdataÚrbz..z'third_party/py/google/protobuf/testdataz9external/com_google_protobuf/src/google/protobuf/testdataz™Could not find golden files.  This test must be run from within the protobuf source package so that it can read test data files from the C++ source tree.)ÚosÚpathÚexistsr"  ÚopenÚRuntimeError)Úfilenamer2  Ú	full_pathr	   r	   r
   Ú
GoldenFilel  s*   
û
ÿ
ÿ
ÿr8  c                 C   s4   t | ƒ}| ¡ W  d  ƒ S 1 sw   Y  dS )z5Finds the given golden file and returns its contents.N)r8  Úread)r6  Úfr	   r	   r
   ÚGoldenFileData  s   
$ÿr;  c                 C   óè   | j  ddg¡ | j ddg¡ | j ddg¡ | j ddg¡ | j d	d
g¡ | j ddg¡ | j ddg¡ | j ddg¡ | j	 ddg¡ | j
 ddg¡ | j ddg¡ | j ddg¡ | j ddg¡ | j tjtjg¡ dS )zgSets every field in the message to a unique value.

  Args:
    message: A TestPackedTypes instance.
  r^   é½  r_   é¾  é[  é¿  é\  éÀ  é]  éÁ  é^  éÂ  é_  éÃ  é`  éÄ  éa  éÅ  éb  éÆ  ç     ƒ@ç     8†@ç      ƒ@ç     @†@TFN)Úpacked_int32ÚextendÚpacked_int64Úpacked_uint32Úpacked_uint64Úpacked_sint32Úpacked_sint64Úpacked_fixed32Úpacked_fixed64Úpacked_sfixed32Úpacked_sfixed64Úpacked_floatÚpacked_doubleÚpacked_boolÚpacked_enumr   r   r~   r   r	   r	   r
   ÚSetAllPackedFields“  ó    

ÿrb  c                 C   s*  | j }t}||j  ddg¡ ||j  ddg¡ ||j  ddg¡ ||j  ddg¡ ||j  d	d
g¡ ||j  ddg¡ ||j	  ddg¡ ||j
  ddg¡ ||j  ddg¡ ||j  ddg¡ ||j  ddg¡ ||j  ddg¡ ||j  ddg¡ ||j  tjtjg¡ dS )z}Sets every extension in the message to a unique value.

  Args:
    message: A unittest_pb2.TestPackedExtensions instance.
  r^   r=  r_   r>  r?  r@  rA  rB  rC  rD  rE  rF  rG  rH  rI  rJ  rK  rL  rM  rN  rO  rP  rQ  rR  TFN)rÃ   r   Úpacked_int32_extensionrT  Úpacked_int64_extensionÚpacked_uint32_extensionÚpacked_uint64_extensionÚpacked_sint32_extensionÚpacked_sint64_extensionÚpacked_fixed32_extensionÚpacked_fixed64_extensionÚpacked_sfixed32_extensionÚpacked_sfixed64_extensionÚpacked_float_extensionÚpacked_double_extensionÚpacked_bool_extensionÚpacked_enum_extensionr   r~   )r   r  r  r	   r	   r
   ÚSetAllPackedExtensionsª  s$   
ÿrr  c                 C   r<  )zvSets every field in the message to a unique value.

  Args:
    message: A unittest_pb2.TestUnpackedTypes instance.
  r^   r=  r_   r>  r?  r@  rA  rB  rC  rD  rE  rF  rG  rH  rI  rJ  rK  rL  rM  rN  rO  rP  rQ  rR  TFN)Úunpacked_int32rT  Úunpacked_int64Úunpacked_uint32Úunpacked_uint64Úunpacked_sint32Úunpacked_sint64Úunpacked_fixed32Úunpacked_fixed64Úunpacked_sfixed32Úunpacked_sfixed64Úunpacked_floatÚunpacked_doubleÚunpacked_boolÚunpacked_enumr   r   r~   r   r	   r	   r
   ÚSetAllUnpackedFieldsÄ  rc  r  c                   @   sZ  e Zd ZdZdUdd„Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Zd;d<„ Z d=d>„ Z!d?d@„ Z"dAdB„ Z#dCdD„ Z$dEdF„ Z%dGdH„ Z&dIdJ„ Z'dKdL„ Z(dMdN„ Z)dOdP„ Z*dQdR„ Z+dSdT„ Z,dS )VÚNonStandardIntegeraÝ  An integer object that does not subclass int.

  This is used to verify that both C++ and regular proto systems can handle
  integer others than int and long and that they handle them in predictable
  ways.

  NonStandardInteger is the minimal legal specification for a custom Integral.
  As such, it does not support 0 < x < 5 and it is not hashable.

  Note: This is added here instead of relying on numpy or a similar library
  with custom integers to limit dependencies.
  Nc                 C   s0   t |tjƒsJ ‚t |tƒr|j}|| _|| _d S ©N)Ú
isinstanceÚnumbersÚIntegralr‚  ÚvalÚerror_string_on_conversion)Úselfr‡  rˆ  r	   r	   r
   Ú__init__é  s
   

zNonStandardInteger.__init__c                 C   ó   | j rt| j ƒ‚t| jƒS rƒ  )rˆ  r5  Úlongr‡  ©r‰  r	   r	   r
   Ú__long__ð  ó   

zNonStandardInteger.__long__c                 C   ó   t t | j¡ƒS rƒ  )r‚  ÚoperatorÚabsr‡  r  r	   r	   r
   Ú__abs__õ  ó   zNonStandardInteger.__abs__c                 C   ó   t t | j|¡ƒS rƒ  ©r‚  r‘  r•   r‡  ©r‰  Úyr	   r	   r
   Ú__add__ø  ó   zNonStandardInteger.__add__c                 C   r•  rƒ  ©r‚  r‘  Údivr‡  r—  r	   r	   r
   Ú__div__û  rš  zNonStandardInteger.__div__c                 C   s   t  | j|¡S rƒ  )r‘  Úeqr‡  r—  r	   r	   r
   Ú__eq__þ  s   zNonStandardInteger.__eq__c                 C   r•  rƒ  ©r‚  r‘  Úfloordivr‡  r—  r	   r	   r
   Ú__floordiv__  rš  zNonStandardInteger.__floordiv__c                 C   r•  rƒ  ©r‚  r‘  Útruedivr‡  r—  r	   r	   r
   Ú__truediv__  rš  zNonStandardInteger.__truediv__c                 C   r  rƒ  )r‚  r‘  Úinvertr‡  r  r	   r	   r
   Ú
__invert__  r”  zNonStandardInteger.__invert__c                 C   r•  rƒ  ©r‚  r‘  Úmodr‡  r—  r	   r	   r
   Ú__mod__
  rš  zNonStandardInteger.__mod__c                 C   r•  rƒ  ©r‚  r‘  Úmulr‡  r—  r	   r	   r
   Ú__mul__  rš  zNonStandardInteger.__mul__c                 C   r  rƒ  )r‚  r‘  Únegr‡  r  r	   r	   r
   Ú__neg__  r”  zNonStandardInteger.__neg__c                 C   r  rƒ  )r‚  r‘  Úposr‡  r  r	   r	   r
   Ú__pos__  r”  zNonStandardInteger.__pos__c                 C   r•  rƒ  ©r‚  r‘  Úpowr‡  r—  r	   r	   r
   Ú__pow__  rš  zNonStandardInteger.__pow__c                 C   s
   t | jƒS rƒ  )Úintr‡  r  r	   r	   r
   Ú	__trunc__  ó   
zNonStandardInteger.__trunc__c                 C   ó   t t || j¡ƒS rƒ  r–  r—  r	   r	   r
   Ú__radd__  rš  zNonStandardInteger.__radd__c                 C   r¸  rƒ  r›  r—  r	   r	   r
   Ú__rdiv__  rš  zNonStandardInteger.__rdiv__c                 C   r¸  rƒ  r¨  r—  r	   r	   r
   Ú__rmod__"  rš  zNonStandardInteger.__rmod__c                 C   r¸  rƒ  r«  r—  r	   r	   r
   Ú__rmul__%  rš  zNonStandardInteger.__rmul__c                 C   r¸  rƒ  r²  r—  r	   r	   r
   Ú__rpow__(  rš  zNonStandardInteger.__rpow__c                 C   r¸  rƒ  r   r—  r	   r	   r
   Ú__rfloordiv__+  rš  z NonStandardInteger.__rfloordiv__c                 C   r¸  rƒ  r£  r—  r	   r	   r
   Ú__rtruediv__.  rš  zNonStandardInteger.__rtruediv__c                 C   r•  rƒ  ©r‚  r‘  Úlshiftr‡  r—  r	   r	   r
   Ú
__lshift__1  rš  zNonStandardInteger.__lshift__c                 C   r•  rƒ  ©r‚  r‘  Úrshiftr‡  r—  r	   r	   r
   Ú
__rshift__4  rš  zNonStandardInteger.__rshift__c                 C   r¸  rƒ  rÀ  r—  r	   r	   r
   Ú__rlshift__7  rš  zNonStandardInteger.__rlshift__c                 C   r¸  rƒ  rÃ  r—  r	   r	   r
   Ú__rrshift__:  rš  zNonStandardInteger.__rrshift__c                 C   ó   t |tƒr|j}t | j|¡S rƒ  )r„  r‚  r‡  r‘  Úler—  r	   r	   r
   Ú__le__=  ó   
zNonStandardInteger.__le__c                 C   rÈ  rƒ  )r„  r‚  r‡  r‘  Últr—  r	   r	   r
   Ú__lt__B  rË  zNonStandardInteger.__lt__c                 C   r•  rƒ  ©r‚  r‘  Úand_r‡  r—  r	   r	   r
   Ú__and__G  rš  zNonStandardInteger.__and__c                 C   r•  rƒ  ©r‚  r‘  Úor_r‡  r—  r	   r	   r
   Ú__or__J  rš  zNonStandardInteger.__or__c                 C   r•  rƒ  ©r‚  r‘  Úxorr‡  r—  r	   r	   r
   Ú__xor__M  rš  zNonStandardInteger.__xor__c                 C   r¸  rƒ  rÎ  r—  r	   r	   r
   Ú__rand__P  rš  zNonStandardInteger.__rand__c                 C   r¸  rƒ  rÑ  r—  r	   r	   r
   Ú__ror__S  rš  zNonStandardInteger.__ror__c                 C   r¸  rƒ  rÔ  r—  r	   r	   r
   Ú__rxor__V  rš  zNonStandardInteger.__rxor__c                 C   ó   | j S rƒ  ©r‡  r  r	   r	   r
   Ú__bool__Y  ó   zNonStandardInteger.__bool__c                 C   rÚ  rƒ  rÛ  r  r	   r	   r
   Ú__nonzero__\  rÝ  zNonStandardInteger.__nonzero__c                 C   ó   | S rƒ  r	   r  r	   r	   r
   Ú__ceil___  ó   zNonStandardInteger.__ceil__c                 C   rß  rƒ  r	   r  r	   r	   r
   Ú	__floor__b  rá  zNonStandardInteger.__floor__c                 C   r‹  rƒ  )rˆ  r5  rµ  r‡  r  r	   r	   r
   Ú__int__e  r  zNonStandardInteger.__int__c                 C   rß  rƒ  r	   r  r	   r	   r
   Ú	__round__j  rá  zNonStandardInteger.__round__c                 C   s
   d| j  S )NzNonStandardInteger(%s)rÛ  r  r	   r	   r
   Ú__repr__m  r·  zNonStandardInteger.__repr__rƒ  )-Ú__name__Ú
__module__Ú__qualname__Ú__doc__rŠ  rŽ  r“  r™  r  rŸ  r¢  r¥  r§  rª  r­  r¯  r±  r´  r¶  r¹  rº  r»  r¼  r½  r¾  r¿  rÂ  rÅ  rÆ  rÇ  rÊ  rÍ  rÐ  rÓ  rÖ  r×  rØ  rÙ  rÜ  rÞ  rà  râ  rã  rä  rå  r	   r	   r	   r
   r‚  Û  sV    
r‚  )ré  Ú
__author__r…  r‘  Úos.pathr1  Úgoogle.protobufr   r   rŒ  Ú	NameErrorrµ  r   r½   rÂ   r  r  r'  r.  r8  r;  rb  rr  r  r†  r‚  r	   r	   r	   r
   Ú<module>   s8   ÿ    S!