o
    j#                     @   s  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dZd	ed
edeeeeef fddZdededededeee  deee  deddfddZdededeee  deee  def
d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 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#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)d*Z			&	&	'd0d+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-d.Z dS )1    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                 C   sj   t | |\}}	}
}t||d}t|	|d}tj|d}tj|d}t||||||| |||
|||	fS )N)Z
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_ttxpath r'   T/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/fontTools/diff/diff.py_get_fonts_and_save_xml   s"   
	r)   c                 C   s   | }|}| }|}||||fS Nr'   )r   r   r"   r    r!   r   r'   r'   r(   r   2   s
   r   r#   r$   r%   r&   c           	      C   s   |r1t  dkr1| |||f||||fg}tdd}|t| W d    d S 1 s*w   Y  d S t| ||| t|||| d S )Nr      )Z	processes)r   r   starmap_ttfont_save_xml)	r#   r$   r%   r&   r   r   r   Zmp_args_listpoolr'   r'   r(   r   =   s   	

"r   ttffilepathc                 C   s   | j |||d dS )z;Writes TTX specification formatted XML to disk on filepath.)ZtablesZ
skipTablesT)ZsaveXML)r/   r0   r   r   r'   r'   r(   r-   Y   s   r-   c              
   c   sH    t  }t| |||||||V  W d    d S 1 sw   Y  d S r*   )tempfileTemporaryDirectoryr)   )r   r   r   r   r   r   r   r   r'   r'   r(   _saved_ttx_filesd   s   

"r3   create_differc                 c   s`    t | ||||||\}}	}
}}}|||	|
|||E d H  W d    d S 1 s)w   Y  d S r*   )r3   )r   r   r   r   r   r   r   r4   r%   r&   r!   r"   r   r    r'   r'   r(   _diff_with_saved_ttx_files{   s4   
"r5      Tcontext_linesc           	      #   sP    dt dt dt dt dt dt dtt  f fdd	}t| |||||||E d
H  d
S )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   s    t | }| }W d    n1 sw   Y  t |}| }	W d    n1 s,w   Y  t|}
t|}t||	|||
| dE d H  d S )N)n)open	readlinesr   r   )r%   r&   r!   r"   r   r    ffZ	fromlinestfZtolinesZfromdateZtodater8   r'   r(   _create_unified_diff   s$   



z$u_diff.<locals>._create_unified_diffNr   r   r5   )	r   r   r8   r   r   r   r   r   r?   r'   r>   r(   u_diff   s4   rA   	diff_tool	diff_argsc	           
      #   sR    dt dt dt dt dt dt dtt  f fdd	}	t||||||||	E d
H  d
S )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   sV    g  | |g }t j|t jt jdd}|jD ]}|V  q|j }	|	r)t|	d S )Nutf8)stdoutstderrencoding)
subprocessPopenPIPErI   rJ   readIOError)
r%   r&   rD   rE   rF   rG   commandprocesslineerrrC   rB   r'   r(   _create_external_diff  s   

z0run_external_diff.<locals>._create_external_diffNr@   )
rB   rC   r   r   r   r   r   r   r   rV   r'   rU   r(   run_external_diff   s4   rW   )r6   NNr7   r7   T)NNr7   r7   T)!r   rL   r1   
contextlibr   difflibr   multiprocessingr   r   typingr   r   r   r	   r
   r   r   r   ZfontTools.ttLibr   utilsr   intboolr)   r   r   r-   r3   r5   rA   rW   r'   r'   r'   r(   <module>   s.   (	

	











	
.

	
G

	
