Advertisement
Guest User

Untitled

a guest
Oct 19th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 24.47 KB | None | 0 0
  1. import pymysql
  2. import random
  3.  
  4. db = pymysql.connect("localhost", "root", "Hero2of1war", "library_system")
  5. cursor = db.cursor()
  6.  
  7.  
  8. class Library(object):
  9.     def __init__(self):
  10.         super(Library, self).__init__()
  11.  
  12.         self.number_of_library = ''  # library_number
  13.         self.street = ''
  14.         self.phone_number = 0
  15.         self.books = []
  16.         self.visitors = []
  17.         self.history = []
  18.         self.authors = []
  19.  
  20.     def add_book(self, book):
  21.         # not_found = True
  22.         # for i in self.books:
  23.         #     if i.name == book.name and i.author == book.author:
  24.         #         not_found = False
  25.         #         break
  26.         # if not_found:
  27.         #     self.books.append(book)
  28.         # else:
  29.         #     print('Book exist!')
  30.  
  31.         for i in self.books:
  32.             if i.name == book.name and i.author == book.author:
  33.                 print('Book exist!')
  34.                 break
  35.         else:
  36.             self.books.append(book)
  37.  
  38.     def delete_book(self, name, author):
  39.         book = False
  40.         for i in lib.books:
  41.             if i.name == name and i.author == author:
  42.                 self.books.remove(i)
  43.                 return True
  44.         if book == False:
  45.             print('This book not exist')
  46.             return False
  47.  
  48.     def search_book(self, book):
  49.         for i in self.books:
  50.             if i.name == book:
  51.                 return i
  52.  
  53.     def add_visitor(self, visitor):
  54.         found = False
  55.         for i in self.visitors:
  56.             print(i.name, i.last_name, i.number)
  57.             print(visitor.name, visitor.last_name, visitor.number)
  58.             if i.name == visitor.name and i.last_name == visitor.last_name and i.number == visitor.number:
  59.                 found = True
  60.         if found == False:
  61.             self.visitors.append(visitor)
  62.         else:
  63.             print('Visitor exist!')
  64.             return True
  65.  
  66.     def remove_visitor(self, name, last_name, number):
  67.         remove = False
  68.         for i in lib.visitors:
  69.             if i.name == name and i.last_name == last_name and i.number == number:
  70.                 lib.visitors.remove(i)
  71.                 return True
  72.         if remove == False:
  73.             print('Can not delete!')
  74.             return False
  75.  
  76.     def write_book_visitor(self, write, book, data):
  77.         book_in_visitor = BookInVisitor(write.name, write.last_name, book.name, book.author_name, book.author_last_name, data)
  78.         book_in_visitor.remove_of_data = 'None'
  79.  
  80.         self.history.append(book_in_visitor)
  81.  
  82.     def print_history(self):
  83.         for i in self.history:
  84.             print(i.visitor_name + ' take', i.book_name)
  85.  
  86.     def edit_book(self, old_name, new_name):
  87.         for i in lib.books:
  88.             if i.name == old_name:
  89.                 i.name = new_name
  90.  
  91.     def edit_visitors(self, old_name, old_last_name, old_number, new_name, new_last_name, new_number):
  92.         for i in lib.visitors:
  93.             if i.name == old_name and i.last_name == old_last_name and i.number == old_number:
  94.                 i.name = new_name
  95.                 i.last_name = new_last_name
  96.                 i.number = new_number
  97.  
  98.     def user_exist(self, old_name, old_last_name, old_number):
  99.         not_exist = False
  100.         for i in lib.visitors:
  101.             if i.name == old_name and i.last_name == old_last_name and i.number == old_number:
  102.                 return True
  103.         if not_exist == False:
  104.             print('Not exist')
  105.             return False
  106.  
  107.     def find_book_by_name(self, book_name, book_author_name, book_author_last_name):
  108.         for i in lib.books:
  109.             if i.name == book_name and i.author_name == book_author_name and i.author_last_name == book_author_last_name:
  110.                 return i
  111.                 # return None
  112.  
  113.     def find_visitor_by_name(self, visitor_name, visitor_last_name):
  114.         for i in lib.visitors:
  115.             if i.name == visitor_name and i.last_name == visitor_last_name:
  116.                 return i
  117.                 # return None
  118.  
  119.     # add_return_date
  120.     def add_data_of_remove(self, visitor_name, visitor_last_name, book_name, author_name, book_author_last_name, remove_date):
  121.         for i in lib.history:
  122.             if i.visitor_name == visitor_name and i.visitor_last_name == visitor_last_name and i.book_name == book_name and i.book_author_name == author_name and i.book_author_last_name == book_author_last_name:
  123.                 i.remove_of_data = remove_date
  124.  
  125.     def initialize_database(self):
  126.         cursor.execute("INSERT INTO gender (id, name) VALUES (NULL, 'male')")
  127.         cursor.execute("INSERT INTO gender (id, name) VALUES (NULL, 'female')")
  128.         db.commit()
  129.         # cursor.execute("SELECT name FROM gender")
  130.         # name_gender = cursor.fetchall()
  131.  
  132.  
  133. class Book(object):
  134.     def __init__(self, id, name, author_name, author_last_name, date, count='', available_count=''):
  135.         super(Book, self).__init__()
  136.  
  137.         self.id = id
  138.         self.name = name
  139.         self.author_name = author_name
  140.         self.author_last_name = author_last_name
  141.         self.date = date
  142.         self.count = count
  143.         self.available_count = available_count
  144.  
  145.     def save(self):
  146.         cursor.execute(
  147.             "INSERT INTO book (id, name, date, count, available_count) VALUES (NULL, '{0}', '{1}', {2}, {3})".format(
  148.                 self.name, self.date, self.count, self.available_count))
  149.  
  150.  
  151. class Visitor(object):
  152.     def __init__(self, id, name, last_name, birth_date, number, gender):
  153.         super(Visitor, self).__init__()
  154.  
  155.         self.id = id
  156.         self.name = name
  157.         self.last_name = last_name
  158.         self.birth_date = birth_date
  159.         self.number = number
  160.         self.gender = gender
  161.  
  162.     def save(self):
  163.         cursor.execute(
  164.             "INSERT INTO visitor (id, name, last_name, birth_date, number, gender_id) VALUES (NULL, '{0}','{1}','{2}','{3}','{4}')".format(self.name, self.last_name, self.birth_date, self.number, self.gender))
  165.  
  166.  
  167. class BookInVisitor(object):
  168.     def __init__(self, visitor_name, visitor_last_name, book_name, book_author_name, book_author_last_name, data_of_take, remove_of_data=''):
  169.         super(BookInVisitor, self).__init__()
  170.  
  171.         self.visitor_name = visitor_name
  172.         self.visitor_last_name = visitor_last_name
  173.         self.book_name = book_name
  174.         self.book_author_name = book_author_name
  175.         self.book_author_last_name = book_author_last_name
  176.         self.data_of_take = data_of_take
  177.         self.remove_of_data = remove_of_data
  178.  
  179.  
  180. class Author(object):
  181.     def __init__(self, id='', name='', last_name=''):
  182.         super(Author, self).__init__()
  183.  
  184.         self.id = id
  185.         self.name = name
  186.         self.last_name = last_name
  187.  
  188.     def save(self):
  189.         cursor.execute(
  190.             "INSERT INTO author (id, name, last_name) VALUES (NULL, '{0}', '{1}')".format(self.name, self.last_name))
  191.  
  192.  
  193. class BookPerAuthor(object):
  194.     def __init__(self, book_id='', author_id=''):
  195.         super(BookPerAuthor, self).__init__()
  196.  
  197.         self.book_id = book_id
  198.         self.author_id = author_id
  199.  
  200.     def save(self):
  201.         cursor.execute(
  202.             "INSERT INTO book_has_author (book_id, author_id) VALUES ({0},{1})".format(self.book_id, self.author_id))
  203.  
  204.  
  205. # user = 'Mike'
  206. # password = '123456'
  207.  
  208. lib = Library()
  209.  
  210. # user_input = input("Enter user: ")
  211. # password_input = input("Enter password: ")
  212.  
  213. # if user == user_input and password == password_input:
  214.  
  215. cursor.execute("SELECT * FROM gender")
  216. bk = cursor.fetchall()
  217. if len(bk) == 0:
  218.     lib.initialize_database()
  219.  
  220. cursor.execute("SELECT * FROM author")
  221. au = cursor.fetchall()
  222. for author in au:
  223.     author = Author(author[0], author[1], author[2])
  224.     lib.authors.append(author)
  225.  
  226. cursor.execute("SELECT * FROM book")
  227. bk = cursor.fetchall()
  228. for book in bk:
  229.     # cursor.execute("SELECT id from book WHERE name = '{0}'".format(book[1]))
  230.     # b = cursor.fetchall()
  231.     b = book[0]
  232.     # print(b)
  233.     cursor.execute("SELECT author_id from book_has_author WHERE book_id = {}".format(b))
  234.     v = cursor.fetchall()
  235.     v = v[0][0]
  236.     # print(v)
  237.     cursor.execute("SELECT name FROM author WHERE id = {}".format(v))
  238.     author_name = cursor.fetchall()
  239.     author_name = author_name[0][0]
  240.     # print(na)
  241.     # print(book)
  242.     cursor.execute("SELECT last_name FROM author WHERE id = {}".format(v))
  243.     author_last_name = cursor.fetchall()
  244.     author_last_name = author_last_name[0][0]
  245.     book = Book(book[0], book[1], author_name, author_last_name, book[2], book[3], book[4])
  246.     lib.books.append(book)
  247.  
  248. cursor.execute("SELECT * FROM visitor")
  249. vs = cursor.fetchall()
  250. for visitor in vs:
  251.     gender_name = visitor[5]
  252.     # print(gender_name)
  253.     cursor.execute("SELECT name FROM gender  WHERE id = {}".format(gender_name))
  254.     gender = cursor.fetchall()
  255.     gender = gender[0][0]
  256.     # print(gender)
  257.     visitor = Visitor(visitor[0], visitor[1], visitor[2], visitor[3], visitor[4], visitor[5])
  258.     lib.visitors.append(visitor)
  259.     # print(visitor)
  260.  
  261. cursor.execute("SELECT * FROM book_in_visitor")
  262. bookinvisitor = cursor.fetchall()
  263. for bkinvs in bookinvisitor:
  264.     """id list"""
  265.     idfirst = bkinvs[0]
  266.     # cursor.execute("SELECT taking_date FROM book_in_visitor WHERE id = {}".format(idfirst))
  267.     # takingdate = cursor.fetchall()  # takingDate, TakingDate, taking_date
  268.     # takingdate = takingdate[0][0]
  269.     taking_date = str(bkinvs[1])
  270.     # print(takingdate)
  271.     # cursor.execute("SELECT returning_date FROM book_in_visitor WHERE id = {}".format(idfirst))
  272.     # returningdate = cursor.fetchall()
  273.     # returningdate = returningdate[0][0]
  274.     returning_date = str(bkinvs[2])
  275.     # print(returningdate)
  276.     # cursor.execute("SELECT visitor_id FROM book_in_visitor WHERE id = {}".format(idfirst))
  277.     """take number from visitor_id"""
  278.     # visid = cursor.fetchall()
  279.     # visid = visid[0][0]
  280.     visid = str(bkinvs[3])
  281.     cursor.execute("SELECT name FROM visitor WHERE id = {}".format(visid))
  282.     """take name"""
  283.     visitor_name = cursor.fetchall()
  284.     visitor_name = visitor_name[0][0]
  285.     # print(visname)
  286.     cursor.execute("SELECT last_name FROM visitor WHERE id = {}".format(visid))
  287.     """take last_name"""
  288.     visitor_last_name = cursor.fetchall()
  289.     visitor_last_name = visitor_last_name[0][0]
  290.     # print(vislastname)
  291.     # cursor.execute("SELECT book_id FROM book_in_visitor WHERE id = {}".format(idfirst))
  292.     """take number book_id"""
  293.     # bookid = cursor.fetchall()
  294.     # bookid = bookid[0][0]
  295.     bookid = str(bkinvs[4])
  296.     # print(bookid)
  297.     '''take name book'''
  298.     cursor.execute("SELECT name FROM book WHERE id = {}".format(bookid))
  299.     book_name = cursor.fetchall()
  300.     book_name = book_name[0][0]
  301.     # print(bookname)
  302.     cursor.execute("SELECT author_id FROM book_has_author WHERE book_id = {}".format(bookid))
  303.     authorid = cursor.fetchall()
  304.     authorid = authorid[0][0]
  305.     # print(authorid)
  306.     '''take author name'''
  307.     cursor.execute("SELECT name FROM author WHERE id = {}".format(authorid))
  308.     author_name = cursor.fetchall()
  309.     author_name = author_name[0][0]
  310.     # print(authorname)
  311.     # cursor.execute("SELECT last_name FROM author WHERE id = {}".format(authorid))
  312.     # authorlastname = cursor.fetchall()
  313.     # authorlastname = authorlastname[0][0]
  314.     # print(authorlastname)
  315.     '''take author last_name'''
  316.     cursor.execute("SELECT last_name FROM author WHERE id = {}".format(authorid))
  317.     author_last_name = cursor.fetchall()
  318.     author_last_name = author_last_name[0][0]
  319.  
  320.     bookvisitor = BookInVisitor(visitor_name, visitor_last_name, book_name, author_name, author_last_name, taking_date, returning_date)
  321.     lib.history.append(bookvisitor)
  322.  
  323. # book1 = Book(None, '300 spartans', 'Zak Plahin', '2001')
  324. # lib.add_book(book1)
  325.  
  326. # visitor1 = Visitor(None, 'Oleg', 'See', '12-12-2001', '+380635887884', 'male')
  327. # lib.add_visitor(visitor1)
  328. #
  329. # visitor2 = Visitor(None, 'Chak', 'Broflovski', '09-11-2001', '+38073911112', 'male')
  330. # lib.add_visitor(visitor2)
  331.  
  332.  
  333. while True:
  334.     number = int(input('1 - Show all books\n2 - Show all visitors\n3 - Add visitor\n4 - Add book\n5 - Show author\n6 - Change visitor\n7 - Write book on visitor\n8 - Add remove date\n9 - Show history\n10 - Serch book by name\n11 - Search book by author\n12 - Show books in visitor\n13 - Read from web_cam\n:'))
  335.     if number == 1:
  336.         if len(lib.books) == 0:
  337.             print('Our library has not book')
  338.         for i in lib.books:
  339.             print(str(i.id) + ' Book: ' + i.name + ', author: ' + i.author_name + ' ' + i.author_last_name + ', date: ' + str(i.date))
  340.     elif number == 2:
  341.         if len(lib.visitors) == 0:
  342.             print('Our library has not visitors')
  343.         for i in lib.visitors:
  344.             cursor.execute(
  345.                 "SELECT name FROM gender WHERE id = '{}'".format(i.gender))  # take gender from bd(id)
  346.             gender = cursor.fetchall()
  347.             gender = gender[0][0]  # take from tuple gender in right appearance
  348.             print('ID: ' + str(i.id) + ', Name: ' + i.name + ', last name: ' + i.last_name + ', birth date: ' + str(
  349.                 i.birth_date) + ', number: ' + str(i.number) + ', gender: ' + gender)
  350.     elif number == 3:
  351.         first_name = input('Enter name: ')
  352.         first_name = first_name.capitalize()
  353.         second_name = input('Enter last_name: ')
  354.         second_name = second_name.capitalize()
  355.         birth_date = input('Enter birth date(yyyy-mm-dd): ')
  356.         number = input('Enter your number(380** *** *** *): ')
  357.         gender = input('Enter: 1-male / 2-female: ')
  358.         if gender == str(1):
  359.             cursor.execute("select name from gender where id = '{}'".format(1))
  360.             sex = cursor.fetchall()
  361.             sex = sex[0][0]
  362.             # print(sex)
  363.         elif gender == str(2):
  364.             cursor.execute("select name from gender where id = '{}'".format(2))
  365.             sex = cursor.fetchall()
  366.             sex = sex[0][0]
  367.             # print(sex)
  368.         else:
  369.             print('Error: gender_id!')
  370.             break
  371.         visit = Visitor(None, first_name, second_name, birth_date, number, gender)
  372.         if lib.add_visitor(visit) == True:
  373.             continue
  374.         visit.save()
  375.         cursor.execute("SELECT last_insert_id()")
  376.         vid = cursor.fetchall()
  377.         db.commit()
  378.         # print(vid)
  379.         visit.id = vid[0][0]
  380.         # lib.add_visitor(visit)
  381.     elif number == 4:
  382.         name_book = input('Enter book name: ')
  383.         name_book = name_book.capitalize()
  384.         author_name = input('Enter author name: ')
  385.         author_name = author_name.capitalize()
  386.         author_last_name = input('Enter author last name: ')
  387.         author_last_name = author_last_name.capitalize()
  388.         found_book = False  # because it could change the variable found on True after checking the author
  389.         for book in lib.books:
  390.             if book.name == name_book:
  391.                 found_book = True
  392.                 print('This book exist')
  393.         if found_book == True:
  394.             continue
  395.         found = False
  396.         for author in lib.authors:
  397.             if author.name == author_name and author.last_name == author_last_name:
  398.                 found = True
  399.                 aid = author.id
  400.                 db.commit()
  401.         if not found:
  402.             author = Author(None, author_name, author_last_name)
  403.             author.save()
  404.             cursor.execute("Select last_insert_id()")
  405.             aid = cursor.fetchall()
  406.             aid = aid[0][0]
  407.             # print(aid)
  408.             author.id = aid
  409.             lib.authors.append(author)
  410.             db.commit()
  411.         if not found_book:
  412.             date = input('Enter date(yyyy-mm-dd): ')
  413.             count = int(input('Enter count:'))
  414.             available_count = count
  415.             # print(available_count)
  416.             # print(count)
  417.             bok = Book(None, name_book, author_name, author_last_name, date, count, available_count)
  418.             bok.save()
  419.             cursor.execute("SELECT last_insert_id()")
  420.             bid = cursor.fetchall()
  421.             bid = bid[0][0]
  422.             db.commit()
  423.             book_per_author = BookPerAuthor(bid, aid)
  424.             book_per_author.save()
  425.             db.commit()
  426.             bok.id = bid
  427.             lib.add_book(bok)
  428.     elif number == 5:
  429.         if len(lib.authors) == 0:
  430.             print("Author do not exist")
  431.         for i in lib.authors:
  432.             print('ID:', i.id, ',' + 'name author: ' + i.name + ', last name: ' + i.last_name)
  433.     elif number == 6:
  434.         old_name = input('Enter old name of visitor: ')
  435.         old_name = old_name.capitalize()
  436.         old_last_name = input('Enter old last name of visitor: ')
  437.         old_last_name = old_last_name.capitalize()
  438.         old_number = input('Enter old number of visitor: ')
  439.         if lib.user_exist(old_name, old_last_name, old_number) == False:
  440.             break
  441.         else:
  442.             new_name = input('Enter new name visitor: ')
  443.             new_name = new_name.capitalize()
  444.             new_last_name = input('Enter new last name visitor: ')
  445.             new_last_name = new_last_name.capitalize()
  446.             new_number = input('Enter new number visitor: ')
  447.             cursor.execute(
  448.                 "UPDATE visitor SET name = '{0}', last_name = '{1}', number = '{2}' WHERE number = '{3}'".format(
  449.                     new_name, new_last_name, new_number, old_number))
  450.             db.commit()
  451.             if new_last_name == '':
  452.                 lib.edit_visitors(old_name, old_last_name, old_number, new_name, old_last_name, new_number)
  453.             elif new_name == '':
  454.                 lib.edit_visitors(old_name, old_last_name, old_number, old_name, new_last_name, new_number)
  455.             elif new_number == '':
  456.                 lib.edit_visitors(old_name, old_last_name, old_number, new_name, new_last_name, old_number)
  457.             else:
  458.                 lib.edit_visitors(old_name, old_last_name, old_number, new_name, new_last_name, new_number)
  459.     elif number == 7:
  460.         visitor_name = input('Enter visitor name: ')
  461.         visitor_name = visitor_name.capitalize()
  462.         visitor_last_name = input('Enter visitor last name: ')
  463.         visitor_last_name = visitor_last_name.capitalize()
  464.         vis = lib.find_visitor_by_name(visitor_name, visitor_last_name)
  465.         data_take = input('Enter data take(yyyy-mm-dd): ')
  466.         if vis == None:
  467.             print('Enter again visitor')
  468.             break
  469.         else:
  470.             book_name = input('Enter book name: ')
  471.             book_name = book_name.capitalize()
  472.             book_author_name = input('Enter author name: ')
  473.             book_author_name = book_author_name.capitalize()
  474.             book_author_last_name = input('Enter author last name: ')
  475.             book_author_last_name = book_author_last_name.capitalize()
  476.             bo = lib.find_book_by_name(book_name, book_author_name, book_author_last_name)
  477.             if bo == None:
  478.                 print('Enter again book')
  479.                 break
  480.             else:
  481.                 cursor.execute("SELECT available_count FROM book WHERE name = '{}'".format(book_name))
  482.                 avcoif = cursor.fetchall()
  483.                 avcoif = avcoif[0][0]
  484.                 if avcoif == 0:
  485.                     print("This book is not available!")
  486.                 else:
  487.                     lib.write_book_visitor(vis, bo, data_take)
  488.                     cursor.execute(
  489.                         "SELECT id FROM visitor WHERE name = '{0}' AND last_name = '{1}'".format(visitor_name,
  490.                                                                                                  visitor_last_name))
  491.                     idvisitor = cursor.fetchall()
  492.                     idvisitor = idvisitor[0][0]
  493.                     # print(idvisitor)
  494.                     cursor.execute("SELECT id FROM book WHERE name = '{}'".format(book_name))
  495.                     idbook = cursor.fetchall()
  496.                     idbook = idbook[0][0]
  497.                     # print(idbook)
  498.                     cursor.execute(
  499.                         "INSERT INTO book_in_visitor (id, taking_date, returning_date, visitor_id, book_id) VALUES (NULL, '{0}', {1}, {2}, {3})".format(
  500.                             data_take, 'NULL', idvisitor, idbook))
  501.                     cursor.execute("SELECT available_count FROM book WHERE id = {}".format(idbook))
  502.                     avco = cursor.fetchall()
  503.                     # print(avco)
  504.                     avco = avco[0][0]
  505.                     # print(avco)
  506.                     result = int(avco) - 1
  507.                     cursor.execute("UPDATE book SET available_count = '{0}' WHERE id = {1}".format(result, idbook))
  508.                     db.commit()
  509.     elif number == 8:
  510.         visitor_name = input('Enter visitor name: ')
  511.         visitor_name = visitor_name.capitalize()
  512.         visitor_last_name = input('Enter last_name: ')
  513.         visitor_last_name = visitor_last_name.capitalize()
  514.         if lib.find_visitor_by_name(visitor_name, visitor_last_name) == None:
  515.             print("This visitor not exist")
  516.             break
  517.         else:
  518.             book_name = input('Enter book: ')
  519.             book_name = book_name.capitalize()
  520.             book_author_name = input('Enter author: ')
  521.             book_author_name = book_author_name.capitalize()
  522.             book_author_last_name = input('Enter author: ')
  523.             book_author_last_name = book_author_last_name.capitalize()
  524.             if lib.find_book_by_name(book_name, book_author_name, book_author_last_name) == None:
  525.                 print("This book not exist")
  526.                 break
  527.             else:
  528.                 data = input('Enter data remove(yyyy-mm-dd): ')
  529.                 cursor.execute("SELECT name FROM book")
  530.                 bookname = [row[0] for row in cursor.fetchall()]
  531.                 # print(bookname)
  532.                 cursor.execute("SELECT id FROM visitor WHERE name = '{0}' AND last_name = '{1}'".format(visitor_name, visitor_last_name))
  533.                 mid = cursor.fetchall()
  534.                 mid = mid[0][0]
  535.                 # print(mid)
  536.                 for i in bookname:
  537.                     if i == book_name:
  538.                         cursor.execute(
  539.                             "UPDATE book_in_visitor SET returning_date = '{0}' WHERE visitor_id = {1}".format(data,
  540.                                                                                                               mid))
  541.                         cursor.execute("SELECT available_count FROM book WHERE name = '{}'".format(book_name))
  542.                         avbo = cursor.fetchall()
  543.                         avbo = avbo[0][0]
  544.                         result = int(avbo) + 1
  545.                         cursor.execute(
  546.                             "UPDATE book SET available_count = '{0}' WHERE name = '{1}'".format(result, book_name))
  547.                         db.commit()
  548.                         lib.add_data_of_remove(visitor_name, visitor_last_name, book_name, book_author_name, book_author_last_name, data)
  549.     elif number == 9:
  550.         for i in lib.history:
  551.             print(i.visitor_name + ' ' + i.visitor_last_name + ' take: ' + i.book_name + ', author: ' + i.book_author_name + ' ' + i.book_author_last_name + ', date: ' + str(i.data_of_take) + ', return: ' + str(i.remove_of_data))
  552.     elif number == 10:
  553.         i = input("Enter book name: ")
  554.         i = i.capitalize()
  555.         found = False
  556.         for book in lib.books:
  557.             if book.name == i:
  558.                 print('ID: ' + str(book.id) + ', Book: ' + book.name + ', Author: ' + book.author_name + ' ' + book.author_last_name)
  559.                 found = True
  560.         if not found:
  561.             print("Not found")
  562.     elif number == 11:
  563.         i = input("Enter author name: ")
  564.         i = i.capitalize()
  565.         found = False
  566.         for book in lib.books:
  567.             if book.author_name == i:
  568.                 print('ID: ' + str(book.id) + ', Book: ' + book.name + ', Author: ' + book.author_name + ' ' + book.author_last_name)
  569.                 found = True
  570.         if not found:
  571.             print("Not found")
  572.     elif number == 12:
  573.         name = input("Enter visitor name: ")
  574.         name = name.capitalize()
  575.         last_name = input("Enter visitor last name: ")
  576.         last_name = last_name.capitalize()
  577.         for i in lib.history:
  578.             if i.visitor_name == name and i.visitor_last_name == last_name and i.remove_of_data == 'None':
  579.                 print('Name: ' + i.visitor_name + ', last name: ' + i.visitor_last_name + ', book: ' + i.book_name + ', author: ' + i.book_author_name + ' ' + i.book_author_last_name + ', date:' + i.data_of_take)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement