@@ 185-206 (lines=22) @@ | ||
182 | # Element operation |
|
183 | # |
|
184 | ############################################ |
|
185 | def update_map_element(element, key, value, comment, _type): |
|
186 | """ |
|
187 | element: |
|
188 | key: |
|
189 | value: |
|
190 | comment: |
|
191 | _type: value type. |
|
192 | """ |
|
193 | if element is None or not isinstance(element, CommentedMap): |
|
194 | print("Only key-value update support") |
|
195 | sys.exit(1) |
|
196 | ||
197 | origin_comment = _map_comment(element, key) |
|
198 | ||
199 | sub_element = element.get(key, None) |
|
200 | if isinstance(sub_element, CommentedMap) or isinstance(sub_element, CommentedSeq): |
|
201 | print("Only support update a single value") |
|
202 | ||
203 | element.update({key: value}) |
|
204 | ||
205 | comment = _obtain_comment(origin_comment, comment) |
|
206 | _add_eol_comment(element, _extract_comment(comment), key) |
|
207 | ||
208 | ||
209 | def update_seq_element(element, value, comment, _type): |
@@ 185-206 (lines=22) @@ | ||
182 | # Element operation |
|
183 | # |
|
184 | ############################################ |
|
185 | def update_map_element(element, key, value, comment, _type): |
|
186 | """ |
|
187 | element: |
|
188 | key: |
|
189 | value: |
|
190 | comment: |
|
191 | _type: value type. |
|
192 | """ |
|
193 | if element is None or not isinstance(element, CommentedMap): |
|
194 | print("Only key-value update support") |
|
195 | sys.exit(1) |
|
196 | ||
197 | origin_comment = _map_comment(element, key) |
|
198 | ||
199 | sub_element = element.get(key, None) |
|
200 | if isinstance(sub_element, CommentedMap) or isinstance(sub_element, CommentedSeq): |
|
201 | print("Only support update a single value") |
|
202 | ||
203 | element.update({key: value}) |
|
204 | ||
205 | comment = _obtain_comment(origin_comment, comment) |
|
206 | _add_eol_comment(element, _extract_comment(comment), key) |
|
207 | ||
208 | ||
209 | def update_seq_element(element, value, comment, _type): |