Handle empty __doc__ when checking lttng module version

Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
This commit is contained in:
Christophe Bedard 2020-03-01 15:57:38 -05:00
parent 9450bfeea9
commit 934a0899b9

View file

@ -41,7 +41,10 @@ def get_version() -> Union[StrictVersion, None]:
:return: the version as a StrictVersion object, or `None` if it cannot be extracted :return: the version as a StrictVersion object, or `None` if it cannot be extracted
""" """
doc_lines = lttng.__doc__.split('\n') doc_lines = lttng.__doc__.split('\n')
first_line: str = list(filter(None, doc_lines))[0] filtered_doc_lines: List[str] = list(filter(None, doc_lines))
if len(filtered_doc_lines) == 0:
return None
first_line = filtered_doc_lines[0]
version_string = first_line.split(' ')[1] version_string = first_line.split(' ')[1]
if not re.compile(r'^[0-9]+\.[0-9]+\.[0-9]+$').match(version_string): if not re.compile(r'^[0-9]+\.[0-9]+\.[0-9]+$').match(version_string):
return None return None