mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 21:33:09 +00:00
Change the way xz/lzma man pages are detected
This avoids the use of the global and puts the diagnostic message in a self-contained location.
This commit is contained in:
parent
1c8c9a10b5
commit
6de9a92582
1 changed files with 10 additions and 7 deletions
|
@ -20,7 +20,6 @@ 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
|
import string, sys, re, os.path, bz2, gzip, traceback, getopt, errno, codecs
|
||||||
from deroff import Deroffer
|
from deroff import Deroffer
|
||||||
|
|
||||||
lzma_printed_msg = False
|
|
||||||
lzma_available = True
|
lzma_available = True
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
|
@ -715,7 +714,7 @@ def parse_manpage_at_path(manpage_path, output_directory):
|
||||||
filename = os.path.basename(manpage_path)
|
filename = os.path.basename(manpage_path)
|
||||||
|
|
||||||
# Clear diagnostics
|
# Clear diagnostics
|
||||||
global diagnostic_indent, lzma_printed_msg
|
global diagnostic_indent
|
||||||
diagnostic_output[:] = []
|
diagnostic_output[:] = []
|
||||||
diagnostic_indent = 0
|
diagnostic_indent = 0
|
||||||
|
|
||||||
|
@ -733,11 +732,6 @@ def parse_manpage_at_path(manpage_path, output_directory):
|
||||||
if IS_PY3: manpage = manpage.decode('latin-1')
|
if IS_PY3: manpage = manpage.decode('latin-1')
|
||||||
elif manpage_path.endswith('.xz') or manpage_path.endswith('.lzma'):
|
elif manpage_path.endswith('.xz') or manpage_path.endswith('.lzma'):
|
||||||
if not lzma_available:
|
if not lzma_available:
|
||||||
if not lzma_printed_msg:
|
|
||||||
add_diagnostic('A man page is compressed with lzma or xz, but the "lzma" module is not available.'
|
|
||||||
' Skipping. (This message is only printed on the first occurrence.)',
|
|
||||||
NOT_VERBOSE)
|
|
||||||
lzma_printed_msg = True
|
|
||||||
return
|
return
|
||||||
fd = lzma.LZMAFile(str(manpage_path), 'r')
|
fd = lzma.LZMAFile(str(manpage_path), 'r')
|
||||||
manpage = fd.read()
|
manpage = fd.read()
|
||||||
|
@ -841,6 +835,15 @@ def parse_and_output_man_pages(paths, output_directory, show_progress):
|
||||||
last_progress_string_length = 0
|
last_progress_string_length = 0
|
||||||
if show_progress and not WRITE_TO_STDOUT:
|
if show_progress and not WRITE_TO_STDOUT:
|
||||||
print("Parsing man pages and writing completions to {0}".format(output_directory))
|
print("Parsing man pages and writing completions to {0}".format(output_directory))
|
||||||
|
|
||||||
|
man_page_suffixes = set([os.path.splitext(m)[1][1:] for m in paths])
|
||||||
|
lzma_xz_occurs = "xz" in man_page_suffixes or "lzma" in man_page_suffixes
|
||||||
|
if lzma_xz_occurs and not lzma_available:
|
||||||
|
add_diagnostic('At least one man page is compressed with lzma or xz, but the "lzma" module is not available.'
|
||||||
|
' Any man page compressed with either will be skipped.',
|
||||||
|
NOT_VERBOSE)
|
||||||
|
flush_diagnostics(sys.stderr)
|
||||||
|
|
||||||
for manpage_path in paths:
|
for manpage_path in paths:
|
||||||
index += 1
|
index += 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue