Skip to content

Commit

Permalink
Relax mandatory need for relative base paths (#41)
Browse files Browse the repository at this point in the history
* Use os.path.relpath for conformation

PurePath.relative_to() requires self to be the subpath of the argument, but os.path.relpath() does not.

Fixes Question on the mandatory need for relative path #37x

* Sort paths and relpaths
to keep log messages and conformation printout self consistent
  • Loading branch information
ruffsl authored Feb 8, 2024
1 parent 35660e2 commit 43a59aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions colcon_clean/subverb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Copyright 2021 Ruffin White
# Licensed under the Apache License, Version 2.0

import os
from pathlib import Path
import shutil

Expand Down Expand Up @@ -231,14 +232,14 @@ def clean_paths(paths, confirmed=False):
cwd_path = Path.cwd()
if not confirmed:
print('Paths:')
for path in sorted(paths):
path = path.relative_to(cwd_path)
relpaths = (os.path.relpath(path, cwd_path) for path in paths)
for path in sorted(relpaths):
print(' ', path)
question = 'Clean the above paths?'
confirmed = query_yes_no(question)

if confirmed:
for path in paths:
for path in sorted(paths):
_clean_path(path)


Expand Down
2 changes: 2 additions & 0 deletions test/spell_check.words
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pathlib
plugin
pydocstyle
pytest
relpath
relpaths
rmtree
rtype
scantree
Expand Down

0 comments on commit 43a59aa

Please sign in to comment.