Last active
August 29, 2015 14:03
-
-
Save migonzalvar/03d49eb0fd806205f7f9 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
#! /usr/bin/env python3 | |
import argparse | |
from fnmatch import fnmatch | |
from os import walk | |
from os.path import join, normpath | |
parser = argparse.ArgumentParser() | |
parser.description = 'Buscar archivos.' | |
parser.add_argument('path', help='Path to search from') | |
parser.add_argument('pattern', help='Support UNIX wildcards') | |
parser.add_argument('--type', '-t', dest='EXT', default='py') | |
args = parser.parse_args() | |
for dirpath, _, filenames in walk(args.path): | |
for filename in filenames: | |
if not filename.endswith(args.EXT): | |
continue | |
if fnmatch(filename, args.pattern): | |
file_path = join(args.path, dirpath, filename) | |
file_path = normpath(file_path) | |
print(file_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment