1
0
mirror of https://github.com/daknuett/licor synced 2024-07-20 12:15:24 +00:00

made filediscovery relative

This commit is contained in:
Daniel Knüttel 2018-10-10 09:45:45 +02:00
parent edc55b40f8
commit 29f806411e

View File

@ -21,14 +21,18 @@
import glob, os import glob, os
def discover_this_path(path, file_ending): def discover_this_path(path, file_ending, root_path = ""):
""" """
Discover all matching files in this path. Discover all matching files in this path.
Return an iterator yielding the filepaths. Return an iterator yielding the filepaths.
""" """
return (os.path.abspath(p) for p in glob.iglob(os.path.join(path, "*." + file_ending))) if(not root_path):
root_path = os.curdir
return (os.path.relpath(os.path.abspath(p), root_path)
for p in glob.iglob(os.path.join(path, "*." + file_ending)))
def discover_all(path, file_ending, ignore_paths = []): def discover_all(path, file_ending, ignore_paths = []):
@ -38,6 +42,7 @@ def discover_all(path, file_ending, ignore_paths = []):
Yield the filepaths. Yield the filepaths.
""" """
root_path = os.path.abspath(path)
for p in os.walk(path): for p in os.walk(path):
path = p[0] path = p[0]
@ -46,7 +51,7 @@ def discover_all(path, file_ending, ignore_paths = []):
if(any( [ignore in splitted for ignore in ignore_paths ])): if(any( [ignore in splitted for ignore in ignore_paths ])):
continue continue
for i in discover_this_path(path, file_ending): for i in discover_this_path(path, file_ending, root_path = root_path):
yield i yield i