Skip to content

Commit

Permalink
Find any of a list of possibilities.
Browse files Browse the repository at this point in the history
  • Loading branch information
thebjorn committed Apr 21, 2017
1 parent f85b617 commit eb7c2e8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions dkfileutils/pfind.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import sys


def pfind(path, fname):
"""Find fname in the closest ancestor directory.
def pfind(path, *fnames):
"""Find the first fname in the closest ancestor directory.
For the purposes of this function, we are our own closest ancestor.
"""

Expand All @@ -24,8 +24,10 @@ def parents():
yield parent

for d in parents():
if fname in os.listdir(d):
return os.path.join(d, fname)
curdirlist = os.listdir(d)
for fname in fnames:
if fname in curdirlist:
return os.path.join(d, fname)

return None

Expand Down

0 comments on commit eb7c2e8

Please sign in to comment.