From a060fae67337156aacee9fa0d137d0140ece5e65 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 5 Jul 2017 11:30:02 +0530 Subject: [PATCH] Dont fail to run sphinx-build if there are no generated languages --- manual/conf.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/manual/conf.py b/manual/conf.py index fb9e3e575c..5ffab2fbb9 100644 --- a/manual/conf.py +++ b/manual/conf.py @@ -11,12 +11,13 @@ # All configuration values have a default value; values that are commented out # serve to show the default value. -import sys, os +import sys, os, errno from datetime import date # If your extensions are in another directory, add it here. -sys.path.append(os.path.dirname(os.path.abspath(__file__))) -sys.path.insert(0, os.path.dirname(sys.path[-1])) +base = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(base) +sys.path.insert(0, os.path.dirname(base)) from setup import __appname__, __version__ import calibre.utils.localization as l # Ensure calibre translations are installed import custom @@ -51,8 +52,19 @@ if tags.has('gettext'): # noqa # The language language = os.environ.get('CALIBRE_OVERRIDE_LANG', 'en') + + +def generated_langs(): + try: + return os.listdir(os.path.join(base, 'generated')) + except EnvironmentError as e: + if e.errno != errno.ENOENT: + raise + return () + + # ignore generated files in languages other than the language we are building for -ge = {'generated/' + x for x in os.listdir('generated')} | { +ge = {'generated/' + x for x in generated_langs()} | { 'generated/' + x for x in os.environ.get('ALL_USER_MANUAL_LANGUAGES', '').split()} ge.discard('generated/' + language) exclude_patterns += list(ge)