Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

normalize paths before comparison in rosmsg #1586

Merged
merged 5 commits into from
Feb 6, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions tools/rosmsg/src/rosmsg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,13 @@ def _get_package_paths(pkgname, rospack):
path = rospack.get_path(pkgname)
paths.append(path)
results = find_in_workspaces(search_dirs=['share'], project=pkgname, first_match_only=True, workspace_to_source_spaces=_catkin_workspace_to_source_spaces, source_path_to_packages=_catkin_source_path_to_packages)
if results and results[0] != path:
paths.append(results[0])
if results:
if os.path.sep != '/':
if path.replace(os.path.sep, '/') != results[0].replace(os.path.sep, '/'):
paths.append(results[0])
else:
if path_in_workspaces != path:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undefined variable path_in_workspaces?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

embarrassed, change to use results[0]

paths.append(results[0])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The duplication of control seems unnecessary. This could simple stay a single condition since on platforms where os.path.sep is / the replace() calls are no-ops:

if results and results[0].replace(os.path.sep, '/') != path.replace(os.path.sep, '/'):
    paths.append(results[0])

return paths

def rosmsg_search(rospack, mode, base_type):
Expand Down