Skip to content

Commit

Permalink
merging branches
Browse files Browse the repository at this point in the history
  • Loading branch information
fit-alessandro-berti committed Oct 4, 2023
2 parents fd2d481 + b456717 commit 4582ee4
Show file tree
Hide file tree
Showing 21 changed files with 172 additions and 117 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
# Changelog of pm4py


## pm4py 2.7.7 (2023.09.22)

### Added
* 056d9e5714e2ad0a21fbcac0725ea4fb7aae260c
* encoding specification in pm4py.read and pm4py.write classes

### Changed
* f81d62ad8dc8a76aabdf90763a8bd8b8e2ea2aa9
* fixed compatibility with Python 3.12 (removed deprecation warnings)

### Deprecated

### Fixed

### Removed

### Other


---


## pm4py 2.7.6 (2023.08.28)

### Added
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# The short X.Y version
version = '2.7'
# The full version, including alpha/beta/rc tags
release = '2.7.6'
release = '2.7.7'

# -- General configuration ---------------------------------------------------

Expand Down
6 changes: 3 additions & 3 deletions pm4py/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
'''

__name__ = 'pm4py'
VERSION = '2.7.6'
VERSION = '2.7.7'
__version__ = VERSION
__doc__ = 'Process mining for Python'
__author__ = 'Fraunhofer Institute for Applied Technology'
__author__ = 'Fraunhofer Institute for Applied Information Technology FIT'
__author_email__ = '[email protected]'
__maintainer__ = 'Fraunhofer Institute for Applied Technology'
__maintainer__ = 'Fraunhofer Institute for Applied Information Technology FIT'
__maintainer_email__ = "[email protected]"
13 changes: 10 additions & 3 deletions pm4py/objects/dfg/exporter/variants/classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
from enum import Enum
from collections import Counter
from pm4py.objects.dfg.utils import dfg_utils
from pm4py.util.constants import DEFAULT_ENCODING
from pm4py.util import constants


class Parameters(Enum):
START_ACTIVITIES = "start_activities"
END_ACTIVITIES = "end_activities"
ENCODING = "encoding"


def export_line_by_line(dfg, parameters=None):
Expand Down Expand Up @@ -91,13 +92,16 @@ def apply(dfg, output_path, parameters=None):
Parameters of the algorithm, including:
Parameters.START_ACTIVITIES => Start activities of the DFG
Parameters.END_ACTIVITIES => End activities of the DFG
Parameters.ENCODING => The encoding to be used (default: utf-8)
"""
if parameters is None:
parameters = {}

encoding = exec_utils.get_param_value(Parameters.ENCODING, parameters, constants.DEFAULT_ENCODING)

F = open(output_path, "wb")
for row in export_line_by_line(dfg, parameters=parameters):
F.write(row.encode(DEFAULT_ENCODING))
F.write(row.encode(encoding))
F.close()


Expand All @@ -113,6 +117,7 @@ def export_as_string(dfg, parameters=None):
Parameters of the algorithm, including:
Parameters.START_ACTIVITIES => Start activities of the DFG
Parameters.END_ACTIVITIES => End activities of the DFG
Parameters.ENCODING => The encoding to be used (default: utf-8)
Returns
--------------
Expand All @@ -122,10 +127,12 @@ def export_as_string(dfg, parameters=None):
if parameters is None:
parameters = {}

encoding = exec_utils.get_param_value(Parameters.ENCODING, parameters, constants.DEFAULT_ENCODING)

ret = []
for row in export_line_by_line(dfg, parameters=parameters):
ret.append(row)
ret = "".join(ret)
ret = ret.encode(DEFAULT_ENCODING)
ret = ret.encode(encoding)

return ret
31 changes: 12 additions & 19 deletions pm4py/objects/dfg/importer/variants/classic.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
'''
This file is part of PM4Py (More Info: https://pm4py.fit.fraunhofer.de).
PM4Py is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
PM4Py is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PM4Py. If not, see <https://www.gnu.org/licenses/>.
'''
from pm4py.util import constants
from pm4py.util import constants, exec_utils
from io import StringIO
from enum import Enum


class Parameters(Enum):
ENCODING = "encoding"


def import_dfg_from_rows(rows, parameters=None):
Expand Down Expand Up @@ -111,7 +100,9 @@ def apply(file_path, parameters=None):
if parameters is None:
parameters = {}

F = open(file_path, "r")
encoding = exec_utils.get_param_value(Parameters.ENCODING, parameters, constants.DEFAULT_ENCODING)

F = open(file_path, "r", encoding=encoding)
content = F.readlines()
F.close()

Expand Down Expand Up @@ -141,7 +132,9 @@ def import_dfg_from_string(dfg_string, parameters=None):
if parameters is None:
parameters = {}

encoding = exec_utils.get_param_value(Parameters.ENCODING, parameters, constants.DEFAULT_ENCODING)

if type(dfg_string) is bytes:
dfg_string = dfg_string.decode(constants.DEFAULT_ENCODING)
dfg_string = dfg_string.decode(encoding)

return import_dfg_from_rows(StringIO(dfg_string).readlines(), parameters=parameters)
Loading

0 comments on commit 4582ee4

Please sign in to comment.