def test_search(self): d = wiki.search("Barack") self.assertIsInstance(d, list) self.assertEqual(len(d), 10) d = wiki.search("sldjflsfkdslfjsl") self.assertEqual(d, "No articles with that name, try another item.")
def do_wiki(self, s): """Jarvis will get wiki details for you""" # if no input or False values after 'wiki' command, return. if not s: return k = s.split(' ', 1) # check for index at 1. try: k[1] except IndexError: self.error() return data = None if k[0] == "search": data = wiki.search(" ".join(k[1:])) elif k[0] == "summary": data = wiki.summary(" ".join(k[1:])) elif k[0] == "content": data = wiki.content(" ".join(k[1:])) if isinstance(data, list): print("\nDid you mean one of these pages?\n") for d in range(len(data)): print(str(d + 1) + ": " + data[d]) else: print("\n" + data)
def do_wiki(self, s): """Jarvis will get wiki details for you""" k = s.split(' ', 1) if k[0] == "search": data = wiki.search(" ".join(k[1:])) elif k[0] == "summary": data = wiki.summary(" ".join(k[1:])) elif k[0] == "content": data = wiki.content(" ".join(k[1:])) if isinstance(data, list): print "\nDid you mean one of these pages?\n" for d in range(len(data)): print(str(d + 1) + ": " + data[d]) else: print("\n" + data)
def do_wiki(self, s): """Jarvis will get wiki details for you""" #ERROR if only uses wiki or wiki search without keyword k = s.split(' ', 1) data = None if k[0] == "search": data = wiki.search(" ".join(k[1:])) elif k[0] == "summary": data = wiki.summary(" ".join(k[1:])) elif k[0] == "content": data = wiki.content(" ".join(k[1:])) if isinstance(data, list): print("\nDid you mean one of these pages?\n") for d in range(len(data)): print(str(d + 1) + ": " + data[d]) # Jarvis don't let to choose over these results else: print("\n" + data)