@@ -88,12 +88,13 @@ def to_intermediate_loop(self, block, result, index=None): # pragma: nocover
88
88
89
89
def to_netjson (self , remove_block = True ):
90
90
"""
91
- Converts the intermediate data structure (``self.intermediate_datra ``)
91
+ Converts the intermediate data structure (``self.intermediate_data ``)
92
92
to a NetJSON configuration dictionary (``self.config``)
93
93
"""
94
94
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])
97
98
# iterate over copied intermediate data structure
98
99
for index , block in enumerate (intermediate_data ):
99
100
if self .should_skip_block (block ):
@@ -109,18 +110,13 @@ def to_netjson(self, remove_block=True):
109
110
# return result, expects dict
110
111
return result
111
112
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 )
124
120
125
121
def to_netjson_loop (self , block , result , index = None ): # pragma: nocover
126
122
"""
0 commit comments