)Ej*$ddlZddlZddlZddlmZddlmZddlmZm Z ddl m Z m Z m Z mZmZmZmZmZddlmZddlmZd ed ed ed eeed eeededededeeeeeeeffdZd ed edeeeeeffdZde de deded eeed eeededdfdZde ded eeed eeedef dZed ed ed eeed eeededededeeeeeeeeffdZd ed ed eeed eeedededede eeeeeege efdeefdZ d'd ed ed"ed eeed eeededededeefd#Z d(d$ed%eed ed ed eeed eeededededeefd&Z dS))N)contextmanager) unified_diff)Pool cpu_count)AnyCallableIterableIteratorListOptionalTextTuple)TTFont)get_file_modtime filepath_a filepath_b tmpdirpathinclude_tablesexclude_tables font_number_a font_number_buse_multiprocessreturnc *t||\}} } } t| |} t| |} tj|d}tj|d}t | | |||||||| | || fS)N) fontNumberzleft.ttxz right.ttx)_get_pre_post_pathsrospathjoin_mp_save_ttx_xml)rrrrrrrr post_pathnamepostpath pre_pathnameprepathtt_lefttt_right left_ttxpath right_ttxpaths EC:\PYTHON\MyICR_Suite\python\Lib\site-packages\fontTools/diff/diff.py_get_fonts_and_save_xmlr+s6IJ662M8\7W777Gh=999H7<< J77LGLL[99M  g}h VVc|}|}|}|}||||fSN)rrr%r#r$r"s r*rr2s'GHLM (L' 99r,r&r'r(r)c|rdtdkrR||||f||||fg}td5}|t|ddddS#1swxYwYdSt||||t||||dS)Nr) processes)rrstarmap_ttfont_save_xml) r&r'r(r)rrr mp_args_listpools r*r!r!=sRIKK!OO lNN C }nn E A    9$ LL)< 8 8 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 ,OOO=..QQQQQsAA!Attffilepathc6||||dS)z;Writes TTX specification formatted XML to disk on filepath.)tables skipTablesT)saveXML)r7r8rrs r*r4r4Ys!KKNKKKK 4r,c #Ktj5}t||||||||VddddS#1swxYwYdSr.)tempfileTemporaryDirectoryr+)rrrrrrrrs r*_saved_ttx_filesr@ds  $ & &  *%                              s<AA create_differc #Kt|||||||5\}} } } } } ||| | | | | Ed{VddddS#1swxYwYdSr.)r@)rrrrrrrrAr(r)r$r%r"r#s r*_diff_with_saved_ttx_filesrC{s      =                !                  sAA AT context_linesc#Kdtdtdtdtdtdtdttffd }t||||||||Ed {Vd S) aPerforms 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#rc 3lKt|5}|}dddn #1swxYwYt|5}|} dddn #1swxYwYt|} t|} t|| ||| | Ed{VdS)N)n)open readlinesrr) r(r)r$r%r"r#ff fromlinestftolinesfromdatetodaterFs r*_create_unified_diffz$u_diff.._create_unified_diffsS,   '2 I ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' -  %BllnnG % % % % % % % % % % % % % % %$G,,!(++                  s488A//A36A3Nr r rC) rrrFrrrrrrRs ` r*u_diffrTs8           $      4*           r, diff_tool diff_argsc #Kdtdtdtdtdtdtdttffd } t|||||||| Ed {Vd 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 _postpathrc3K g z||gz}tj|tjtjd}|jD]}|V|j} | rt | dS)Nutf8)stdoutstderrencoding) subprocessPopenPIPEr^r_readIOError) r(r)rXrYrZr[commandprocesslineerrrVrUs r*_create_external_diffz0run_external_diff.._create_external_diffs+ )\=,II" ??    N  DJJJJn!!##  #,,   r,NrS) rUrVrrrrrrrrjs `` r*run_external_diffrks>      $,*           r,)rDNNrErET)NNrErET)!rrar> contextlibrdifflibrmultiprocessingrrtypingrrr r r r r rfontTools.ttLibrutilsrintboolr+rr!r4r@rCrTrkr/r,r*rts %%%%%% ++++++++QQQQQQQQQQQQQQQQQQQQ""""""######WWWWT$Z( W T$Z( W  WWW 4tT4 -.WWWW<::: 4tT !"::::R RRR R T$Z( R T$Z( RR RRRR8 T$Z(T$Z(      T$Z( T$Z(       eD$dD$678    ,! ! ! T$Z(! T$Z( !  !  ! ! T4tT4@(4.PQ! d^! ! ! ! \+/+/!?????T$Z( ? T$Z( ?  ???d^????N,0+/!>>>Dz>> > T$Z( > T$Z( >>>>d^>>>>>>r,