def _get_viewport(viewport):
    """Check that viewport is valid and within acceptable bounds.

    >>> f = '99x99 99x100 100x99 4097x4097 1280.720 wxy'.split()
    >>> p = '100x100 1280x720 4096x2160'.split()
    >>> _get_viewport(None) == _DEFAULT_VIEWPORT
    True
    >>> all(_get_viewport(i) == _DEFAULT_VIEWPORT for i in f)
    True
    >>> all(_get_viewport(i) == i for i in p)
    True
    """
    try:
        assert viewport is not None
        v = viewport.split('x')
        if len(v) != 2:
            raise ValueError('Viewport must have width and height')
        w, h = int(v[0]), int(v[1])
        if not (99 < w < 4097 and 99 < h < 4097):
            raise ValueError('Viewport out of bounds')
    except (AssertionError, TypeError, ValueError):
        return _DEFAULT_VIEWPORT
    return viewport
Check that viewport is valid and within acceptable bounds.

    >>> f = '99x99 99x100 100x99 4097x4097 1280.720 wxy'.split()
    >>> p = '100x100 1280x720 4096x2160'.split()
    >>> _get_viewport(None) == _DEFAULT_VIEWPORT
    True
    >>> all(_get_viewport(i) == _DEFAULT_VIEWPORT for i in f)
    True
    >>> all(_get_viewport(i) == i for i in p)
    True
    
slyd/slyd/splash/utils.py