Skip to content

Commit 7a02abe

Browse files
Resolved the bug in ISAC -> local variable 'yaml' referenced before assignment (#556)
* Resolved the bug in ISAC -> local variable 'yaml' referenced before assignment * Removed the redundent files of riscof_work
1 parent 13fb359 commit 7a02abe

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

requirements.txt

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ PyYAML>=5.1.1
3434
requests>=2.22.0
3535
restructuredtext-lint>=1.3.0
3636
riscv_isac>=0.14.0
37-
ruamel.yaml>=0.16.0
37+
ruamel.yaml>=0.18.0
3838
six>=1.12.0
3939
smmap2>=2.0.5
4040
snowballstemmer>=1.2.1

riscv-isac/riscv_isac/utils.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,28 @@ def get_value_at_location(elf_path, location, bytes):
5252
return int.from_bytes(value, byteorder='little', signed=False)
5353
return None
5454

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):
5656
"""
5757
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.
5959
"""
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+
6263
if outfile is None:
6364
buf = io.StringIO()
6465
yaml.dump(foo, buf)
6566
return buf.getvalue()
6667
return yaml.dump(foo, outfile)
6768

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+
6877
def load_yaml_file(foo):
6978
try:
7079
with open(foo, "r") as file:

0 commit comments

Comments
 (0)