Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Avoid sed inconpatibility #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
find locale/pot -name '*.pot' | xargs sed -i -e '/^"POT-Creation-Date: 20/d'
$(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
9 changes: 9 additions & 0 deletions Doc/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
28 changes: 28 additions & 0 deletions Doc/tools/delete_pot_creation_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-

import io
import os
import sys


def delete_pot_creation_date(filename):
with io.open(filename, 'r', encoding='utf-8') as f:
lines = f.readlines()

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')))


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} <basedir>'.format(sys.argv[0]))
sys.exit(1)
sys.exit(main(sys.argv[1]))