Ejemplo n.º 1
0
def main():
    """
    creates a list and fills it with Item objects. Creates a Library object, a catalogue object
    and a LibraryItemGenerator object. While loop runs until user inputs 0, other inputs demonstrate
    the possible functions within library and catalogue modules.
    :return:
    """
    item_list = [
        item.Book("Lord of the Rings", "1023.2323", "JRR Tolkien", 1),
        item.Book("Game of Thrones", "1032.1212", "GRR Martin", 1),
        item.Book("Harry Potter", "1111.2222", "JK Rowling", 1),
        item.DVD("Pursuit of Happiness", "April 12, 1974", "NTSC", 1, "12121"),
        item.Journal("National Geographic", 10, "Science", 1, "51232"),
        item.Book("Game of Thrones", "1033", "GRR Martin", 1)
    ]
    biblioteca = Library(item_list)
    catalogue_ = catalogue.Catalogue(item_list)
    generator_ = catalogue.LibraryItemGenerator(item_list)
    choice = 1
    while choice != 0:
        print("Welcome to Biblioteca self-service")
        print("If you would like to find a book, press 1")
        print("If you would like to request an item be removed press 2")
        print("If you would like to check out an item press 3")
        print("If you would like to return an item press 4")
        print("If you would like to add an item press 5")
        print("If you would like to browse the full catalogue press 6")
        print("If you would like to end self-service press 0")

        choice = int(input("what would you like to do? "))

        if choice == 1:
            title = input("Enter the title of the book you are looking for: ")
            if isinstance(title, str):
                catalogue_.find_item(title)
            else:
                return "Sorry, that is an invalid title"
        if choice == 2:
            call_number = input("Enter the call number for the book: ")
            if isinstance(call_number, str):
                catalogue_.remove_item(call_number)
            else:
                return "That is an invalid call number"
        if choice == 3:
            call_number = input("Enter the call number for the book: ")
            if isinstance(call_number, str):
                biblioteca.check_out(call_number)
            else:
                return "That is an invalid call number"

        if choice == 4:
            call_number = input("Enter the call number for the book: ")
            if isinstance(call_number, str):
                biblioteca.return_item(call_number)
            else:
                return "that is an invalid call number"
        if choice == 5:
            generator_.generate_item(item_list)
        if choice == 6:
            display_available_books(item_list)
Ejemplo n.º 2
0
 def return_item(self, call_number):
     """
     search through item list and if found, increase num_copies by 1
     :param call_number: unique id for item
     :return:
     """
     item_copy_cata = catalogue.Catalogue(self.item_list)
     for Item in self.item_list:
         if call_number == Item.call_number:
             item_copy_cata.increment_copy(Item)
             print(f"thanks for returning your book, "
                   f"there are now {Item.num_copies} left!")
Ejemplo n.º 3
0
 def check_out(self, call_number):
     """
     Searching through item list for call number and checks if num copies >= 1, if yes, reduces
     num_copies by 1 and if not, tells user that book is unavailable
     :param call_number: unique id for items
     :return:
     """
     item_copy_cata = catalogue.Catalogue(self.item_list)
     for Item in self.item_list:
         if call_number == Item.call_number and Item.num_copies >= 1:
             item_copy_cata.decrement_copy(Item)
             print(
                 f"{Item.title} has been checked out, there are {Item.num_copies} left"
             )
         elif call_number == Item.call_number and Item.num_copies <= 0:
             print("Sorry that book is unavailable right now")
Ejemplo n.º 4
0
def main():
    """
    creates a list and fills it with Item objects. Creates a Library object, a catalogue object
    and a LibraryItemGenerator object. While loop runs until user inputs 0, other inputs demonstrate
    the possible functions within library and catalogue modules.
    :return:
    """
    item_list = [
        item.Book(title='got',
                  author="grrm",
                  num_copies=2,
                  call_number="12323"),
        item.DVD(title='Shrek',
                 release_date='2001',
                 region_code='ntsc',
                 num_copies=0,
                 call_number="23123")
    ]

    biblioteca = Library(item_list)
    catalogue_ = catalogue.Catalogue(item_list)
    book_factory = item.BookFactory()
    dvd_factory = item.DvdFactory()
    journal_factory = item.JournalFactory()
    choice = 1
    while choice != 0:
        print("\nWelcome to Biblioteca self-service")
        print("If you would like to find a book, press 1")
        print("If you would like to request an item be removed press 2")
        print("If you would like to check out an item press 3")
        print("If you would like to return an item press 4")
        print("If you would like to add an item press 5")
        print("If you would like to browse the full catalogue press 6")
        print("If you would like to end self-service press 0")

        choice = int(input("what would you like to do? \n"))

        if choice == 1:
            title = input("Enter the title of the book you are looking for: ")
            if isinstance(title, str):
                catalogue_.find_item(title)
            else:
                return "Sorry, that is an invalid title"
                input()
        if choice == 2:
            call_number = input("Enter the call number for the book: ")
            if isinstance(call_number, str):
                catalogue_.remove_item(call_number)
            else:
                return "That is an invalid call number"
        if choice == 3:
            call_number = input("Enter the call number for the book: ")
            if isinstance(call_number, str):
                biblioteca.check_out(call_number)
            else:
                return "That is an invalid call number"

        if choice == 4:
            call_number = input("Enter the call number for the book: ")
            if isinstance(call_number, str):
                biblioteca.return_item(call_number)
            else:
                return "that is an invalid call number"
        if choice == 5:
            print(f"what kind of item would you like to make?\n ")
            print(f"1. Book")
            print(f"2. DVD")
            print(f"3. Journal")
            choice = int(input(">"))
            if choice == 1:
                new_item = book_factory.create_item()
                catalogue_.add_item(new_item)
            if choice == 2:
                new_item = dvd_factory.create_item()
                catalogue_.add_item(new_item)
            if choice == 3:
                new_item = journal_factory.create_item()
                catalogue_.add_item(new_item)
        if choice == 6:
            biblioteca.display_available_books()
Ejemplo n.º 5
0
    def setup_ui(self):
        self.setObjectName('asset')
        self.setWindowTitle('Show Inputs ({} {})'.format(
            self.lable, self.version))
        self.resize(1000, 600)
        self.verticallayout = QtGui.QVBoxLayout(self)
        self.verticallayout.setObjectName('verticallayout')
        self.verticallayout.setSpacing(10)
        self.verticallayout.setContentsMargins(10, 10, 10, 10)

        self.label_logo = QtGui.QLabel(self)
        self.label_logo.setObjectName('label_subins_toolkits')
        self.label_logo.setPixmap(
            QtGui.QPixmap(
                os.path.join(resources.getIconPath(),
                             'subins_toolkits_2.png')))
        self.label_logo.setScaledContents(True)
        self.label_logo.setMinimumSize(QtCore.QSize(500, 142))
        self.label_logo.setMaximumSize(QtCore.QSize(500, 142))
        self.verticallayout.addWidget(self.label_logo)

        self.horizontallayout = QtGui.QHBoxLayout()
        self.horizontallayout.setObjectName('horizontallayout')
        self.verticallayout.addLayout(self.horizontallayout)

        self.verticalLayout_shows_a = QtGui.QVBoxLayout()
        self.verticalLayout_shows_a.setObjectName('verticalLayout_show_a')
        self.horizontallayout.addLayout(self.verticalLayout_shows_a)

        self.verticalLayout_pipe = QtGui.QVBoxLayout()
        self.verticalLayout_pipe.setObjectName('verticalLayout_pipe')
        self.horizontallayout.addLayout(self.verticalLayout_pipe)

        self.groupbox_shows = QtGui.QGroupBox(self)
        self.groupbox_shows.setObjectName('groupbox_shows')
        self.groupbox_shows.setTitle('Shows')
        self.verticalLayout_pipe.addWidget(self.groupbox_shows)

        self.verticalLayout_shows_b = QtGui.QVBoxLayout(self.groupbox_shows)
        self.verticalLayout_shows_b.setObjectName('verticalLayout_show_b')

        self.listWidget_shows = catalogue.Catalogue(parent=self.groupbox_shows,
                                                    width=self.width,
                                                    height=self.height)
        self.listWidget_shows.itemClicked.connect(
            partial(self.set_my_show,
                    self.listWidget_shows))  # Load Pose to UI
        self.verticalLayout_shows_b.addWidget(self.listWidget_shows)

        self.groupbox_toolbar = QtGui.QGroupBox(self)
        self.groupbox_toolbar.setObjectName('groupbox_toolbar')
        # self.groupbox_toolbar.setTitle('groupbox_toolbar')
        self.groupbox_toolbar.setMinimumSize(QtCore.QSize(0, 35))
        self.groupbox_toolbar.setMaximumSize(QtCore.QSize(16777215, 35))
        self.groupbox_toolbar.hide()
        self.verticalLayout_pipe.addWidget(self.groupbox_toolbar)

        self.horizontallayout_toolbar = QtGui.QHBoxLayout(
            self.groupbox_toolbar)
        self.horizontallayout_toolbar.setObjectName('horizontallayout_toolbar')

        self.groupbox_show = QtGui.QGroupBox(self)
        self.groupbox_show.setObjectName('groupbox_show')
        # self.groupbox_show.setTitle('Show')
        self.groupbox_show.hide()
        self.verticalLayout_pipe.addWidget(self.groupbox_show)

        self.verticalLayout_show = QtGui.QVBoxLayout(self.groupbox_show)
        self.verticalLayout_show.setObjectName('verticalLayout_show')

        self.splitter = QtGui.QSplitter(self.groupbox_show)
        self.splitter.setOrientation(QtCore.Qt.Horizontal)
        self.splitter.setObjectName('splitter')

        self.verticalLayout_show.addWidget(self.splitter)

        self.treewidget_discipline = QtGui.QTreeWidget(self.splitter)
        self.treewidget_discipline.setObjectName('treewidget_discipline')
        # self.treewidget_discipline.setStyleSheet('font: 14pt \"Sans Serif\";')
        self.treewidget_discipline.headerItem().setText(0, 'Deciplines')
        self.treewidget_discipline.setAlternatingRowColors(True)

        self.splitter.addWidget(self.treewidget_discipline)

        self.treewidget = QtGui.QTreeWidget(self.splitter)
        self.treewidget.setObjectName('treewidget')
        self.treewidget.setAlternatingRowColors(True)
        self.treewidget.setSortingEnabled(True)
        self.treewidget.setColumnCount(0)
        self.splitter.addWidget(self.treewidget)

        self.groupbox_details = QtGui.QGroupBox(self.splitter)
        self.groupbox_details.setObjectName('groupbox_details')
        self.groupbox_details.setTitle('Details')
        self.splitter.addWidget(self.groupbox_details)
        self.splitter.setSizes([171, 381, 108])

        self.treewidget_discipline.itemClicked.connect(
            partial(self.set_my_discipline, self.treewidget_discipline,
                    self.treewidget))