Example #1
0
    def add_track(track_info: tuple, cd: DC.CD) -> None:
        """adds a Track object with attributes in track_info to cd


        Args:
            track_info (tuple): Tuple containing track info (position, title, Length).
            cd (DC.CD): cd object the tarck gets added to.

        Raises:
            Exception: DESCraised in case position is not an integer.

        Returns:
            None: DESCRIPTION.

        """

        # TO Done add code as required
        trkPos, trkTitle, trkLength = track_info
        try:
            trkPos = int(trkPos)
        except:
            raise Exception('\nTrack position must be an integer.')

        track = DC.Track(trkPos, trkTitle, trkLength)
        cd.add_track(track)
Example #2
0
    def add_track(track_info: tuple, cd: DC.CD) -> None:
        """adds a Track object with attributes in track_info to cd


        Args:
            track_info (tuple): Tuple containing track info (position, title, Length).
            cd (DC.CD): cd object the track gets added to.

        Raises:
            Exception: Exception raised in case position is not an integer.

        Returns:
            None: track is added to cd object passed in

        """

        try:
            for row in cd.cd_tracks:
                if row != None and row.position == track_info[0]:
                    print('!A Track with ID:', track_info[0] ,' already exists. Unable to add CD.\n')
                    return
            new_track = DC.Track(track_info[0], track_info[1], track_info[2])
            cd.add_track(new_track)
        except:
            raise Exception ("Unable to add track to CD.")
    def add_track(track_info: tuple, cd: DC.CD) -> None:
        """adds a Track object with attributes in track_info to cd


        Args:
            track_info (tuple): Tuple containing track info (position, title, Length).
            cd (DC.CD): cd object the track gets added to.

        Raises:
            Exception: DESCraised in case position is not an integer.

        Returns:
            None: DESCRIPTION.

        """
        trkPos, trkTitle, trkLength = track_info
        try:
            trkPos = int(trkPos)
        except Exception as e:
            print('Position must be an integer',
                  e,
                  e.__doc__,
                  type(e),
                  sep='\n')
        track = DC.Track(trkPos, trkTitle, trkLength)
        cd.add_track(track)
Example #4
0
    def add_track(track_info: tuple, cd: DC.CD) -> None:
        """adds a Track object with attributes in track_info to cd

        Args:
            track_info (tuple): Tuple containing track info (position, title, Length).
            cd (DC.CD): cd object the tarck gets added to.

        Raises:
            Exception: DESCraised in case position is not an integer.

        Returns:
            None: DESCRIPTION.
        """

        trkPos, trkTitle, trkLength = track_info
        try:
            trkPos = int(trkPos)
            if trkPos <= 0:
                raise ValueError
        except ValueError:
            print('====Error!!=====')
            print(f'You entered {trkPos}, which is not a valid Track ID.')
            print('Please enter a number for Track ID.')
            print()
            return

        track = DC.Track(trkPos, trkTitle, trkLength)
        cd.add_track(track)
Example #5
0
    def del_track(rem_track: int, cd: DC.CD) -> None:
        """Deletes a Track for the list of cd_tracks


        Args:
            rem_track (int): Position of the track to be deleted.
            cd (DC.CD): cd object the track gets deleted from.

        Raises:
            Exception: DESCraised in case position is not an integer.

        Returns:
            track (string): Track string that matches rem_track, if no match returns None

        """
        tracks = cd.cd_tracks
        try:
            rem_track = int(rem_track)
        except:
            raise Exception('Track must be an Integer!')
        for track in tracks:
            if (track is not None):
                if track.position == rem_track:
                    cd.rmv_track(rem_track)
                    print('Track was removed!')
                    return track
Example #6
0
    def add_track(track_info: tuple, cd: DC.CD) -> None:
        """adds a Track object with attributes in track_info to cd


        Args:
            track_info (tuple): Tuple containing track info (position, title, Length).
            cd (DC.CD): cd object the tarck gets added to.

        Raises:
            Exception: DESCraised in case position is not an integer.

        Returns:
            None

        """

        trkPos, trkTitle, trkLength = track_info
        try:
            trkPos = int(trkPos)
        except:
            raise Exception('Position must be an Integer')
        track = DC.Track(trkPos, trkTitle, trkLength)
        cd.add_track(
            track
        )  #calls function that appends track object to CD obect than sorts tracks.
Example #7
0
    def add_track_from_tuple(track_info: tuple, cd: DC.CD) -> None:
        """Adds a Track object with attributes in track_info to CD

        Args:
            track_info (tuple): Tuple containing track info (position, title, Length, cd_id).
            cd (DC.CD): cd object the track gets added to.

        Raises:
            Exception: raised in case position is not an integer.

        Returns:
            None.
        """
        track_object = DC.Track(track_info[0], track_info[1], track_info[2],
                                track_info[3])
        cd.add_track(track_object)
Example #8
0
    def remove_track(track_position: int, cd: DC.CD) -> None:
        """removes a Track object with the given track position


        Args:
            track_position (int): integer of the track position to remove
            cd (DC.CD): cd object the track gets added to.

        Raises:
            Exception: Exception raised in case position is not an integer.

        Returns:
            None: track is removed from cd object passed in

        """
        try:
            cd.rmv_track(track_position)
        except:
            raise Exception ("Unable to  add track to CD.")
Example #9
0
    def add_track(track_info: tuple, cd: DC.CD) -> None:
        """adds a Track object with attributes in track_info to cd


        Args:
            track_info (tuple): Tuple containing track info (position, title, Length).
            cd (DC.CD): cd object the tarck gets added to.

        Raises:
            Exception: DESCraised in case position is not an integer.

        Returns:
            None: DESCRIPTION.

        """
        uniFlag = 0

        try:
            trackPos, trackTitle, trackLen = track_info
        except:
            raise Exception('Track info must be a tuple!')

        try:
            intTrPos = int(trackPos)
        except:
            raise Exception('Track position must be an Integer!')

        # Check for unique ID
        for row in cd.cd_tracks:
            if row == None:
                continue
            if intTrPos == row.position:
                uniFlag = 1

        if uniFlag:
            print('\n-------- WARNING MESSAGE --------')
            print('Track value is not unique. Please enter a unique value!')
            print('Data entry not recorded!')
            print('---------------------------------\n')
        else:
            trackObj = DC.Track(trackPos, trackTitle, trackLen)
            cd.add_track(trackObj)
Example #10
0
 def add_track(track_info: tuple, cd: DC.CD) -> None:
     """adds a Track object with attributes in track_info to cd
     
     Args:
         track_info (tuple): Tuple containing track info (position, title, Length).
         cd (DC.CD): cd object the track gets added to.
         
     Raises:
         ValueError exception: raised in case position is not an integer.
         
     Returns:
         None.
     """
     position, title, length = track_info
     try:
         position = int(position)
         track = DC.Track(position, title, length)
         cd.add_track(track)
     except ValueError:
         print('Position must be an integer.\n')
Example #11
0
    def add_track(track_info: tuple, cd: DC.CD) -> None:
        """adds a Track object with attributes in track_info to cd

        Args:
            track_info (tuple): Tuple containing track info (position, title, Length).
            cd (DC.CD): cd object the tarck gets added to.

        Raises:
            Exception: DESCraised in case position is not an integer.

        Returns:
            None: DESCRIPTION.
        """
        # TODO add code as required
        try:
            trackPos = int(track_info[0])
        except:
            raise Exception("Track position is not an integer.")
        toAddTrack = DC.Track(track_info[0], track_info[1], track_info[2])
        cd.add_track(toAddTrack)
    def remove_track(track: int, cd: DC.CD) -> None:
        """Removes a Track object from cd


        Args:
            track (int): Integer containing user choice of track to remove
            cd (DC.CD): cd object the tarck gets added to.

        Raises:
            Exception: DESCraised in case position is not an integer.

        Returns:
            None

        """
        try:
            track = int(track)
        except:
            raise Exception('ID must be an Integer!')
        cd.rmv_track(track)
Example #13
0
    def add_track(track_info: tuple, cd: DC.CD) -> None:
        """adds a Track object with attributes in track_info to cd


        Args:
            track_info (tuple): Tuple containing track info (position, title, Length).
            cd (DC.CD): cd object the tarck gets added to.

        Raises:
            Exception: DESCraised in case position is not an integer.

        Returns:
            None: DESCRIPTION.

        """
        pos = track_info[0]
        if type(pos) != type(0):
            raise Exception('position must be an integer!')
        tite = track_info[1]
        leng = track_info[2]
        track = DC.Track(pos, tite, leng)
        cd.add_track(track)
    def add_track(track_info: tuple, cd: DC.CD) -> None:
        """adds a Track object with attributes in track_info to cd


        Args:
            track_info (tuple): Tuple containing track info (position, title, Length).
            cd (DC.CD): cd object the tracck gets added to.

        Raises:
            Exception: DESCraised in case position is not an integer.

        Returns:
            None: DESCRIPTION.

        """
        tracknum, tracktitle, tracklen = track_info
        try:
            tracknum = int(tracknum)
        except:
            raise Exception('The track number must be an Integer!')
        track = DC.Track(tracknum, tracktitle, tracklen)
        cd.add_track(track)
Example #15
0
 def remove_track(track_pos: int, cd: DC.CD) -> None:
     """removes a track from the CD
     
     Args:
         track_pos (int): the position of the track to be removed
         cd (DC.CD): the cd object the track is to be removed from
     
     Raises:
         ValueError Exception: raised in case position is not an integer.
         Exception: raised in case the track does not exist
     
     Returns:
         None
     """
     try:
         track_pos = int(track_pos)
         try:
             cd.rmv_track(track_pos)
         except Exception as e:
             print('Track does not exist.\n', str(e))
     except ValueError:
         print('Position must be an integer.')
    def add_track(track_info: tuple, cd: DC.CD) -> None:
        """adds a Track object with attributes in track_info to cd


        Args:
            track_info (tuple): Tuple containing track info (position, title, Length).
            cd (DC.CD): cd object the track gets added to.

        Raises:
            Exception: Raised in case position is not an integer.

        Returns:
            None.

        """
        trk_position, trk_title, trk_artist = track_info
        try:
            trk_position = int(trk_position)
        except:
            raise Exception('Position must be an Integer!')
        track = DC.Track(trk_position, trk_title, trk_artist)
        cd.add_track(track)
Example #17
0
    def add_track(track_info: tuple, cd: DC.CD) -> None:
        """adds a Track object with attributes in track_info to cd


        Args:
            track_info (tuple): Tuple containing track info (position, title, Length).
            cd (DC.CD): cd object the tarck gets added to.

        Raises:
            Exception: DESCraised in case position is not an integer.

        Returns:
            None: DESCRIPTION.

        """

        idPos, title, length = track_info
        try:
            idPos = int(idPos)
        except Exception as e:
            raise Exception('can not add track:\n' + str(e))
        trackObj = DC.Track(idPos, title, length)
        cd.add_track(trackObj)
    def add_track(track_info: tuple, cd: DC.CD) -> None:
        """adds a Track object with attributes in track_info to cd


        Args:
            track_info (tuple): Tuple containing track info (position, title, Length).
            cd (DC.CD): cd object the tarck gets added to.

        Except:
            prints Exception, and will not add track if exception is raised

        Returns:
            None: DESCRIPTION.

        """

        newPos, newTtl, newLnth = track_info
        try:
            newPos = int(newPos)
            track = DC.Track(newPos, newTtl, newLnth)
            cd.add_track(track)
        except Exception as e:
            print(e)
    def add_track(track_info: tuple, cd: DC.CD) -> None:
        """adds a Track object with attributes in track_info to cd


        Args:
            track_info (tuple): Tuple containing track info (position, title, Length, track list).
            cd (DC.CD): cd object the tarck gets added to.

        Raises:
            Exception: DESCraised in case position is not an integer.

        Returns:
            None

        """

        trackId, trackTitle, trackLength = track_info
        try:
            trackId = int(trackId)
        except:
            raise Exception('ID must be an Integer!')
        newTrack = DC.Track(trackId, trackTitle, trackLength)
        cd.add_track(newTrack)
Example #20
0
    def add_track(track_info: tuple, cd: DC.CD) -> None:
        """adds a Track object with attributes in track_info to cd
        
        
        Args:
        track_info (tuple): Tuple containing track info (position, title, Length).
        cd (DC.CD): cd object the tarck gets added to.
        
        Raises:
        Exception: DESCraised in case position is not an integer.
        dule 09 Page 35
        
        Returns:
        None: DESCRIPTION.
        
        """

        trkPos, trkTitle, trkLength = track_info
        try:
            trkPos = int(trkPos)
        except:
            raise ValueError('Position must be an Integer')
        track = DC.Track(trkPos, trkTitle, trkLength)
        cd.add_track(track)