aboutsummaryrefslogtreecommitdiffhomepage
path: root/share
diff options
context:
space:
mode:
authorGravatar Marc Joliet <marcec@gmx.de>2013-09-26 17:15:53 +0200
committerGravatar Marc Joliet <marcec@gmx.de>2013-10-17 12:12:04 +0200
commit6de9a9258207ca38d320cc0bc3c3653deef12d7d (patch)
tree8a2a7df4802c411c1dd6f9efa4cb222e6017268a /share
parent1c8c9a10b5d7d42731befa6ef2eb9ba60b4c7f1d (diff)
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.
Diffstat (limited to 'share')
-rwxr-xr-xshare/tools/create_manpage_completions.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/share/tools/create_manpage_completions.py b/share/tools/create_manpage_completions.py
index f12d5c14..41fae2ed 100755
--- a/share/tools/create_manpage_completions.py
+++ b/share/tools/create_manpage_completions.py
@@ -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
from deroff import Deroffer
-lzma_printed_msg = False
lzma_available = True
try:
try:
@@ -715,7 +714,7 @@ def parse_manpage_at_path(manpage_path, output_directory):
filename = os.path.basename(manpage_path)
# Clear diagnostics
- global diagnostic_indent, lzma_printed_msg
+ global diagnostic_indent
diagnostic_output[:] = []
diagnostic_indent = 0
@@ -733,11 +732,6 @@ def parse_manpage_at_path(manpage_path, output_directory):
if IS_PY3: manpage = manpage.decode('latin-1')
elif manpage_path.endswith('.xz') or manpage_path.endswith('.lzma'):
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
fd = lzma.LZMAFile(str(manpage_path), 'r')
manpage = fd.read()
@@ -841,6 +835,15 @@ 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))
+
+ 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:
index += 1