o
    h                     @   s,  d dl Z G dd deZG dd deZG dd deZG dd	 d	eZG d
d deZG dd deZG dd deZG dd deZ	G dd deZ
G dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG d d! d!eZG d"d# d#eZG d$d% d%eZdS )&    Nc                   @      e Zd ZdZdS )VarLibErrorz%Base exception for the varLib module.N__name__
__module____qualname____doc__ r	   r	   k/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/fontTools/varLib/errors.pyr          r   c                   @   r   )VarLibValidationErrorz>Raised when input data is invalid from varLib's point of view.Nr   r	   r	   r	   r
   r      r   r   c                   @   sN   e Zd ZdZdddZedd Zdd Zed	d
 Zedd Z	dd Z
dS )VarLibMergeErrorz=Raised when input data cannot be merged into a variable font.Nc                 K   s8   || _ |si }d|v r|d | _|d= ng | _|| _d S )Nstack)mergerr   causeselfr   kwargsr	   r	   r
   __init__   s   

zVarLibMergeError.__init__c                 C   s   | j S N)r   r   r	   r	   r
   reason   s   zVarLibMergeError.reasonc                 C   sd   | j d ur-| j j| }d|v r|d  r|d  S t|jdr-t|jjdr-|jjjS d| S )Nnamefilezmaster number )r   ttfsgetBestFullNamehasattrreaderr   r   )r   ixttfr	   r	   r
   _master_name   s   


zVarLibMergeError._master_namec                    sh   d j v r2d j v r2 fdd j d D d} |}d j v r.| d j d  d}||fS d	S )
Nexpectedgotc                    s   g | ]	}| j d  kqS )r!   )r   .0xr   r	   r
   
<listcomp>*   s    z-VarLibMergeError.offender.<locals>.<listcomp>Flocation ())NNr   indexr    )r   r+   master_namer	   r   r
   offender'   s   

zVarLibMergeError.offenderc                 C   sT   d| j v r(d| j v r(| j\}}| j d | }d| jd  d| j d d|dS dS )	Nr!   r"   zExpected to see r   ==z, instead saw 
 )r   r-   r   )r   offender_indexr-   r"   r	   r	   r
   details3   s
   
$zVarLibMergeError.detailsc                 C   s\   | j \}}d}|rd| d}dt| j}tjd| j d| dd}d| | | j S )	Nr0   z!

The problem is likely to be in z:
z"Couldn't merge the fonts, because z:. This happened while performing the following operation: N   )widthz

)r-   joinreversedr   textwrapfillr   r2   )r   r1   r-   r'   contextbasicr	   r	   r
   __str__;   s   

zVarLibMergeError.__str__r   )r   r   r   r   r   propertyr   r    r-   r2   r;   r	   r	   r	   r
   r      s    

	

r   c                       s$   e Zd ZdZe fddZ  ZS )ShouldBeConstantz9some values were different, but should have been the samec                    s   t  j} jd dks jd u r|S  jd dksJ  j\}} jj| }t fdd jjD }dd | jd  jjj	D }dd | jd  jjj	D }|d	d

| dd

| d S )Nr   z.FeatureCountc                 3   s@    | ]} j d  |v r| j d   jjj jd kr|V  qdS )r!   N)r   tableFeatureListFeatureCountr   )r$   r   r   r	   r
   	<genexpr>V   s    z+ShouldBeConstant.details.<locals>.<genexpr>c                 S      g | ]}|j qS r	   
FeatureTagr#   r	   r	   r
   r&   ^       z,ShouldBeConstant.details.<locals>.<listcomp>r>   c                 S   rC   r	   rD   r#   r	   r	   r
   r&   b   rF   z2
Incompatible features between masters.
Expected: z, z.
Got: z.
)superr2   r   r   r-   r   nextr?   r@   FeatureRecordr5   )r   basic_messager1   _bad_ttfgood_ttfgood_featuresbad_features	__class__r   r
   r2   L   s,   
zShouldBeConstant.details)r   r   r   r   r<   r2   __classcell__r	   r	   rP   r
   r=   I   s    r=   c                   @   (   e Zd ZdZedd Zedd ZdS )
FoundANonezAone of the values in a list was empty when it shouldn't have beenc                 C   (   dd | j d D d}|| |fS )Nc                 S   s   g | ]}|d u qS r   r	   r#   r	   r	   r
   r&   r       z'FoundANone.offender.<locals>.<listcomp>r"   Tr*   r   r+   r	   r	   r
   r-   p      zFoundANone.offenderc                 C   &   | j | j}}|d  d|d  dS Nr   r.   r"   r/   r   r   r   r   r   r	   r	   r
   r2   u      zFoundANone.detailsNr   r   r   r   r<   r-   r2   r	   r	   r	   r
   rT   m       
rT   c                   @   rS   )NotANonezBone of the values in a list was not empty when it should have beenc                 C   rU   )Nc                 S   s   g | ]}|d uqS r   r	   r#   r	   r	   r
   r&      rV   z%NotANone.offender.<locals>.<listcomp>r"   Tr*   rW   r	   r	   r
   r-   ~   rX   zNotANone.offenderc                 C   rY   rZ   r[   r\   r	   r	   r
   r2      r]   zNotANone.detailsNr^   r	   r	   r	   r
   r`   {   r_   r`   c                   @   r   )MismatchedTypeszdata had inconsistent typesNr   r	   r	   r	   r
   ra      r   ra   c                   @   r   )LengthsDifferz*a list of objects had inconsistent lengthsNr   r	   r	   r	   r
   rb      r   rb   c                   @   r   )
KeysDifferz$a list of objects had different keysNr   r	   r	   r	   r
   rc      r   rc   c                   @   r   )InconsistentGlyphOrderz0the glyph order was inconsistent between mastersNr   r	   r	   r	   r
   rd      r   rd   c                   @   r   )InconsistentExtensionsz6the masters use extension lookups in inconsistent waysNr   r	   r	   r	   r
   re      r   re   c                       s.   e Zd ZdZd fdd	Zedd Z  ZS )UnsupportedFormatz6an OpenType subtable (%s) had a format I didn't expectNc                    s*   t  j|fi | | jsdg| _d S d S )Nz.Format)rG   r   r   r   rP   r	   r
   r      s   zUnsupportedFormat.__init__c                 C   s4   | j | jd  }d| jv r|d| jd d7 }|S )Nsubtablevaluer(   r)   )r   r   )r   sr	   r	   r
   r      s   
zUnsupportedFormat.reasonr   )r   r   r   r   r   r<   r   rR   r	   r	   rP   r
   rf      s
    rf   c                   @   r   )InconsistentFormatszBan OpenType subtable (%s) had inconsistent formats between mastersNr   r	   r	   r	   r
   rj      r   rj   c                   @   s   e Zd ZdS )VarLibCFFMergeErrorN)r   r   r   r	   r	   r	   r
   rk      s    rk   c                   @      e Zd ZdZdd ZdS )VarLibCFFDictMergeErrorz/Raised when a CFF PrivateDict cannot be merged.c                 C   s6   d| d| d}|D ]	}|d| 7 }q|f| _ d S )NzFor the Private Dict key 'z!', the default font value list:
	z5
had a different number of values than a region font:z
	args)r   keyrh   values	error_msgregion_valuer	   r	   r
   r      s   z VarLibCFFDictMergeError.__init__Nr   r   r   r   r   r	   r	   r	   r
   rm          rm   c                   @   rl   )VarLibCFFPointTypeMergeErrorzKRaised when a CFF glyph cannot be merged because of point type differences.c                 C   0   d| d| d| d| d| d}|f| _ d S )NGlyph '': 'z' at point index  in master index z+ differs from the default font point type ''rn   )r   
point_typept_indexm_indexdefault_type
glyph_namerr   r	   r	   r
   r         z%VarLibCFFPointTypeMergeError.__init__Nrt   r	   r	   r	   r
   rv      ru   rv   c                   @   rl   )VarLibCFFHintTypeMergeErrorzJRaised when a CFF glyph cannot be merged because of hint type differences.c                 C   rw   )Nrx   ry   z' at index rz   z* differs from the default font hint type 'r{   rn   )r   	hint_type	cmd_indexr~   r   r   rr   r	   r	   r
   r      r   z$VarLibCFFHintTypeMergeError.__init__Nrt   r	   r	   r	   r
   r      ru   r   c                   @   r   )VariationModelErrorz(Raised when a variation model is faulty.Nr   r	   r	   r	   r
   r      r   r   )r7   	Exceptionr   r   r   r=   rT   r`   ra   rb   rc   rd   re   rf   rj   rk   rm   rv   r   r   r	   r	   r	   r
   <module>   s&    =$