From 2d708bd7cf802fd76617e7255f81efec7d4c1adf Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Tue, 10 May 2016 07:03:54 +0200 Subject: [PATCH] Simplify .po file generation We can generate the file with the cirrect line endings directly instead of calling a helper script to convert them. --- development/Makefile.am | 1 - development/cmake/po/cat.py | 10 ++++++++-- development/cmake/po/dos2unix.py | 17 ----------------- po/CMakeLists.txt | 2 -- 4 files changed, 8 insertions(+), 22 deletions(-) delete mode 100644 development/cmake/po/dos2unix.py diff --git a/development/Makefile.am b/development/Makefile.am index 43ca80821e..796e964d4a 100644 --- a/development/Makefile.am +++ b/development/Makefile.am @@ -159,7 +159,6 @@ cmake/modules/PCHSupport_26.cmake \ cmake/modules/ProjectSourceGroup.cmake \ cmake/pcheaders.h \ cmake/po/cat.py \ -cmake/po/dos2unix.py \ cmake/po/unix2dos.py \ cmake/post_install/CMakeLists.txt \ cmake/scripts/LyXCreateImagesResource.cmake \ diff --git a/development/cmake/po/cat.py b/development/cmake/po/cat.py index 02655dc564..7a1ee2699b 100644 --- a/development/cmake/po/cat.py +++ b/development/cmake/po/cat.py @@ -25,11 +25,17 @@ for (opt, param) in options: out = sys.stdout if outfile: - out = open(outfile, "w") + # always write unix line endings, even on windows + out = open(outfile, "wb") for f in args: - fil = open(f, "r") + # accept both windows and unix line endings, since it can happen that we + # are on unix, but the file has been written on windows or vice versa. + fil = open(f, "rU") for l in fil: + # this does always write unix line endings since the file has + # been opened in binary mode. This is needed since both gettext + # and our .pot file manipulation scripts assume unix line ends. out.write(l) fil.close() diff --git a/development/cmake/po/dos2unix.py b/development/cmake/po/dos2unix.py deleted file mode 100644 index a5b6431429..0000000000 --- a/development/cmake/po/dos2unix.py +++ /dev/null @@ -1,17 +0,0 @@ -#! /usr/bin/env python - -############### -import sys - -for fname in sys.argv[1:]: - infile = open( fname, "r" ) - instr = infile.read() - infile.close() - outstr = instr.replace( "\r\n", "\n" ).replace( "\r", "\n" ) - - if outstr == instr: - continue - - outfile = open( fname , "w" ) - outfile.write( outstr ) - outfile.close() diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt index 4d70d24042..3f2f9ad7e7 100755 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -90,8 +90,6 @@ ADD_CUSTOM_COMMAND( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot" COMMAND ${LYX_PYTHON_EXECUTABLE} ARGS "${TOP_CMAKE_PATH}/po/cat.py" ${_py_sources} > "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat_tmp.pot" - COMMAND ${LYX_PYTHON_EXECUTABLE} - ARGS "${TOP_CMAKE_PATH}/po/dos2unix.py" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat_tmp.pot" COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat_tmp.pot" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot" DEPENDS ${_py_sources} -- 2.39.2