Skip to content

Commit fd156f5

Browse files
committed
updated status and error messages
1 parent 6e52197 commit fd156f5

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

PyDoc.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,24 @@ def run(self, selected_text):
1515
if selections:
1616
needle = self.view.substr(selections[0])
1717
if len(needle) == 0:
18-
print("PyDOC Plugin Error: There was no selected string for the Python 3 documentation search. Please select a string in your document and try again.")
18+
print("PyDOC Plugin Error: You did not select text for the Python 3 documentation search. Please select a Python built-in object in your editor and try again.")
1919
else:
2020
if version_info[0] == 2:
2121
needle = urllib.quote_plus(needle) # url encode Python 2 interpreter
2222
url = "http://docs.python.org/3/search.html?q=" + needle + "&check_keywords=yes"
2323
else:
2424
url = "http://docs.python.org/3/search.html?q=" + needle + "&check_keywords=yes"
2525
url = urllib.parse.urlparse(url).geturl() # url encode Python 3 interpreter
26-
print("PyDOC: Performing search for Python 3 documentation on the keyword, '" + needle + "'")
26+
user_message = "PyDOC: Performing search for Python 3 documentation on the keyword, '" + needle + "'"
27+
print(user_message)
28+
sublime.status_message(user_message)
2729
webbrowser.open(url)
2830
else:
29-
print("PyDOC Plugin Error: There was no selected string for the search. Please select a string in your document and try again.")
31+
print("PyDOC Plugin Error: You did not select text for the Python 3 documentation search. Please select a Python built-in object in your editor and try again.")
32+
sublime.status_message("PyDOC Plugin Error: Text was not selected")
3033
except Exception as e:
3134
print("PyDOC Plugin Error: There was an error during the execution of the plugin.\n")
35+
sublime.status_message("PyDOC Plugin Error: Open console for info")
3236
raise e
3337

3438
# Python 2 Documentation Search
@@ -39,19 +43,23 @@ def run(self, selected_text):
3943
if selections:
4044
needle = self.view.substr(selections[0])
4145
if len(needle) == 0:
42-
print("PyDOC Plugin Error: There was no selected string for the Python 2 documentation search. Please select a string in your document and try again.")
46+
print("PyDOC Plugin Error: You did not select text for the Python 2 documentation search. Please select a Python built-in object in your editor and try again.")
4347
else:
4448
if version_info[0] == 2:
4549
needle = urllib.quote_plus(needle)
4650
url = "http://docs.python.org/2/search.html?q=" + needle + "&check_keywords=yes" # url encode Python 2 interpreter
4751
else:
4852
url = "http://docs.python.org/2/search.html?q=" + needle + "&check_keywords=yes"
4953
url = urllib.parse.urlparse(url).geturl() # url encode Python 3 interpreter
50-
print("PyDOC: Performing search for Python 2 documentation on the keyword, '" + needle + "'")
54+
user_message = "PyDOC: Performing search for Python 2 documentation on the keyword, '" + needle + "'"
55+
print(user_message)
56+
sublime.status_message(user_message)
5157
webbrowser.open(url)
5258
else:
53-
print("PyDOC Plugin Error: There was no selected string for the search. Please select a string in your document and try again.")
59+
print("PyDOC Plugin Error: You did not select text for the Python 2 documentation search. Please select a Python built-in object in your editor and try again.")
60+
sublime.status_message("PyDOC Plugin Error: Text was not selected")
5461
except Exception as e:
5562
print("PyDOC Plugin Error: There was an error during the execution of the plugin.\n")
63+
sublime.status_message("PyDOC Plugin Error: Open console for info")
5664
raise e
5765

0 commit comments

Comments
 (0)