Пример #1
0
 def dollar_replace(self, value):
     '''Replaces all occurrences of ${} for different types.'''
     if Encoding.is_unicode(value):
         return self.__dollar_replace_string(value)
     if isinstance(value, list):
         return self.__dollar_replace_list(value)
     # Never reached: unknown type
     print("Cfg never reached [%s] [%s]" % (type(value), value))
     assert False
Пример #2
0
def cfg_key(key):
    """Configuration key handling

    If the key is a string, it is converted to the internally
    used list of strings.
    The original string is split at '.'.
    """
    if isinstance(key, list):
        return key
    if Encoding.is_unicode(key):
        return key.split('.')
    print("Invalid key type [%s]" % type(key))
    assert False
Пример #3
0
    def _check_list_of_strings(name, tbc):
        '''Checks if the given variable is a list of strings or None.'''
        if tbc is None:
            tracer.debug("Ignoring non existent configuration for [%s]", tbc)
            return

        if not isinstance(tbc, list):
            assert False
            raise RMTException(103, "Configuration error: [%s] configuration "
                               "must be a list, is [%s]" % (name, type(tbc)))

        if not tbc:
            raise RMTException(105, "Configuration error: [%s] configuration "
                               "must be a non empty list" % name)

        for string in tbc:
            if not Encoding.is_unicode(string):
                raise RMTException(104, "Configuration error: [%s].[%s] "
                                   " configuration must be a string"
                                   % (name, string))
Пример #4
0
    def _check_list_of_strings(name, tbc):
        '''Checks if the given variable is a list of strings or None.'''
        if tbc is None:
            tracer.debug("Ignoring non existent configuration for [%s]", tbc)
            return

        if not isinstance(tbc, list):
            assert False
            raise RMTException(
                103, "Configuration error: [%s] configuration "
                "must be a list, is [%s]" % (name, type(tbc)))

        if not tbc:
            raise RMTException(
                105, "Configuration error: [%s] configuration "
                "must be a non empty list" % name)

        for string in tbc:
            if not Encoding.is_unicode(string):
                raise RMTException(
                    104, "Configuration error: [%s].[%s] "
                    " configuration must be a string" % (name, string))