@classmethod
def from_python(cls, level: int) ->'LogLevel':
    """Map Python log level to katcp log level"""
    try:
        return cls(level)
    except ValueError:
        ans = cls.ALL
        for member in cls.__members__.values():
            if member > ans and member <= level and member != cls.OFF:
                ans = member
        return member
