
    Li#                        d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZm	Z	 d dl
mZmZmZmZmZmZmZmZ d dlmZ ddlmZ d	ed
ededeee      deee      dedededeeeeeeef   fdZd	ed
edeeeeef   fdZdededededeee      deee      deddfdZdededeee      deee      def
dZed	ed
edeee      deee      dedededeeeeeeeef      fd       Zd	ed
edeee      deee      dedededeeeeeeegee   f   dee   fdZ	 	 	 	 	 	 d$d	ed
ededeee      deee      dedededee   fd Z	 	 	 	 	 d%d!ed"ee   d	ed
edeee      deee      dedededee   fd#Z y)&    N)contextmanager)unified_diff)Pool	cpu_count)AnyCallableIterableIteratorListOptionalTextTuple)TTFont   )get_file_modtime
filepath_a
filepath_b
tmpdirpathinclude_tablesexclude_tablesfont_number_afont_number_buse_multiprocessreturnc           	      
   t        | |      \  }}	}
}t        ||      }t        |	|      }t        j                  j	                  |d      }t        j                  j	                  |d      }t        |||||||       |||
|||	fS )N)
fontNumberzleft.ttxz	right.ttx)_get_pre_post_pathsr   ospathjoin_mp_save_ttx_xml)r   r   r   r   r   r   r   r   post_pathnamepostpathpre_pathnameprepathtt_lefttt_rightleft_ttxpathright_ttxpaths                   Y/home/ubuntu/crypto_trading_bot/.venv/lib/python3.12/site-packages/fontTools/diff/diff.py_get_fonts_and_save_xmlr+      s     6IJ62M8\7 W7Gh=9H77<<
J7LGGLL[9M g}hVV    c                     | }|}| }|}||||fS N )r   r   r%   r#   r$   r"   s         r*   r   r   2   s'     GHLM(L'99r,   r&   r'   r(   r)   c                     |rEt               dkD  r8| |||f||||fg}t        d      5 }|j                  t        |       d d d        y t        | |||       t        ||||       y # 1 sw Y   y xY w)Nr      )	processes)r   r   starmap_ttfont_save_xml)	r&   r'   r(   r)   r   r   r   mp_args_listpools	            r*   r!   r!   =   s     IK!O lNNC}nnE
 A 	9$LL)<8	9 	9 	,O=..Q	9 	9s   A%%A.ttffilepathc                 ,    | j                  |||       y)z;Writes TTX specification formatted XML to disk on filepath.)tables
skipTablesT)saveXML)r7   r8   r   r   s       r*   r4   r4   Y   s     KKNKKr,   c              #      K   t        j                         5 }t        | |||||||       d d d        y # 1 sw Y   y xY wwr.   )tempfileTemporaryDirectoryr+   )r   r   r   r   r   r   r   r   s           r*   _saved_ttx_filesr@   d   sO      
	$	$	& 

*%	
 		


 

 

s   A5	A>Acreate_differc           	   #      K   t        | ||||||      5 \  }}	}
}}} |||	|
|||      E d {    d d d        y 7 # 1 sw Y   y xY wwr.   )r@   )r   r   r   r   r   r   r   rA   r(   r)   r$   r%   r"   r#   s                 r*   _diff_with_saved_ttx_filesrC   {   s      

 

 
 	
 	
!
 
 	
!
 
s%   A<:<	A<AAcontext_linesc              #      K   dt         dt         dt         dt         dt         dt         dt        t            ffd}t        | |||||||      E d	{    y	7 w)
a  Performs a unified diff on a TTX serialized data format dump of font binary data using
    a modified version of the Python standard libary difflib module.

    filepath_a: (string) pre-file local file path
    filepath_b: (string) post-file local file path
    context_lines: (int) number of context lines to include in the diff (default=3)
    include_tables: (list of str) Python list of OpenType tables to include in the diff
    exclude_tables: (list of str) Python list of OpentType tables to exclude from the diff
    use_multiprocess: (bool) use multi-processor optimizations (default=True)

    include_tables and exclude_tables are mutually exclusive arguments.  Only one should
    be defined

    :returns: Generator of ordered diff line strings that include newline line endings
    :raises: KeyError if include_tables or exclude_tables includes a mis-specified table
    that is not included in filepath_a OR filepath_b
    r(   r)   r$   r%   r"   r#   r   c           	   3   2  K   t        |       5 }|j                         }d d d        t        |      5 }|j                         }	d d d        t        |      }
t        |      }t        	|||
|      E d {    y # 1 sw Y   ^xY w# 1 sw Y   FxY w7 w)N)n)open	readlinesr   r   )r(   r)   r$   r%   r"   r#   ff	fromlinestftolinesfromdatetodaterD   s               r*   _create_unified_diffz$u_diff.<locals>._create_unified_diff   s      , 	'2I	'-  	%BllnG	% $G,!(+
 	
 	
	' 	'	% 	%	
s>   BA=BB	3B7B8B=BB	BBNr   r	   rC   )	r   r   rD   r   r   r   r   r   rP   s	     `      r*   u_diffrR      s~     8


 
 	

 
 
 
$
4 *	 	 	s   AAAA	diff_tool	diff_argsc	              #       K   dt         dt         dt         dt         dt         dt         dt        t            f fd}	t        ||||||||	      E d	{    y	7 w)
a'  Performs a unified diff on a TTX serialized data format dump of font binary data using
    an external diff executable that is requested by the caller via `command`

    diff_tool: (string) command line executable string
    diff_args: (list of strings) arguments for the diff tool
    filepath_a: (string) pre-file local file path
    filepath_b: (string) post-file local file path
    include_tables: (list of str) Python list of OpenType tables to include in the diff
    exclude_tables: (list of str) Python list of OpentType tables to exclude from the diff
    use_multiprocess: (bool) use multi-processor optimizations (default=True)

    include_tables and exclude_tables are mutually exclusive arguments.  Only one should
    be defined

    :returns: Generator of ordered diff line strings that include newline line endings
    :raises: KeyError if include_tables or exclude_tables includes a mis-specified table
    that is not included in filepath_a OR filepath_b
    :raises: IOError if exception raised during execution of `command` on TTX files
    r(   r)   _pre_pathname_prepath_post_pathname	_postpathr   c              3     K   g
z   | |gz   }t        j                  |t         j                  t         j                  d      }|j                  D ]  }|  |j                  j                         }	|	rt        |	      y w)Nutf8)stdoutstderrencoding)
subprocessPopenPIPEr\   r]   readIOError)r(   r)   rV   rW   rX   rY   commandprocesslineerrrT   rS   s             r*   _create_external_diffz0run_external_diff.<locals>._create_external_diff  s      +	)\=,II""????	
 NN 	DJ	nn!!##, s   A>BNrQ   )
rS   rT   r   r   r   r   r   r   r   rh   s
   ``        r*   run_external_diffri      s~     >  	
   
$, *	 	 	s   AAAA)   NNrk   T)NNrk   rk   T)!r   r_   r>   
contextlibr   difflibr   multiprocessingr   r   typingr   r   r	   r
   r   r   r   r   fontTools.ttLibr   utilsr   intboolr+   r   r!   r4   r@   rC   rR   ri   r/   r,   r*   <module>rt      s   	   %   + Q Q Q " #WWW W T$Z(	W
 T$Z(W W W W 4tT4-.W<::: 4tT!":RRR R 	R
 T$Z(R T$Z(R R 
R8	 T$Z( T$Z(	
 
 


 T$Z(
 T$Z(	

 
 
 
 eD$dD$678
 
,!
!
!
 T$Z(!
 T$Z(	!

 !
 !
 !
 T4tT4@(4.PQ!
 d^!
\ +/+/!??? ? T$Z(	?
 T$Z(? ? ? ? d^?N ,0+/!>>Dz> > 	>
 T$Z(> T$Z(> > > > d^>r,   