from opyenxes.data_in.XMxmlParser import XMxmlParser
import gzip
[docs]class XMxmlGZIPParser(XMxmlParser):
"""Parser for the compressed MXML format for event logs (deprecated).
:param factory: The factory to use for XES model building.
:type factory: `XFactory`
"""
def __init__(self, factory=None):
super().__init__(factory)
[docs] def can_parse(self, file):
"""Checks whether this parser can handle the given file.
:param file: path of the file to check against parser.
:type file: str
:return: Whether this parser can handle the given file.
:rtype: bool
"""
return super().ends_with_ignore_case(file, ".mxml.gz")
[docs] def parse(self, file):
"""Parses a log from the given input stream, which is supposed to
deliver an XES log in XML representation.
:param file: file generated by the function 'open(path)', which is
supposed to deliver an XES log in XML representation.
:type file: _io.TextIOWrapper
:return: The parsed log.
:rtype: list[`XLog`]
"""
path = file.name
file.close()
with gzip.open(path) as file:
return super().parse(file)