Esempio n. 1
0
 def basic_key(self, s, pos):
     try:
         return self._basic_key(s)
     except ValueError as e:
         raise_with_same_tb(
             ZConfig.ConfigurationSyntaxError(
                 "could not convert basic-key value: " + str(e), *pos))
Esempio n. 2
0
    def addValue(self, key, value, position):
        try:
            realkey = self.type.keytype(key)
        except ValueError as e:
            raise_with_same_tb(ZConfig.DataConversionError(e, key, position))

        if realkey in self.optionbag:
            return
        ZConfig.matcher.BaseMatcher.addValue(self, key, value, position)
Esempio n. 3
0
    def addValue(self, key, value, position):
        try:
            realkey = self.type.keytype(key)
        except ValueError as e:
            raise_with_same_tb(ZConfig.DataConversionError(e, key, position))

        if realkey in self.optionbag:
            return
        ZConfig.matcher.BaseMatcher.addValue(self, key, value, position)
Esempio n. 4
0
 def _raise_open_error(self, url, message):
     if url[:7].lower() == "file://":
         what = "file"
         ident = urllib2.url2pathname(url[7:])
     else:
         what = "URL"
         ident = url
     error = ZConfig.ConfigurationError(
         "error opening %s %s: %s" % (what, ident, message), url)
     raise_with_same_tb(error)
Esempio n. 5
0
 def _raise_open_error(self, url, message):
     if url[:7].lower() == "file://":
         what = "file"
         ident = urllib2.url2pathname(url[7:])
     else:
         what = "URL"
         ident = url
     error = ZConfig.ConfigurationError(
         "error opening %s %s: %s" % (what, ident, message),
         url)
     raise_with_same_tb(error)
Esempio n. 6
0
    def constuct(self):
        values = self._values
        for name, ci in self.type:
            assert ci.attribute is not None
            attr = ci.attribute
            if ci.ismulti():
                if ci.issection():
                    v = []
                    for s in values[attr]:
                        if s is not None:
                            st = s.getSectionDefinition()
                            try:
                                s = st.datatype(s)
                            except ValueError as e:
                                raise_with_same_tb(
                                    ZConfig.DataConversionError(
                                        e, s, (-1, -1, None)))

                        v.append(s)
                elif ci.name == '+':
                    v = values[attr]
                    for key, val in v.items():
                        v[key] = [vi.convert(ci.datatype) for vi in val]
                else:
                    v = [vi.convert(ci.datatype) for vi in values[attr]]
            elif ci.issection():
                if values[attr] is not None:
                    st = values[attr].getSectionDefinition()
                    try:
                        v = st.datatype(values[attr])
                    except ValueError as e:
                        raise_with_same_tb(
                            ZConfig.DataConversionError(
                                e, values[attr], (-1, -1, None)))

                else:
                    v = None
            elif name == '+':
                v = values[attr]
                if not v:
                    for key, val in ci.getdefault().items():
                        v[key] = val.convert(ci.datatype)
                else:
                    for key, val in v.items():
                        v[key] = val.convert(ci.datatype)
            else:
                v = values[attr]
                if v is not None:
                    v = v.convert(ci.datatype)
            values[attr] = v
            if ci.handler is not None:
                self.handlers.append((ci.handler, v))
        return self.createValue()
Esempio n. 7
0
    def constuct(self):
        values = self._values
        for name, ci in self.type:
            assert ci.attribute is not None
            attr = ci.attribute
            if ci.ismulti():
                if ci.issection():
                    v = []
                    for s in values[attr]:
                        if s is not None:
                            st = s.getSectionDefinition()
                            try:
                                s = st.datatype(s)
                            except ValueError as e:
                                raise_with_same_tb(ZConfig.DataConversionError(
                                    e, s, (-1, -1, None)))

                        v.append(s)
                elif ci.name == '+':
                    v = values[attr]
                    for key, val in v.items():
                        v[key] = [vi.convert(ci.datatype) for vi in val]
                else:
                    v = [vi.convert(ci.datatype) for vi in values[attr]]
            elif ci.issection():
                if values[attr] is not None:
                    st = values[attr].getSectionDefinition()
                    try:
                        v = st.datatype(values[attr])
                    except ValueError as e:
                        raise_with_same_tb(ZConfig.DataConversionError(
                            e, values[attr], (-1, -1, None)))

                else:
                    v = None
            elif name == '+':
                v = values[attr]
                if not v:
                    for key, val in ci.getdefault().items():
                        v[key] = val.convert(ci.datatype)
                else:
                    for key, val in v.items():
                        v[key] = val.convert(ci.datatype)
            else:
                v = values[attr]
                if v is not None:
                    v = v.convert(ci.datatype)
            values[attr] = v
            if ci.handler is not None:
                self.handlers.append((ci.handler, v))
        return self.createValue()
Esempio n. 8
0
 def basic_key(self, s, pos):
     try:
         return self._basic_key(s)
     except ValueError as e:
         raise_with_same_tb(ZConfig.ConfigurationSyntaxError(
             "could not convert basic-key value: " + str(e), *pos))
Esempio n. 9
0
 def error(self, message):
     raise_with_same_tb(
         ZConfig.ConfigurationSyntaxError(message, self.url, self.lineno))
Esempio n. 10
0
 def error(self, message):
     raise_with_same_tb(self.initerror(ZConfig.SchemaError(message)))
Esempio n. 11
0
 def error(self, message, kind=None):
     # Can't do this as a default value because of import order
     kind = kind or ZConfig.SchemaError
     raise_with_same_tb(self.initerror(kind(message)))
Esempio n. 12
0
 def error(self, message):
     raise_with_same_tb(self.initerror(ZConfig.SchemaError(message)))
Esempio n. 13
0
 def error(self, message):
     raise_with_same_tb(
         ZConfig.ConfigurationSyntaxError(
             message, self.url, self.lineno))