Minor code cleanup.

Add and use helper function to ask a yes/no question.
This commit is contained in:
Hartmut Goebel
2019-04-16 12:31:20 +02:00
parent da5486d004
commit b0ba30b5f3

View File

@ -169,9 +169,14 @@ def get_entry(entry, generator=None):
} }
def setup(config_file): def setup(config_file):
def yes_no(question):
res = input(question + ' [y/n] ')
return res.lower() in "y1"
url = input('What is your Mastodon Instance URL? ') url = input('What is your Mastodon Instance URL? ')
have_app = input('Do you have your app credentials already? [y/n] ') have_app = yes_no('Do you have your app credentials already?')
if have_app.lower() == 'y': if have_app:
name = 'feediverse' name = 'feediverse'
client_id = input('What is your app\'s client id: ') client_id = input('What is your app\'s client id: ')
client_secret = input('What is your client secret: ') client_secret = input('What is your client secret: ')