|
From: <ai...@us...> - 2013-07-07 18:00:12
|
Revision: 12405
http://sourceforge.net/p/plplot/code/12405
Author: airwin
Date: 2013-07-07 18:00:07 +0000 (Sun, 07 Jul 2013)
Log Message:
-----------
Initial commit of python script to follow includes in gtk jhbuild
xml module files to generate an equivalent single module file.
At this stage, the script does not follow includes so simply copies
the file specified as an argument to the script to stdout.
Tested by: Alan W. Irwin <ai...@us...> using
./gtk_xml_recursive_process.py README |diff - README
Added Paths:
-----------
trunk/cmake/build_projects/gtk_xml_recursive_process.py
Added: trunk/cmake/build_projects/gtk_xml_recursive_process.py
===================================================================
--- trunk/cmake/build_projects/gtk_xml_recursive_process.py (rev 0)
+++ trunk/cmake/build_projects/gtk_xml_recursive_process.py 2013-07-07 18:00:07 UTC (rev 12405)
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+# Recursively read gtk jhbuild xml module files following include
+# elements to produce the equivalent single xml file.
+
+# Copyright (C) 2013 Alan W. Irwin
+
+# This file is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with this file; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+import sys
+
+def recursive_process(path, filename, if_included):
+ fullpath = path + "/" + filename
+ fileobject = open(fullpath)
+ line = fileobject.readline()
+ while line:
+ sys.stdout.write(line)
+ line = fileobject.readline()
+ fileobject.close()
+
+fullpath = sys.argv[1]
+index = fullpath.rfind("/")
+if index >=0 and len(fullpath) > index + 1:
+ path = fullpath[:index]
+ filename = fullpath[index+1:]
+elif index < 0 and len(fullpath) >= 1:
+ path = "."
+ filename = fullpath
+else:
+ print("%s is invalid fullpath name of a file" % fullpath)
+ sys.exit()
+
+recursive_process(path, filename, False)
Property changes on: trunk/cmake/build_projects/gtk_xml_recursive_process.py
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ai...@us...> - 2013-07-07 20:03:05
|
Revision: 12406
http://sourceforge.net/p/plplot/code/12406
Author: airwin
Date: 2013-07-07 20:03:03 +0000 (Sun, 07 Jul 2013)
Log Message:
-----------
The overview is the stdout from this script will be used as input for
another python script (still being designed) to transform the single
complete xml file into build_projects configuration files.
This should be the final version of this script for gtk-3.4.1, but it
is likely changes will have to be made for other versions of gtk
modules (when we move to those) since some exact syntax assumptions
are made that are correct for 3.4.1 jhbuild module files, but might
not be correct for other versions.
Tested by: Alan W. Irwin <ai...@us...> by running
./gtk_xml_recursive_process.py /home/software/pango_stack/jhbuild/modulesets/3.4.1/gnome-apps-3.4.1.modules
This command followed all the includes. That is, all *.modules files
in that directory were included in the output to stdout as measured by
some spot checking and "wc -l" line count results that jibed with the
total line count for *.modules files in that directory (if you account
for three dropped include lines and two head lines and one tail line
that are dropped from the included files).
Modified Paths:
--------------
trunk/cmake/build_projects/gtk_xml_recursive_process.py
Modified: trunk/cmake/build_projects/gtk_xml_recursive_process.py
===================================================================
--- trunk/cmake/build_projects/gtk_xml_recursive_process.py 2013-07-07 18:00:07 UTC (rev 12405)
+++ trunk/cmake/build_projects/gtk_xml_recursive_process.py 2013-07-07 20:03:03 UTC (rev 12406)
@@ -3,6 +3,12 @@
# Recursively read gtk jhbuild xml module files following include
# elements to produce the equivalent single xml file.
+# N.B. This logic assumes exact syntax that is in gtk 3.4.1 version of
+# module files including blank characters, and there is no guarantee
+# for different gtk that that syntax will be immutable. So it is likely
+# this file will need maintenance for other versions of gtk. See EXACT
+# comments below where changes might have to be made.
+
# Copyright (C) 2013 Alan W. Irwin
# This file is free software; you can redistribute it and/or
@@ -26,10 +32,33 @@
fileobject = open(fullpath)
line = fileobject.readline()
while line:
- sys.stdout.write(line)
+ if if_included:
+ # ignore certain lines if the file is included
+ # EXACT
+ if line.find('<?xml version="1.0" ?>') >= 0:
+ line = fileobject.readline()
+ continue
+ # EXACT
+ if line.find('<moduleset>') >= 0:
+ line = fileobject.readline()
+ continue
+ # EXACT
+ if line.find('</moduleset>') >= 0:
+ line = fileobject.readline()
+ continue
+ # EXACT
+ index = line.find('<include href="')
+ if index >=0:
+ start = line.index('"')
+ stop = line.rindex('"')
+ included_filename = line[start+1: stop]
+ recursive_process(path, included_filename, True)
+ else:
+ sys.stdout.write(line)
line = fileobject.readline()
fileobject.close()
+#sys.setrecursionlimit(10)
fullpath = sys.argv[1]
index = fullpath.rfind("/")
if index >=0 and len(fullpath) > index + 1:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|