From b56b27fd1c4b93505c4f6a0e3584a8793a763d4f Mon Sep 17 00:00:00 2001 From: florent Date: Sun, 22 Apr 2012 23:31:35 +0000 Subject: update doc list in scripts + sort po content in po-to-sphinx script --- diff --git a/utils/po-to-sphinx.py b/utils/po-to-sphinx.py index a994460..cf047e0 100644 --- a/utils/po-to-sphinx.py +++ b/utils/po-to-sphinx.py @@ -3,8 +3,24 @@ import codecs, os, subprocess SRC = [ 'index', 'credits', - 'summary', 'prolog', + 'intro', + 'section_1', + 'chapter_1', + 'chapter_2', + 'chapter_3', + 'chapter_4', + 'chapter_5', + 'chapter_6', + 'chapter_7', + 'chapter_8', + 'section_2', + 'chapter_9', + 'chapter_10', + 'chapter_11', + 'chapter_12', + 'annex', + 'credits_photo', ] OUT = 'ceibal' @@ -14,6 +30,32 @@ FILE_SEP = '^-^_^-^_^-^_^-^_^-^_^-^_^-^_^-^_' path_in_po = os.path.join('tmp', '%s-fr.po' % OUT) path_in_txt = os.path.join('tmp', '%s.txt' % OUT) +# split po in blocks to sort them +block_list = dict() +with codecs.open(path_in_po, 'rb', 'utf-8') as f: + # init block and key + block = '' + key = 0 + for r in f.readlines(): + if r.startswith('#'): + if ':' in r: + # add new block + block_list[key] = block + # reset block and key + block = '' + key = int(r.strip().split(':')[-1]) + # add current row + block += r + # add last block + block_list[key] = block + +# sort blocks and write in po +with codecs.open(path_in_po, 'wb', 'utf-8') as f: + keys = block_list.keys() + keys.sort() + for k in keys: + f.write(block_list[k]) + subprocess.call('po2txt --encoding utf-8 %s %s' % (path_in_po, path_in_txt), shell=True) diff --git a/utils/sphinx-to-po.py b/utils/sphinx-to-po.py index 77ffac7..2781360 100644 --- a/utils/sphinx-to-po.py +++ b/utils/sphinx-to-po.py @@ -3,8 +3,24 @@ import codecs, os, subprocess SRC = [ 'index', 'credits', - 'summary', 'prolog', + 'intro', + 'section_1', + 'chapter_1', + 'chapter_2', + 'chapter_3', + 'chapter_4', + 'chapter_5', + 'chapter_6', + 'chapter_7', + 'chapter_8', + 'section_2', + 'chapter_9', + 'chapter_10', + 'chapter_11', + 'chapter_12', + 'annex', + 'credits_photo', ] OUT = 'ceibal' -- cgit v0.9.1