leapp.dialogs package

Submodules

leapp.dialogs.components module

class leapp.dialogs.components.BooleanComponent(key=None, label=None, description=None, default=None, reason=None, values=None)

Bases: leapp.dialogs.components.Component

BooleanComponent is used for boolean inputs such as Yes/No questions.

Parameters:
  • key – Unique key within a dialog scope. Needs to be in the format: [a-zA-Z_][a-zA-Z0-9_]*
  • label – Label for the input to print
  • description – Description what this value is used for.
  • default – Default value to
  • reason – The reason why we need this value.
  • values – Values to use as True and False, first is always True and the second is always False (e.g. Yes/No)
choices = ('True', 'False')
default = None
description = None
dispatch(renderer, dialog)
key = None
label = None
reason = None
serialize()
Returns:Serialized component information
value = None
value_type

alias of bool

values = ('Yes', 'No')
class leapp.dialogs.components.ChoiceComponent(choices=None, key=None, label=None, description=None, default=None, reason=None)

Bases: leapp.dialogs.components.Component

ChoiceComponent is used to give a list of options and allows to select one (like a radio button)

Parameters:
  • key – Unique key within a dialog scope. Needs to be in the format: [a-zA-Z_][a-zA-Z0-9_]*
  • label – Label for the input to print
  • description – Description what this value is used for.
  • default – Default value to
  • reason – The reason why we need this value.
  • choices – Choices that are available to the user
choices = ()
default = None
description = None
dispatch(renderer, dialog)
key = None
label = None
multi = False
reason = None
serialize()
Returns:Serialized component information
value = None
value_type

alias of unicode

class leapp.dialogs.components.Component(key=None, label=None, description=None, default=None, reason=None)

Bases: object

Base class for all components

Parameters:
  • key – Unique key within a dialog scope. Needs to be in the format: [a-zA-Z_][a-zA-Z0-9_]*
  • label – Label for the input to print
  • description – Description what this value is used for.
  • default – Default value to
  • reason – The reason why we need this value.
default = None
description = None
dispatch(renderer, dialog)
key = None
label = None
reason = None
serialize()
Returns:Serialized component information
value = None
value_type = None
class leapp.dialogs.components.MultipleChoiceComponent(choices=None, key=None, label=None, description=None, default=None, reason=None)

Bases: leapp.dialogs.components.ChoiceComponent

MultipleChoiceComponent is used to give a list of options and allows to select more than one (like checkboxes)

Parameters:
  • key – Unique key within a dialog scope. Needs to be in the format: [a-zA-Z_][a-zA-Z0-9_]*
  • label – Label for the input to print
  • description – Description what this value is used for.
  • default – Default value to
  • reason – The reason why we need this value.
  • choices – Choices that are available to the user
choices = ()
default = None
description = None
dispatch(renderer, dialog)

Calls the appropriate rendering implementation on the renderer and passes itself and the dialog instance to it.

Parameters:
Returns:

key = None
label = None
multi = True
reason = None
serialize()
Returns:Serialized component information
value = None
value_type

alias of tuple

class leapp.dialogs.components.NumberComponent(key=None, label=None, description=None, default=None, reason=None)

Bases: leapp.dialogs.components.Component

NumberComponent is used for integer inputs.

Parameters:
  • key – Unique key within a dialog scope. Needs to be in the format: [a-zA-Z_][a-zA-Z0-9_]*
  • label – Label for the input to print
  • description – Description what this value is used for.
  • default – Default value to
  • reason – The reason why we need this value.
default = -1
description = None
dispatch(renderer, dialog)
key = None
label = None
reason = None
serialize()
Returns:Serialized component information
value = None
value_type

alias of int

class leapp.dialogs.components.PasswordComponent(key=None, label=None, description=None, default=None, reason=None)

Bases: leapp.dialogs.components.TextComponent

PasswordComponent is a text input component which will use non echoing input when possible (see getpass).

Parameters:
  • key – Unique key within a dialog scope. Needs to be in the format: [a-zA-Z_][a-zA-Z0-9_]*
  • label – Label for the input to print
  • description – Description what this value is used for.
  • default – Default value to
  • reason – The reason why we need this value.
default = None
description = None
dispatch(renderer, dialog)
key = None
label = 'Password'
reason = None
serialize()
Returns:Serialized component information
value = None
value_type

alias of str

class leapp.dialogs.components.TextComponent(key=None, label=None, description=None, default=None, reason=None)

Bases: leapp.dialogs.components.Component

TextComponent is a text input component.

Parameters:
  • key – Unique key within a dialog scope. Needs to be in the format: [a-zA-Z_][a-zA-Z0-9_]*
  • label – Label for the input to print
  • description – Description what this value is used for.
  • default – Default value to
  • reason – The reason why we need this value.
default = None
description = None
dispatch(renderer, dialog)
key = None
label = None
reason = None
serialize()
Returns:Serialized component information
value = None
value_type

alias of str

leapp.dialogs.dialog module

class leapp.dialogs.dialog.Dialog(scope, reason, title=None, components=None, key=None)

Bases: object

The dialog class is used to declare the information passed to the user and retrieved from the user during an interaction.

Parameters:
  • scope (str) – Unique scope identifier for the data to be stored in the answer files. Scope + component key is used to address values.
  • reason (str) – An explanation for what the data in this dialog is needed for.
  • title (str) – Title of the dialog
  • components (tuple(leapp.dialogs.components.Component)) – Components to display in the given order in the dialog
  • key (str) – Key to appear in the dialog-related report entry
answer(component, value)

Implements storing of answers.

Parameters:
  • component – Component for which the answer is set
  • value – The answer value
Returns:

None

answerfile_sections
component_by_key(key)

Finds the component with the given key

Parameters:key (str) – Key of the component to return
Returns:Component found or None
components = ()

Components to display in the given order in the dialog

get_answers(store)

Checks answerstore if an answer is recorded for the dialog.

Parameters:store – AnswerStore instance
Returns:Dictionary with answers once retrieved
min_label_width
Returns:Returns the highest number of characters all labels in the dialog have, to help calculating the minimum width the labels should have.
reason = None

An explanation for what the data in this dialog is needed for.

request_answers(store, renderer)

Same as get_answers but with interactive retrieval of the answer in case no recorded answer found in answerstore.

Parameters:
  • store – AnswerStore instance
  • renderer – Target renderer instance
Returns:

Dictionary with answers once retrieved

scope = None

Unique scope identifier for the data to be stored in the answer files. Scope + component key is used to address values.

serialize()
Returns:Dictionary with the serialized representation of a component
title = None

Title of the dialog

leapp.dialogs.renderer module

class leapp.dialogs.renderer.CommandlineRenderer

Bases: leapp.dialogs.renderer.DialogRendererBase

CommandlineRenderer implements the handling for commandline user interactions.

render(dialog)

Renders the given dialog

Parameters:dialog (leapp.dialogs.dialog.Dialog) – The dialog to render
Returns:None
render_bool_component(component, dialog)

Renders the boolean component for displaying Yes/No questions

Parameters:
Returns:

None

render_choice_component(component, dialog)

Renders the choices component

Parameters:
  • component (leapp.dialogs.components.ChoicesComponent) – The choices component to render
  • dialog (leapp.dialogs.dialog.Dialog) – The dialog to render
Returns:

None

render_multiple_choice_component(component, dialog)

Renders the multiple choices component

Parameters:
Returns:

None

render_number_component(component, dialog)

Renders the number component

Parameters:
Returns:

None

render_password_component(component, dialog)

Renders the password component

Parameters:
Returns:

None

render_text_component(component, dialog)

Renders the text component

Parameters:
Returns:

None

class leapp.dialogs.renderer.DialogRendererBase

Bases: object

Base class for all renderer implementations

render(dialog)

Renders the given dialog

Parameters:dialog (leapp.dialogs.dialog.Dialog) – The dialog to render
Returns:None
render_bool_component(component, dialog)

Renders the boolean component for displaying Yes/No questions

Parameters:
Returns:

None

render_choice_component(component, dialog)

Renders the choices component

Parameters:
  • component (leapp.dialogs.components.ChoicesComponent) – The choices component to render
  • dialog (leapp.dialogs.dialog.Dialog) – The dialog to render
Returns:

None

render_multiple_choice_component(component, dialog)

Renders the multiple choices component

Parameters:
Returns:

None

render_number_component(component, dialog)

Renders the number component

Parameters:
Returns:

None

render_password_component(component, dialog)

Renders the password component

Parameters:
Returns:

None

render_text_component(component, dialog)

Renders the text component

Parameters:
Returns:

None

Module contents

class leapp.dialogs.RawMessageDialog(message)

Bases: leapp.dialogs.dialog.Dialog

Reusable message dialog. - This sends a message to the user only without any special formatting.

answer(component, value)

Implements storing of answers.

Parameters:
  • component – Component for which the answer is set
  • value – The answer value
Returns:

None

answerfile_sections
component_by_key(key)

Finds the component with the given key

Parameters:key (str) – Key of the component to return
Returns:Component found or None
components = ()
get_answers(store)

Checks answerstore if an answer is recorded for the dialog.

Parameters:store – AnswerStore instance
Returns:Dictionary with answers once retrieved
min_label_width
Returns:Returns the highest number of characters all labels in the dialog have, to help calculating the minimum width the labels should have.
reason = None
request_answers(store, renderer)
Parameters:
  • store – AnswerStore instance
  • renderer – Target renderer instance
Returns:

Dictionary with answers once retrieved

scope = None
serialize()
Returns:Dictionary with the serialized representation of a component
title = ''
class leapp.dialogs.UsernamePasswordDialog(scope, reason, title=None, components=None, key=None)

Bases: leapp.dialogs.dialog.Dialog

Reusable username and password request dialog.

Parameters:
  • scope (str) – Unique scope identifier for the data to be stored in the answer files. Scope + component key is used to address values.
  • reason (str) – An explanation for what the data in this dialog is needed for.
  • title (str) – Title of the dialog
  • components (tuple(leapp.dialogs.components.Component)) – Components to display in the given order in the dialog
  • key (str) – Key to appear in the dialog-related report entry
answer(component, value)

Implements storing of answers.

Parameters:
  • component – Component for which the answer is set
  • value – The answer value
Returns:

None

answerfile_sections
component_by_key(key)

Finds the component with the given key

Parameters:key (str) – Key of the component to return
Returns:Component found or None
components = (<leapp.dialogs.components.TextComponent object>, <leapp.dialogs.components.PasswordComponent object>)
get_answers(store)

Checks answerstore if an answer is recorded for the dialog.

Parameters:store – AnswerStore instance
Returns:Dictionary with answers once retrieved
min_label_width
Returns:Returns the highest number of characters all labels in the dialog have, to help calculating the minimum width the labels should have.
reason = None
request_answers(store, renderer)

Same as get_answers but with interactive retrieval of the answer in case no recorded answer found in answerstore.

Parameters:
  • store – AnswerStore instance
  • renderer – Target renderer instance
Returns:

Dictionary with answers once retrieved

scope = None
serialize()
Returns:Dictionary with the serialized representation of a component
title = 'Please enter username and password'