Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
app = next(a for a in APPS if id_or_name in [a.id, a.name])
except StopIteration:
if strict:
raise AppSelectionError("App not found (strict is set)")
else:
return DEFAULT_APP
if app.name == "default":
return app
if not cast_type:
raise AppSelectionError("Cast type is needed for app selection")
elif cast_type not in app.supported_device_types:
msg = "The {} app is not available for this device".format(app.name.capitalize())
if strict:
raise AppSelectionError("{} (strict is set)".format(msg))
elif show_warning:
warning(msg)
return DEFAULT_APP
else:
return app
def get_app(id_or_name, cast_type=None, strict=False, show_warning=False):
try:
app = next(a for a in APPS if id_or_name in [a.id, a.name])
except StopIteration:
if strict:
raise AppSelectionError("App not found (strict is set)")
else:
return DEFAULT_APP
if app.name == "default":
return app
if not cast_type:
raise AppSelectionError("Cast type is needed for app selection")
elif cast_type not in app.supported_device_types:
msg = "The {} app is not available for this device".format(app.name.capitalize())
if strict:
raise AppSelectionError("{} (strict is set)".format(msg))
elif show_warning:
warning(msg)
return DEFAULT_APP
else:
def get_app(id_or_name, cast_type=None, strict=False, show_warning=False):
try:
app = next(a for a in APPS if id_or_name in [a.id, a.name])
except StopIteration:
if strict:
raise AppSelectionError("App not found (strict is set)")
else:
return DEFAULT_APP
if app.name == "default":
return app
if not cast_type:
raise AppSelectionError("Cast type is needed for app selection")
elif cast_type not in app.supported_device_types:
msg = "The {} app is not available for this device".format(app.name.capitalize())
if strict:
raise AppSelectionError("{} (strict is set)".format(msg))
elif show_warning:
warning(msg)
return DEFAULT_APP
else:
return app