Source code for mwtp.exceptions

[docs]class InvalidTitle(Exception): """ Umbrella exception for all kinds of exceptions a parser might raise. """ pass
[docs]class TitleContainsIllegalCharacter(InvalidTitle): """ Raised if the title contains illegal characters. """ def __init__(self) -> None: super().__init__("Title contains illegal characters")
[docs]class TitleContainsSignatureComponent(InvalidTitle): """ Raised if the title contains ``~~~``. """ def __init__(self) -> None: super().__init__("Title contains a signature component")
[docs]class TitleContainsURLEncodedCharacter(InvalidTitle): """ Raised if the title contains a URL-encoded character. """ def __init__(self) -> None: super().__init__("Title contains a URL-encoded character")
[docs]class TitleContainsHTMLEntity(InvalidTitle): """ Raised if the title contains an HTML entity or something that looks like one. """ def __init__(self) -> None: super().__init__("Title contains a HTML entity look-alike")
[docs]class TitleHasRelativePathComponent(InvalidTitle): """ Raised if the title contains a relative path component or only consists of either one or two dots. """ def __init__(self) -> None: super().__init__("Title contains a relative path component")
[docs]class TitleHasSecondLevelNamespace(InvalidTitle): """ Raised if the title is determined to be in the ``Talk:`` namespace while also contains a second valid namespace. """ def __init__(self) -> None: super().__init__("Second level namespace cannot be resolved")
[docs]class TitleIsBlank(InvalidTitle): """ Raised if the title contains nothing but whitespaces and/or a leading colon. """ def __init__(self) -> None: super().__init__("Title is blank or only has the namespace part")
[docs]class TitleIsTooLong(InvalidTitle): """ Raised if the title's length exceed the maximum length of a title. """ def __init__(self) -> None: super().__init__("Title exceeds maximum length of 256 bytes")
[docs]class TitleStartsWithColon(InvalidTitle): """ Raised if the page name starts with a colon, or the namespace part starts with more than one colon. """ def __init__(self) -> None: super().__init__("Invalid colon at the start of namespace or page name")