Add the travere_parents function to a utility directory
This commit is contained in:
1 parent
81a30d61d6
commit
24adebb69d
3 files changed
+14
-13
No files matched your search
@@ -0,0 +1,12 @@
|
||||
import os
|
||||
|
||||
|
||||
def traverse_parents(path, include_current=False):
|
||||
if not include_current:
|
||||
path = os.path.dirname(path)
|
||||
|
||||
previous = None
|
||||
while previous != path:
|
||||
yield path
|
||||
previous = path
|
||||
path = os.path.dirname(path)
|
||||
Reference in new issue
Block a user