File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ import os
2
+ import tempfile
3
+
4
+ from fontTools .ttLib import TTFont
5
+
6
+ from fdiff .utils import get_file_modtime
7
+ from fdiff .thirdparty .fdifflib import unified_diff
8
+
9
+
10
+ def u_diff (filepath_a , filepath_b , context_lines ):
11
+ tt_left = TTFont (filepath_a )
12
+ tt_right = TTFont (filepath_b )
13
+
14
+ fromdate = get_file_modtime (filepath_a )
15
+ todate = get_file_modtime (filepath_b )
16
+
17
+ with tempfile .TemporaryDirectory () as tmpdirname :
18
+ tt_left .saveXML (os .path .join (tmpdirname , "left.ttx" ))
19
+ tt_right .saveXML (os .path .join (tmpdirname , "right.ttx" ))
20
+
21
+ with open (os .path .join (tmpdirname , "left.ttx" )) as ff :
22
+ fromlines = ff .readlines ()
23
+ with open (os .path .join (tmpdirname , "right.ttx" )) as tf :
24
+ tolines = tf .readlines ()
25
+
26
+ return unified_diff (
27
+ fromlines ,
28
+ tolines ,
29
+ filepath_a ,
30
+ filepath_b ,
31
+ fromdate ,
32
+ todate ,
33
+ n = context_lines ,
34
+ )
You can’t perform that action at this time.
0 commit comments