Exemplo n.º 1
0
 def process_input(entry: str) -> tuple:
     """
     Handle all option and special option actions.
     :param str entry: User's input
     :return tuple: True = Success or False = Fail, next menu or status message
     """
     if entry.upper() == 'B':
         menu_manager.back()
         return False, ''
     elif entry.upper() == 'Q':
         # Quit
         quit()
     if len(entry) < 4:
         # Entry is too short or too long, redisplay prompt
         logger.log_message(
             1, 'User entered less than four characters! ' + entry)
         return False, 'WARNING: Input was less than 4 characters! '
     else:
         # Input is good, query MovieDB
         response = moviedb.query(entry)
         if response[0]:
             if len(response[1]) == 0:
                 # logger.log_message(1, 'No movie found!')
                 return False, 'WARNING: No movie found! '
             else:
                 # Movies found, open Movie_Select
                 next_menu = MovieSelect(response[1], 'I')
                 return True, next_menu
         else:
             return response
Exemplo n.º 2
0
 def process_input(entry: str) -> tuple:
     """
     Handle all option and special option actions.
     :param str entry: User's input
     :return tuple: True = forward into next menu or False = back to previous menu, next menu to display
     """
     entry = entry.upper()
     if entry == '1':
         # Create StatusMessage object
         status = StatusMessage('Dead End',
                                'Press any key to return to the last menu',
                                'This is a StatusMessage')
         status.menu_logic()
         ''' Do something else here if you don't want to return to this menu '''
         return False, ''
     elif entry == '2':
         # Create AnotherMenu object
         another_menu = AnotherMenu()
         return True, another_menu
     if entry.upper() == 'B':
         # Call the menu manager function to go back to the previous menu
         menu_manager.back()
         return False, ''
     elif entry.upper() == 'M':
         # Call the menu manager function to go back to the root (main) menu
         menu_manager.to_menu_root()
         return False, ''
     else:
         # Quit
         quit()
Exemplo n.º 3
0
    def process_input(self, entry) -> tuple:
        """
        Handle all option and special option actions.
        :param str entry: User's input
        :return tuple: True = Success or False = Fail, next menu to display or failure message
        """
        if entry.upper() == 'B':
            menu_manager.back()
            return False, ''
        elif entry.upper() == 'Q':
            # Quit
            quit()

        if self._mode == 'I':
            format_menu = FormatSelect(self._movie_list[int(entry) - 1])
        while True:
            if self._mode == 'I':
                response = format_menu.menu_logic()
            else:
                response = True, ''
            if response[0]:
                # If format entry is in options/special_options, pass entry to process input
                if self._mode == 'I':
                    response = format_menu.process_input(response[1])
                if response[0]:
                    # If format was successfully chosen, retrieve movie's IMDB ID from MovieDB
                    if self._mode == 'I':
                        movie = response[1]
                        response = moviedb.get_movie_imdb_id(response[1].movie_db_id)
                    else:
                        movie = self._movie_list[int(entry) - 1]
                    if response[0]:
                        # If movie's IMDB ID was successfully retrieved, create LibraryDB_Movie object with IMDB ID
                        if self._mode == 'I':
                            movie = LibraryDBMovie(movie.title,
                                                   movie.movie_db_id,
                                                   movie.title_format,
                                                   movie.title_status,
                                                   response[1],
                                                   movie.genre_ids,
                                                   movie.description,
                                                   movie.release_date,
                                                   movie.poster_url)
                        return True, MovieParams(movie, self._mode)
                    else:
                        # Couldn't obtain IMDB ID, back to format select menu.
                        format_menu.val_input = False
                        format_menu.inval_prompt = response[1]
                        continue
                else:
                    # Error choosing format, back to format select
                    format_menu.val_input = False
                    format_menu.inval_prompt = response[1]
                    continue
            else:
                # Error choosing format, back to format select
                format_menu.val_input = False
                format_menu.inval_prompt = response[1]
                continue
Exemplo n.º 4
0
 def process_input(entry: str) -> tuple:
     """
     Handle all option and special option actions.
     :param str entry: User's input
     :return tuple: False (to drop back into the Menu Manager loop), status message or next menu
     """
     if entry.upper() == 'B':
         menu_manager.back()
         return False, ''
     elif entry.upper() == 'Q':
         # Quit
         quit()
     # Check if entry is in the form of IMDB ID
     # tt9999999
     if len(entry) != 9:
         # Entry is too short or too long, redisplay prompt
         logger.log_message(
             1, 'Entry is ' + str(len(entry)) +
             ' characters long. Entry: ' + entry)
         return False, 'WARNING: Input should be 9 characters! '
     else:
         pattern = re.compile('tt\d{7}')
         match = pattern.search(entry)
         # logger.log_message(1, 'Looking for regex match...')
         if match:
             # Matches IMDB ID form, query MovieDB
             # logger.log_message(1, 'Searching MovieDB...')
             response = _query_moviedb(entry)
             if response[0] is False:
                 return response
             else:
                 # logger.log_message(1, 'Proper IMDB ID entered, opening Format_Select.')
                 format_menu = FormatSelect(response[1])
                 while True:
                     response = format_menu.menu_logic()
                     if response[0]:
                         # If selection is in options/special_options, process input
                         response = format_menu.process_input(response[1])
                         if response[0]:
                             # If format was successfully selected, return LibraryDB_Movie object
                             return True, MovieParams(response[1], 'I')
                         else:
                             # Format not successfully selected, back to format select menu
                             format_menu.val_input = False
                             format_menu.inval_prompt = response[1]
                             continue
                     else:
                         # Format not successfully selected, back to format select menu
                         format_menu.val_input = False
                         format_menu.inval_prompt = response[1]
                         continue
         else:
             # Entry is not IMDB ID, redisplay prompt
             logger.log_message(1, 'NOT AN IMDB ID! ' + entry)
             return False, 'NOT AN IMDB ID! '
Exemplo n.º 5
0
 def process_input(entry) -> tuple:
     """
     Handle all option and special option actions.
     :param str entry: User's input
     :return tuple: Success = True or Fail = False, next menu or status message
     """
     entry = entry.upper()
     if entry == '1':
         # Create MovieDB IMDB ID search Option_Select menu
         next_menu = MovieDBIMDBID()
         return True, next_menu
     elif entry == '2':
         # Create MovieDB text search Option_Select menu
         next_menu = MovieDBSearch()
         return True, next_menu
     elif entry == 'B':
         menu_manager.back()
         return False, ''
     else:
         # Quit
         quit()
Exemplo n.º 6
0
 def process_input(entry: str) -> tuple:
     """
     Handle all option and special option actions.
     :param str entry: User's input
     :return tuple: True = Success or False = Fail, next menu or status message
     """
     if entry.upper() == 'B':
         # Call the menu manager function to go back to the previous menu
         menu_manager.back()
         return False, ''
     elif entry.upper() == 'M':
         # Call the menu manager function to go back to the root (main) menu
         menu_manager.to_menu_root()
         return False, ''
     elif entry.upper() == 'Q':
         # Quit
         quit()
     else:
         # Input is good
         status = StatusMessage('Status Message',
                                'Press any key to return to the last menu',
                                'You entered: ' + entry)
         status.menu_logic()
         return False, ''
Exemplo n.º 7
0
    def process_input(self, entry: str) -> tuple:
        """
        Handle all option and special option actions.
        :param str entry: User's input
        :return tuple: True = Success or False = Fail, next menu to display or failure message
        """
        param_menu = None
        if entry == '1':
            # Param_Edit title
            param_menu = ParamEdit(('name', self.movie.title))
        elif entry == '2':
            # Param_Edit movie_db_id
            param_menu = ParamEdit(('movie_db_id', self.movie.movie_db_id))
        elif entry == '3':
            # Param_Edit format
            param_menu = ParamEdit(('format', self.movie.title_format))
        elif entry == '4':
            # Param_Edit imdb_id
            param_menu = ParamEdit(('imdb_id', self.movie.imdb_id))
        elif entry == '5':
            # Param_Edit genres
            param_menu = ParamEdit(('genres', self.movie.genre_ids))
        elif entry == '6':
            # Param_Edit description
            param_menu = ParamEdit(('description', self.movie.description))
        elif entry == '7':
            # Param_Edit release_data
            param_menu = ParamEdit(('release_date', self.movie.release_date))
        elif entry == '8':
            # Param_Edit posterUrl
            param_menu = ParamEdit(('posterUrl', self.movie.poster_url))
        elif entry.upper() == 'I':
            confirm_insert = ConfirmInsert(self.movie)
            entry = confirm_insert.menu_logic()
            if entry[0]:
                entry = confirm_insert.process_input(entry[1])
                return entry
        elif entry.upper() == 'U':
            confirm_update = ConfirmUpdate(self.movie)
            entry = confirm_update.menu_logic()
            if entry[0]:
                entry = confirm_update.process_input(entry[1])
                return entry
        elif entry.upper() == 'B':
            menu_manager.back()
            return False, ''
        else:
            # Quit
            quit()

        while True:
            sel = param_menu.menu_logic()
            print(sel)
            if sel[0]:
                sel = param_menu.process_input(sel[1])
                if sel[0]:
                    self.update_movie(entry, sel[1])
                    return False, ''
                else:
                    if len(sel[1]) > 0:
                        param_menu.inval_prompt = sel[1]
                        continue
                    else:
                        return sel
            else:
                return sel