a
    CgN                     @   s*   d dl mZ d dlmZ G dd dZdS )    )List)Blockc                   @   sv   e Zd ZdZdZdeeeddddZedd	d
ZedddZ	e
eed  dddZe
eed  dddZdS )Commandz
    A Command represents an operation that has to be executed
    on a block for it to be converted into an arbitrary number
    of HTML nodes.
    nameindexdata N)r   r   r   returnc                 C   s   || _ || _|| _d S Nr   )selfr   r   r    r   W/var/www/lab.imftr.de/x/nb_venv/lib/python3.9/site-packages/draftjs_exporter/command.py__init__   s    zCommand.__init__)r
   c                 C   s   d| j  d| j d| j dS )Nz	<Command  >r   r   r   r   r   __str__   s    zCommand.__str__c                 C   s   t | S r   )strr   r   r   r   __repr__   s    zCommand.__repr__)blockr
   c                 C   sZ   g }| d D ]H}t |d }|d }||d  }|td|| |td|| q|S )u   
        Creates a list of commands from a block’s list of entity ranges.
        Each range is converted to two commands: a start_* and a stop_*.
        ZentityRangeskeyoffsetlengthZstart_entityZstop_entity)r   appendr   r   commandsrr   startstopr   r   r   from_entity_ranges   s    zCommand.from_entity_rangesc                 C   sV   g }| d D ]D}|d }|d }||d  }| td|| | td|| q|S )u   
        Creates a list of commands from a block’s list of style ranges.
        Each range is converted to two commands: a start_* and a stop_*.
        ZinlineStyleRangesstyler   r   Zstart_inline_styleZstop_inline_style)r   r   r   r   r   r   from_style_ranges+   s    zCommand.from_style_ranges)r	   )__name__
__module____qualname____doc__	__slots__r   intr   r   r   staticmethodr   r   r    r"   r   r   r   r   r      s   r   N)typingr   Zdraftjs_exporter.typesr   r   r   r   r   r   <module>   s   