From 84bc02c56627f2c6c3d88ac49161fcd0cd3e2db8 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Fri, 26 Jan 2018 11:53:06 +0000 Subject: [PATCH] Add --ignore-file option --- wagtail/bin/wagtail.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/wagtail/bin/wagtail.py b/wagtail/bin/wagtail.py index 1749f8028..48ebc5251 100644 --- a/wagtail/bin/wagtail.py +++ b/wagtail/bin/wagtail.py @@ -1,5 +1,6 @@ #!/usr/bin/env python import fileinput +import fnmatch import os import re import sys @@ -108,11 +109,18 @@ class UpdateModulePaths(Command): parser.add_argument('root_path', nargs='?', help="Path to your project's root") parser.add_argument('--list', action='store_true', dest='list_files', help="Show the list of files to change, without modifying them") parser.add_argument('--diff', action='store_true', help="Show the changes that would be made, without modifying the files") + parser.add_argument( + '--ignore-file', action='append', dest='ignored_patterns', metavar='NAME', + help="Ignore files with this name (supports wildcards)" + ) - def run(self, root_path=None, list_files=False, diff=False): + def run(self, root_path=None, list_files=False, diff=False, ignored_patterns=None): if root_path is None: root_path = os.getcwd() + if ignored_patterns is None: + ignored_patterns = [] + checked_file_count = 0 changed_file_count = 0 @@ -121,6 +129,9 @@ class UpdateModulePaths(Command): if not filename.lower().endswith('.py'): continue + if any(fnmatch.fnmatch(filename, pattern) for pattern in ignored_patterns): + continue + path = os.path.join(dirpath, filename) checked_file_count += 1