User Input

class korus.app.app_util.ui.InputLogger[source]

Bases: object

Class for logging input values

Stores data in a JSON file named ‘last_submit.json’ in the user’s home directory under $HOME/.ktam/

Implements the methods write() and read() for writing and reading to the file.

read(name, group=None)[source]

Retrieve a value

Args:
name: str

Parameter name

group: str

Optional group name, used for organising the data.

write(name, value, group=None)[source]

Log a value

Args:
name: str

Parameter name

value:

The value to be logged

group: str

Optional group name, used for organising the data. Parameter names must be unique within each group.

class korus.app.app_util.ui.Option(key, message, fcn)[source]

Bases: object

Class for handling specific, configurable input options

Args:
key: str,list,tuple

Input key(s) used to select the option

message: str

Message describing actions triggered by the option

fcn: callable

Function carrying out the action

is_selected(key)[source]

Returns True if @key matches one of the input keys associated with this option

key_str()[source]

Concatenates the input key(s) into a human-readable string

class korus.app.app_util.ui.UserInput(name, message, transform_fcn=<function UserInput.<lambda>>, group=None, json_fcn=<function UserInput.<lambda>>, allowed_values=None, unknown=False)[source]

Bases: object

Interactive session for requesting user input via console.

Args:
name: str

Parameter name

message: str

Request message presented to the user

transform_fcn: callable

Function applied to input provided by the user via the console.

group: str

Group that the parameter belongs to. Optional. Parameter names must be unique within groups.

json_fcn: callable

Function applied to input when storing in JSON logging file.

allowed_values:

Allowed input value(s).

add_option(key, message, fcn)[source]

Add a special, configurable option to the user prompt.

key: str,list,tuple

Input key(s) used to select the option

message: str

Message describing actions triggered by the option

fcn: callable

Function carrying out the action

request(logger=None)[source]

Request input from the user via the console.

Args:
logger: korus.app.app_util.ui.InputLogger

Input logger.

class korus.app.app_util.ui.UserInputSound(name, message, conn, taxonomy_id, group=None, default=None)[source]

Bases: UserInput

Interactive session specifically for inputting sound-source and sound-type information.

Args:
name: str

Parameter name

message: str

Request message presented to the user

conn: sqlite3.Connection

Database connection

taxonomy_id: int

Index of the reference taxonomy for interpreting the tags provided by the user.

group: str

Group that the parameter belongs to. Optional. Parameter names must be unique within groups.

class korus.app.app_util.ui.UserInputYesNo(name, message, group=None)[source]

Bases: UserInput

Interactive session specifically for inputting yes/no answers.

Args:
name: str

Parameter name

message: str

Request message presented to the user

group: str

Group that the parameter belongs to. Optional. Parameter names must be unique within groups.