File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
_utils/_translation_utils Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ echo "============================ post processing step 1 ======================
1010# read b
1111bash _utils/_translation_utils/prepare_tx_config_postprocess.sh .tx/config /tmp/tx-mapping
1212
13+ echo " ============================ remove obsolete files ======================================="
14+ python3 _utils/_translation_utils/remove_obsolete_files.py " $1 " " $2 " /tmp/tx-mapping
1315
1416echo " ============================ post processing step 2 ======================================"
1517# read b
Original file line number Diff line number Diff line change 1+ #!/usr/bin/python3
2+
3+ import argparse
4+ import os
5+ import sys
6+
7+ parser = argparse .ArgumentParser ()
8+ parser .add_argument ('lang' )
9+ parser .add_argument ('translation_dir' )
10+ parser .add_argument ('tx_mapping' )
11+
12+ def main ():
13+ args = parser .parse_args ()
14+
15+ valid_files = set ()
16+ with open (args .tx_mapping ) as f_mapping :
17+ for line in f_mapping .readlines ():
18+ if line .startswith ('file_filter = ' ):
19+ valid_files .add (line .strip ().split (' = ' )[1 ].replace ('<lang>' , args .lang ))
20+
21+ if not valid_files :
22+ print ('No files found in {}, aborting!' .format (args .tx_mapping ))
23+ return 1
24+
25+ existing_files = set ()
26+ for dirpath , dirs , files in os .walk (args .translation_dir ):
27+ existing_files .update (os .path .join (dirpath , name ) for name in files )
28+
29+ if not existing_files :
30+ print ('No files found in {}, aborting!' .format (args .translation_dir ))
31+ return 1
32+
33+ for obsolete in existing_files .difference (valid_files ):
34+ print ('Removing {}' .format (obsolete ))
35+ os .unlink (obsolete )
36+
37+
38+ if __name__ == '__main__' :
39+ sys .exit (main ())
40+
You can’t perform that action at this time.
0 commit comments