From 670d3d29fcb0fbdc9cfe35a2ae4d416b85a43404 Mon Sep 17 00:00:00 2001
From: Stefan Froehlich <s.froehlich@fz-juelich.de>
Date: Wed, 3 Feb 2016 14:57:28 +0000
Subject: [PATCH] Task #9058 Its possible to have this functionality when
 remembering the order of the replacement keys. Not a very elegant solution
 but it should work.

---
 CEP/Pipeline/recipes/sip/bin/genericpipeline.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/CEP/Pipeline/recipes/sip/bin/genericpipeline.py b/CEP/Pipeline/recipes/sip/bin/genericpipeline.py
index 12c30f3b5dc..f2f85a78f63 100755
--- a/CEP/Pipeline/recipes/sip/bin/genericpipeline.py
+++ b/CEP/Pipeline/recipes/sip/bin/genericpipeline.py
@@ -3,6 +3,7 @@ import os
 import sys
 import copy
 import re
+from collections import OrderedDict
 from lofarpipe.support.parset import Parset
 from lofarpipe.support.control import control
 
@@ -504,7 +505,7 @@ class GenericPipeline(control):
         steplist = []
 
     def _replace_values(self):
-        replacedict = {}
+        replacedict = OrderedDict()
         for check in self.parset.keywords():
             if str(check).startswith('!'):
                 replacedict[str(check).lstrip('!').lstrip(' ')] = str(self.parset[check])
@@ -512,7 +513,7 @@ class GenericPipeline(control):
                 replacedict[str(check).replace('pipeline.replace.', '').lstrip(' ')] = str(self.parset[check])
         #print 'REPLACEDICT: ',replacedict
         for check in self.parset.keywords():
-            for k, v in replacedict.iteritems():
+            for k, v in reversed(replacedict.items()):
                 if '{{ '+k+' }}' in str(self.parset[check]):
                     replacestring = str(self.parset[check]).replace('{{ '+k+' }}',v)
                     self.parset.replace(check,replacestring)
-- 
GitLab