Raised when a section is repeated in an input source. Possible repetitions that raise this exception are: multiple creation using the API or in strict parsers when a section is found more than once in a single input file, string or dictionary.
| 196 | |
| 197 | |
| 198 | class DuplicateSectionError(Error): |
| 199 | """Raised when a section is repeated in an input source. |
| 200 | |
| 201 | Possible repetitions that raise this exception are: multiple creation |
| 202 | using the API or in strict parsers when a section is found more than once |
| 203 | in a single input file, string or dictionary. |
| 204 | """ |
| 205 | |
| 206 | def __init__(self, section, source=None, lineno=None): |
| 207 | msg = [repr(section), " already exists"] |
| 208 | if source is not None: |
| 209 | message = ["While reading from ", repr(source)] |
| 210 | if lineno is not None: |
| 211 | message.append(" [line {0:2d}]".format(lineno)) |
| 212 | message.append(": section ") |
| 213 | message.extend(msg) |
| 214 | msg = message |
| 215 | else: |
| 216 | msg.insert(0, "Section ") |
| 217 | Error.__init__(self, "".join(msg)) |
| 218 | self.section = section |
| 219 | self.source = source |
| 220 | self.lineno = lineno |
| 221 | self.args = (section, source, lineno) |
| 222 | |
| 223 | |
| 224 | class DuplicateOptionError(Error): |
no outgoing calls
no test coverage detected
searching dependent graphs…