Created
April 29, 2010 16:35
-
-
Save bebraw/383857 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
# let's find all js files in the src sibling directory (not recursive!) | |
for file_path in glob.iglob('../src/*.js'): | |
print file_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fnmatch | |
import os | |
def locate(pattern, root=os.curdir): | |
'''Locate all files matching supplied filename pattern in and below | |
supplied root directory. | |
Original version: http://code.activestate.com/recipes/499305/ | |
''' | |
for path, dirs, files in os.walk(os.path.abspath(root)): | |
for filename in fnmatch.filter(files, pattern): | |
yield os.path.join(path, filename) | |
# let's find all js files in the src sibling directory (recurses!) | |
for file_path in locate('*.js', '../src'): | |
print file_path # this should print whole path to the file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment