lkj
Recipes
#2
Replies: 1 comment
-
Get a list of unique relative file pathsA from functools import partial
import os
unique_relative_paths = partial(unique_affixes, suffix=True, ingress=partial(str.split, sep=os.path.sep), egress=os.path.sep.join)
# Example
test_paths = paths = [
'/home/user/project/unique/file.py',
'/home/user/project/src/file1.py',
'/home/user/project/tests/file1.py',
'/home/user/project/src/utils/file2.py',
'/home/user/project/docs/file2.py'
]
assert unique_relative_paths(test_paths) == [
'file.py',
'src/file1.py',
'tests/file1.py',
'utils/file2.py',
'docs/file2.py',
] Note that |
Beta Was this translation helpful? Give feedback.
-
A bunch of recipes using
lkj
tools.Beta Was this translation helpful? Give feedback.
All reactions