def main(): # def __init__(self, title, call_no, author, num_copies): # issue, publisher): # def __init__(self, title, call_no, author, num_copies, name, # issue, publisher): b1 = Book("Provenance", "342.2", "Anne Leckie", 20) b2 = Book("Ancillary Justice", "342.2A", "Anne Leckie", 1) j1 = Journal("Individual Psychology", "123.4", "Gabriela Pap", 1, "Journal of Psychology", 23, "SAGE Publications") d1 = Dvd("Mad Max: Fury Road", "789.0", "George Miller", 8, "May 15, 2015", "1") cat = Catalogue({ "342.2": Book("Provenance", "342.2", "Anne Leckie", 20), "342.2A": Book("Ancillary Justice", "342.2A", "Anne Leckie", 1), "123.4": Journal("Individual Psychology", "123.4", "Gabriela Pap", 1, "Journal of Psychology", 23, "SAGE Publications"), "789.0": Dvd("Mad Max: Fury Road", "789.0", "George Miller", 8, "May 15, 2015", "1") }) vpl = Library(cat) display_menu = True while display_menu: print("What would you like to do?") print("1. Find item by title (String)") print("2. Add item to catalogue") print("3. Remove item from catalogue (call no)") print("4. Check out a copy (call no)") print("5. Return your copy (call no)") print("6. Display library catalogue") print("7. Quit menu") choice = int(input("Select action: ")) if choice == 2: vpl.get_cat().add_item() elif choice == 6: vpl.display_available_books() elif choice == 7: display_menu = False elif choice not in range(1, 6): print("\nInvalid input. Try again.\n") else: par = input("Enter parameter: ") input_dict = { 1: vpl.search, 3: cat.remove_item, 4: vpl.check_out, 5: vpl.return_item } print(input_dict.get(choice)(par))
def test_journal_add_content(): if os.path.exists(file_path): os.remove(file_path) entry_1 = 'This is my first entry journal entry' entry_2 = 'Now we have excellent history features.' expected = "{}\n{}\n".format(entry_1, entry_2) journal = Journal() journal.add(entry_1) journal.save() journal = Journal() journal.add(entry_2) journal.save() actual = open(file_path, 'r').read() assert expected == actual
def loadJournals(self): journalList = [] first = True with open(self._journalCsv, 'rb') as csvfile: journalReader = csv.reader(csvfile) for row in journalReader: if first: first = False continue journal = Journal(self._xLen, self._yLen, self._zLen) print "{} {} {} {} {} {} {} {}".format( \ row[0], row[1], row[2], row[3], \ row[4], row[5], row[6], row[7]) # Timestamp = row[0] journal.work_text = row[1].strip() journal.misc_text = row[2].strip() journal.eventful = int(row[3]) journal.moods = self.parseMoodList(row[4], journal) date = row[5] time = row[6] journal.setTimeSec(self.parseDateTime(date, time)) journal.weights = [int(w) for w in row[7].split(",")] journalList.append(journal) self._journalList = journalList print "list: " + str(len(journalList)) + " self: " + str(len(self._journalList)) return journalList
def create_item(): """ Creates an item. :return: an item """ print( "What kind of items would you like to add to the library catalogue?" ) print("1. Book") print("2. DVD") print("3. Journal") option = int(input("Select type of item: ")) title = input("Enter title: ") call_num = input("Enter call number: ") author = input("Enter author name: ") num_copies = input("Enter the number of copies: ") if option == 1: return Book(call_num, title, num_copies, author) if option == 2: release_date = input("Enter release date: ") region_code = input("Enter region code: ") return Dvd(call_num, title, num_copies, author, release_date, region_code) if option == 3: names = input("Enter name: ") issue_number = input("Enter issue number: ") publisher = input("Enter publisher: ") return Journal(call_num, title, num_copies, author, names, issue_number, publisher)
def get_fresh_journal_list(scenario, my_jwt): from package import Package my_package = Package.query.filter( Package.package_id == scenario.package_id).scalar() journals_to_exclude = ["0370-2693"] issn_ls = scenario.data["unpaywall_downloads_dict"].keys() issnls_to_build = [ issn_l for issn_l in issn_ls if issn_l not in journals_to_exclude ] # only include things in the counter file if my_package.is_demo: issnls_to_build = [ issn_l for issn_l in issnls_to_build if issn_l in scenario.data[DEMO_PACKAGE_ID]["counter_dict"].keys() ] package_id = DEMO_PACKAGE_ID else: issnls_to_build = [ issn_l for issn_l in issnls_to_build if issn_l in scenario.data[ scenario.package_id]["counter_dict"].keys() ] package_id = scenario.package_id journals = [ Journal(issn_l, package_id=package_id) for issn_l in issnls_to_build if issn_l ] for my_journal in journals: my_journal.set_scenario(scenario) return journals
def create_item(): """ Create Item based on user input. :return: as Item """ print("What type of item would you like to add to" "the library catalogue?") print("1. Book") print("2. DVD") print("3. Scientific Journal") choice = int(input("Select type of item: ")) title = input("Enter title: ") call_no = input("Enter call number: ") author = input("Enter author name: ") num_copies = input("Enter the number of copies: ") if choice == 1: return Book(title, call_no, author, num_copies) if choice == 2: release = input("Enter release date: ") region = input("Enter region code: ") return Dvd(title, call_no, author, num_copies, release, region) if choice == 3: name = input("Enter name of publication: ") issue = input("Enter issue number: ") publisher = input("Enter publisher: ") return Journal(title, call_no, author, num_copies, name, issue, publisher)
def generate_test_items(): """ Return a list of items with dummy data. :return: a list """ kwargs1 = { "call_num": "100.200.300", "title": "Harry Potter 1", "num_copies": 2 } kwargs2 = { "call_num": "425.63.775", "title": "Toy Story", "num_copies": 2 } kwargs3 = { "call_num": "874.234.863", "title": "Science Journal", "num_copies": 5 } item_list = [ Book("J K Rowling", **kwargs1), Dvd("10-10-2004", "NA", **kwargs2), Journal("Dr. Smart", 7, "Pearsons", **kwargs3) ] return item_list
def generate_item(call_num): user_input = None # If entered invalid option, loops user back to choices below while user_input != 4: print("What type of item would you like to add") print("1. Book") print("2. DVD") print("3. Journal") print("4. Back") string_input = input("Please enter your choice (1-4)") user_input = int(string_input) title = input("Enter title: ") num_copies = int(input("Enter number of copies (positive number): ")) item_data = (call_num, title, num_copies) # creates the item object of input choice if user_input == 1: author = input("Enter Author Name: ") return Book(item_data[0], item_data[1], item_data[2], author) if user_input == 2: release_date = input("Enter release date (yyyy/mm/dd): ") code = input("Enter region code: ") return DVD(item_data[0], item_data[1], item_data[2], release_date, code) if user_input == 3: names = input("Enter names") issue_number = input("Please enter issue number") publisher = input("Enter publisher") return Journal(item_data[0], item_data[1], item_data[2], names, issue_number, publisher) # return to menu if user_input == 4: pass
def __init__(self, sanityModel, startSimThread=True): self.journal = Journal(sanityModel) self.simulation = Simulation(sanityModel, startSimThread) self.localTargets = { 'simulation': marshal.channel(self.simulation), 'journal': marshal.channel(self.journal), }
def test_journal_save(): if os.path.exists(file_path): os.remove(file_path) expected = True Journal().save() actual = os.path.exists(file_path) assert expected == actual
def __init__(self, name, room): self.action_index = ACTION_INDEX self.base_defense = 10 self.attack = 0.01 self.xp = 0 self.level = 1 self.xp_to_level = self.set_xp_to_level() self.constitution = 10 self.dexterity = 10 self.intelligence = 10 self.strength = 10 self.find_traps = 50 self.turn_counter = 1 self.max_hp = self.set_max_hp() # TODO: Figure out how to calculate Stamina and Mana; # TODO: Implement stamina and mana drain from certain abilities. # TODO: Implement stamina and mana regen during advance_turn(). self.stamina = 0 self.mana = 0 self.inventory = Inventory() self.journal = Journal() self.explored_rooms = dict() self.cooldowns = dict() self.messages = None super().__init__(name, room, max_hp=self.max_hp) self.assign_room(room)
def login(u_name, password): user_details = file_obj.readFile() print("Received Password") print(password) rec_password = crypto.decrypt(password) print("Decrypted Password") print(rec_password) print(type(password)) journal_flow = 0 for user in user_details: # if user["uname"] == u_name and user["password"] == password: f_uname = user['uname'] f_pass = user["password"] f_pass = crypto.decrypt(f_pass) if f_uname==u_name and f_pass==rec_password: print("Authentication Successful!") journal_flow = 1 break if journal_flow == 0: print("login failed") login_new() else: while journal_flow == 1: list_or_create = int(input("\n Press 1 for listing previous entries \n Press 2 for creating new entry \n Press 3 to login as new User \n Press 5 to exit application \n")) if list_or_create == 1: print("list codde") journal_obj = Journal(u_name) entries = journal_obj.read_journal() print("entries are ", entries) elif list_or_create == 2: print("create code") j_entry = str(input("\n Write an entry for the journal")) journal_obj = Journal(u_name) journal_obj.write_entry(j_entry) print("entry written") elif list_or_create == 3: journal_flow = 0 login_new() elif list_or_create == 5: break else: journal_flow = 1 print("invalid input")
def test_journal_add_new_content(): if os.path.exists(file_path): os.remove(file_path) entry_1 = 'This is my first entry journal entry' expected = 'Your 1 journal entry\n\n1. {}\n'.format(entry_1) journal = Journal() journal.add(entry_1) actual = journal.list() assert expected == actual
def create_journal(item_info: dict) -> Journal: """ Creates a Journal. """ issue_number = input("Enter Issue Number: ") publisher = input("Enter Publisher Name: ") item_info["issue_number"] = issue_number item_info["publisher"] = publisher return Journal(**item_info)
def test_journal_save_content(): if os.path.exists(file_path): os.remove(file_path) entry_1 = 'This is my first entry journal entry' expected = '{}\n'.format(entry_1) journal = Journal() journal.add(entry_1) journal.save() actual = open(file_path, 'r').read() assert expected == actual
def create_journal() -> Journal: """ Creates a Journal. """ call_number = input("Enter Call Number: ") title = input("Enter Journal Name: ") num_copies = int(input("Enter Number of Copies: ")) issue_number = input("Enter Issue Number: ") publisher = input("Enter Publisher Name: ") return Journal(call_number, title, num_copies, issue_number, publisher)
def main(): journal = Journal() menu = Menu() selection = menu.prompt() while selection != 'x': if selection == 'l': print(journal.list()) elif selection == 'a': journal.add(input('Enter your journal entry:\n')) selection = menu.prompt() journal.save()
def test_journal_list(): if os.path.exists(file_path): os.remove(file_path) entry_1 = 'This is my first entry journal entry' entry_2 = 'Now we have excellent history features.' entry_3 = 'What a sunny Saturday. Time for some exercise!' entries = [entry_1, entry_2, entry_3] listing = '1. {}\n2. {}\n3. {}\n'.format(entry_3, entry_2, entry_1) expected = 'Your 3 journal entries\n\n{}'.format(listing) actual = Journal(entries).list() assert expected == actual
def create(): title = input("Enter a title: ") call_num = input("Enter a call number: ") num_copies = input("Enter number of copies: ") issue = input("Enter Issue Number: ") publisher = input("Enter Publisher Name: ") return Journal(title=title, call_num=call_num, num_copies=num_copies, issue_number=issue, publisher=publisher)
def __init__(self, xLen, yLen, zLen, journalCsv): self._xLen = xLen self._yLen = yLen self._zLen = zLen self._journalCsv = journalCsv self._moodFactory = MoodFactory(self._xLen, self._yLen, self._zLen) self._journalList = [] self._testJournal = Journal(self._xLen, self._yLen, self._zLen, 0) self._testJournal.addMood(self._moodFactory.makeMood("TestMood"), 100)
def run_event_loop(): my_journal = Journal('personal') command = query_user() while command != 'x': if command == 'l': my_journal.list() elif command == 'a': my_journal.add(input('Enter your journal entry:\n')) command = query_user() my_journal.save()
def add_journal(self): """ Add a brand new journal to the library with a unique call number. :return: a Journal """ journal_data = self.add_basic_info() issue_number = input("Enter Issue Number: ") publisher = input("Enter publisher") new_journal = Journal(journal_data[0], journal_data[1], journal_data[2], issue_number, publisher) return new_journal
def create_journal(cls): """ Prompts user to create a dvd item :return: a dvd item """ title = input("input journal title\n") call_num = input("input journal call number\n") num_copies = input("input number of copies\n") issue_num = input("input issue number\n") publisher = input("input publisher\n") return Journal(title, call_num, int(num_copies), issue_num, publisher)
def create_item(self): call_number = input("Enter Call Number: ") title = input("Enter title: ") num_copies = int(input("Enter number of copies " "(positive number): ")) author = input("Enter Author Name: ") issue_number = input("Enter Issue Number: ") publisher = input("Enter Publisher: ") kwargs = {"call_num": call_number, "title": title, "num_copies": num_copies} new_journal = Journal(author, issue_number, publisher, kwargs) return new_journal
def generate_test_items(): """ Return a list of items with dummy data. :return: a list """ item_list = [ Book("100.200.300", "Harry Potter 1", 2, "J K Rowling"), Book("999.224.854", "Harry Potter 2", 5, "J K Rowling"), Journal("631.495.302", "Harry Potter 3", 4, "53434", "Router"), DVD("123.02.204", "The Cat in the Hat", 1, "2014-01-05", "342DV") ] return item_list
def create_item(self): item_type = input("Enter an item type:\n1: Book\n2: Dvd\n3: Journal") item = "invalid input given" if item_type == "1": item = Book(self._title, input("Enter Authour name: "), self._call_num, self._num_copies) elif item_type == "2": item = DVD(self._title, input("Enter Release Date: "), input("Enter Region Code: "),\ self._call_num, self._num_copies) elif item_type == "3": item = Journal(self._title, input("Enter Issue Number: "), input("Enter Publisher Name: "), self._call_num, self._num_copies) return item
def generate_test_books() -> list: """ Return a list of books with dummy data. :return: a list """ book_list = [ Book("100.200.300", "Harry Potter 1", 2, "J K Rowling"), Book("999.224.854", "Harry Potter 2", 5, "J K Rowling"), Book("631.495.302", "Harry Potter 3", 4, "J K Rowling"), Book("123.02.204", "The Cat in the Hat", 1, "Dr. Seuss"), Journal("100.132.126", "My Travel", 5, "123.1231.614a", "Luke"), DVD("123.456.123", "My Dream", 10, "2020-03-10", "123") ] return book_list
def generate_test_items(): """ Return a list of items with dummy data. :return: a list """ item_list = [ Book("100.200.300", "Harry Potter 1", 2, "J K Rowling"), Book("999.224.854", "Harry Potter 2", 5, "J K Rowling"), Book("631.495.302", "Harry Potter 3", 4, "J K Rowling"), Book("123.02.204", "The Cat in the Hat", 1, "Dr. Seuss"), Dvd("425.63.775", "Toy Story", 2, "10-10-2004", "NA"), Journal("874.234.863", "Science Journal", 1, "Dr. Smart", 7, "Pearsons") ] return item_list
def __create_journal(): """ Creates a journal :return: a journal """ call_number = input("Enter Call Number: ") title = input("Enter title: ") num_copies = int(input("Enter number of copies " "(positive number): ")) author = input("Enter Author Name: ") issue_number = input("Enter Issue Number: ") publisher = input("Enter Publisher: ") new_journal = Journal(call_number, title, num_copies, author, issue_number, publisher) return new_journal
def main(): ''' This is where all the user input going to be coded :return: None ''' # Ask for user input # assuming the user input is always valid journal = Journal() journal.display_today() loop = True while loop: loop = user_input(journal) journal.end()