<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_default_viewport(self):

 """
 Calculates the viewport based on the configured aspect ratio.
 Will add black borders and center the viewport if the window
 do not match the configured viewport.
 
 If aspect ratio is None the viewport will be scaled
 to the entire window size regardless of size.
 """

        if self.aspect_ratio:
            expected_width = int(self.buffer_height * self.aspect_ratio)
            expected_height = int(expected_width / self.aspect_ratio)

            if expected_width > self.buffer_width:
                expected_width = self.buffer_width
                expected_height =  int(expected_width / self.aspect_ratio)

            blank_space_x = self.buffer_width - expected_width
            blank_space_y = self.buffer_height - expected_height

            self.ctx.viewport = (
                blank_space_x // 2,
                blank_space_y // 2,
                expected_width,
                expected_height,
            )
        else:
            self.ctx.viewport = (0, 0, self.buffer_width, self.buffer_height)