Skip to content

Commit

Permalink
run black
Browse files Browse the repository at this point in the history
  • Loading branch information
bckohan committed Feb 21, 2024
1 parent 004af10 commit 12b40a0
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions sphinxcontrib/typer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
SELENIUM_DEFAULT_WINDOW_WIDTH = 1920
SELENIUM_DEFAULT_WINDOW_HEIGHT = 2048


def _filter_commands(
ctx: click.Context, cmd_filter: t.Optional[t.List[str]] = None
):
Expand Down Expand Up @@ -723,7 +724,7 @@ def typer_svg2pdf(directive: TyperDirective, svg_contents: str, pdf_path: str):
def typer_get_web_driver(
directive: TyperDirective,
width: int = SELENIUM_DEFAULT_WINDOW_WIDTH,
height: int = SELENIUM_DEFAULT_WINDOW_HEIGHT
height: int = SELENIUM_DEFAULT_WINDOW_HEIGHT,
) -> t.Any:
"""
The default get_web_driver function. This function yields a selenium web driver
Expand Down Expand Up @@ -830,7 +831,7 @@ def typer_convert_png(
rendered: str,
png_path: t.Union[str, Path],
selenium_width: int = SELENIUM_DEFAULT_WINDOW_WIDTH,
selenium_height: int = SELENIUM_DEFAULT_WINDOW_HEIGHT
selenium_height: int = SELENIUM_DEFAULT_WINDOW_HEIGHT,
):
"""
The default typer_convert_png function. This function writes a png file to the given
Expand Down Expand Up @@ -874,17 +875,20 @@ def typer_convert_png(
# Get the element's location and size
location = element.location
size = element.size

if size['width'] > selenium_width or size['height'] > selenium_height:

if (
size['width'] > selenium_width
or size['height'] > selenium_height
):
# if our window is too small, resize it with some padding and try again
return typer_convert_png(
directive,
rendered,
png_path,
size['width']+100,
size['height']+100
size['width'] + 100,
size['height'] + 100,
)

# Open the screenshot and crop it to the element
im = Image.open(BytesIO(png))
left = location['x'] * pixel_ratio
Expand Down

0 comments on commit 12b40a0

Please sign in to comment.