Example #1
0
 def load_next_disk(self) -> None:
     """Load the next disk into the reader
     
     Ejects the tray, places the disk, and returns the tray.
     """
     open_tray()
     self.place_disk()
     close_tray()
Example #2
0
    def reject_current_disk(self) -> None:
        """Reject the currently loaded disk

        Ejects the disk, picks it up, and drops it into
        the reject pile.
        """
        open_tray()
        self.lift_disk()
        close_tray()
        self.reject_disk()
Example #3
0
 def accept_current_disk(self) -> None:
     """Accept the currently loaded disk
     
     Ejects the disk, picks it up, and drops it into
     the accept pile.
     """
     open_tray()
     self.lift_disk()
     close_tray()
     self.accept_disk()
Example #4
0
    def map_over_disks(self, func: Callable[[], bool]) -> None:
        """Maps the function `func` over all disks in the disk queue
        
        `func` should return whether to accept or reject the current disk
        """
        # Handle if there's not already a disk in the tray
        open_tray()
        if not self.get_state()["disk_in_open_tray"]:
            self.load_next_disk()
        close_tray()

        try:
            while True:
                if func():
                    self.accept_current_disk()
                else:
                    self.reject_current_disk()
                self.load_next_disk()

        except NoDiskError:
            # No more disks means we're done
            return