@@ 37-59 (lines=23) @@ | ||
34 | return str_ |
|
35 | ||
36 | ||
37 | def _add_eol_comment(element, *args, **kwargs): |
|
38 | """ |
|
39 | add_eol_comment |
|
40 | args --> (comment, key) |
|
41 | """ |
|
42 | if element is None or \ |
|
43 | (not isinstance(element, CommentedMap) and |
|
44 | not isinstance(element, CommentedSeq)) or \ |
|
45 | args[0] is None or \ |
|
46 | len(args[0]) == 0: |
|
47 | return |
|
48 | ||
49 | comment = args[0] |
|
50 | # comment is empty, do nothing |
|
51 | if not comment: |
|
52 | return |
|
53 | ||
54 | key = args[1] |
|
55 | try: |
|
56 | element.yaml_add_eol_comment(*args, **kwargs) |
|
57 | except Exception: |
|
58 | element.ca.items.pop(key, None) |
|
59 | element.yaml_add_eol_comment(*args, **kwargs) |
|
60 | ||
61 | ||
62 | def _map_comment(_element, _key): |
@@ 37-59 (lines=23) @@ | ||
34 | return str_ |
|
35 | ||
36 | ||
37 | def _add_eol_comment(element, *args, **kwargs): |
|
38 | """ |
|
39 | add_eol_comment |
|
40 | args --> (comment, key) |
|
41 | """ |
|
42 | if element is None or \ |
|
43 | (not isinstance(element, CommentedMap) and |
|
44 | not isinstance(element, CommentedSeq)) or \ |
|
45 | args[0] is None or \ |
|
46 | len(args[0]) == 0: |
|
47 | return |
|
48 | ||
49 | comment = args[0] |
|
50 | # comment is empty, do nothing |
|
51 | if not comment: |
|
52 | return |
|
53 | ||
54 | key = args[1] |
|
55 | try: |
|
56 | element.yaml_add_eol_comment(*args, **kwargs) |
|
57 | except Exception: |
|
58 | element.ca.items.pop(key, None) |
|
59 | element.yaml_add_eol_comment(*args, **kwargs) |
|
60 | ||
61 | ||
62 | def _map_comment(_element, _key): |