Ticket #17628: makemessages-ignore-dirs.diff

File makemessages-ignore-dirs.diff, 1.8 KB (added by andreiko, 13 years ago)
  • django/core/management/commands/makemessages.py

    diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py
    index 95c1da0..07e5439 100644
    a b def _popen(cmd):  
    4444    p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE, close_fds=os.name != 'nt', universal_newlines=True)
    4545    return p.communicate()
    4646
    47 def walk(root, topdown=True, onerror=None, followlinks=False):
     47def walk(root, topdown=True, onerror=None, followlinks=False, ignore_patterns=[], verbosity=0):
    4848    """
    4949    A version of os.walk that can follow symlinks for Python < 2.6
    5050    """
    5151    for dirpath, dirnames, filenames in os.walk(root, topdown, onerror):
     52        remove_dirs = []
     53        for dirname in dirnames:
     54            if is_ignored(os.path.normpath(os.path.join(dirpath, dirname)), ignore_patterns):
     55                remove_dirs.append(dirname)
     56        for dirname in remove_dirs:
     57            dirnames.remove(dirname)
     58            if verbosity > 1:
     59                sys.stdout.write('ignoring directory %s\n' % dirname)
    5260        yield (dirpath, dirnames, filenames)
    5361        if followlinks:
    5462            for d in dirnames:
    def find_files(root, ignore_patterns, verbosity, symlinks=False):  
    7179    Helper function to get all files in the given root.
    7280    """
    7381    all_files = []
    74     for (dirpath, dirnames, filenames) in walk(".", followlinks=symlinks):
     82    for (dirpath, dirnames, filenames) in walk(".", followlinks=symlinks,
     83                                    ignore_patterns=ignore_patterns, verbosity=verbosity):
    7584        for f in filenames:
    7685            norm_filepath = os.path.normpath(os.path.join(dirpath, f))
    7786            if is_ignored(norm_filepath, ignore_patterns):
Back to Top