o
    a                     @   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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	   9/usr/lib/python3/dist-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   s   | j d ur?| j j| }d|v r-|d dr-|d dr-|d dd |d d S t|jdr?t|jjdr?|jjjS d| S )Nname       filezmaster number )r   ttfsZgetDebugNamehasattrreaderr   r   )r   ZixZttfr	   r	   r
   _master_name   s   
 

zVarLibMergeError._master_namec                    sD   d j v r d j v r  fdd j d 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)NN)r   indexr   )r   r&   r	   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
   details4   s
   
$zVarLibMergeError.detailsc                 C   s\   | j \}}d}|rd| d}dt| j}tjd| j d| dd}d| | | j S )	Nr*   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   r,   )r   r+   r'   locationcontextZbasicr	   r	   r
   __str__<   s   

zVarLibMergeError.__str__r   )r   r   r   r   r   propertyr   r   r'   r,   r5   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   | j d dks| jd u rt jS | j\}}| jj| }| 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.FeatureCountr   c                 S      g | ]}|j qS r	   Z
FeatureTagr"   r	   r	   r
   r%   U       z,ShouldBeConstant.details.<locals>.<listcomp>c                 S   r8   r	   r9   r"   r	   r	   r
   r%   Y   r:   z2
Incompatible features between masters.
Expected: z, z.
Got: z.
)
r   r   superr,   r'   r   tableZFeatureListZFeatureRecordr/   )r   r+   r'   Zbad_ttfZgood_ttfZgood_featuresZbad_features	__class__r	   r
   r,   M   s"   
zShouldBeConstant.details)r   r   r   r   r6   r,   __classcell__r	   r	   r>   r
   r7   J   s    r7   c                   @   s(   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   s0   | j d }dd |d D d}|| |fS )Nr   c                 S   s   g | ]}|d u qS r   r	   r"   r	   r	   r
   r%   j   s    z'FoundANone.offender.<locals>.<listcomp>r!   T)argvr&   r   )r   r   r&   r	   r	   r
   r'   g   s   
zFoundANone.offenderc                 C   s2   | j d | j dd  }}|d  d|d  dS )Nr   r   r(   r!   r)   argsr   r   r   r	   r	   r
   r,   m   s   zFoundANone.detailsN)r   r   r   r   r6   r'   r,   r	   r	   r	   r
   rA   d   s    
rA   c                   @   r   )MismatchedTypeszdata had inconsistent typesNr   r	   r	   r	   r
   rF   s   r   rF   c                   @   r   )LengthsDifferz*a list of objects had inconsistent lengthsNr   r	   r	   r	   r
   rG   w   r   rG   c                   @   r   )
KeysDifferz$a list of objects had different keysNr   r	   r	   r	   r
   rH   {   r   rH   c                   @   r   )InconsistentGlyphOrderz0the glyph order was inconsistent between mastersNr   r	   r	   r	   r
   rI      r   rI   c                   @   r   )InconsistentExtensionsz6the masters use extension lookups in inconsistent waysNr   r	   r	   r	   r
   rJ      r   rJ   c                   @   s   e Zd ZdZedd ZdS )UnsupportedFormatz6an OpenType subtable (%s) had a format I didn't expectc                 C   s(   | j d | j dd  }}| j|d  S )Nr   r   Zsubtable)rD   r   rE   r	   r	   r
   r      s   zUnsupportedFormat.reasonN)r   r   r   r   r6   r   r	   r	   r	   r
   rK      s    rK   c                   @   r   )rK   zBan OpenType subtable (%s) had inconsistent formats between mastersNr   r	   r	   r	   r
   rK      r   c                   @   s   e Zd ZdS )VarLibCFFMergeErrorN)r   r   r   r	   r	   r	   r
   rL      s    rL   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
	rC   )r   keyvaluevalues	error_msgZregion_valuer	   r	   r
   r      s   z VarLibCFFDictMergeError.__init__Nr   r   r   r   r   r	   r	   r	   r
   rN          rN   c                   @   rM   )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 ''rC   )r   Z
point_typeZpt_indexm_indexdefault_type
glyph_namerR   r	   r	   r
   r         z%VarLibCFFPointTypeMergeError.__init__NrS   r	   r	   r	   r
   rU      rT   rU   c                   @   rM   )VarLibCFFHintTypeMergeErrorzJRaised when a CFF glyph cannot be merged because of hint type differences.c                 C   rV   )NrW   rX   z' at index rY   z* differs from the default font hint type 'rZ   rC   )r   Z	hint_typeZ	cmd_indexr[   r\   r]   rR   r	   r	   r
   r      r^   z$VarLibCFFHintTypeMergeError.__init__NrS   r	   r	   r	   r
   r_      rT   r_   c                   @   r   )VariationModelErrorz(Raised when a variation model is faulty.Nr   r	   r	   r	   r
   r`      r   r`   )r1   	Exceptionr   r   r   r7   rA   rF   rG   rH   rI   rJ   rK   rL   rN   rU   r_   r`   r	   r	   r	   r
   <module>   s$    >	