mini_project_1.common module

common utilities utilized by mini-project-1

exception mini_project_1.common.ShellArgumentException(*args, **kwargs)[source]

Bases: Exception

Custom exception class noting a invalid argument within a shell.MiniProjectShell command

class mini_project_1.common.ShellArgumentParser(*args, **kwargs)[source]

Bases: argparse.ArgumentParser

Custom argument parser for use in :class`.shell.MiniProjectShell`

error(message: string)[source]

Prints a usage message incorporating the message to stderr and exits.

If you override this in a subclass, it should not return – it should either exit or raise an exception.

exception mini_project_1.common.ValueNotFoundException(*args, **kwargs)[source]

Bases: Exception

Exception for queries with no results

mini_project_1.common.check_valid_email(database, email)[source]

Checks whether an email is in the database

Return type:bool
mini_project_1.common.check_valid_lcode(database, lcode)[source]

Checks whether a lcode is in the database

Return type:bool
mini_project_1.common.date(date_str)[source]
Return type:DateTime
mini_project_1.common.get_location_id(dbcursor, keyword, prompt=None)[source]

Gets a location lcode from the user.

mini_project_1.common.get_selection(items, prompt='Enter selection number: ')[source]

Gets the user to select a item from a list, displaying up to 5 items at a time.

Parameters:
  • items (list) – list of items
  • prompt (str) – a prompt for user input, default is “Enter selection number: “
Returns:

selected item from items

mini_project_1.common.greater_than_zero_number(value)[source]
Return type:int
mini_project_1.common.price(price_string)[source]
Return type:int
mini_project_1.common.send_message(database, recipient, sender, content, rno)[source]