def _play_day(money, stock_portfolio):
    prices = _get_prices()

    while True:
        _print_output(money, stock_portfolio, prices)
        try:
            answers = columbo.get_answers(
                questions,
                answers={
                    'money': money,
                    'portfolio': stock_portfolio,
                    'prices': prices
                },
            )
        except ValueError:  # a ValueError will be raised if the user wants to buy/sell stock he/she cannot
            continue

        if answers['action'] == 'buy':
            money, stock_portfolio = buy(money, stock_portfolio, prices,
                                         answers)
        elif answers['action'] == 'sell':
            money, stock_portfolio = sell(money, stock_portfolio, prices,
                                          answers)
        elif answers['action'] == 'view':
            pass
        else:
            # we're done!
            return money, stock_portfolio
Exemple #2
0
import columbo


def user_has_dog(answers: columbo.Answers) -> bool:
    return answers["has_dog"]


interactions = [
    columbo.Confirm("has_dog", "Do you have a dog?", default=True),
    columbo.BasicQuestion(
        "dog_name",
        "What is the name of the dog?",
        should_ask=user_has_dog,
        default="Kaylee",
    ),
    columbo.BasicQuestion(
        "dog_breed",
        "What is the breed of the dog?",
        should_ask=user_has_dog,
        default="Basset Hound",
    ),
]

user_answers = columbo.get_answers(interactions)
print(user_answers)
        default="A flasky app.",
    ),
    columbo.Confirm(
        "use_pipenv",
        "Should this project use pipenv?",
        default=False,
    ),
    columbo.Choice(
        "python_version",
        "Which version of Python will this application use?",
        options=["3.10", "3.9", "3.8", "3.7"],
        default="3.10",
    ),
    columbo.Choice(
        "node_version",
        "Which version of Node will this application use?",
        options=["16", "14", "12"],
        default="16",
    ),
    columbo.Confirm(
        "use_heroku",
        "Will this project be deployed using heroku?",
        default=False,
    ),
]

if __name__ == "__main__":
    args = handle_cli_input()
    answers = columbo.get_answers(interactions, no_user_input=args.no_input)
    cookiecutter(args.template, no_input=True, extra_context=answers)