Commit 48ea9d1b authored by Fabrice  ALLAIN's avatar Fabrice ALLAIN
Browse files

Refactored part of ariaecsettings

parent ee28ce7f
......@@ -110,9 +110,9 @@ celerybeat-schedule
# Environments
################################################################################
.env
.venv
.venv*
env/
venv/
venv*/
ENV/
# Spyder project settings
......
......@@ -491,7 +491,6 @@ class AriaEcCommands(object):
LOG.info("Initialize settings")
settings = AriaEcSettings(self.args.command)
LOG.debug("Loading default config file")
settings.load_config(self.default_confile, pkg=True)
if self.args.conf_file:
LOG.info("Updating settings according to config file")
settings.load_config(self.args.conf_file)
......
......@@ -46,8 +46,9 @@ class Settings(object):
self.configfile = ''
for section in self._sections:
setattr(self, section, Setting())
self.load_config()
def load_config(self, configpath, pkg=False):
def load_config(self, configpath="conf/config.ini", pkg=True):
"""
Use ConfigParser module to load config sections
......
......@@ -32,8 +32,11 @@ from future.moves.collections import UserDict
from .ariabase import AriaBaseClass, YES, NO, GZIP
from .TypeChecking import *
from .tools import make_block
from logging import getLogger
NOT_INIT = '<not initialized>'
LOG = getLogger(__name__)
class EntityError(Exception):
......@@ -70,6 +73,7 @@ class Entity:
def set_default_value(self, v):
LOG.debug("Check validity of value %s", v)
try:
self.validate(v)
......@@ -125,8 +129,8 @@ class Entity:
return 0
def validate(self, value):
LOG.debug("Validity of value %s: %s", value, self._is_valid(value))
if not self._is_valid(value):
err_msg = self.getErrorMessage(value)
if err_msg is None:
......@@ -667,6 +671,7 @@ class Settings(UserDict, AriaBaseClass):
self.update(default_settings)
for key, value in self.create_default_values().items():
print(key, value)
entity = self.getEntity(key)
entity.set_default_value(value)
......@@ -726,6 +731,8 @@ class Settings(UserDict, AriaBaseClass):
def getEntity(self, key):
LOG.debug("Get entity %s", key)
check_string(key)
if key not in self.keys():
......
......@@ -26,9 +26,12 @@ $Author: bardiaux $
$Revision: 1.1.1.1 $
$Date: 2010/03/23 15:27:24 $
"""
from __future__ import absolute_import, division, print_function
from numpy import zeros as _zeros
import numpy
import logging
from numpy import zeros as _zeros
FLOAT = 'FLOAT'
FLOAT64 = 'FLOAT64'
......@@ -54,9 +57,10 @@ TYPES = {type(0.): FLOAT,
type(None): NONE,
type(True): BOOL,
type(False): BOOL}
TYPES.update(dict((v, k) for k, v in TYPES.items()))
LOG = logging.getLogger(__name__)
# TODO [FALLAIN] code below doesn't works with python3
# for python_type, my_type in TYPES.items():
# TYPES[my_type] = python_type
......@@ -81,6 +85,7 @@ class TypeChecker:
def is_type(self, token, name):
LOG.debug("Check %s type of %s", name, token)
t = type(token)
try:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment