Skip to content

Commit

Permalink
Resolved the bug in ISAC -> local variable 'yaml' referenced before a…
Browse files Browse the repository at this point in the history
…ssignment (#556)

* Resolved the bug in ISAC -> local variable 'yaml' referenced before assignment

* Removed the redundent files of riscof_work
  • Loading branch information
UmerShahidengr authored Nov 13, 2024
1 parent 13fb359 commit 7a02abe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ PyYAML>=5.1.1
requests>=2.22.0
restructuredtext-lint>=1.3.0
riscv_isac>=0.14.0
ruamel.yaml>=0.16.0
ruamel.yaml>=0.18.0
six>=1.12.0
smmap2>=2.0.5
snowballstemmer>=1.2.1
Expand Down
17 changes: 13 additions & 4 deletions riscv-isac/riscv_isac/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,28 @@ def get_value_at_location(elf_path, location, bytes):
return int.from_bytes(value, byteorder='little', signed=False)
return None

def dump_yaml(foo, outfile = None, indent = None, block_seq_indent = None):
def dump_yaml(foo, outfile=None, indent=None, block_seq_indent=None):
"""
Dump yaml to outfile. If outfile is None, dump to string. If indent or
block_seq_indent is set, create a new yaml object with suchconfig.
block_seq_indent is set, create a new yaml object with such config.
"""
if indent is not None or block_seq_indent is not None:
yaml = create_yaml(indent=indent, block_seq_indent=block_seq_indent)
# Create a default yaml object if no custom settings are provided
yaml = create_yaml() if indent is None and block_seq_indent is None else create_yaml(indent=indent, block_seq_indent=block_seq_indent)

if outfile is None:
buf = io.StringIO()
yaml.dump(foo, buf)
return buf.getvalue()
return yaml.dump(foo, outfile)

def create_yaml(indent=None, block_seq_indent=None):
yaml = ruamel.yaml.YAML()
if indent is not None:
yaml.indent = indent
if block_seq_indent is not None:
yaml.block_seq_indent = block_seq_indent
return yaml

def load_yaml_file(foo):
try:
with open(foo, "r") as file:
Expand Down

0 comments on commit 7a02abe

Please sign in to comment.