Skip to content

Commit

Permalink
Moved tar.gz decompression from single importers to the factory
Browse files Browse the repository at this point in the history
  • Loading branch information
fit-alessandro-berti committed Jan 8, 2019
1 parent 046cdf4 commit f5ca153
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
4 changes: 4 additions & 0 deletions pm4py/objects/log/importer/xes/factory.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pm4py.objects.log.importer.xes.versions import iterparse_xes, python_nonstandard
from pm4py.objects.log.util import string_to_file
from pm4py.objects.log.util import compression

ITERPARSE = "iterparse"
NONSTANDARD = "nonstandard"
Expand Down Expand Up @@ -61,6 +62,9 @@ def import_log(path, parameters=None, variant=ITERPARSE):
log
Trace log object
"""
if path.endswith("gz"):
path = compression.decompress(path)

return VERSIONS[variant](path, parameters=parameters)


Expand Down
3 changes: 0 additions & 3 deletions pm4py/objects/log/importer/xes/versions/iterparse_xes.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ def import_log(filename, parameters=None):
if "max_no_traces_to_import" in parameters:
max_no_traces_to_import = parameters["max_no_traces_to_import"]

if filename.endswith("gz"):
filename = compression.decompress(filename)

context = etree.iterparse(filename, events=['start', 'end'])

log = None
Expand Down
4 changes: 0 additions & 4 deletions pm4py/objects/log/importer/xes/versions/python_nonstandard.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import ciso8601

from pm4py.objects import log as log_lib
from pm4py.objects.log.util import compression
from pm4py.objects.log.util import sorting


Expand Down Expand Up @@ -48,9 +47,6 @@ def import_log(filename, parameters=None):
if "max_no_traces_to_import" in parameters:
max_no_traces_to_import = parameters["max_no_traces_to_import"]

if filename.endswith("gz"):
filename = compression.decompress(filename)

log = log_lib.log.TraceLog()
tracecount = 0
trace = None
Expand Down

0 comments on commit f5ca153

Please sign in to comment.