Raised by strict parsers when an option is repeated in an input source. Current implementation raises this exception only when an option is found more than once in a single file, string or dictionary.
| 222 | |
| 223 | |
| 224 | class DuplicateOptionError(Error): |
| 225 | """Raised by strict parsers when an option is repeated in an input source. |
| 226 | |
| 227 | Current implementation raises this exception only when an option is found |
| 228 | more than once in a single file, string or dictionary. |
| 229 | """ |
| 230 | |
| 231 | def __init__(self, section, option, source=None, lineno=None): |
| 232 | msg = [repr(option), " in section ", repr(section), |
| 233 | " already exists"] |
| 234 | if source is not None: |
| 235 | message = ["While reading from ", repr(source)] |
| 236 | if lineno is not None: |
| 237 | message.append(" [line {0:2d}]".format(lineno)) |
| 238 | message.append(": option ") |
| 239 | message.extend(msg) |
| 240 | msg = message |
| 241 | else: |
| 242 | msg.insert(0, "Option ") |
| 243 | Error.__init__(self, "".join(msg)) |
| 244 | self.section = section |
| 245 | self.option = option |
| 246 | self.source = source |
| 247 | self.lineno = lineno |
| 248 | self.args = (section, option, source, lineno) |
| 249 | |
| 250 | |
| 251 | class NoOptionError(Error): |
no outgoing calls
no test coverage detected
searching dependent graphs…