def _get_viewport(viewport):
 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

def _get_viewport ( viewport ) : 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 .