mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-10 01:50:59 +00:00
Add --ignore-file option
This commit is contained in:
parent
3927ccf568
commit
84bc02c566
1 changed files with 12 additions and 1 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue