File: //usr/lib64/python3.9/site-packages/rhsm/__pycache__/bitstream.cpython-39.opt-1.pyc
a
X�Zh� � @ s. d dl mZ d dlmZmZ G dd� d�ZdS )� )�deque)�List�Unionc @ s� e Zd ZdZeeef dd�dd�Zd d�dd�Zed�d d
�Z e
d�dd�Zee
ed
�dd��Z
ee
ed�dd��Zeee
e
d�dd��ZdS )�GhettoBitStreama�
Accepts binary data and makes it available as a stream of bits or one byte
at a time. Python does not provide a built-in way to read a stream of bits,
or a way to represent a single bit. Thus, this class uses character '0'
or '1' to represent the status of each bit.
Data is converted into the '0' and '1' characters one byte at a time, since
that operation multiplies the size of the data by a factor of 8, and it may
not be desirable to inflate all the data at once.
N)�data�returnc C s t t|��| _t � | _dS )z9
:param data: binary data in a string
N)r � bytearray�bytes�_bit_buffer)�selfr � r �4/usr/lib64/python3.9/site-packages/rhsm/bitstream.py�__init__ s zGhettoBitStream.__init__)r c C s | S )Nr �r r r r
�__iter__$ s zGhettoBitStream.__iter__c C sJ | j s@z| �� }W n ty( t�Y n0 | �|�}| j �|� | j �� S )z�
converts one byte at a time into a bit representation, waiting until
those bits have been consumed before converting another byte
:return: next bit in the stream, either '0' or '1'
:rtype: string
)r
�pop_byte�
IndexError�
StopIteration�
_byte_to_bits�extend�popleft)r �byte�bitsr r r
�__next__'