浏览代码

minor fixes

nico 8 年之前
父节点
当前提交
1adbb2dfec

+ 5 - 7
core/ConfigurationManager/BrainLoader.py

@@ -1,16 +1,14 @@
 from YAMLLoader import YAMLLoader
 
-class BrainLoader(YAMLLoader):
+FILE_NAME = "brain.yml"
 
-    FILE_NAME = "brain.yml"
 
-    def __init__(self):
-        self.fileName =  self.FILE_NAME
-        self.filePath = "../../" + self.fileName
-        YAMLLoader.__init__(self, self.filePath)
+class BrainLoader(YAMLLoader):
 
-    def __init__(self, filename):
+    def __init__(self, filename=None):
         self.fileName = filename
+        if filename is None:
+            self.fileName = FILE_NAME
         self.filePath = "../../" + self.fileName
         YAMLLoader.__init__(self, self.filePath)
 

+ 5 - 5
core/ConfigurationManager/ConfigurationManager.py

@@ -1,11 +1,11 @@
 from BrainLoader import BrainLoader
 from SettingLoader import SettingLoader
 
-class ConfigurationManager() :
 
-    BRAIN_FILE_NAME = "brain.yml"
-    SETTING_FILE_NAME = "settings.yml"
+class ConfigurationManager:
 
     def __init__(self):
-        self.brainLoader = BrainLoader(self.BRAIN_FILE_NAME)
-        self.settingLoader = SettingLoader(self.SETTING_FILE_NAME)
+        BRAIN_FILE_NAME = "brain.yml"
+        SETTING_FILE_NAME = "settings.yml"
+        self.brainLoader = BrainLoader(BRAIN_FILE_NAME)
+        self.settingLoader = SettingLoader(SETTING_FILE_NAME)

+ 6 - 8
core/ConfigurationManager/SettingLoader.py

@@ -1,18 +1,16 @@
 from YAMLLoader import YAMLLoader
 
-class SettingLoader(YAMLLoader) :
+FILE_NAME = "settings.yml"
 
-    FILE_NAME = "settings.yml"
 
-    def __init__(self):
-        self.fileName =  self.FILE_NAME
-        self.filePath = "../../" + self.fileName
-        YAMLLoader.__init__(self, self.filePath)
+class SettingLoader(YAMLLoader):
 
-    def __init__(self, filename):
+    def __init__(self, filename=None):
         self.fileName = filename
+        if filename is None:
+            self.fileName = FILE_NAME
         self.filePath = "../../" + self.fileName
         YAMLLoader.__init__(self, self.filePath)
 
     def get_config(self):
-        return YAMLLoader.get_config(self)
+        return YAMLLoader.get_config(self)

+ 5 - 4
core/ConfigurationManager/YAMLLoader.py

@@ -1,17 +1,18 @@
 import os
 import yaml
 
-class YAMLLoader() :
 
-    def __init__(self, file):
-        self.file = file
+class YAMLLoader:
+
+    def __init__(self, yaml_file):
+        self.file = yaml_file
 
     def get_config(self):
         """
         Load settings file
         :return: cfg : the configuration file
         """
-        # Load settings. Will be used to convert slot number into GPIO pin number
+        # Load settings.
         __location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
         with open(os.path.join(__location__, self.file)) as ymlfile:
             cfg = yaml.load(ymlfile)

+ 1 - 1
core/OrderAnalyser.py

@@ -10,7 +10,7 @@ class OrderAnalyser:
         """
         self.main_controller = main_controller
         self.order = order
-        self.brain = main_controller.conf.brainLoader.get_config() # Bouh ! pas beau !
+        self.brain = main_controller.conf.brainLoader.get_config()
         print "Receiver order: %s" % self.order
 
     def start(self):