File manager - Edit - /usr/local/CyberCP/lib/python3.10/site-packages/proto/marshal/rules/__pycache__/bytes.cpython-310.pyc
Back
o �h9 � @ s d dl Z G dd� d�ZdS )� Nc @ s, e Zd ZdZdd�defdd�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)�absentr c C s |S )N� )�self�valuer r r �L/usr/local/CyberCP/lib/python3.10/site-packages/proto/marshal/rules/bytes.py� to_python# s zBytesRule.to_pythonc C s: t |t�r|�d�}|ddt|�d 7 }t�|�}|S )Nzutf-8� =� )� isinstance�str�encode�len�base64�urlsafe_b64decode)r r r r r �to_proto&