]> git.lyx.org Git - features.git/commitdiff
Removed _one_ perl-dependency in creating po-files.
authorKornel Benko <kornel@lyx.org>
Fri, 9 Jul 2010 19:02:04 +0000 (19:02 +0000)
committerKornel Benko <kornel@lyx.org>
Fri, 9 Jul 2010 19:02:04 +0000 (19:02 +0000)
 'cat.py' created by Richard Heck

This script resembles the unix command 'cat', valid now on every
platform.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34828 a592a061-630c-0410-9148-cb99ea01b6c8

development/cmake/CMakeLists.txt
development/cmake/po/CMakeLists.txt
development/cmake/po/cat.py [new file with mode: 0644]

index 401c7f1494c4910a4bf7fb13b95032febd538ed0..2913288caa8fc0b24082309303379e6f30b36970 100644 (file)
@@ -429,7 +429,7 @@ endif()
 
 FIND_PROGRAM(_PERL_EXECUTABLE perl)
 FIND_PROGRAM(_PYTHON_EXECUTABLE python)
-if((NOT ${_PERL_EXECUTABLE} MATCHES "-NOTFOUND") AND ( NOT ${_PYTHON_EXECUTABLE} MATCHES "-NOTFOUND"))
+if( NOT ${_PYTHON_EXECUTABLE} MATCHES "-NOTFOUND")
     if(LYX_NLS)
       find_package(LyXGettext REQUIRED)
       include_directories(${TOP_SRC_DIR}/po)
index d7fd5fa10d77fbad80c9436df3b90a6e04aa56b0..8cf32c8fe858976b0a5ab4cdb75d2dff301edf06 100755 (executable)
@@ -70,8 +70,8 @@ FIND_PROGRAM(GETTEXT_MSGUNIQ_EXECUTABLE msguniq)
 
 ADD_CUSTOM_COMMAND(
     OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
-    COMMAND ${_PERL_EXECUTABLE}
-    ARGS -e "\"while(<>){print;}\"" ${_py_sources} > "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
+    COMMAND ${_PYTHON_EXECUTABLE}
+    ARGS   "${CMAKE_SOURCE_DIR}/po/cat.py" ${_py_sources} > "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
     DEPENDS ${_py_sources}
     )
 
diff --git a/development/cmake/po/cat.py b/development/cmake/po/cat.py
new file mode 100644 (file)
index 0000000..be8f4b2
--- /dev/null
@@ -0,0 +1,35 @@
+#! /usr/bin/env python
+
+import sys
+from getopt import getopt
+
+usage = '''
+python cat.py -o OUTFILE FILE1 FILE2 .... FILEn
+
+Replacement for:
+       cat FILE1 FILE2 ... .FILEn > OUTFILE
+If the -o argument is not given, writes to stdout.
+'''
+
+outfile = ""
+
+(options, args) = getopt(sys.argv[1:], "ho:")
+for (opt, param) in options:
+       if opt == "-o":
+               outfile = param
+       elif opt == "-h":
+               print usage
+               sys.exit(0)
+
+out = sys.stdout
+if outfile:
+       out = open(outfile, "w")
+
+for f in args:
+       fil = open(f, "r")
+       for l in fil:
+               out.write(l)
+       fil.close()
+
+if outfile:
+       out.close()