示例#1
0
def get_yes_or_no( prompt_str ):
    """
    Asks the user for a yes or no response.
    Args:
        (str) prompt_str - the question

    Returns:
        (boolean) yes (true) or no (false)
    """
    is_yes_or_no = VerticalPrompt(
            [
              YesNo("{}".format(prompt_str)
                    )
              ],
              spacing = 1
            )

    try:
        yes_or_no = is_yes_or_no.launch()[0][1]

    except:
        print( "{}".format("Bad keystroke - try again"))
        yes_or_no = get_yes_or_no( prompt_str )

    return yes_or_no
示例#2
0
def run_cli() -> Options:
    """
    Run CLI and return options
    """

    cli = VerticalPrompt(
        [
            Input("Project Name? ", default="latex_project", strip=True),
            Bullet(
                "Which template to use?",
                choices=[
                    t
                    for t in os.listdir("./latex_up/templates") if "." not in t
                ],
            ),
            Check(
                "Include lists? (Press Space to check/uncheck)",
                ["Enumerate", "Itemize", "Description"],
            ),
            Check(
                "Choose other latex structures to include. (Press Space to check/uncheck)",
                ["Graphic", "Bibtex", "Equation"],
            ),
        ],
        spacing=1,
    )

    result = cli.launch()

    return Options.from_args(result[0][1], result[1][1], *result[2][1],
                             *result[3][1])
示例#3
0
def continue_user():
    user_input = VerticalPrompt([
        Input("username: "******"password: "******"*", indent=0),
    ],
                                spacing=0)
    user_login = user_input.launch()
    print(user_login[0][1])
示例#4
0
def main():
    print("Let's create a Module!")
    cli = VerticalPrompt(
        [Input("Module Name (with spaces):  "),
         Input("First Command:  ")])
    result = cli.launch()
    name = "".join([word.capitalize() for word in result[0][1].split(' ')])
    command = result[1][1]
    # Create module folder
    path = os.path.join("iota", "modules", name)
    os.mkdir(path)
    # Create init
    Path(os.path.join(path, '__init__.py')).touch()
    # Create basic config file
    build_config(name, command, path)
    # Create Module Class file
    build_module(name, path)
示例#5
0
def new_user():
    user_input = VerticalPrompt([
        Input("username: "******"password: "******"*", indent=0),
        Password("repeat password: "******"*", indent=0),
    ],
                                spacing=0)

    new_login = user_input.launch()
    if new_login[1][1] == new_login[2][1]:
        add_user(new_login[0][1], new_login[1][1])
    else:
        print(Fore.RED + "\nPasswords do not match!" + Fore.WHITE)
        time.sleep(2)
        clearConsoleUp(5)
        clearLine()
        new_user()
def parse_config():
    cli = VerticalPrompt(
        [
            Bullet("choice env? ",
                   choices=['test', 'new-test']),
        ],
        spacing=1
    )
    result = cli.launch()
    _, subj = result[0]
    if subj == 'new-test':
        subj = 'test-next'

    log = ["  "] + get_git_log('/mnt/api-site', 'ydl', subj)
    cli = VerticalPrompt(
        [
            Bullet("choice git log: ",
                   choices=log),
            YesNo("send? "),
        ],
        spacing=1
    )
    result = cli.launch()
    _, text = result[0]
    _, yes_or_no = result[1]
    return subj, text, yes_or_no
示例#7
0
def get_contact_details():
    contact_info = VerticalPrompt([
        Input("First Name: "),
        Input("Last name: "),
        Bullet(prompt="Choose a contact type from the items below: ",
               choices=[
                   'PERSON', 'COMPANY', 'ASSOCIATION', 'PUBLIC_BODY',
                   'RESELLER'
               ],
               **styles.Ocean),
        Input("Organization name (Used when contact type is not a person): ",
              pattern=".*"),
        Input("Address Line 1: "),
        Input("Address Line 2: "),
        Input("City: "),
        Input("State: "),
        Input("Two Digit Country Code (e.g. US, GB, JP): ",
              pattern="^[A-Z]{2}$"),
        Input("Zip Code: "),
        Input(
            "Phone Number with period after country code (e.g. for United States: +1.5556667788): ",
            pattern="^\+[0-9]{1,2}\.[0-9]{10}$"),
        Input("Email: ")
    ],
                                  spacing=1).launch()
    details = {
        'FirstName': contact_info[0][1],
        'LastName': contact_info[1][1],
        'ContactType': contact_info[2][1],
        'AddressLine1': contact_info[4][1],
        'AddressLine2': contact_info[5][1],
        'City': contact_info[6][1],
        'State': contact_info[7][1],
        'CountryCode': contact_info[8][1],
        'ZipCode': contact_info[9][1],
        'PhoneNumber': contact_info[10][1],
        'Email': contact_info[11][1],
    }
    if details['ContactType'] != "PERSON":
        details["OrganizationName"] = contact_info[3][1]
    return details
示例#8
0
import sys

TITLE_LAYOUT = 0
BLANK = 10
FONT = "Calibri"
FILE_LOC = ""
SERMON_SERIES = "Signs of Life Series in John’s Gospel"

cli = VerticalPrompt(
    [
        Input("What is the reference for Call to Worship?"),
        Input("Filename?"),
        Input("What is the reference for Confession of Sin?"),
        Input("Filename?"),
        Input("What is the reference for Assurance of Worship?"),
        Input("Filename?"),
        YesNo("Is it prayers of the people? "),
        Input("Sermon title?"),
        Input("Sermon reference?"),
        #Bullet("What is your favorite programming language? ",
        #     choices = ["C++", "Python", "Javascript", "Not here!"]),
    ],
    spacing=1)

result = cli.launch()


class LiturgyElem:
    def __init__(self, f_name):
        self.title = ""
        self.lyrics = []
def canvas_git_map_table_wizard(course : Course) -> Table:
    """Create a Canvas-Git map CSV file."""
    students = course.students()

    if len(students) <= 0:
        warn((f"No students found for course '{course.name}'."))
        return Table([])

    number_of_students  = len(students)
    head                = min(number_of_students, HEAD)
    number_shown        = head if head < number_of_students else "all"
    table               = tabulate([s.fields() for s in students[:head]], headers = "keys")

    inform((f"Found {len(students)} students for this course. "
            f"Showing available data for {number_shown} of them: \n\n"
            f"{table}\n"))

    canvas_id_key = CANVAS_LOGIN_ID
    inform((f"The column '{canvas_id_key}' contains students' Canvas ID."))

    cli = VerticalPrompt([
        Bullet(
            prompt  = ASK_GIT_ID,
            choices = PUBLIC_USER_FIELDS,
            bullet  = " >",
            margin  = 2,
            align   = 1,
            shift   = 1,
        ),
        Check(
            prompt  = ASK_EXTRA_COLUMNS,
            choices = PUBLIC_USER_FIELDS,
            check   = " >",
            margin  = 2,
            align   = 1,
            shift   = 1,
        ),
    ])

    git_id_key, extra_columns = [r for (p, r) in cli.launch()]

    data = []

    for student in students:
        row = {}
        fields = student.fields()

        if canvas_id_key in fields:
            row[CANVAS_ID] = fields[canvas_id_key]
        else:
            row[CANVAS_ID] = ""

        if git_id_key in fields:
            row[GIT_ID] = fields[git_id_key]
        else:
            row[GIT_ID] = ""

        for column in extra_columns:
            if column in fields:
                row[column] = fields[column]
            else:
                row[column] = ""

        data.append(row)

    return Table(data)