浏览代码

metaclass fixes

Julien Schueller 8 年之前
父节点
当前提交
c6f0aaf356

+ 3 - 3
Tests/test_singleton.py

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

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

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

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

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