Skip to content

Commit 3fc4f65

Browse files
authored
Merge pull request #1921 from yarikoptic/bf-nodoubleslash
Strip possibly present trailing / (os.sep) before adding one
2 parents 7ce4276 + 81e7a43 commit 3fc4f65

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tools/examplecode/example.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
"""
99

10-
import os
10+
import posixpath
1111

1212

1313
class DirectoryTree:
@@ -69,7 +69,9 @@ def _add_dictionary(
6969

7070
# We are dealing with a directory
7171
else:
72-
self._tree.append(f"{prefix}{connector} {entry}{os.sep}")
72+
self._tree.append(
73+
f"{prefix}{connector} {entry.rstrip(posixpath.sep)}{posixpath.sep}"
74+
)
7375
prefix += (
7476
self.PIPE_PREFIX if index != entries_count - 1 else self.SPACE_PREFIX
7577
)

0 commit comments

Comments
 (0)