ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxm...@apache.org
Subject incubator-ariatosca git commit: review 2 [Forced Update!]
Date Tue, 31 Jan 2017 11:41:50 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-66-Convert-custom-parser-fields-into-sqla-based-fields 05b7a2559 -> ea5add2e0
(forced update)


review 2


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/ea5add2e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/ea5add2e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/ea5add2e

Branch: refs/heads/ARIA-66-Convert-custom-parser-fields-into-sqla-based-fields
Commit: ea5add2e0db27832826e9748fe158e343c21764f
Parents: 57dcaa8
Author: mxmrlv <mxmrlv@gmail.com>
Authored: Tue Jan 31 13:24:47 2017 +0200
Committer: mxmrlv <mxmrlv@gmail.com>
Committed: Tue Jan 31 13:41:41 2017 +0200

----------------------------------------------------------------------
 aria/storage/type.py | 35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ea5add2e/aria/storage/type.py
----------------------------------------------------------------------
diff --git a/aria/storage/type.py b/aria/storage/type.py
index a713d9c..6b3406d 100644
--- a/aria/storage/type.py
+++ b/aria/storage/type.py
@@ -177,20 +177,20 @@ class _MutableList(mutable.MutableList):
         except ValueError as e:
             raise exceptions.StorageError('SQL Storage error: {0}'.format(str(e)))
 
-StrictDictID = namedtuple('StrictDictID', 'key_cls, value_cls')
-StrictValue = namedtuple('StrictValue', 'type_cls, listener_cls')
+_StrictDictID = namedtuple('_StrictDictID', 'key_cls, value_cls')
+_StrictValue = namedtuple('_StrictValue', 'type_cls, listener_cls')
 
 
 class _StrictDict(object):
     """
     This entire class functions as a factory for strict dicts and their listeners.
-    No type class, and no listener type class is created (and associated) more than once.
If a
-    relevant type class exists it is returned.
+    No type class, and no listener type class is created more than once. If a relevant type
class
+    exists it is returned.
     """
     _strict_map = {}
 
     def __call__(self, key_cls=None, value_cls=None):
-        strict_dict_map_key = StrictDictID(key_cls=key_cls, value_cls=value_cls)
+        strict_dict_map_key = _StrictDictID(key_cls=key_cls, value_cls=value_cls)
         if strict_dict_map_key not in self._strict_map:
             # Creating the type class itself. this class would be returned (used by the sqlalchemy
             # Column).
@@ -199,17 +199,16 @@ class _StrictDict(object):
                 (Dict, ),
                 {}
             )
-            # Creating the type listening class and associating it with the newly created
type.
-            # The new class inherits from both the _MutableList class and the _StrictListMixin,
+            # Creating the type listening class.
+            # The new class inherits from both the _MutableDict class and the _StrictDictMixin,
             # while setting the necessary _key_cls and _value_cls as class attributes.
             listener_cls = type(
                 'StrictMutableDict_{0}_{1}'.format(key_cls.__name__, value_cls.__name__),
                 (_StrictDictMixin, _MutableDict),
                 {'_key_cls': key_cls, '_value_cls': value_cls}
             )
-            listener_cls.associate_with(strict_dict_cls)
-            self._strict_map[strict_dict_map_key] = StrictValue(type_cls=strict_dict_cls,
-                                                                listener_cls=listener_cls)
+            self._strict_map[strict_dict_map_key] = _StrictValue(type_cls=strict_dict_cls,
+                                                                 listener_cls=listener_cls)
 
         return self._strict_map[strict_dict_map_key].type_cls
 
@@ -218,9 +217,9 @@ StrictDict = _StrictDict()
 
 class _StrictList(object):
     """
-    This entire class functions as a factory for strict dicts and their listeners.
-    No type class, and no listener type class is created (and associated) more than once.
If a
-    relevant type class exists it is returned.
+    This entire class functions as a factory for strict lists and their listeners.
+    No type class, and no listener type class is created more than once. If a relevant type
class
+    exists it is returned.
     """
     _strict_map = {}
 
@@ -234,7 +233,7 @@ class _StrictList(object):
                 (List, ),
                 {}
             )
-            # Creating the type listening class and associating it with the newly created
type.
+            # Creating the type listening class.
             # The new class inherits from both the _MutableList class and the _StrictListMixin,
             # while setting the necessary _item_cls as class attribute.
             listener_cls = type(
@@ -242,8 +241,8 @@ class _StrictList(object):
                 (_StrictListMixin, _MutableList),
                 {'_item_cls': item_cls}
             )
-            self._strict_map[item_cls] = StrictValue(type_cls=strict_list_cls,
-                                                     listener_cls=listener_cls)
+            self._strict_map[item_cls] = _StrictValue(type_cls=strict_list_cls,
+                                                      listener_cls=listener_cls)
 
         return self._strict_map[item_cls].type_cls
 
@@ -260,14 +259,14 @@ def _mutable_association_listener(mapper, cls):
     for prop in mapper.column_attrs:
         column_type = prop.columns[0].type
         # Dict Listeners
-        if any(isinstance(column_type, v) for v in strict_dict_type_to_listener):
+        if type(column_type) in strict_dict_type_to_listener:
             strict_dict_type_to_listener[type(column_type)].associate_with_attribute(
                 getattr(cls, prop.key))
         elif isinstance(column_type, Dict):
             _MutableDict.associate_with_attribute(getattr(cls, prop.key))
 
         # List Listeners
-        if any(isinstance(column_type, v) for v in strict_list_type_to_listener):
+        if type(column_type) in strict_list_type_to_listener:
             strict_list_type_to_listener[type(column_type)].associate_with_attribute(
                 getattr(cls, prop.key))
         elif isinstance(column_type, List):


Mime
View raw message