Commit 03b27886 authored by Robert Jensch's avatar Robert Jensch

Added: - function locate (Locate all files matching supplied filename pattern in…

Added: - function locate (Locate all files matching supplied filename pattern in and below supplied root directory)
with following code in Manifest.py all vhd files within the module are located
from hdlmake.util import path
files = path.locate("*.vhd")
parent d0ba0268
......@@ -26,6 +26,7 @@ from __future__ import print_function
from __future__ import absolute_import
import os
import re
import fnmatch
def url_parse(url):
......@@ -165,3 +166,17 @@ def flatten_list(sth):
else:
sth = []
return sth
def locate(pattern, root=os.curdir):
"""Locate all files matching supplied filename pattern in and below
supplied root directory."""
print(root)
located_files = []
for path, dirs, files in os.walk(os.path.abspath(root)):
for filename in fnmatch.filter(files, pattern):
rel_path = os.path.relpath(path, root)
if root != os.curdir:
located_files.append(os.path.join(root, rel_path, filename))
else:
located_files.append(os.path.join(rel_path, filename))
return located_files
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment