Skip to content

Commit

Permalink
Merge branch 'release/0.14.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
aranega committed Nov 1, 2023
2 parents 889fdbb + 9a7453f commit 92c1c0c
Show file tree
Hide file tree
Showing 15 changed files with 102 additions and 59 deletions.
4 changes: 3 additions & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.13.2
current_version = 0.14.0
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+))?
Expand All @@ -16,3 +16,5 @@ values =
[bumpversion:file:pyecore/__init__.py]

[bumpversion:file:setup.py]

[bumpversion:file:doc/source/conf.py]
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "pypy-3.7", "pypy-3.8"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "pypy-3.7", "pypy-3.8", "pypy-3.9", "pypy-3.10"]

steps:
- uses: actions/checkout@v3
Expand Down
61 changes: 41 additions & 20 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
Changelog
---------

0.14.0
++++++

**Features**

- Add json resource in global registry. The json resource is now registered by default, it's not necessary anymore to explicitly register it
- Add argument passing to ``Resource`` instances from a ``ResourceSet``. This feature allows the user to pass arguments to a resource when using ``get_resources`` or ``create_resources`` from a ``ResourceSet``.

**Bugfixes**

- Fix issue with file protocol starting with ``file:/`` (Thanks `@jameswpm <https://github.com/jameswpm>`_ for the ticket and the discussion).
- Fix deserialization of boolean in json resources.
- Fix enum literals serialization in json resources. Depending on the "level" where's defined the EnumerationLiteral, the serialization should be different: (1) if serialization happens at the metamodel level, all the internal information of the EnumerationLiteral should be written in the json file, (2) if serialization happens at the model level (a model uses a literal defined in the metamodel it conforms to), the EnumerationLiteral should be serialized only by its name.

**Miscellaneous**

- Pass from "beta" to "stable".
- Add pypy 3.9 and 3.10 as target test Python VM.
- Fix CHANGELOG.rst.


0.13.2
++++++

**Bugfixes**

- Fix Elements not loaded in to ``EList``
- Update ResourcePython for CVE-2023-37271
- Fix Elements not loaded in to ``EList``.
- Update ResourcePython for CVE-2023-37271.

0.13.1
++++++
Expand All @@ -33,8 +54,8 @@ Changelog
**Bugfixes**

- Fix issue with (de)serialization of references in JSON.
- Fix missing f-string in JSON resources. Thanks `@pablo-campillo https://github.com/pablo-campillo`_ for the pull request.
- Fix ``URI.relative_from_me`` method for resources (de)serialization. Thanks `@jamoralp https://github.com/jamoralp`_ for the pull request.
- Fix missing f-string in JSON resources. Thanks `@pablo-campillo <https://github.com/pablo-campillo>`_ for the pull request.
- Fix ``URI.relative_from_me`` method for resources (de)serialization. Thanks `@jamoralp <https://github.com/jamoralp>`_ for the pull request.
- Fix missing import of ``chain``. Thanks `@ubmarco <https://github.com/ubmarco>`_ for the pull request.


Expand All @@ -49,7 +70,7 @@ Changelog

**Bugfixes**

- Fix bad deserialization of float values in JSON for value like "42" (no dot). Thanks `@pablo-campillo https://github.com/pablo-campillo`_ for the issue.
- Fix bad deserialization of float values in JSON for value like "42" (no dot). Thanks `@pablo-campillo <https://github.com/pablo-campillo>`_ for the issue.


0.12.1
Expand Down Expand Up @@ -88,17 +109,17 @@ Changelog

**Bugfixes**

- Fix issue with ``xmi:type`` and ``xsi:type`` for mixed XMI. In some XMI files, the field related to type can be mixed and sometimes prefixed by ``xmi`` or ``xsi``. The flip-flop between the two mode was only performed once in the previous algorithm, now it is adaptive. Thanks `@aacebedo https://github.com/aacebedo`_ for the pull request.
- Fix issue with ``xmi:type`` and ``xsi:type`` for mixed XMI. In some XMI files, the field related to type can be mixed and sometimes prefixed by ``xmi`` or ``xsi``. The flip-flop between the two mode was only performed once in the previous algorithm, now it is adaptive. Thanks `@aacebedo <https://github.com/aacebedo>`_ for the pull request.

- Fix missing ``EShortObject``. Thanks `@aacebedo https://github.com/aacebedo`_ for the pull request.
- Fix missing ``EShortObject``. Thanks `@aacebedo <https://github.com/aacebedo>`_ for the pull request.

- Fix MRO problem when updating inheritance. The previous algorithm was not taking into account dynamic additions of inheritance relationship. Thanks `@mn3mos https://github.com/mn3mos`_ for the issue.

- Fix issue on metamodel with ``@abstract`` decorator.

- Fix issue with ``EEnumLiteral`` serialization for JSON resource. Thanks `@jinhu https://github.com/jinhu`_ and Marc Hamilton for the issues and the pull request.
- Fix issue with ``EEnumLiteral`` serialization for JSON resource. Thanks `@jinhu <https://github.com/jinhu>`_ and Marc Hamilton for the issues and the pull request.

- Fix issue with clearing non unique collections. A set operation was performed on the collection to safely iterate on it, implying that some elements were forget during a full clear. Thanks `@ewoudwerkman https://github.com/ewoudwerkman`_ for the issue.
- Fix issue with clearing non unique collections. A set operation was performed on the collection to safely iterate on it, implying that some elements were forget during a full clear. Thanks `@ewoudwerkman <https://github.com/ewoudwerkman>`_ for the issue.

**Miscellaneous**

Expand All @@ -108,17 +129,17 @@ Changelog

- Improve eType computation for speed.

- Disabling resolve cache for resources when a resource had been properly load. Thanks `@ewoudwerkman https://github.com/ewoudwerkman`_ for the suggestion.
- Disabling resolve cache for resources when a resource had been properly load. Thanks `@ewoudwerkman <https://github.com/ewoudwerkman>`_ for the suggestion.


0.11.7
++++++

**Bugfixes**

- Fix issue with MRO calculation. This happend when the Ecore inheritence tree is not compatible with Python C3 linearization algorithm. Thanks `@mn3mos https://github.com/mn3mos`_ for the issue.
- Fix issue with MRO calculation. This happend when the Ecore inheritence tree is not compatible with Python C3 linearization algorithm. Thanks `@mn3mos <https://github.com/mn3mos>`_ for the issue.

- Fix non-serializable ``EDataType`` ``instanceClassName``. The property was not serialized by the XMI resource. Thanks `@4ekin https://github.com/4ekin`_ for the pull requests.
- Fix non-serializable ``EDataType`` ``instanceClassName``. The property was not serialized by the XMI resource. Thanks `@4ekin <https://github.com/4ekin>`_ for the pull requests.


0.11.6
Expand All @@ -127,7 +148,7 @@ Changelog
**Bugfixes**

- Fix issue with new ``ordered_set`` version. This new version removed some
parts functions about iterables. Thanks `@fgro93 <https://github.com/fgro93>`_ for the issue.
parts functions about iterables. Thanks `@fgro93 <https://github.com/fgro93>`_ for the issue.


0.11.5
Expand All @@ -138,7 +159,7 @@ parts functions about iterables. Thanks `@fgro93 <https://github.com/fgro93>`_
- Fix issue with default value computation using ``defaultValueLiteral``. PyEcore
was providing it's own "default value" mechanism that had an higher priority than
the one usually used by EMF. This resulted in the default value not being computed
correctly. Thanks `@annighoefer <https://github.com/annighoefer>`_ for the PR
correctly. Thanks `@annighoefer <https://github.com/annighoefer>`_ for the PR
and pointing out the issue.


Expand Down Expand Up @@ -177,7 +198,7 @@ resolve.
**Bugfixes**

- Fix change of container of an objet when the reference is single.
Thanks `@annighoefer <https://github.com/annighoefer>`_ for the fix!
Thanks `@annighoefer <https://github.com/annighoefer>`_ for the fix!
The issue came when an object was moved from a single relationship container to another one from the same class, the contained object was contained by the two containers.

- Fix Fix root element id not added to uuid_dict if its feature.ID is set.
Expand Down Expand Up @@ -211,7 +232,7 @@ Each new converter can be isolated by ``ResourceSet`` or globaly for every

**Bugfixes**

- Fix empty valued id attributes to be used as keys in reference links when saving a resource (Thanks `@annighoefer <https://github.com/annighoefer>`_!).
- Fix empty valued id attributes to be used as keys in reference links when saving a resource (Thanks `@annighoefer <https://github.com/annighoefer>`_!).

**Miscellaneous**

Expand All @@ -229,7 +250,7 @@ This patch provides a solution to the issues with time zone information in dates
It makes the parsing and serialization of dates compatible with how EMF currently
handles dates and UTC offsets.

- Fix xmi empty references refer to root (Thanks `@annighoefer <https://github.com/annighoefer>`_!).
- Fix xmi empty references refer to root (Thanks `@annighoefer <https://github.com/annighoefer>`_!).
Deleted objects that were also referred by non-containment references elsewhere were serialized in xmi
as `ref=""`, introducing a `BadValueError` when loading the file again as the root of the model was found as reference.
The fix solves the loading issue by skiping empty references.
Expand All @@ -242,7 +263,7 @@ The fix solves the loading issue by skiping empty references.
**Miscellaneous**

- Add custom JSON serializer support
(Thanks `@rodriguez-facundo <https://github.com/rodriguez-facundo>`_ and `@filippometacell <https://github.com/filippometacell>`_!)
(Thanks `@rodriguez-facundo <https://github.com/rodriguez-facundo>`_ and `@filippometacell <https://github.com/filippometacell>`_!)
This support is not yet documented and will perhaps never be.


Expand All @@ -259,10 +280,10 @@ The fix solves the loading issue by skiping empty references.

- Fix issue with XMI serialization for single element container. In those cases
the path towards the object was not well serialized. It results in a false
XMI path which made the produced XMI not usable with Eclipse EMF. (Thanks `@annighoefer <https://github.com/annighoefer>`_!)
XMI path which made the produced XMI not usable with Eclipse EMF. (Thanks `@annighoefer <https://github.com/annighoefer>`_!)

- Prevent ``id`` with spaces from being used. Spaces are used for separating
multiple references to other objects. (Thanks `@annighoefer <https://github.com/annighoefer>`_!)
multiple references to other objects. (Thanks `@annighoefer <https://github.com/annighoefer>`_!)


**Miscellaneous**
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2016-2021, Vincent Aranega
Copyright (c) 2016-2023, Vincent Aranega
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
4 changes: 2 additions & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
# built documents.
#
# The short X.Y version.
version = '0.7.4'
version = '0.14.0'
# The full version, including alpha/beta/rc tags.
release = '0.7.4'
release = '0.14.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 2 additions & 2 deletions doc/source/example/fsm_executable.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _FSM:

Executable Model Example: Fine State Machine
============================================
Executable Model Example: Finite State Machine
==============================================

As an example, this description re-implements the Finite State Machine (FSM) example as
described in the `ALE tutorial page <http://gemoc.org/ale-lang/tutorial.html>`_.
Expand Down
1 change: 1 addition & 0 deletions doc/source/user/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,7 @@ PyEcore how to translate the URIs appropriately.
Dealing with JSON Resources
---------------------------
*Since version 14.0, the JSonResource is registered by default in the global registry, you don't need to register it manually, you can unregister it by removing the "json" extension from the global_registry*
PyEcore is also able to load/save JSON models/metamodels. The JSON format it uses
tries to be close to the one described in the `emfjson-jackson <https://github.com/emfjson/emfjson-jackson>`_ project.
The way the JSON serialization/deserialization works, is similar to XMI resources,
Expand Down
2 changes: 1 addition & 1 deletion pyecore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"""

__version__ = "0.13.2"
__version__ = "0.14.0"
2 changes: 1 addition & 1 deletion pyecore/ecore.py
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ def abstract(cls):

EBoolean = EDataType('EBoolean', bool, False,
to_string=lambda x: str(x).lower(),
from_string=lambda x: x in ['True', 'true'])
from_string=lambda x: x in ['True', 'true'] or x is True)
EBooleanObject = EDataType('EBooleanObject', bool,
to_string=lambda x: str(x).lower(),
from_string=lambda x: x in ['True', 'true'])
Expand Down
2 changes: 2 additions & 0 deletions pyecore/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
global_uri_mapper, global_uri_converter, \
HttpURIConverter, AbstractURIConverter
from . import xmi
from . import json
from .. import ecore as Ecore

# Register basic resource factory
ResourceSet.resource_factory = {'xmi': xmi.XMIResource,
'ecore': xmi.XMIResource,
'json': json.JsonResource,
'*': xmi.XMIResource}

global_registry[Ecore.nsURI] = Ecore
Expand Down
28 changes: 16 additions & 12 deletions pyecore/resources/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from functools import lru_cache
import json
from .resource import Resource
from ..ecore import EObject, EProxy, ECollection, EClass, EEnumLiteral
from ..ecore import EObject, EProxy, ECollection, EClass, EEnumLiteral, EStringToStringMapEntry


@unique
Expand Down Expand Up @@ -84,7 +84,7 @@ def object_uri(self, obj):
# resource_uri = self.eResource.uri if obj.eResource else ''
return self._build_path_from(obj)[0]

def _to_ref_from_obj(self, obj, opts=None, use_uuid=None, resource=None):
def _to_ref_from_obj(self, obj, opts=None, use_uuid=None, resource=None, **kwargs):
uri = self.serialize_eclass(obj.eClass)
ref = {'eClass': uri}
ref[self.ref_tag] = self.object_uri(obj)
Expand Down Expand Up @@ -128,20 +128,20 @@ def _to_ref_from_obj(self, obj, opts=None, use_uuid=None, resource=None):
# result.append(write_object)
# return result

def to_dict(self, obj, is_ref=False):
def to_dict(self, obj, is_noncont_ref=False, is_attr=False):
if isinstance(obj, type) and issubclass(obj, EObject):
if is_ref:
if is_noncont_ref:
fun = self._to_ref_from_obj
return fun(obj.eClass, self.options, self.use_uuid, self)
# else:
# cls = obj.python_class
# mapper = next((self.mappers[k] for k in self.mappers
# if issubclass(cls, k)), self.default_mapper)
# fun = mapper.to_dict_from_obj
elif isinstance(obj, EEnumLiteral):
elif isinstance(obj, EEnumLiteral) and is_attr:
return obj.name
elif isinstance(obj, EObject):
if is_ref:
if is_noncont_ref:
fun = self._to_ref_from_obj
else:
cls = obj.eClass.python_class
Expand All @@ -151,10 +151,10 @@ def to_dict(self, obj, is_ref=False):
return fun(obj, self.options, self.use_uuid, self)

elif isinstance(obj, ECollection):
fun = self._to_ref_from_obj if is_ref else self.to_dict
fun = self._to_ref_from_obj if is_noncont_ref else self.to_dict
result = []
for x in obj:
write_object = fun(x)
write_object = fun(x, is_noncont_ref, is_attr)
if write_object is NO_OBJECT:
continue
result.append(write_object)
Expand Down Expand Up @@ -211,12 +211,16 @@ def to_obj(self, d, owning_feature=None, first=False):
ereferences.append((feature, value))
self.process_inst(inst, eattributes)
self.process_inst(inst, containments, owning_feature)
self._load_href[inst] = ereferences
if ereferences:
self._load_href[inst] = ereferences
return inst

def process_inst(self, inst, features, owning_feature=None):
for feature, value in features:
if isinstance(value, dict):
if feature._eType is EStringToStringMapEntry and isinstance(value, dict):
key, val = next(iter(value.items()))
inst.eGet(feature)[key] = val
elif isinstance(value, dict):
element = self.to_obj(value, owning_feature=feature)
inst.eSet(feature, element)
elif isinstance(value, list):
Expand Down Expand Up @@ -252,9 +256,9 @@ def to_dict_from_obj(self, obj, options, use_uuid, resource):
value = obj.eGet(attr)
serialize_default_option = JsonOptions.SERIALIZE_DEFAULT_VALUES
if (not options.get(serialize_default_option, False)
and value == attr.get_default_value()):
and value == attr.get_default_value()):
continue
write_object = resource.to_dict(value, is_ref=is_ref)
write_object = resource.to_dict(value, is_noncont_ref=is_ref, is_attr=attr.is_attribute)
if write_object is not NO_OBJECT:
d[attr._name] = write_object
if use_uuid:
Expand Down
Loading

0 comments on commit 92c1c0c

Please sign in to comment.