File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,8 +53,8 @@ def get_msgs(lines):
5353 lineno += 1
5454 return msgids , msgstrs
5555
56- def main (fp ):
57- p = subprocess .Popen (['git' , 'show' , 'HEAD:' + fp ], stdout = subprocess .PIPE )
56+ def main (fp , original_po_commit = 'HEAD' ):
57+ p = subprocess .Popen (['git' , 'show' , f' { original_po_commit } : { fp } ' ], stdout = subprocess .PIPE )
5858 out , err = p .communicate ()
5959 head_po = out .decode ().splitlines ()
6060 msgids , msgstrs = get_msgs (head_po )
@@ -94,11 +94,21 @@ def main(fp):
9494
9595if __name__ == '__main__' :
9696 import sys
97+
9798 if len (sys .argv ) < 2 :
98- print ('Usage: python fix_diffs.py <po_file_path>' )
99+ print ('Usage:' )
100+ print ('\t python fix_diffs.py <po_file_path> [<original_po_file_commit>]' )
101+ print ('Option:' )
102+ print ('\t <original_po_file_commit>: The original .po file(s) commit record (default to HEAD).' )
103+ sys .exit (1 )
99104
100- fp = sys .argv [1 ]
101- output_lines = main (fp )
105+ fp = './' + sys .argv [1 ]
106+ output_lines = None
107+ if len (sys .argv ) == 3 :
108+ original_commit = sys .argv [2 ]
109+ output_lines = main (fp , original_commit )
110+ else :
111+ output_lines = main (fp )
102112
103113 with open (fp , 'w' ) as f :
104114 f .writelines ([s + '\n ' for s in output_lines ])
You can’t perform that action at this time.
0 commit comments