Skip to content

Instantly share code, notes, and snippets.

@Glutexo
Last active July 18, 2019 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Glutexo/be5fe4febba36b7172ca117993bcbfd5 to your computer and use it in GitHub Desktop.
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
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