Skip to content

Commit

Permalink
Update set_metadata in World to accept locations and objects as list …
Browse files Browse the repository at this point in the history
…as well
  • Loading branch information
kumar-sanjeeev committed Jan 4, 2025
1 parent 4a836e4 commit 7f6a76d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pyrobosim/pyrobosim/core/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def add_metadata(cls, filename):
:param filename: Path to location metadata YAML file.
:type filename: str
"""
if not hasattr(cls, "metadata") or cls.metadata is None:
if not hasattr(cls, "metadata"):
cls.metadata = EntityMetadata()

cls.metadata.add(filename)
Expand Down
46 changes: 26 additions & 20 deletions pyrobosim/pyrobosim/core/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,22 @@ def set_metadata(self, locations=None, objects=None):
"""
Sets location and object metadata from the specified files.
:param locations: Path to location metadata YAML file.
:type locations: str, optional
:param objects: Path to object metadata YAML file.
:type objects: str, optional
:param locations: Path(s) to location metadata YAML file(s).
:type locations: str | list[str] | None
:param objects: Path(s) to object metadata YAML file(s).
:type objects: str | list[str] | None
"""
if locations is not None:
Location.set_metadata(locations)
if objects is not None:
Object.set_metadata(objects)
if isinstance(locations, list):
for location in locations:
Location.add_metadata(location)
elif isinstance(locations, str):
Location.add_metadata(locations)

if isinstance(objects, list):
for object in objects:
Object.add_metadata(object)
elif isinstance(objects, str):
Object.add_metadata(objects)

def add_metadata(self, locations=None, objects=None):
"""
Expand All @@ -112,18 +119,17 @@ def add_metadata(self, locations=None, objects=None):
:type objects: str | list[str] | None
"""

if locations is not None:
if isinstance(locations, list):
for location in locations:
Location.add_metadata(location)
else:
Location.add_metadata(locations)
if objects is not None:
if isinstance(objects, list):
for object in objects:
Object.add_metadata(object)
else:
Object.add_metadata(objects)
if isinstance(locations, list):
for location in locations:
Location.add_metadata(location)
elif isinstance(locations, str):
Location.add_metadata(locations)

if isinstance(objects, list):
for object in objects:
Object.add_metadata(object)
elif isinstance(objects, str):
Object.add_metadata(objects)

def get_location_metadata(self):
"""
Expand Down

0 comments on commit 7f6a76d

Please sign in to comment.