def extractall(patt, filename, tag=0, conv=None, encoding='utf-8'):
"""Extract all values from the capturing group ``tag`` of a matching regex
``patt`` in the file ``filename``.
:arg patt: The regex pattern to search.
Any standard Python `regular expression
<https://docs.python.org/3.6/library/re.html#regular-expression-syntax>`_
is accepted.
:arg filename: The name of the file to examine.
:arg encoding: The name of the encoding used to decode the file.
:arg tag: The regex capturing group to be extracted.
Group ``0`` refers always to the whole match.
Since the file is processed line by line, this means that group ``0``
returns the whole line that was matched.
:arg conv: A callable that takes a single argument and returns a new value.
If provided, it will be used to convert the extracted values before
returning them.
:returns: A list of the extracted values from the matched regex.
:raises reframe.core.exceptions.SanityError: In case of errors.
"""
return list(evaluate(x)
for x in extractiter(patt, filename, tag, conv, encoding))
评论列表
文章目录