From 9a953b638fd9ab814804d2285fd700da88183e8c Mon Sep 17 00:00:00 2001 From: James Xu Date: Tue, 22 Jan 2019 17:22:57 -0800 Subject: [PATCH 1/5] normalize paths before comparison in rosmsg --- tools/rosmsg/src/rosmsg/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/rosmsg/src/rosmsg/__init__.py b/tools/rosmsg/src/rosmsg/__init__.py index 83b629e7e6..4380582d19 100644 --- a/tools/rosmsg/src/rosmsg/__init__.py +++ b/tools/rosmsg/src/rosmsg/__init__.py @@ -549,10 +549,14 @@ def iterate_packages(rospack, mode): def _get_package_paths(pkgname, rospack): paths = [] path = rospack.get_path(pkgname) + path = os.path.normcase(os.path.normpath(path)) 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: + path_in_workspaces = results[0] + path_in_workspaces = os.path.normcase(os.path.normpath(path_in_workspaces)) + if path_in_workspaces != path: + paths.append(results[0]) return paths def rosmsg_search(rospack, mode, base_type): From 93c2023c258110a65e98f9b413ad668084dd90a8 Mon Sep 17 00:00:00 2001 From: James Xu Date: Tue, 5 Feb 2019 15:10:47 -0800 Subject: [PATCH 2/5] remove use of normcase and remove path_in_workspaces temp variable --- tools/rosmsg/src/rosmsg/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/rosmsg/src/rosmsg/__init__.py b/tools/rosmsg/src/rosmsg/__init__.py index 4380582d19..bfef7d3f40 100644 --- a/tools/rosmsg/src/rosmsg/__init__.py +++ b/tools/rosmsg/src/rosmsg/__init__.py @@ -549,14 +549,15 @@ def iterate_packages(rospack, mode): def _get_package_paths(pkgname, rospack): paths = [] path = rospack.get_path(pkgname) - path = os.path.normcase(os.path.normpath(path)) 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: - path_in_workspaces = results[0] - path_in_workspaces = os.path.normcase(os.path.normpath(path_in_workspaces)) - if path_in_workspaces != path: - paths.append(results[0]) + 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: + paths.append(results[0]) return paths def rosmsg_search(rospack, mode, base_type): From c29af32a770c0b859f24d71021947eed9f3d6af8 Mon Sep 17 00:00:00 2001 From: James Xu Date: Tue, 5 Feb 2019 15:28:06 -0800 Subject: [PATCH 3/5] remove duplicated control --- tools/rosmsg/src/rosmsg/__init__.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tools/rosmsg/src/rosmsg/__init__.py b/tools/rosmsg/src/rosmsg/__init__.py index bfef7d3f40..0f155336f7 100644 --- a/tools/rosmsg/src/rosmsg/__init__.py +++ b/tools/rosmsg/src/rosmsg/__init__.py @@ -551,15 +551,10 @@ 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: - 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: - paths.append(results[0]) + if results and path.replace(os.path.sep, '/') != results[0].replace(os.path.sep, '/'): + paths.append(results[0]) return paths - + def rosmsg_search(rospack, mode, base_type): """ Iterator for all packages that contain a message matching base_type From dedc0aa08a5da8f0ca98924eeee4e74f3adfc710 Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Tue, 5 Feb 2019 15:32:56 -0800 Subject: [PATCH 4/5] revert unrelated whitespace changes --- tools/rosmsg/src/rosmsg/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/rosmsg/src/rosmsg/__init__.py b/tools/rosmsg/src/rosmsg/__init__.py index 0f155336f7..abaecaf064 100644 --- a/tools/rosmsg/src/rosmsg/__init__.py +++ b/tools/rosmsg/src/rosmsg/__init__.py @@ -554,7 +554,7 @@ def _get_package_paths(pkgname, rospack): if results and path.replace(os.path.sep, '/') != results[0].replace(os.path.sep, '/'): paths.append(results[0]) return paths - + def rosmsg_search(rospack, mode, base_type): """ Iterator for all packages that contain a message matching base_type From 993673c4644feba296b90e24b95f7b0b8f7a4f4c Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Tue, 5 Feb 2019 15:34:02 -0800 Subject: [PATCH 5/5] keep order of operands --- tools/rosmsg/src/rosmsg/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/rosmsg/src/rosmsg/__init__.py b/tools/rosmsg/src/rosmsg/__init__.py index abaecaf064..4ed7aa542a 100644 --- a/tools/rosmsg/src/rosmsg/__init__.py +++ b/tools/rosmsg/src/rosmsg/__init__.py @@ -551,7 +551,7 @@ 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 path.replace(os.path.sep, '/') != results[0].replace(os.path.sep, '/'): + if results and results[0].replace(os.path.sep, '/') != path.replace(os.path.sep, '/'): paths.append(results[0]) return paths