mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-12 07:57:22 +00:00
Skip lzma/xz manpages if lzma module not available
Skip man pages compressed with lzma/xz if the lzma module is not available; also print a corresponding diagnostic message.
This commit is contained in:
parent
4856567a2a
commit
fc7c489ab6
1 changed files with 10 additions and 2 deletions
|
@ -20,10 +20,14 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|||
import string, sys, re, os.path, bz2, gzip, traceback, getopt, errno, codecs
|
||||
from deroff import Deroffer
|
||||
|
||||
lzma_available = True
|
||||
try:
|
||||
import backports.lzma as lzma
|
||||
try:
|
||||
import backports.lzma as lzma
|
||||
except ImportError:
|
||||
import lzma
|
||||
except ImportError:
|
||||
import lzma
|
||||
lzma_available = False
|
||||
|
||||
# Whether we're Python 3
|
||||
IS_PY3 = sys.version_info[0] >= 3
|
||||
|
@ -727,6 +731,8 @@ def parse_manpage_at_path(manpage_path, output_directory):
|
|||
manpage = fd.read()
|
||||
if IS_PY3: manpage = manpage.decode('latin-1')
|
||||
elif manpage_path.endswith('.xz') or manpage_path.endswith('.lzma'):
|
||||
if not lzma_available:
|
||||
return
|
||||
fd = lzma.LZMAFile(str(manpage_path), 'r')
|
||||
manpage = fd.read()
|
||||
if IS_PY3: manpage = manpage.decode('latin-1')
|
||||
|
@ -829,6 +835,8 @@ def parse_and_output_man_pages(paths, output_directory, show_progress):
|
|||
last_progress_string_length = 0
|
||||
if show_progress and not WRITE_TO_STDOUT:
|
||||
print("Parsing man pages and writing completions to {0}".format(output_directory))
|
||||
if not lzma_available and not WRITE_TO_STDOUT:
|
||||
print('"lzma" module not available, cannot parse man pages compressed with xz or lzma')
|
||||
for manpage_path in paths:
|
||||
index += 1
|
||||
|
||||
|
|
Loading…
Reference in a new issue