def main():
   se = SearchEngine()
   option_str = displayMenu()
   option = int(option_str)
   while(option !=5):
      results = list()
      if option == 1:
         callNumber = input("Enter Call Number: ")
         results = se.search_by_call_no(callNumber)
         se.display(results)
      elif option == 2:
         subject = input("Enter Subject: ")
         results = se.search_by_subjects(subject)
         se.display(results)
      elif option == 3:
         title = input("Enter Title: ")
         results = se.search_by_title(title)
         se.display(results)
      elif option == 4:
         other = input("Enter Other : ")
         results = se.search_by_other(other)
         se.display(results)
      else:
         print('\n')   
         print("Enter Correct option:")
      print('\n')   
      print("Total No. of Matching Result: ", len(results))
      print('\n')   
      option_str = displayMenu()
      option = int(option_str)
Esempio n. 2
0
while choice != 5:
    print("\n\t\t\t ###############################  GAVELTON LIBRARY ############################### \n"
          "\n Welcome! Looking for something? I can help!")

    search_str = raw_input("\n Enter a word or a phrase to get started: ")
    print("\n How do you wanna search?\n"
          " 1. Search by call number\n"
          " 2. Search by title\n"
          " 3. Search by subject\n"
          " 4. Search by other\n"
          " 5. Quit\n")
    choice = input(" Your Choice: ")

    if choice == 1:
        results = search_engine.search_by_call_no(search_str)
        if len(results) > 0:
            print("\n\t\t\t ************************** Search Results ************************** ")
            for item in results:
		item.display()

        else:
            print("\n Sorry no results found with <" + search_str + "> in call number")

    elif choice == 2:
        results = search_engine.search_by_title(search_str)
        if len(results) > 0:
            print("\t\t\t ************************** Search Results ************************** ")
            for item in results:
                item.display()