File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ import json
2
+ import os
3
+ import sys
4
+ from collections import defaultdict
5
+
6
+ OUTPUT_FILE = "selected_l10n_mappings"
7
+
8
+
9
+ def valid_l10n_mappings ():
10
+ mapping = defaultdict (set )
11
+ region_paths = [d for d in os .listdir ("./l10n_CM/region/" )]
12
+ for region_path in region_paths :
13
+ if region_path != "Unified.json" :
14
+ region = region_path .split ("." )[0 ]
15
+ with open (f"./l10n_CM/region/{ region_path } " , "r+" ) as f :
16
+ region_file = json .load (f )
17
+ if region_file .get ("sites" ):
18
+ for site in region_file .get ("sites" ):
19
+ mapping [site ].add (region )
20
+ return mapping
21
+
22
+
23
+ if __name__ == "__main__" :
24
+ l10n_mappings = valid_l10n_mappings ()
25
+ with open (OUTPUT_FILE , "w" ) as file :
26
+ pass # File is created or cleared
27
+ for site , regions in l10n_mappings .items ():
28
+ with open (OUTPUT_FILE , "a+" ) as fh :
29
+ fh .write (f"{ site } { ' ' .join (regions )} \n " )
30
+ sys .exit (0 )
You can’t perform that action at this time.
0 commit comments