-
Notifications
You must be signed in to change notification settings - Fork 986
Minor code cleaning, formatted error messages #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
9d57936
2f2d8c8
2d792b8
f1ba941
0b034e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
EXAMPLE_ANIME = """ | ||
- Death Note anime, | ||
- Dragon ball super anime status, | ||
- What is the anime rating of One Punch Man?""" | ||
|
||
EXAMPLE_BOOKS = """ | ||
- book timeline | ||
- harry potter book plot | ||
- little women book rating""" | ||
|
||
EXAMPLE_CONVERSIONS = """ | ||
- HKD to USD | ||
- USD to EUR rate | ||
- how much is 100 USD to INR""" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W293 blank line contains whitespace |
||
EXAMPLE_DEFINITIONS = """ | ||
- define comfort | ||
- cloud definition | ||
- what does an accolade mean?""" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W293 blank line contains whitespace |
||
EXAMPLE_LYRICS = """ | ||
- paradise lyrics | ||
- lyrics of the song hall of fame | ||
- What are the lyrics to see you again?""" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W293 blank line contains whitespace |
||
EXAMPLE_MOVIES = """ | ||
- batman movie | ||
- iron man 2 movie plot | ||
- What is the rating of happiness movie?""" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W293 blank line contains whitespace |
||
EXAMPLE_TIME = """ | ||
- time in new york | ||
- india time | ||
- time at paris""" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W293 blank line contains whitespace |
||
EXAMPLE_VIDEOS = """ | ||
- sia videos | ||
- videos by eminem | ||
- video coldplay""" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W293 blank line contains whitespace |
||
EXAMPLE_WEATHER = """ | ||
- tell me the weather in London | ||
- weather Delhi | ||
- What's the weather in Texas?""" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W293 blank line contains whitespace |
||
EXAMPLE_WIKI = """ | ||
- wikipedia barack | ||
- html wiki | ||
- who is sachin tendulkar""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W292 no newline at end of file |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't a module. It's more of a helper class. Can be moved to modules/examples.py There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unsure, so asking for clarification: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make only one file now: examples.py. (error_msg.py can be created later if required; let the error messages be in the corresponding module itself, like it is now. Will visit it later) |
||
BASE_ERROR = "\nPlease ask me something else, like:" | ||
QUERY_ERROR = "I couldn't find any {} matching your query." + BASE_ERROR | ||
CONVERT_ERROR = "I couldn't convert between those {}." + BASE_ERROR | ||
LOCATION_ERROR = "I couldn't get the {} at the location you specified." + BASE_ERROR | ||
|
||
EXAMPLE_ANIME = """ | ||
- Death Note anime, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W291 trailing whitespace |
||
- Dragon ball super anime status, | ||
- What is the anime rating of One Punch Man?""" | ||
|
||
EXAMPLE_BOOKS = """ | ||
- book timeline | ||
- harry potter book plot | ||
- little women book rating""" | ||
|
||
EXAMPLE_CONVERSIONS = """ | ||
- HKD to USD | ||
- USD to EUR rate | ||
- how much is 100 USD to INR""" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W293 blank line contains whitespace |
||
EXAMPLE_DEFINITIONS = """ | ||
- define comfort | ||
- cloud definition | ||
- what does an accolade mean?""" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W293 blank line contains whitespace |
||
EXAMPLE_LYRICS = """ | ||
- paradise lyrics | ||
- lyrics of the song hall of fame | ||
- What are the lyrics to see you again?""" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W293 blank line contains whitespace |
||
EXAMPLE_MOVIES = """ | ||
- batman movie | ||
- iron man 2 movie plot | ||
- What is the rating of happiness movie?""" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W293 blank line contains whitespace |
||
EXAMPLE_TIME = """ | ||
- time in new york | ||
- india time | ||
- time at paris""" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W293 blank line contains whitespace |
||
EXAMPLE_VIDEOS = """ | ||
- sia videos | ||
- videos by eminem | ||
- video coldplay""" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W293 blank line contains whitespace |
||
EXAMPLE_WEATHER = """ | ||
- tell me the weather in London | ||
- weather Delhi | ||
- What's the weather in Texas?""" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W293 blank line contains whitespace |
||
EXAMPLE_WIKI = """ | ||
- wikipedia barack | ||
- html wiki | ||
- who is sachin tendulkar""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W292 no newline at end of file |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,35 +2,36 @@ | |
|
||
|
||
def process(input, entities=None): | ||
help = 'Hi there! I\'m Jarvis, your personal assistant.' | ||
if entities is not None: | ||
helper = 'Hi there! I\'m Jarvis, your personal assistant.\n' | ||
if entities: | ||
if 'sender' in entities and 'first_name' in entities['sender']: | ||
sender_name = entities['sender']['first_name'] | ||
help = help.replace('there', sender_name) | ||
help += '\n\nYou can tell me things like:' | ||
help += '\n - define comfort' | ||
help += '\n - iron man 2 movie plot' | ||
help += '\n - tell me a joke/quote/fact' | ||
help += '\n - wiki html' | ||
help += '\n - anything you want book' | ||
help += '\n - usd to eur rate' | ||
help += '\n - death note anime' | ||
help += '\n - time in seattle' | ||
help += '\n - songs by linkin park' | ||
help += '\n - shorten google.com' | ||
help += '\n - weather in london' | ||
help += '\n - videos of sia' | ||
help += '\n - flip a coin' | ||
help += '\n - roll a die' | ||
help += '\n - show a random xkcd comic' | ||
help += '\n - latest news' | ||
help += '\n - paradise lyrics' | ||
help += '\n\nI\'m always learning, so do come back and say hi from time to time!' | ||
help += '\nHave a nice day. :)' | ||
helper = helper.replace('there', entities['sender']['first_name']) | ||
helper += """ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reset this file and others which are related to triple-quoting the strings. They can be picked up in a separate PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Covered in the initial pull-request; I will include it with the next one, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove these changes for now. Only keep the examples refactoring in this PR. |
||
You can tell me things like: | ||
- define comfort | ||
- iron man 2 movie plot | ||
- tell me a joke/quote/fact | ||
- wiki html | ||
- anything you want book | ||
- usd to eur rate | ||
- death note anime | ||
- time in seattle | ||
- songs by linkin park | ||
- shorten google.com | ||
- weather in london | ||
- videos of sia | ||
- flip a coin | ||
- roll a die | ||
- show a random xkcd comic | ||
- latest news | ||
- paradise lyrics | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W293 blank line contains whitespace |
||
I'm always learning, so do come back and say hi from time to time! | ||
Have a nice day. :)""" | ||
|
||
output = { | ||
'input': input, | ||
'output': TextTemplate(help).get_message(), | ||
'output': TextTemplate(helper).get_message(), | ||
'success': True | ||
} | ||
return output |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,11 +34,13 @@ def process(input, entities): | |
output['output'] = template.get_message() | ||
output['success'] = True | ||
except: | ||
error_message = 'I couldn\'t find any music matching your query.' | ||
error_message += '\nPlease ask me something else, like:' | ||
error_message += '\n - hymn for the weekend song' | ||
error_message += '\n - linkin park songs' | ||
error_message += '\n - play hotel california' | ||
error_message = """\ | ||
I couldn't find any music matching your query. | ||
Please ask me something else, like: | ||
- hymn for the weekend song | ||
- linkin park songs | ||
- play hotel california""" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W293 blank line contains whitespace |
||
output['error_msg'] = TextTemplate(error_message).get_message() | ||
output['success'] = False | ||
return output |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,9 @@ | |
|
||
|
||
def process(input, entities=None): | ||
request = 'Kindly use the following buttons to:' | ||
request += '\n - Request a new feature, by including some sample queries and their expected results.' | ||
request += '\n - Report a bug (I couldn\'t handle the query and/or gave unexpected results), by including your search query and the expected result.' | ||
request = """Kindly use the following buttons to: | ||
- Request a new feature, by including some sample queries and their expected results. | ||
- Report a bug (I couldn't handle the query and/or gave unexpected results), by including your search query and the expected result.""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. E501 line too long (139 > 120 characters) |
||
template = ButtonTemplate(request) | ||
template.add_web_url('File an Issue', 'https://github.com/swapagarwal/JARVIS-on-Messenger/issues/new') | ||
template.add_web_url('Chat with my Master', 'https://gitter.im/swapagarwal/JARVIS-on-Messenger') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,11 +27,7 @@ def process(input, entities): | |
'abbreviation']).get_message() | ||
output['success'] = True | ||
except: | ||
error_message = 'I couldn\'t get the time at the location you specified.' | ||
error_message += '\nPlease ask me something else, like:' | ||
error_message += '\n - time in new york' | ||
error_message += '\n - india time' | ||
error_message += '\n - time at paris' | ||
error_message = LOCATION_ERROR.format('time') + EXAMPLE_TIME | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. F821 undefined name 'LOCATION_ERROR' |
||
output['error_msg'] = TextTemplate(error_message).get_message() | ||
output['success'] = False | ||
return output |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
import config | ||
from templates.generic import * | ||
from templates.text import TextTemplate | ||
from error_msg import QUERY_ERROR | ||
|
||
YOUTUBE_DATA_API_KEY = os.environ.get('YOUTUBE_DATA_API_KEY', config.YOUTUBE_DATA_API_KEY) | ||
|
||
|
@@ -33,11 +34,7 @@ def process(input, entities): | |
output['output'] = template.get_message() | ||
output['success'] = True | ||
except: | ||
error_message = 'I couldn\'t find any videos matching your query.' | ||
error_message += '\nPlease ask me something else, like:' | ||
error_message += '\n - sia videos' | ||
error_message += '\n - videos by eminem' | ||
error_message += '\n - video coldplay' | ||
error_message = QUERY_ERROR.format('videos') + EXAMPLE_VIDEOS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. F405 'EXAMPLE_VIDEOS' may be undefined, or defined from star imports: templates.generic |
||
output['error_msg'] = TextTemplate(error_message).get_message() | ||
output['success'] = False | ||
return output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
W291 trailing whitespace