Guard against files that don't end in .[1...9]

It seems smart to only let files be parsed that are clearly
manpage files. Other files wouldn't be openend by man so
I think it is safe to guess that only these files are man
pages.
This commit is contained in:
Alexander Hedges 2015-11-07 18:12:03 +01:00 committed by ridiculousfish
parent 8d97a85834
commit 22493c9df8

View File

@ -736,12 +736,14 @@ def parse_manpage_at_path(manpage_path, output_directory):
fd = lzma.LZMAFile(str(manpage_path), 'r')
manpage = fd.read()
if IS_PY3: manpage = manpage.decode('latin-1')
else:
elif manpage_path.endswith((".1", ".2", ".3", ".4", ".5", ".6", ".7", ".8", ".9")):
if IS_PY3:
fd = open(manpage_path, 'r', encoding='latin-1')
else:
fd = open(manpage_path, 'r')
manpage = fd.read()
else:
return
fd.close()
manpage = str(manpage)