From 95aa722824acaf6f8556b70282a6b84661bcded8 Mon Sep 17 00:00:00 2001
From: imcovangent <I.vanGent@tudelft.nl>
Date: Thu, 22 Jun 2017 15:25:59 +0200
Subject: [PATCH] Push before branch change

Former-commit-id: f657cceaed491568ace20d79f699750762e7cd09
---
 kadmos/graph/mixin_rce.py                     |  3 +-
 .../RCE_CPACS-XML-merger/CPACS-XML-merger.py  | 61 +++++++++++++++++++
 .../XMLmappings/XMLmapping-copy.xml           | 10 +++
 .../RCE_CPACS-XML-merger/__init__.py          |  0
 .../rce-workflow-info.txt                     |  1 +
 5 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 pyKADMOS/temp/CPACS-XML-merger_42890a67-e514-4f5b-a60c-8c7fe75fe9de/RCE_CPACS-XML-merger/CPACS-XML-merger.py
 create mode 100644 pyKADMOS/temp/CPACS-XML-merger_42890a67-e514-4f5b-a60c-8c7fe75fe9de/RCE_CPACS-XML-merger/XMLmappings/XMLmapping-copy.xml
 create mode 100644 pyKADMOS/temp/CPACS-XML-merger_42890a67-e514-4f5b-a60c-8c7fe75fe9de/RCE_CPACS-XML-merger/__init__.py
 create mode 100644 pyKADMOS/temp/CPACS-XML-merger_42890a67-e514-4f5b-a60c-8c7fe75fe9de/rce-workflow-info.txt

diff --git a/kadmos/graph/mixin_rce.py b/kadmos/graph/mixin_rce.py
index f997e0379..0fd07d94f 100644
--- a/kadmos/graph/mixin_rce.py
+++ b/kadmos/graph/mixin_rce.py
@@ -64,8 +64,7 @@ class RceMixin(object):
 
         # Create graph object
         from graph_process import RceGraph
-        rce_graph = RceGraph(self, rce_working_dir=rce_working_dir, rce_wf_filename=rce_wf_filename,
-                                           name=name)
+        rce_graph = RceGraph(self, rce_working_dir=rce_working_dir, rce_wf_filename=rce_wf_filename, name=name)
 
         # Add diagonal positions to rce_graph based on MPG
         rce_graph.add_diagonal_positions(MPG)
diff --git a/pyKADMOS/temp/CPACS-XML-merger_42890a67-e514-4f5b-a60c-8c7fe75fe9de/RCE_CPACS-XML-merger/CPACS-XML-merger.py b/pyKADMOS/temp/CPACS-XML-merger_42890a67-e514-4f5b-a60c-8c7fe75fe9de/RCE_CPACS-XML-merger/CPACS-XML-merger.py
new file mode 100644
index 000000000..34520f898
--- /dev/null
+++ b/pyKADMOS/temp/CPACS-XML-merger_42890a67-e514-4f5b-a60c-8c7fe75fe9de/RCE_CPACS-XML-merger/CPACS-XML-merger.py
@@ -0,0 +1,61 @@
+import os
+import sys
+from xml.etree import ElementTree as et
+
+
+class hashabledict(dict):
+    def __hash__(self):
+        return hash(tuple(sorted(self.items())))
+
+
+class XMLCombiner(object):
+    def __init__(self, filenames):
+        assert len(filenames) > 0, 'No filenames!'
+        # save all the roots, in order, to be processed later
+        self.roots = [et.parse(f).getroot() for f in filenames]
+
+    def combine(self):
+        for r in self.roots[1:]:
+            # combine each element with the first one, and update that
+            self.combine_element(self.roots[0], r)
+        # return the string representation
+        return et.ElementTree(self.roots[0])
+
+    def combine_element(self, one, other):
+        """
+        This function recursively updates either the text or the children
+        of an element if another element is found in `one`, or adds it
+        from `other` if not found.
+        """
+        # Create a mapping from tag name to element, as that's what we are fltering with
+        mapping = {(el.tag, hashabledict(el.attrib)): el for el in one}
+        for el in other:
+            if len(el) == 0:
+                # Not nested
+                try:
+                    # Update the text
+                    mapping[(el.tag, hashabledict(el.attrib))].text = el.text
+                except KeyError:
+                    # An element with this name is not in the mapping
+                    mapping[(el.tag, hashabledict(el.attrib))] = el
+                    # Add it
+                    one.append(el)
+            else:
+                try:
+                    # Recursively process the element, and update it in the same way
+                    self.combine_element(mapping[(el.tag, hashabledict(el.attrib))], el)
+                except KeyError:
+                    # Not in the mapping
+                    mapping[(el.tag, hashabledict(el.attrib))] = el
+                    # Just add it
+                    one.append(el)
+
+if __name__ == '__main__':
+    sys.stdout.write('XML MERGER\n')
+    for file in sys.argv[1:]:
+        if file.endswith('.xml'):
+            sys.stdout.write('file: ' + file + '\n')
+    r = XMLCombiner(sys.argv[1:]).combine()
+    print '-'*20
+    print et.tostring(r.getroot())
+    r.write('Merger-output-loc.xml', encoding="iso-8859-1", xml_declaration=True)
\ No newline at end of file
diff --git a/pyKADMOS/temp/CPACS-XML-merger_42890a67-e514-4f5b-a60c-8c7fe75fe9de/RCE_CPACS-XML-merger/XMLmappings/XMLmapping-copy.xml b/pyKADMOS/temp/CPACS-XML-merger_42890a67-e514-4f5b-a60c-8c7fe75fe9de/RCE_CPACS-XML-merger/XMLmappings/XMLmapping-copy.xml
new file mode 100644
index 000000000..a75e7d3e8
--- /dev/null
+++ b/pyKADMOS/temp/CPACS-XML-merger_42890a67-e514-4f5b-a60c-8c7fe75fe9de/RCE_CPACS-XML-merger/XMLmappings/XMLmapping-copy.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<map:mappings xmlns:map="http://www.rcenvironment.de/2015/mapping"
+              xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+    <map:mapping>
+        <map:source>/cpacs</map:source>
+        <map:target>/cpacs</map:target>
+    </map:mapping>
+
+</map:mappings>
\ No newline at end of file
diff --git a/pyKADMOS/temp/CPACS-XML-merger_42890a67-e514-4f5b-a60c-8c7fe75fe9de/RCE_CPACS-XML-merger/__init__.py b/pyKADMOS/temp/CPACS-XML-merger_42890a67-e514-4f5b-a60c-8c7fe75fe9de/RCE_CPACS-XML-merger/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/pyKADMOS/temp/CPACS-XML-merger_42890a67-e514-4f5b-a60c-8c7fe75fe9de/rce-workflow-info.txt b/pyKADMOS/temp/CPACS-XML-merger_42890a67-e514-4f5b-a60c-8c7fe75fe9de/rce-workflow-info.txt
new file mode 100644
index 000000000..759f30f41
--- /dev/null
+++ b/pyKADMOS/temp/CPACS-XML-merger_42890a67-e514-4f5b-a60c-8c7fe75fe9de/rce-workflow-info.txt
@@ -0,0 +1 @@
+Workflow name: tu_delft_wing_design_converged-DOE-GS2017-06-20_17:41:13_39
\ No newline at end of file
-- 
GitLab