def convert_template(template_path, target_path): ensure_target_dir_exists(target_path) template_file = open(template_path, "rb") target_file = cStringIO.StringIO() original_file = read_original_target(target_path) pot2po.convertpot(template_file, target_file, original_file, classes=factory_classes) output_file = open(target_path, "wb") output_file.write(target_file.getvalue()) output_file.close()
def convertpot(self, potsource, posource=None): """helper that converts pot source to po source without requiring files""" potfile = wStringIO.StringIO(potsource) if posource: pofile = wStringIO.StringIO(posource) else: pofile = None pooutfile = wStringIO.StringIO() pot2po.convertpot(potfile, pooutfile, pofile) pooutfile.seek(0) return po.pofile(pooutfile.read())
def convertpot(potsource, posource=None): """helper that converts pot source to po source without requiring files""" potfile = BytesIO(potsource.encode()) if posource: pofile = BytesIO(posource.encode()) else: pofile = None pooutfile = BytesIO() pot2po.convertpot(potfile, pooutfile, pofile) pooutfile.seek(0) return po.pofile(pooutfile.read())