Created
August 26, 2021 15:52
-
-
Save sblack4/b5e001c84a561e7490add1d2f9a332f3 to your computer and use it in GitHub Desktop.
Crawls through files and provides hooks to process name or contents
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 glob | |
import os.path | |
root_dir = '' | |
def filename_hook(filename): | |
print(filename) | |
def filetxt_hook(filetxt): | |
print(filetxt) | |
for filename in glob.iglob(root_dir + '**/**', recursive=True): | |
filename_hook(filename) | |
if not os.path.isfile(filename): | |
print(f'ERROR file doesnt exist: {filename}') | |
continue | |
with open(filename, 'r') as fh: | |
file_text = fh.readlines() | |
filetxt_hook(file_text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment