@@ -52,19 +52,28 @@ def get_value_at_location(elf_path, location, bytes):
52
52
return int .from_bytes (value , byteorder = 'little' , signed = False )
53
53
return None
54
54
55
- def dump_yaml (foo , outfile = None , indent = None , block_seq_indent = None ):
55
+ def dump_yaml (foo , outfile = None , indent = None , block_seq_indent = None ):
56
56
"""
57
57
Dump yaml to outfile. If outfile is None, dump to string. If indent or
58
- block_seq_indent is set, create a new yaml object with suchconfig .
58
+ block_seq_indent is set, create a new yaml object with such config .
59
59
"""
60
- if indent is not None or block_seq_indent is not None :
61
- yaml = create_yaml (indent = indent , block_seq_indent = block_seq_indent )
60
+ # Create a default yaml object if no custom settings are provided
61
+ yaml = create_yaml () if indent is None and block_seq_indent is None else create_yaml (indent = indent , block_seq_indent = block_seq_indent )
62
+
62
63
if outfile is None :
63
64
buf = io .StringIO ()
64
65
yaml .dump (foo , buf )
65
66
return buf .getvalue ()
66
67
return yaml .dump (foo , outfile )
67
68
69
+ def create_yaml (indent = None , block_seq_indent = None ):
70
+ yaml = ruamel .yaml .YAML ()
71
+ if indent is not None :
72
+ yaml .indent = indent
73
+ if block_seq_indent is not None :
74
+ yaml .block_seq_indent = block_seq_indent
75
+ return yaml
76
+
68
77
def load_yaml_file (foo ):
69
78
try :
70
79
with open (foo , "r" ) as file :
0 commit comments