Skip to content

Commit

Permalink
Merge branch 'dev' into Zcf-Zcd
Browse files Browse the repository at this point in the history
  • Loading branch information
anuani21 authored Nov 15, 2024
2 parents da49c95 + cd94912 commit 0b5a365
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@
riscv-target/

#ignore venv
riscv-isac/riscv-env
riscv-isac/riscv-env

__pycache__
riscof_work
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 0b5a365

Please sign in to comment.