From d1317d396799d3a1831bacacf3e061fca8dd00b5 Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Sun, 16 Aug 2020 19:47:30 +0100 Subject: [PATCH 1/2] Combine duplicate if branches --- pyganja/script_api.py | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/pyganja/script_api.py b/pyganja/script_api.py index b676d3f..2e2a732 100644 --- a/pyganja/script_api.py +++ b/pyganja/script_api.py @@ -246,27 +246,18 @@ def draw(objects, color=Color.DEFAULT, sig=None, *, if not new_window: render_notebook_script(objects, **kwargs) else: - if CEFAVAILABLE: - if browser_window: - render_browser_script(objects, **kwargs) - else: - render_cef_script(objects, **kwargs) + if CEFAVAILABLE and not browser_window: + render_cef_script(objects, **kwargs) else: render_browser_script(objects, **kwargs) else: - if CEFAVAILABLE: - if browser_window: - render_browser_script(objects, **kwargs) - else: - render_cef_script(objects, **kwargs) + if CEFAVAILABLE and not browser_window: + render_cef_script(objects, **kwargs) else: render_browser_script(objects, **kwargs) else: - if CEFAVAILABLE: - if browser_window: - render_browser_script(objects, **kwargs) - else: - render_cef_script(objects, **kwargs) + if CEFAVAILABLE and not browser_window: + render_cef_script(objects, **kwargs) else: render_browser_script(objects, **kwargs) From dd76bc980003dbd5426673f054f42a958bbd2a4f Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Sun, 16 Aug 2020 19:49:20 +0100 Subject: [PATCH 2/2] Combine even more duplicate if branches --- pyganja/script_api.py | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/pyganja/script_api.py b/pyganja/script_api.py index 2e2a732..dfb1107 100644 --- a/pyganja/script_api.py +++ b/pyganja/script_api.py @@ -241,25 +241,12 @@ def isnotebook(): def draw(objects, color=Color.DEFAULT, sig=None, *, browser_window=False, new_window=False, static=False, **kwargs): kwargs = dict(sig=sig, default_color=color, default_static=static, **kwargs) - if JUPYTERAVAILABLE: - if isnotebook(): - if not new_window: - render_notebook_script(objects, **kwargs) - else: - if CEFAVAILABLE and not browser_window: - render_cef_script(objects, **kwargs) - else: - render_browser_script(objects, **kwargs) - else: - if CEFAVAILABLE and not browser_window: - render_cef_script(objects, **kwargs) - else: - render_browser_script(objects, **kwargs) + if JUPYTERAVAILABLE and isnotebook() and not new_window: + render_notebook_script(objects, **kwargs) + elif CEFAVAILABLE and not browser_window: + render_cef_script(objects, **kwargs) else: - if CEFAVAILABLE and not browser_window: - render_cef_script(objects, **kwargs) - else: - render_browser_script(objects, **kwargs) + render_browser_script(objects, **kwargs) def _to_scene_string(objects, default_color=Color.DEFAULT, default_static=False):