From 03eb04cc5eaed20ed81d6ec8a6ec9da3a2e3f5f1 Mon Sep 17 00:00:00 2001 From: cocoatomo Date: Tue, 28 Feb 2017 00:53:37 +0900 Subject: [PATCH 1/4] Implement script to delete "POT CREATTION DATE" row --- Doc/Makefile | 2 +- Doc/make.bat | 9 +++++++++ Doc/tools/delete_pot_creation_date.py | 25 +++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 Doc/tools/delete_pot_creation_date.py diff --git a/Doc/Makefile b/Doc/Makefile index 161f7183597376..0eff19a7426e20 100644 --- a/Doc/Makefile +++ b/Doc/Makefile @@ -189,4 +189,4 @@ autobuild-stable-html: .PHONY: gettext gettext: sphinx-build -E -b gettext -D gettext_compact=0 -w warnings.txt -d build/.doctrees . locale/pot - find locale/pot -name '*.pot' | xargs sed -i -e '/^"POT-Creation-Date: 20/d' + python tools/delete_pot_creation_date.py locale/pot diff --git a/Doc/make.bat b/Doc/make.bat index d0b59618261011..4f67a4df614caa 100644 --- a/Doc/make.bat +++ b/Doc/make.bat @@ -40,6 +40,9 @@ if "%1" == "clean" ( goto end ) +rem JP: i18n target +if "%1" EQU "gettext" goto gettext + %SPHINXBUILD% >nul 2> nul if errorlevel 9009 ( echo. @@ -126,5 +129,11 @@ goto end cmd /C %PYTHON% ..\Tools\scripts\serve.py %BUILDDIR%\html goto end +:gettext +cmd /C %SPHINXBUILD% -E -b gettext -D gettext_compact=0 -w warnings.txt -d build\.doctrees . locale\pot +cmd /C %PYTHON% tools\delete_pot_creation_date.py locale\pot + +goto end + :end popd diff --git a/Doc/tools/delete_pot_creation_date.py b/Doc/tools/delete_pot_creation_date.py new file mode 100644 index 00000000000000..9c2d24b4af2958 --- /dev/null +++ b/Doc/tools/delete_pot_creation_date.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +import codecs +import os +import sys + +def delete_pot_creation_date(filename): + with codecs.open(filename, 'r', encoding='utf-8') as f: + lines = f.readlines() + + with codecs.open(filename, 'w', encoding='utf-8') as f: + f.writelines((line for line in lines if not line.startswith('"POT-Creation-Date: 20'))) + +def main(basedir): + for dirpath, _, filenames in os.walk(basedir): + for filename in filenames: + if filename.endswith('.pot'): + delete_pot_creation_date(os.path.join(dirpath, filename)) + +if __name__ == '__main__': + if len(sys.argv) < 2: + print('too few argument') + print('Usage: {0} '.format(sys.argv[0])) + sys.exit(1) + sys.exit(main(sys.argv[1])) From 6c97e43f319df69af4c1cebbd997cdf551cd7f74 Mon Sep 17 00:00:00 2001 From: cocoatomo Date: Tue, 28 Feb 2017 10:53:28 +0900 Subject: [PATCH 2/4] flake8 --- Doc/tools/delete_pot_creation_date.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Doc/tools/delete_pot_creation_date.py b/Doc/tools/delete_pot_creation_date.py index 9c2d24b4af2958..54d985c0c259e8 100644 --- a/Doc/tools/delete_pot_creation_date.py +++ b/Doc/tools/delete_pot_creation_date.py @@ -4,6 +4,7 @@ import os import sys + def delete_pot_creation_date(filename): with codecs.open(filename, 'r', encoding='utf-8') as f: lines = f.readlines() @@ -11,12 +12,14 @@ def delete_pot_creation_date(filename): with codecs.open(filename, 'w', encoding='utf-8') as f: f.writelines((line for line in lines if not line.startswith('"POT-Creation-Date: 20'))) + def main(basedir): for dirpath, _, filenames in os.walk(basedir): for filename in filenames: if filename.endswith('.pot'): delete_pot_creation_date(os.path.join(dirpath, filename)) + if __name__ == '__main__': if len(sys.argv) < 2: print('too few argument') From 7b19f09faf540634a27ca73cb822ae7ce2efa1f1 Mon Sep 17 00:00:00 2001 From: cocoatomo Date: Tue, 28 Feb 2017 12:43:23 +0900 Subject: [PATCH 3/4] Use io.open instead of codecs.open --- Doc/tools/delete_pot_creation_date.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/tools/delete_pot_creation_date.py b/Doc/tools/delete_pot_creation_date.py index 54d985c0c259e8..53903b23c183d4 100644 --- a/Doc/tools/delete_pot_creation_date.py +++ b/Doc/tools/delete_pot_creation_date.py @@ -1,15 +1,15 @@ # -*- coding: utf-8 -*- -import codecs +import io import os import sys def delete_pot_creation_date(filename): - with codecs.open(filename, 'r', encoding='utf-8') as f: + with io.open(filename, 'r', encoding='utf-8') as f: lines = f.readlines() - with codecs.open(filename, 'w', encoding='utf-8') as f: + with io.open(filename, 'w', encoding='utf-8') as f: f.writelines((line for line in lines if not line.startswith('"POT-Creation-Date: 20'))) From 23fe6c287cdbb70b122a6412568d023ed7a58168 Mon Sep 17 00:00:00 2001 From: cocoatomo Date: Tue, 28 Feb 2017 15:25:48 +0900 Subject: [PATCH 4/4] Use variables for command names --- Doc/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/Makefile b/Doc/Makefile index 0eff19a7426e20..162a87647b528d 100644 --- a/Doc/Makefile +++ b/Doc/Makefile @@ -188,5 +188,5 @@ autobuild-stable-html: # i18n commands .PHONY: gettext gettext: - sphinx-build -E -b gettext -D gettext_compact=0 -w warnings.txt -d build/.doctrees . locale/pot - python tools/delete_pot_creation_date.py locale/pot + $(SPHINXBUILD) -E -b gettext -D gettext_compact=0 -w warnings.txt -d build/.doctrees . locale/pot + $(PYTHON) tools/delete_pot_creation_date.py locale/pot