From f8ea839aa531b8cf1de2f623f37064178d24f033 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Wed, 25 Oct 2017 21:00:02 +0200 Subject: [PATCH] fixxref/rebase: move the exception handling to the common module Handle the exception in the commond module. This was added in the previous commit, but this is only called from exactly those two functions. --- gtkdoc/common.py | 8 ++++++-- gtkdoc/fixxref.py | 30 +++++++++++++----------------- gtkdoc/rebase.py | 13 +++++-------- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/gtkdoc/common.py b/gtkdoc/common.py index 470722e..50c9f5f 100644 --- a/gtkdoc/common.py +++ b/gtkdoc/common.py @@ -99,9 +99,13 @@ def GetModuleDocDir(module_name): module_name (string): The module, e.g. 'glib-2.0' Returns: - str: the doc directory + str: the doc directory or None """ - path = subprocess.check_output([config.pkg_config, '--variable=prefix', module_name], universal_newlines=True) + path = None + try: + path = subprocess.check_output([config.pkg_config, '--variable=prefix', module_name], universal_newlines=True) + except subprocess.CalledProcessError: + return None return os.path.join(path.strip(), 'share/gtk-doc/html') diff --git a/gtkdoc/fixxref.py b/gtkdoc/fixxref.py index 739e84b..3027c10 100755 --- a/gtkdoc/fixxref.py +++ b/gtkdoc/fixxref.py @@ -71,27 +71,23 @@ def Run(options): # We scan the directory containing GLib and any directories in GNOME2_PATH # first, but these will be overriden by any later scans. - try: - dir = common.GetModuleDocDir('glib-2.0') - except subprocess.CalledProcessError: - pass - else: - if os.path.exists(dir): - # Some predefined link targets to get links into type hierarchies as these - # have no targets. These are always absolute for now. - Links['GBoxed'] = dir + '/gobject/gobject-Boxed-Types.html' - Links['GEnum'] = dir + '/gobject/gobject-Enumeration-and-Flag-Types.html' - Links['GFlags'] = dir + '/gobject/gobject-Enumeration-and-Flag-Types.html' - Links['GInterface'] = dir + '/gobject/GTypeModule.html' - - if dir != options.html_dir: - logging.info('Scanning GLib directory: %s', dir) - ScanIndices(dir, (re.search(prefix_match, dir) is None)) + dir = common.GetModuleDocDir('glib-2.0') + if dir and os.path.exists(dir): + # Some predefined link targets to get links into type hierarchies as these + # have no targets. These are always absolute for now. + Links['GBoxed'] = dir + '/gobject/gobject-Boxed-Types.html' + Links['GEnum'] = dir + '/gobject/gobject-Enumeration-and-Flag-Types.html' + Links['GFlags'] = dir + '/gobject/gobject-Enumeration-and-Flag-Types.html' + Links['GInterface'] = dir + '/gobject/GTypeModule.html' + + if dir != options.html_dir: + logging.info('Scanning GLib directory: %s', dir) + ScanIndices(dir, (re.search(prefix_match, dir) is None)) path = os.environ.get('GNOME2_PATH') if path: for dir in path.split(':'): - dir += '/share/gtk-doc/html' + dir += 'share/gtk-doc/html' if os.path.exists(dir) and dir != options.html_dir: logging.info('Scanning GNOME2_PATH directory: %s', dir) ScanIndices(dir, (re.search(prefix_match, dir) is None)) diff --git a/gtkdoc/rebase.py b/gtkdoc/rebase.py index 23e3d6e..e518586 100755 --- a/gtkdoc/rebase.py +++ b/gtkdoc/rebase.py @@ -59,18 +59,15 @@ def run(options): # first, but these will be overriden by any later scans. if "GNOME2_PATH" in os.environ: for dir in os.environ["GNOME2_PATH"].split(':'): - dir = os.path.join(dir, "/share/gtk-doc/html") + dir = os.path.join(dir, "share/gtk-doc/html") if os.path.isdir(dir): log(options, "Prepending GNOME2_PATH directory:", dir) other_dirs = [dir] + other_dirs - try: - dir = common.GetModuleDocDir('glib-2.0') - except subprocess.CalledProcessError: - pass - else: - log(options, "Prepending GLib directory", dir) - other_dirs = [dir] + other_dirs + glib_dir = common.GetModuleDocDir('glib-2.0') + if glib_dir: + log(options, "Prepending GLib directory", glib_dir) + other_dirs = [glib_dir] + other_dirs # Check all other dirs, but skip already scanned dirs ord subdirs of those -- 2.11.4.GIT