Commit 60ae6262 authored by Devaev Maxim's avatar Devaev Maxim

Refactoring

parent 79ddc21a
# -*- coding: utf-8 -*-
import os import os
import ConfigParser import ConfigParser
...@@ -5,6 +7,7 @@ import const ...@@ -5,6 +7,7 @@ import const
import config import config
#####
ConfigDictObject = { ConfigDictObject = {
"service" : { "service" : {
"name" : (const.DEFAULT_CONFIG_SERVICE_NAME, str, None), "name" : (const.DEFAULT_CONFIG_SERVICE_NAME, str, None),
...@@ -14,6 +17,7 @@ ConfigDictObject = { ...@@ -14,6 +17,7 @@ ConfigDictObject = {
} }
#####
class ValidatorError(Exception) : class ValidatorError(Exception) :
pass pass
...@@ -21,6 +25,7 @@ class ValueError(Exception) : ...@@ -21,6 +25,7 @@ class ValueError(Exception) :
pass pass
##### Public #####
def setValue(section, option, value, validator = None, valid_values_list = None) : def setValue(section, option, value, validator = None, valid_values_list = None) :
global ConfigDictObject global ConfigDictObject
......
# -*- coding: utf-8 -*-
MY_NAME = "settingsd" MY_NAME = "settingsd"
PLUGINS_DIR = "plugins" PLUGINS_DIR = "plugins"
CONFIGS_DIR = "configs" CONFIGS_DIR = "configs"
CONFIG_FILE_POSTFIX = ".conf" CONFIG_FILE_POSTFIX = ".conf"
CONFIG_SERVICE_BUS_TYPE_SYSTEM = "system" CONFIG_SERVICE_BUS_TYPE_SYSTEM = "system"
CONFIG_SERVICE_BUS_TYPE_SESSION = "session" CONFIG_SERVICE_BUS_TYPE_SESSION = "session"
CONFIG_VALID_SERVICE_BUS_TYPES_LIST = ( CONFIG_VALID_SERVICE_BUS_TYPES_LIST = (
...@@ -11,8 +15,8 @@ CONFIG_VALID_SERVICE_BUS_TYPES_LIST = ( ...@@ -11,8 +15,8 @@ CONFIG_VALID_SERVICE_BUS_TYPES_LIST = (
CONFIG_SERVICE_BUS_TYPE_SESSION CONFIG_SERVICE_BUS_TYPE_SESSION
) )
DEFAULT_CONFIG_SERVICE_NAME = "org.etersoft.%s" % (MY_NAME) DEFAULT_CONFIG_SERVICE_NAME = "org.etersoft.%s" % (MY_NAME)
DEFAULT_CONFIG_SERVICE_PATH = "/org/etersoft/%s" % (MY_NAME) DEFAULT_CONFIG_SERVICE_PATH = "/org/etersoft/%s" % (MY_NAME)
DEFAULT_CONFIG_SERVICE_BUS_TYPE = CONFIG_SERVICE_BUS_TYPE_SYSTEM DEFAULT_CONFIG_SERVICE_BUS_TYPE = CONFIG_SERVICE_BUS_TYPE_SYSTEM
def __joinItems(separator, first, *others_list) : # -*- coding: utf-8 -*-
##### Public #####
def joinPath(first, *others_list) :
return joinItems("/", first, *others_list)
def joinMethod(first, *others_list) :
return joinItems(".", first, *others_list)
##### Private #####
def joinItems(separator, first, *others_list) :
for others_list_item in others_list : for others_list_item in others_list :
if len(first) == 0 : if len(first) == 0 :
first = others_list_item first = others_list_item
...@@ -6,9 +18,3 @@ def __joinItems(separator, first, *others_list) : ...@@ -6,9 +18,3 @@ def __joinItems(separator, first, *others_list) :
first += separator + others_list_item first += separator + others_list_item
return first return first
def joinPath(first, *others_list) :
return __joinItems("/", first, *others_list)
def joinMethod(first, *others_list) :
return __joinItems(".", first, *others_list)
Markdown is supported
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