Skip to content

Commit

Permalink
Merge pull request #1023 from ioam/find_file
Browse files Browse the repository at this point in the history
find_file utility handles absolute path
  • Loading branch information
jlstevens authored Jan 17, 2017
2 parents 18b87e1 + e64a9b6 commit 8e67b33
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions holoviews/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,12 +758,17 @@ def get_spec(obj):

def find_file(folder, filename):
"""
Find a file given folder and filename.
Find a file given folder and filename. If the filename can be
resolved directly returns otherwise walks the supplied folder.
"""
matches = []
if os.path.isabs(filename) and os.path.isfile(filename):
return filename
for root, _, filenames in os.walk(folder):
for filename in fnmatch.filter(filenames, filename):
matches.append(os.path.join(root, filename))
for fn in fnmatch.filter(filenames, filename):
matches.append(os.path.join(root, fn))
if not matches:
raise IOError('File %s could not be found' % filename)
return matches[-1]


Expand Down

0 comments on commit 8e67b33

Please sign in to comment.