Skip to content

Commit

Permalink
Return zip file name after export with assets.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 626975425
Change-Id: I2fe18df78812bff12ad59cb8f1b3e507da3b55c2
  • Loading branch information
erez-tom authored and copybara-github committed Apr 22, 2024
1 parent 7a6a530 commit 554ad27
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dm_control/mjcf/export_with_assets_as_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def export_with_assets_as_zip(mjcf_model, out_dir, model_name=None,
quantities.
zero_threshold: (optional) When outputting XML, floating point quantities
whose absolute value falls below this threshold will be treated as zero.
Returns:
The full path to the .zip file.
"""

if model_name is None:
Expand All @@ -57,6 +60,8 @@ def export_with_assets_as_zip(mjcf_model, out_dir, model_name=None,

if not os.path.exists(out_dir):
os.makedirs(out_dir)
with zipfile.ZipFile(os.path.join(out_dir, zip_name), 'w') as zip_file:
file_name = os.path.join(out_dir, zip_name)
with zipfile.ZipFile(file_name, 'w') as zip_file:
for filename, contents in files_to_zip.items():
zip_file.writestr(os.path.join(model_name, filename), contents)
return file_name

0 comments on commit 554ad27

Please sign in to comment.