Browse Source

metaclass fixes

Julien Schueller 8 years ago
parent
commit
c6f0aaf356

+ 3 - 3
Tests/test_singleton.py

@@ -1,15 +1,15 @@
 import unittest
+import sys
+from six import with_metaclass
 
 from kalliope.core.Models import Singleton
 
 
-class MyClass(object):
-    __metaclass__ = Singleton
+class MyClass(with_metaclass(Singleton, object)):
 
     def __init__(self):
         self.value = "test"
 
-
 class TestSingleton(unittest.TestCase):
 
     def setUp(self):

+ 2 - 2
kalliope/core/ConfigurationManager/BrainLoader.py

@@ -1,6 +1,7 @@
 import inspect
 import logging
 import os
+from six import with_metaclass
 
 from .YAMLLoader import YAMLLoader
 from kalliope.core.Utils import Utils
@@ -23,11 +24,10 @@ class BrainNotFound(Exception):
     pass
 
 
-class BrainLoader(object):
+class BrainLoader(with_metaclass(Singleton, object)):
     """
     This Class is used to get the brain YAML and the Brain as an object
     """
-    __metaclass__ = Singleton
 
     def __init__(self, file_path=None):
         sl = SettingLoader()

+ 2 - 2
kalliope/core/ConfigurationManager/SettingLoader.py

@@ -1,5 +1,6 @@
 import logging
 import os
+from six import with_metaclass
 
 from .YAMLLoader import YAMLLoader
 from kalliope.core.Models.Resources import Resources
@@ -45,11 +46,10 @@ class SettingNotFound(Exception):
     pass
 
 
-class SettingLoader(object):
+class SettingLoader(with_metaclass(Singleton, object)):
     """
     This Class is used to get the Settings YAML and the Settings as an object
     """
-    __metaclass__ = Singleton
 
     def __init__(self, file_path=None):
         self.file_path = file_path