Skip to content

Commit a8c18c9

Browse files
authored
Uso de pahlib en conf.py (#1171)
Este PR busco de alguna manera reemplazar el uso de os.walk con pathlib.glob(). Esto desde mi punto de vista simplifica en cierto grado el entendimiento del código.
1 parent 7172e06 commit a8c18c9

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

conf.py

+9-13
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,15 @@
4747

4848
if not os.environ.get('SPHINX_GETTEXT') == 'True':
4949
# Override all the files from ``.overrides`` directory
50-
import glob
51-
for root, dirs, files in os.walk('.overrides'):
52-
for fname in files:
53-
if fname == 'README.rst' and root == '.overrides':
54-
continue
55-
destroot = root.replace('.overrides', '').lstrip('/')
56-
outputdir = os.path.join(
57-
'cpython',
58-
'Doc',
59-
destroot,
60-
fname,
61-
)
62-
os.system(f'ln -nfs `pwd`/{root}/{fname} {outputdir}')
50+
from pathlib import Path
51+
overrides_paths = Path('.overrides')
52+
53+
for path in overrides_paths.glob('**/*.*'):
54+
if path.name == 'README.rst' and path.parent == '.overrides':
55+
continue
56+
destroot = str(path.parent).replace('.overrides', '').lstrip('/')
57+
outputdir = Path('cpython/Doc') / destroot / path.name
58+
os.system(f'ln -nfs `pwd`/{path.parent}/{path.name} {outputdir}')
6359

6460
gettext_compact = False
6561
locale_dirs = ['../locales', 'cpython/locales'] # relative to the sourcedir

0 commit comments

Comments
 (0)