From 3accdd99b9824e5888ca9f163f42159ec9450716 Mon Sep 17 00:00:00 2001 From: Emmanuel Arias Date: Sun, 13 Dec 2020 19:35:35 -0300 Subject: [PATCH] Uso de pahlib en conf.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- conf.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/conf.py b/conf.py index 4b6fce0378..8ecc6c9d56 100644 --- a/conf.py +++ b/conf.py @@ -47,19 +47,15 @@ if not os.environ.get('SPHINX_GETTEXT') == 'True': # Override all the files from ``.overrides`` directory - import glob - for root, dirs, files in os.walk('.overrides'): - for fname in files: - if fname == 'README.rst' and root == '.overrides': - continue - destroot = root.replace('.overrides', '').lstrip('/') - outputdir = os.path.join( - 'cpython', - 'Doc', - destroot, - fname, - ) - os.system(f'ln -nfs `pwd`/{root}/{fname} {outputdir}') + from pathlib import Path + overrides_paths = Path('.overrides') + + for path in overrides_paths.glob('**/*.*'): + if path.name == 'README.rst' and path.parent == '.overrides': + continue + destroot = str(path.parent).replace('.overrides', '').lstrip('/') + outputdir = Path('cpython/Doc') / destroot / path.name + os.system(f'ln -nfs `pwd`/{path.parent}/{path.name} {outputdir}') gettext_compact = False locale_dirs = ['../locales', 'cpython/locales'] # relative to the sourcedir