15 if not os.path.exists(n): os.mkdir(n)
17 dst = os.path.dirname(fname)
18 name = os.path.basename(fname).split('.')[0]
20 dst2 = os.path.join(dst, name)
22 data = json.load(open(fname))
24 dst3 = os.path.join(dst2, ip['fields']['slug'])
25 for fld in ip['fields'].keys():
26 if filter(lambda x: fld.startswith(x),
27 ['title', 'left_column', 'right_column']):
28 if lang and not fld.endswith("_"+lang):
31 o = open(os.path.join(dst3, fld+".txt"), 'r')
36 txt = txt.decode('utf-8')
38 txt = txt.decode('utf-16')
40 ip['fields'][fld] = txt
45 print "no infopages file for field %s" % fld
48 out = open(fname, 'w')
50 out.write(json.dumps(data,indent=4))