Repository navigation
feat: add ignore_hidden parameter to extract_from_dir - #1410
Open
2025sl93041-gkb wants to merge 1 commit into
Open
2025sl93041-gkb wants to merge 1 commit into
2025sl93041-gkb wants to merge 1 commit into
Conversation
Add an `ignore_hidden: bool = False` parameter to `extract_from_dir()`. When True, files and directories whose names start with a dot are skipped during the os.walk traversal. Previously there was no way to exclude hidden files (e.g. `.gitignore`, `.env.py`) from extraction; only hidden directories were filtered by the default directory filter. This adds an explicit opt-in mechanism. Closes python-babel#471
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an
ignore_hidden: bool = Falseparameter toextract_from_dir().When
True, any file or directory whose name starts with.is skippedduring traversal.
Motivation
Closes #471. Prior to this change there was no way for a user to exclude
hidden files (e.g.
.gitignore,.env.py,.hidden_template.html) frommessage extraction. Hidden directories were already filtered by the
default directory filter (since Babel 2.9), but hidden files were
always extracted if they matched a pattern in the method map.
What this does
ignore_hiddentoextract_from_dir()signature (defaultFalsefor backwards compatibility).
True, theos.walkloop skips filenames and subdirectory namesstarting with
., regardless of what thedirectory_filtercallbackreturns.
Version 2.19.0 (Unreleased).Tests
Added
test_extract_from_dir_ignore_hiddenintests/messages/test_extract.pycovering:ignore_hidden=False): hidden files are extracted.ignore_hidden=True: hidden files are not extracted.ignore_hidden=Trueoverrides a permissivedirectory_filtertoalso exclude hidden directories.