Skip to content

Commit

Permalink
avoid duplicate prefix paths (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk-thomas authored Apr 11, 2019
1 parent d959c86 commit 223a466
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions colcon_core/prefix_path/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def get_chained_prefix_path(*, skip=None):
Get the chained prefix paths.
The items are ordered from higher to lower priority paths.
Repeated paths are skipped.
:param skip: The current prefix path to be skipped and not be included in
the return value
Expand All @@ -83,6 +84,11 @@ def get_chained_prefix_path(*, skip=None):
"'{extension.PREFIX_PATH_NAME}': {e}\n{exc}"
.format_map(locals()))
# skip failing extension, continue with next one
return [
p for p in chained_prefix_path
if skip is None or str(p) != str(skip)]
unique_prefix_path = []
for p in chained_prefix_path:
if skip is not None and str(p) == str(skip):
continue
if p in unique_prefix_path:
continue
unique_prefix_path.append(p)
return unique_prefix_path
4 changes: 2 additions & 2 deletions test/test_prefix_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ def test_get_chained_prefix_path():
with EnvironmentContext(COLCON_PREFIX_PATH=os.pathsep.join(
[str(basepath), str(basepath)]
)):
# multiple results
# multiple results, duplicates being skipped
prefix_path = get_chained_prefix_path(skip='/path/to/skip')
assert prefix_path == [str(basepath), str(basepath)]
assert prefix_path == [str(basepath)]

# skipping results
prefix_path = get_chained_prefix_path(skip=str(basepath))
Expand Down

0 comments on commit 223a466

Please sign in to comment.