Author: kornel
Date: Tue May 24 20:36:27 2011
New Revision: 38832
URL: http://www.lyx.org/trac/changeset/38832
Log:
Backport r38791, Replace a perl-script with the python version
Added:
lyx-devel/branches/BRANCH_2_0_X/development/cmake/doc/ReplaceValues.py
(contents, props changed)
Modified:
lyx-devel/branches/BRANCH_2_0_X/development/cmake/CMakeLists.txt
lyx-devel/branches/BRANCH_2_0_X/development/cmake/doc/CMakeLists.txt
lyx-devel/branches/BRANCH_2_0_X/lib/doc/es/Customization.lyx
lyx-devel/branches/BRANCH_2_0_X/lib/doc/fr/Customization.lyx
lyx-devel/branches/BRANCH_2_0_X/lib/doc/ja/Customization.lyx
Modified: lyx-devel/branches/BRANCH_2_0_X/development/cmake/CMakeLists.txt
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/development/cmake/CMakeLists.txt Tue May
24 19:26:56 2011 (r38831)
+++ lyx-devel/branches/BRANCH_2_0_X/development/cmake/CMakeLists.txt Tue May
24 20:36:27 2011 (r38832)
@@ -13,7 +13,8 @@
cmake_policy(SET CMP0005 OLD)
endif()
-set(LYX_PROJECT lyx)
+#needed to distinguish fron trunk, so we can install both simultaneously
+set(LYX_PROJECT lyx20)
project(${LYX_PROJECT})
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
@@ -488,9 +489,8 @@
if(LYX_INSTALL)
- FIND_PROGRAM(LYX_PERL_EXECUTABLE perl)
- if(${LYX_PERL_EXECUTABLE} MATCHES "-NOTFOUND")
- message(STATUS "Perl required to create doc!")
+ if(${LYX_PYTHON_EXECUTABLE} MATCHES "-NOTFOUND")
+ message(STATUS "Python required to create doc!")
else()
add_subdirectory(man)
add_subdirectory(doc)
Modified: lyx-devel/branches/BRANCH_2_0_X/development/cmake/doc/CMakeLists.txt
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/development/cmake/doc/CMakeLists.txt
Tue May 24 19:26:56 2011 (r38831)
+++ lyx-devel/branches/BRANCH_2_0_X/development/cmake/doc/CMakeLists.txt
Tue May 24 20:36:27 2011 (r38832)
@@ -7,9 +7,6 @@
project(doc)
-#TODO: replace perl script with python, see scons:
-#
http://www.lyx.org/trac/browser/lyx-devel/trunk/development/scons/scons_utils.py
-
SET(_docs)
file(GLOB_RECURSE _rel_lyx_docs RELATIVE "${TOP_SRC_DIR}/lib/doc"
"${TOP_SRC_DIR}/lib/doc/*.lyx" "${TOP_SRC_DIR}/lib/doc/*.txt")
@@ -29,8 +26,8 @@
SET_SOURCE_FILES_PROPERTIES(${_created_doc} GENERATED)
add_custom_command(
OUTPUT "${_created_doc}"
- COMMAND perl "${CMAKE_SOURCE_DIR}/doc/ReplaceValues.pl"
"LYX_USERDIR_VER=${LYX_USERDIR_VER}" "LYX_DIR_VER=${LYX_DIR_VER}"
"${TOP_SRC_DIR}/lib/doc/${_rel_doc}" > "${_created_doc}"
- DEPENDS "${TOP_SRC_DIR}/lib/doc/${_rel_doc}"
+ COMMAND ${LYX_PYTHON_EXECUTABLE}
"${TOP_SRC_DIR}/development/cmake/doc/ReplaceValues.py"
"LYX_USERDIR_VER=${LYX_USERDIR_VER}" "LYX_DIR_VER=${LYX_DIR_VER}"
"${TOP_SRC_DIR}/lib/doc/${_rel_doc}" > "${_created_doc}"
+ DEPENDS "${TOP_SRC_DIR}/lib/doc/${_rel_doc}"
"${TOP_SRC_DIR}/development/cmake/doc/ReplaceValues.py"
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${_rel_doc}" DESTINATION
"${LYX_DATA_SUBDIR}doc/${_rel_dir_part}")
LIST(APPEND _docs "${_created_doc}")
Added: lyx-devel/branches/BRANCH_2_0_X/development/cmake/doc/ReplaceValues.py
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ lyx-devel/branches/BRANCH_2_0_X/development/cmake/doc/ReplaceValues.py
Tue May 24 20:36:27 2011 (r38832)
@@ -0,0 +1,55 @@
+#! /usr/bin/env python
+
+# file ReplaceValues.py
+#
+# This file is part of LyX, the document processor.
+# Licence details can be found in the file COPYING.
+#
+# author: Kornel Benko, [email protected]
+#
+# Syntax: ReplaceValues.py [<var1>=<Subst1> [<var2>=<Subst> ...]] <Inputfile>
[<Inputfile> ...]
+
+import sys
+import re
+
+Subst = {} # map of desired substitutions
+prog = re.compile("")
+
+def createProg():
+ matchingS = "\\b|\\b".join(Subst.keys())
+ pattern = "".join(["(.*)(\\b", matchingS, "\\b)(.*)"])
+ return re.compile(pattern)
+
+def SubstituteDataInLine(line):
+ result = line
+ m = prog.match(result)
+ if m:
+ return "".join([SubstituteDataInLine(m.group(1)),
+ Subst[m.group(2)],
+ SubstituteDataInLine(m.group(3))])
+ return line
+
+
+def SubstituteDataInFile(InFile):
+ for line in open(InFile):
+ print SubstituteDataInLine(line[:-1])
+
+##########################################
+
+
+args = sys.argv
+
+del args[0] # we don't need the name ot this script
+while len(args) > 0:
+ arg = args[0]
+ entry = args[0].split("=",1)
+ if len(entry) == 2:
+ key=entry[0]
+ val=entry[1]
+ if len(key) > 0:
+ Subst[key] = val
+ else:
+ prog = createProg()
+ SubstituteDataInFile(args[0])
+ del args[0]
+
Modified: lyx-devel/branches/BRANCH_2_0_X/lib/doc/es/Customization.lyx
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/lib/doc/es/Customization.lyx Tue May
24 19:26:56 2011 (r38831)
+++ lyx-devel/branches/BRANCH_2_0_X/lib/doc/es/Customization.lyx Tue May
24 20:36:27 2011 (r38832)
@@ -1192,7 +1192,7 @@
status collapsed
\begin_layout Plain Layout
-LYX_USERDIR_20x
+LYX_USERDIR_VER
\end_layout
\end_inset
Modified: lyx-devel/branches/BRANCH_2_0_X/lib/doc/fr/Customization.lyx
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/lib/doc/fr/Customization.lyx Tue May
24 19:26:56 2011 (r38831)
+++ lyx-devel/branches/BRANCH_2_0_X/lib/doc/fr/Customization.lyx Tue May
24 20:36:27 2011 (r38832)
@@ -1186,7 +1186,7 @@
Ces répertoires sont complètement indépendants (mais lisez la suite).
Notez que positionner la variable d'environnement
\family typewriter
-LYX_USERDIR_16x
+LYX_USERDIR_VER
\family default
a exactement le même effet.
\end_layout
Modified: lyx-devel/branches/BRANCH_2_0_X/lib/doc/ja/Customization.lyx
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/lib/doc/ja/Customization.lyx Tue May
24 19:26:56 2011 (r38831)
+++ lyx-devel/branches/BRANCH_2_0_X/lib/doc/ja/Customization.lyx Tue May
24 20:36:27 2011 (r38832)
@@ -1267,7 +1267,7 @@
status collapsed
\begin_layout Plain Layout
-LYX_USERDIR_20x
+LYX_USERDIR_VER
\end_layout
\end_inset