Skip to content

Commit

Permalink
Also look for old manifest.xml when walking up the directory tree.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamheins committed Feb 27, 2024
1 parent bf76c19 commit 331f65d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/xacrodoc/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,35 @@ def walk_up_from(self, path, priority=0):
"""
resolved = Path(path).resolve()

def func(pkg):
def finder_func(pkg):
path = resolved
while path.as_posix() != path.root:

# check for package.xml, get the package name from it
package_xml_path = path / "package.xml"
package_xml_path = path / rospkg.common.PACKAGE_FILE
if package_xml_path.exists():
with open(package_xml_path) as f:
doc = minidom.parse(f)
names = doc.getElementsByTagName("name")

if len(names) != 1:
raise ValueError(
f"Excepted one name in {package_xml_path}, but found {len(names)}"
f"Expected one name in {package_xml_path}, but found {len(names)}"
)
if names[0].firstChild.data == pkg:
return path.as_posix()

# check for manifest.xml (used in the old, deprecated rosbuild
# system); if it exists, the package name is the directory name
manifest_xml_path = path / rospkg.common.MANIFEST_FILE
if manifest_xml_path.exists():
return path.as_posix()

# go up to the next directory
path = path.parent
raise PackageNotFoundError(pkg)

self.finder_funcs.insert(priority, (func, PackageNotFoundError))
self.finder_funcs.insert(priority, (finder_func, PackageNotFoundError))

def get_path(self, pkg):
"""Attempt to get the path of a package.
Expand Down

0 comments on commit 331f65d

Please sign in to comment.