
    Li:5                        d dl Z d dlZd dlZd dlZd dlZd dlmZmZmZm	Z	m
Z
mZ ddlmZ ddlmZmZ ddlmZmZ deddfd	Zd
edefdZ	 	 ddee   de	ee      de	ee      dee   fdZ	 	 	 	 ddedede	ee      de	ee      dededeeef   fdZ	 	 	 	 ddedede	ee      de	ee      dededeeef   fdZd Zdee
   fdZy)    N)IterableIteratorListOptionalTextTuple   )color_unified_diff_line)run_external_diffu_diff)file_existsget_tables_argument_listoutputreturnc                 <   | syt         j                  j                         s t         j                  j                  |        yt	        j
                  d      xs t        j                  d      }|s t         j                  j                  |        y|g}dt        j                  j                  |      v r|j                  d       t        j                  |t        j                  d      }	 |j                  j                  |        |j                  j                          |j!                          y# t"        t$        f$ r+ |j                  r|j                  j                          Y yY yt&        $ r( |j                  r|j                  j                           w xY w)zDPipes output to a pager if stdout is a TTY and a pager is available.NPAGERlessz-RT)stdintext)sysstdoutisattywriteosgetenvshutilwhichpathbasenameappend
subprocessPopenPIPEr   closewaitBrokenPipeErrorKeyboardInterrupt	Exception)r   pager	pager_cmdprocs       ]/home/ubuntu/crypto_trading_bot/.venv/lib/python3.12/site-packages/fontTools/diff/__init__.pypipe_outputr-      s.    ::

 IIg6&,,v"6E

 I!!%((IZ__4HD

 

		./  ::JJ   ::JJs   ,AD2 25F+0F	diff_toolc                     	 t        j                  | dgt         j                  t         j                  d      }|j                  xs d|j
                  xs dz   }d|v S # t        $ r Y yw xY w)z9Returns True if the provided diff executable is GNU diff.z	--versionT)r   stderrr   F zGNU diffutils)r!   runr#   OSErrorr   r0   )r.   r+   version_outputs      r,   _is_gnu_diffr5   3   sk    ~~$????	
 kk'RDKK,=2>Nn,,	  s   7A 	A*)A*tagsinclude_tablesexclude_tablesc              #   >   K   | D ]  }|r||v r
|r||vr|  y w)N )r6   r7   r8   tags       r,   _iter_filtered_table_tagsr<   C   s6     
  c^3c7	s   file1file2font_number_1font_number_2c                    ddl m}  || d|      5 } ||d|      5 }|j                  j                         D 	ch c]  }	t	        |	       }
}	|j                  j                         D 	ch c]  }	t	        |	       }}	t        t        t        |
|z  ||                  }|D 	cg c]  }	|	|
v s|	|vs|	 }}	|D 	cg c]  }	|	|v s|	|
vs|	 }}	|D 	cg c]  }	|	|
v s|	|v s|	 }}	d}g }|j                  d       |j                  d|  d       |j                  d	| d       |rUd
}|j                  dt        |       d       |D ]0  }	|j                  d|	 dt        |j                  |	          d       2 |rUd
}|j                  dt        |       d       |D ]0  }	|j                  d|	 dt        |j                  |	          d       2 |j                  dt        |       d       |D ]v  }	|j                  |	   }|j                  |	   }||k(  r"|j                  d|	 dt        |       d       Hd
}|j                  d|	 dt        |       dt        |       d       x |r|j                  d       n|j                  d       |dj                  |      fcd d d        cd d d        S c c}	w c c}	w c c}	w c c}	w c c}	w # 1 sw Y   nxY wd d d        y # 1 sw Y   y xY w)Nr   TTFontTlazy
fontNumberr7   r8   zBinary table summary:
z	  file1: 
z	  file2: Fz
Tables only in file1 (z):
z- z (z bytes)
z
Tables only in file2 (z+ z
Tables in both (z  z: SAME (z* z: DIFF (z vs z
Result: SAME
z
Result: DIFFERENT
r1   )fontTools.ttLibrC   readerkeysstrsortedsetr<   r    lenjoin)r=   r>   r7   r8   r?   r@   rC   font1font2r;   tags1tags2all_tagsonly1only2both	identicallinesdata1data2s                       r,   	summarizer]   P   s    ' 	u4M:6)>Cu4M:6)>C%*\\%6%6%89cS99%*\\%6%6%89cS99)EM#1#1
 !)NC5LS=MNN (NC5LS=MNN'I3%<C5LII	.0yr*+yr*+ILL3CJ<tDE Lr#bU\\#->)?(@	JKLILL3CJ<tDE Lr#bU\\#->)?(@	JKL 	)#d)D9: 	VCLL%ELL%E~r#hs5zl)DE!	r#hs5zl$s5zl)TU	V LL+,LL01"''%.(m6) 6) 6) :9 ONI'6) 6) 6) 6) 6)s   K+KJ=K+K=)K&	K0K5K9K?	K	KKK	K"K'K+F?K*	K+=KK	K++K4c                    ddl m}  || d|      5 } ||d|      5 }|j                  j                         D 	ch c]  }	t	        |	       }
}	|j                  j                         D 	ch c]  }	t	        |	       }}	t        t        t        |
|z  ||                  }|D 	cg c]  }	|	|
v s|	|v s|	 }}	t               }|D ]7  }	|j                  |	   }|j                  |	   }||k(  s'|j                  |	       9 |cd d d        cd d d        S c c}	w c c}	w c c}	w # 1 sw Y   nxY wd d d        y # 1 sw Y   y xY w)Nr   rB   TrD   rG   )	rI   rC   rJ   rK   rL   rM   rN   r<   add)r=   r>   r7   r8   r?   r@   rC   rQ   rR   r;   rS   rT   rU   rX   outr[   r\   s                    r,   get_binary_exclude_tablesra      sB    ' 	u4M:>Cu4M:>C%*\\%6%6%89cS99%*\\%6%6%89cS99)EM#1#1
  (I3%<C5LIIe 	CLL%ELL%E~		 5   :9 J#    s]   D9D$DD$+D=)D$&	D0D5D94D$.D$	D9D$$D-	)D99Ec                  B   d} 	 t        t        j                  dd       } | S # t        $ r Y | S t        $ rh t        j                  t
        j                  t
        j                        }t        j                  |t        j                  j                                Y | S w xY w)z!Compare two fonts for differencesr   r	   N)r2   r   argvr'   r&   r   opendevnullO_WRONLYdup2r   fileno)retre   s     r,   mainrj      s     C.#((12, J   J  . ''"**bkk2
**,-J.s   " 	BA,BBrc   c                    t        j                  d      }|j                  dddd       |j                  dd	t        d
d       |j                  ddt        dd d       |j                  ddt        dd d       |j                  dt        d       |j                  dt        d d       |j                  dg ddd       |j                  dt        d d!d"#       |j                  d$t        d d!d%#       |j                  d&d'dd(       |j                  d)d*dd+       |j                  d,d-dd.       |j                  d/d01       |j                  d2d31       |j                  |       }|j                  rI|j                  r=|j                  s0t        j                  j                  d4t        j                          y5|j                  sd6|_        t        |j                        sJ|j                  s=t        j                  j                  d7|j                   d8t        j                          y5t        |j                         sJ|j                  s=t        j                  j                  d7|j                    d8t        j                          y5t#        |j$                        }t#        |j&                        }|j(                  rn	 t+        |j                  |j                   |||j,                  |j.                  9      \  }}|j                  st        j0                  j                  |       |rd:S d;S |j                  rnt5        |j                  |j                   |||j,                  |j.                  9      }||D 	cg c]	  }	|	|vs|	 }}	n|g }|j7                  t9        |             |j:                  }
|j<                  d=k(  xs+ |j<                  dk(  xr t        j0                  j>                  }|
tA        jB                  d>      }
nc|
ratA        jB                  |
      }
|
J|j                  s=t        j                  j                  d?|j:                   d@t        j                          y5	 |
r|jD                  }|L|jF                  d
k(  rdAg}ndBjI                  |jF                        g}tK        |
      r"|jM                  dC       n|jO                         }tQ        |
||j                  |j                   |||j,                  |j.                  d6D	      }nEtS        |j                  |j                   |jF                  |||j,                  |j.                  d6E      }|r|D cg c]  }tU        |       }}dFjW                  |      }|j                  stY        |       |rd;S d:S # t2        $ rH}|j                  s2t        j                  j                  d<| t        j                          Y d }~y5d }~ww xY wc c}	w c c}w # t2        $ rH}|j                  s2t        j                  j                  d<| t        j                          Y d }~y5d }~ww xY w)GNz&An OpenType table diff tool for fonts.)descriptionz-lz	--summary
store_truez.Report table presence and binary equality only)actionhelpz-Uz--lines   z5Number of context lines for unified diff (default: 3))typedefaultro   z-tz	--include+z5Font tables to include. Multiple options are allowed.)rq   nargsrr   ro   z-xz	--excludez5Font tables to exclude. Multiple options are allowed.z--diffz.Run external diff tool command (default: diff))rq   ro   z
--diff-argz*External diff tool arguments (default: -u)z--color)autoneveralwaysru   z*Whether to colorize output (default: auto))choicesrr   ro   z--y1NUMBERzMSelect font number for TrueType Collection (.ttc/.otc) FILE1, starting from 0)rq   rr   metavarro   z--y2zMSelect font number for TrueType Collection (.ttc/.otc) FILE2, starting from 0z-az--alwaysz'Compare tables even if binary identicalz-bz--binaryz0Compare tables only if binaries differ (default)z-qz--quietzSuppress all outputFILE1zFont file path 1)ro   FILE2zFont file path 2zv[*] Error: --always and --binary are mutually exclusive options. Please use ONLY one of these options in your command.   Tz[*] ERROR: The file path 'z' can not be found.)r7   r8   r?   r@   r   r	   z[*] ERROR: rw   diffz.[*] ERROR: The external diff tool executable 'z' was not found.z-uz-u{}z-F^\s\s<)r7   r8   font_number_afont_number_buse_multiprocess)context_linesr7   r8   r   r   r   r1   )-argparseArgumentParseradd_argumentintrL   
parse_argsrw   binaryquietr   r0   r   r   linesepr   r|   r}   r   includeexcludesummaryr]   y1y2r   r(   ra   extendrM   r   colorr   r   r   diff_argrZ   formatr5   r    splitr   r   r
   rP   r-   )rc   parserargsinclude_listexclude_listrY   r   eexcluded_binary_tablesr;   r.   color_outputr   lines                 r,   r2   r2      s    $$<F =	   D   D   D   s!Q   9	   +9	   \   \   6	   ?	   i3H   &89
&89%006D {{t{{zzJJHHJ

|U ;; tzz"zzJJ,TZZL8KBJJ<X tzz"zzJJ,TZZL8KBJJ<X  *B$,,)OL)A$,,)OL||	 )



++"gg"gg!Iv ::

  (!1(q( {{!:JJJJ''''''"
 #+s:P/PL  #!'= >?		I::) 

f2!2!2  LL(		LL+	::

  		{"22::,@ /}}H::? $vH &djj 9:H	*OOK0#>>+&



++"gg"gg!%
F 



"jj++"gg"gg!%	F @FG-d3GFGzzq!!e  	::

  ;qc"**!>?	| H  zzJJ{1#bjj\:;s\   A*V, 6V, 	X X 6C4X
 *X<-X
 *X
 ,	W=5>W88W=X
 
	Y>YY)NN)NNry   ry   )r   r   r   r   r!   typingr   r   r   r   r   r   r   r
   r   r   r   utilsr   r   rL   r-   boolr5   r<   r   r]   ra   rj   r2   r:       r,   <module>r      s    	 
   B B * + 8# # #L-C -D -$ +/*.

3-
T#Y'
 T#Y'
 c]	
  +/*.@)@)@) T#Y'@) T#Y'	@)
 @) @) 49@)L +/*.$$$ T#Y'$ T#Y'	$
 $ $ 49$N(kd4j kr   