|
Server : LiteSpeed System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64 User : nandedex ( 1060) PHP Version : 8.1.33 Disable Function : NONE Directory : /opt/cppython/lib/python3.8/site-packages/proto/marshal/rules/__pycache__/ |
U
O��g9 � @ s d dl Z G dd� d�ZdS )� Nc @ s, e Zd ZdZdd�ed�dd�Zdd� ZdS )� BytesRulea� A marshal between Python strings and protobuf bytes.
Note: this conversion is asymmetric because Python does have a bytes type.
It is sometimes necessary to convert proto bytes fields to strings, e.g. for
JSON encoding, marshalling a message to a dict. Because bytes fields can
represent arbitrary data, bytes fields are base64 encoded when they need to
be represented as strings.
It is necessary to have the conversion be bidirectional, i.e.
my_message == MyMessage(MyMessage.to_dict(my_message))
To accomplish this, we need to intercept assignments from strings and
base64 decode them back into bytes.
N)�absentc C s |S )N� )�self�valuer r r �F/opt/cppython/lib/python3.8/site-packages/proto/marshal/rules/bytes.py� to_python# s zBytesRule.to_pythonc C s: t |t�r6|�d�}|ddt|�d 7 }t�|�}|S )Nzutf-8� =� )�
isinstance�str�encode�len�base64�urlsafe_b64decode)r r r r r �to_proto&