Skip all hidden directories in `CatalogRepository` (#11667)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This commit is contained in:
Aryaz Eghbali 2023-09-21 11:30:26 +02:00 committed by GitHub
parent 5494640890
commit abf42e901e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View File

@ -27,6 +27,8 @@ Bugs fixed
* #11617: ANSI control sequences are stripped from the output when writing to
a warnings file with :option:`-w <sphinx-build -w>`.
Patch by Bénédikt Tran.
* #11666: Skip all hidden directories in ``CatalogRepository.pofiles``.
Patch by Aryaz Eghbali.
Testing
-------

View File

@ -99,9 +99,8 @@ class CatalogRepository:
basedir = path.join(locale_dir, self.language, 'LC_MESSAGES')
for root, dirnames, filenames in os.walk(basedir):
# skip dot-directories
for dirname in dirnames:
if dirname.startswith('.'):
dirnames.remove(dirname)
for dirname in [d for d in dirnames if d.startswith('.')]:
dirnames.remove(dirname)
for filename in filenames:
if filename.endswith('.po'):

View File

@ -160,6 +160,8 @@ def test_CatalogRepository(tmp_path):
(tmp_path / 'loc2' / 'xx' / 'LC_MESSAGES').mkdir(parents=True, exist_ok=True)
(tmp_path / 'loc2' / 'xx' / 'LC_MESSAGES' / 'test1.po').write_text('#', encoding='utf8')
(tmp_path / 'loc2' / 'xx' / 'LC_MESSAGES' / 'test7.po').write_text('#', encoding='utf8')
(tmp_path / 'loc1' / 'xx' / 'LC_MESSAGES' / '.dotdir2').mkdir(parents=True, exist_ok=True)
(tmp_path / 'loc1' / 'xx' / 'LC_MESSAGES' / '.dotdir2' / 'test8.po').write_text('#', encoding='utf8')
# for language xx
repo = i18n.CatalogRepository(tmp_path, ['loc1', 'loc2'], 'xx', 'utf-8')