Split up _asciidoc_fallback_path from qute_help
This commit is contained in:
parent
be0d6ef3d2
commit
27d0d148b8
@ -349,6 +349,23 @@ def qute_gpl(_url):
|
||||
return 'text/html', utils.read_file('html/license.html')
|
||||
|
||||
|
||||
def _asciidoc_fallback_path(path):
|
||||
"""Fall back to plaintext asciidoc if the HTML is unavailable."""
|
||||
asciidoc_path = path.replace('.html', '.asciidoc')
|
||||
asciidoc_paths = [asciidoc_path]
|
||||
if asciidoc_path.startswith('html/doc/'):
|
||||
asciidoc_paths += [asciidoc_path.replace('html/doc/', '../doc/help/'),
|
||||
asciidoc_path.replace('html/doc/', '../doc/')]
|
||||
|
||||
for path in asciidoc_paths:
|
||||
try:
|
||||
return utils.read_file(path)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
return None
|
||||
|
||||
|
||||
@add_handler('help')
|
||||
def qute_help(url):
|
||||
"""Handler for qute://help."""
|
||||
@ -373,22 +390,7 @@ def qute_help(url):
|
||||
try:
|
||||
data = utils.read_file(path)
|
||||
except OSError:
|
||||
# No .html around, let's see if we find the asciidoc
|
||||
asciidoc_path = path.replace('.html', '.asciidoc')
|
||||
asciidoc_paths = [asciidoc_path]
|
||||
if asciidoc_path.startswith('html/doc/'):
|
||||
asciidoc_paths += [asciidoc_path.replace('html/doc/', '../doc/help/'),
|
||||
asciidoc_path.replace('html/doc/', '../doc/')]
|
||||
|
||||
asciidoc = None
|
||||
|
||||
for path in asciidoc_paths:
|
||||
try:
|
||||
asciidoc = utils.read_file(path)
|
||||
except OSError:
|
||||
pass
|
||||
else:
|
||||
break
|
||||
asciidoc = _asciidoc_fallback_path(path)
|
||||
|
||||
if asciidoc is None:
|
||||
raise
|
||||
|
Loading…
Reference in New Issue
Block a user