@@ -88,12 +88,13 @@ def to_intermediate_loop(self, block, result, index=None): # pragma: nocover
8888
8989 def to_netjson (self , remove_block = True ):
9090 """
91- Converts the intermediate data structure (``self.intermediate_datra ``)
91+ Converts the intermediate data structure (``self.intermediate_data ``)
9292 to a NetJSON configuration dictionary (``self.config``)
9393 """
9494 result = OrderedDict ()
95- # Clean intermediate data
96- intermediate_data = self .clean_intermediate_data (list (self .intermediate_data [self .intermediate_key ]))
95+ # clean intermediate data
96+ intermediate_data = self .to_netjson_clean (self .intermediate_data [self .intermediate_key ])
97+ # intermediate_data = list(self.intermediate_data[self.intermediate_key])
9798 # iterate over copied intermediate data structure
9899 for index , block in enumerate (intermediate_data ):
99100 if self .should_skip_block (block ):
@@ -109,18 +110,13 @@ def to_netjson(self, remove_block=True):
109110 # return result, expects dict
110111 return result
111112
112- def clean_intermediate_data (self , intermediate_data ):
113- """
114- Utility method called to clean data for backend in ``to_netjson``
115- """
116- clean_intermediate_data , appendto_clean_intermediate_data = [], []
117- for block in intermediate_data :
118- if '.type' in block and block ['.type' ] == 'switch_vlan' :
119- appendto_clean_intermediate_data .append (block )
120- else :
121- clean_intermediate_data .append (block )
122- clean_intermediate_data .extend (appendto_clean_intermediate_data )
123- return clean_intermediate_data
113+ def to_netjson_clean (self , intermediate_data ):
114+ """
115+ Utility method called to pre-process the intermediate data structure
116+ during backward conversion (``to_netjson``)
117+ """
118+ # returns a copy in order to avoid modifying the original structure
119+ return list (intermediate_data )
124120
125121 def to_netjson_loop (self , block , result , index = None ): # pragma: nocover
126122 """
0 commit comments