-
Notifications
You must be signed in to change notification settings - Fork 914
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
normalize paths before comparison in rosmsg #1586
Conversation
tools/rosmsg/src/rosmsg/__init__.py
Outdated
if path.replace(os.path.sep, '/') != results[0].replace(os.path.sep, '/'): | ||
paths.append(results[0]) | ||
else: | ||
if path_in_workspaces != path: |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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]
tools/rosmsg/src/rosmsg/__init__.py
Outdated
paths.append(results[0]) | ||
else: | ||
if path_in_workspaces != path: | ||
paths.append(results[0]) |
There was a problem hiding this comment.
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])
Thanks for the patch. |
@dirk-thomas, thanks for merging this change! While not related to this change, here is something I'd love to share and ask for opinions: the reason for the test failure behind this change is essentially because 1 path is normalized, and the other one is not. this normalization happens during https://github.com/ros/ros_comm/blob/melodic-devel/tools/rosmsg/src/rosmsg/__init__.py#L551
and inside
from python documentation:
I haven't had time to dig in further on the behavior of
|
Due to the size of the code base I can't suggest either of the two approaches. Just blindly applying normalization doesn't sounds appealing to me. Removing it from that specific instance might have unintended side effects. I guess it would need to be tried... |
* normalize paths before comparison in rosmsg * remove use of normcase and remove path_in_workspaces temp variable * remove duplicated control * revert unrelated whitespace changes * keep order of operands
this is a minor update to the existing
results[0] != path:
comparison:normalize all paths before comparison or adding them into
paths
to make sure all elements inpaths
are really unique_get_package_paths
will return 2 paths for the same package; for example:C:\\ros-win\\install_isolated\\share\\test_rosmaster
andC:/ros-win/install_isolated\\share\\test_rosmaster
will both be returned fortest_rosmaster
, resulting in duplicated output