Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def alert(text, *args):
'''Alert the user to an error. This should be used in situations where
there is a problem that will prevent normal execution.
'''
ui = UI.instance()
if not ui.use_color():
text = unstyled(text)
args = [unstyled(x) for x in args]
ui.alert(text, *args)
def warn(text, *args):
'''Warn the user that something is not right. This should be used in
situations where the problem is not fatal nor will prevent continued
execution. (For problems that prevent continued execution, use the
alert(...) method instead.)
'''
ui = UI.instance()
if not ui.use_color():
text = unstyled(text)
args = [unstyled(x) for x in args]
ui.warn(text, *args)
def alert_fatal(text, *args, **kwargs):
'''Print or display a message reporting a fatal error. The keyword
argument 'details' can be supplied to pass a longer explanation that will
be displayed (when a GUI is being used) if the user presses the 'Help'
button in the dialog.
Note that when a GUI interface is in use, this method will cause the
GUI to exit after the user clicks the OK button, so that the calling
application can regain control and exit.
'''
ui = UI.instance()
if not ui.use_color():
text = unstyled(text)
args = [unstyled(x) for x in args]
ui.alert_fatal(text, *args, **kwargs)
def alert(text, *args):
'''Alert the user to an error. This should be used in situations where
there is a problem that will prevent normal execution.
'''
ui = UI.instance()
if not ui.use_color():
text = unstyled(text)
args = [unstyled(x) for x in args]
ui.alert(text, *args)
def alert_fatal(text, *args, **kwargs):
'''Print or display a message reporting a fatal error. The keyword
argument 'details' can be supplied to pass a longer explanation that will
be displayed (when a GUI is being used) if the user presses the 'Help'
button in the dialog.
Note that when a GUI interface is in use, this method will cause the
GUI to exit after the user clicks the OK button, so that the calling
application can regain control and exit.
'''
ui = UI.instance()
if not ui.use_color():
text = unstyled(text)
args = [unstyled(x) for x in args]
ui.alert_fatal(text, *args, **kwargs)
def inform(text, *args):
'''Print an informational message to the user. The 'text' can contain
string format placeholders such as "{}", and the additional arguments in
args are values to use in those placeholders.
'''
ui = UI.instance()
if not ui.use_color():
text = unstyled(text)
args = [unstyled(x) for x in args]
ui.inform(text, *args)
def inform(text, *args):
'''Print an informational message to the user. The 'text' can contain
string format placeholders such as "{}", and the additional arguments in
args are values to use in those placeholders.
'''
ui = UI.instance()
if not ui.use_color():
text = unstyled(text)
args = [unstyled(x) for x in args]
ui.inform(text, *args)
def warn(text, *args):
'''Warn the user that something is not right. This should be used in
situations where the problem is not fatal nor will prevent continued
execution. (For problems that prevent continued execution, use the
alert(...) method instead.)
'''
ui = UI.instance()
if not ui.use_color():
text = unstyled(text)
args = [unstyled(x) for x in args]
ui.warn(text, *args)