From 2b1e8411ab5eaa7e1349b78d03270ab02ae2950d Mon Sep 17 00:00:00 2001 From: schneefux Date: Mon, 6 Oct 2014 16:52:53 +0200 Subject: Fix flake8 style nits --- client/populate.py | 53 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 18 deletions(-) (limited to 'client/populate.py') diff --git a/client/populate.py b/client/populate.py index e871f26..c309500 100644 --- a/client/populate.py +++ b/client/populate.py @@ -7,10 +7,13 @@ from pytz import timezone import feedparser import jasperpath + def run(): profile = {} - print "Welcome to the profile populator. If, at any step, you'd prefer not to enter the requested information, just hit 'Enter' with a blank field to continue." + print("Welcome to the profile populator. If, at any step, you'd prefer " + + "not to enter the requested information, just hit 'Enter' with a " + + "blank field to continue.") def simple_request(var, cleanVar, cleanInput=None): input = raw_input(cleanVar + ": ") @@ -24,20 +27,29 @@ def run(): simple_request('last_name', 'Last name') # gmail - print "\nJasper uses your Gmail to send notifications. Alternatively, you can skip this step (or just fill in the email address if you want to receive email notifications) and setup a Mailgun account, as at http://jasperproject.github.io/documentation/software/#mailgun.\n" + print("\nJasper uses your Gmail to send notifications. Alternatively, " + + "you can skip this step (or just fill in the email address if you " + + "want to receive email notifications) and setup a Mailgun " + + "account, as at http://jasperproject.github.io/documentation/" + + "software/#mailgun.\n") simple_request('gmail_address', 'Gmail address') profile['gmail_password'] = getpass() # phone number clean_number = lambda s: re.sub(r'[^0-9]', '', s) - phone_number = clean_number(raw_input( - "\nPhone number (no country code). Any dashes or spaces will be removed for you: ")) + phone_number = clean_number(raw_input("\nPhone number (no country " + + "code). Any dashes or spaces will " + + "be removed for you: ")) profile['phone_number'] = phone_number # carrier print("\nPhone carrier (for sending text notifications).") - print( - "If you have a US phone number, you can enter one of the following: 'AT&T', 'Verizon', 'T-Mobile' (without the quotes). If your carrier isn't listed or you have an international number, go to http://www.emailtextmessages.com and enter the email suffix for your carrier (e.g., for Virgin Mobile, enter 'vmobl.com'; for T-Mobile Germany, enter 't-d1-sms.de').") + print("If you have a US phone number, you can enter one of the " + + "following: 'AT&T', 'Verizon', 'T-Mobile' (without the quotes). " + + "If your carrier isn't listed or you have an international " + + "number, go to http://www.emailtextmessages.com and enter the " + + "email suffix for your carrier (e.g., for Virgin Mobile, enter " + + "'vmobl.com'; for T-Mobile Germany, enter 't-d1-sms.de').") carrier = raw_input('Carrier: ') if carrier == 'AT&T': profile['carrier'] = 'txt.att.net' @@ -50,7 +62,8 @@ def run(): # location def verifyLocation(place): - feed = feedparser.parse('http://rss.wunderground.com/auto/rss_full/' + place) + feed = feedparser.parse('http://rss.wunderground.com/auto/rss_full/' + + place) numEntries = len(feed['entries']) if numEntries == 0: return False @@ -58,18 +71,20 @@ def run(): print("Location saved as " + feed['feed']['description'][33:]) return True - print( - "\nLocation should be a 5-digit US zipcode (e.g., 08544). If you are outside the US, insert the name of your nearest big town/city. For weather requests.") + print("\nLocation should be a 5-digit US zipcode (e.g., 08544). If you " + + "are outside the US, insert the name of your nearest big " + + "town/city. For weather requests.") location = raw_input("Location: ") - while location and (verifyLocation(location) == False): + while location and not verifyLocation(location): print("Weather not found. Please try another location.") location = raw_input("Location: ") if location: profile['location'] = location # timezone - print( - "\nPlease enter a timezone from the list located in the TZ* column at http://en.wikipedia.org/wiki/List_of_tz_database_time_zones, or none at all.") + print("\nPlease enter a timezone from the list located in the TZ* " + + "column at http://en.wikipedia.org/wiki/" + + "List_of_tz_database_time_zones, or none at all.") tz = raw_input("Timezone: ") while tz: try: @@ -80,8 +95,8 @@ def run(): print("Not a valid timezone. Try again.") tz = raw_input("Timezone: ") - response = raw_input( - "\nWould you prefer to have notifications sent by email (E) or text message (T)? ") + response = raw_input("\nWould you prefer to have notifications sent by " + + "email (E) or text message (T)? ") while not response or (response != 'E' and response != 'T'): response = raw_input("Please choose email (E) or text message (T): ") profile['prefers_email'] = (response == 'E') @@ -91,9 +106,10 @@ def run(): "google": "GOOGLE_SPEECH" } - response = raw_input( - "\nIf you would like to choose a specific STT engine, please specify which." + - "\nAvailable implementations: %s. (Press Enter to default to PocketSphinx): " % stt_engines.keys()) + response = raw_input("\nIf you would like to choose a specific STT " + + "engine, please specify which.\nAvailable " + + "implementations: %s. (Press Enter to default " + + "to PocketSphinx): " % stt_engines.keys()) if (response in stt_engines): profile["stt_engine"] = response api_key_name = stt_engines[response] @@ -101,7 +117,8 @@ def run(): key = raw_input("\nPlease enter your API key: ") profile["keys"] = {api_key_name: key} else: - print("Unrecognized STT engine. Available implementations: %s" % stt_engines.keys()) + print("Unrecognized STT engine. Available implementations: %s" + % stt_engines.keys()) profile["stt_engine"] = "sphinx" # write to profile -- cgit v1.3.1