Last active
July 18, 2019 11:08
-
-
Save Glutexo/be5fe4febba36b7172ca117993bcbfd5 to your computer and use it in GitHub Desktop.
Fix all text files in RedHatInsights/insights-host-inventory by a pre-commit hook
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
from glob import glob | |
from os.path import join | |
from pre_commit_hooks.end_of_file_fixer import fix_file | |
PATTERNS = ( | |
"*.py", | |
"*.ini", | |
"README", | |
"*.mako", | |
"*.yaml", | |
".gitignore", | |
"*.yml", | |
"*.groovy", | |
"Pipfile", | |
"Pipfile.lock", | |
"*.md", | |
) | |
def fix_all(func): | |
for pattern in PATTERNS: | |
for path in glob(join("**", pattern), recursive=True): | |
print(path, end=" ") | |
with open(path, "r+") as file: | |
result = func(file) | |
print(result) | |
if __name__ == "__main__": | |
fix_all(fix_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment