From 40bb991dfd8e9df348dc43c3f9c6d7c24f2ed463 Mon Sep 17 00:00:00 2001 From: Rachel Hunt Date: Fri, 25 Oct 2019 12:06:50 -0700 Subject: [PATCH] Accommodated Deprecation Warning: 'The readPlist function is deprecated use load() instead' by adding getPlist function that calls load().' --- playlist/playlist.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/playlist/playlist.py b/playlist/playlist.py index 10cc17f..185913f 100644 --- a/playlist/playlist.py +++ b/playlist/playlist.py @@ -14,6 +14,10 @@ import plistlib import numpy as np +def getPlist(fileName): + with open(fileName, 'rb') as fp: + plist = plistlib.load(fp) + return plist def findCommonTracks(fileNames): """ @@ -25,8 +29,11 @@ def findCommonTracks(fileNames): for fileName in fileNames: # create a new set trackNames = set() + # line below throws warning: deprecated in 3.4 load recommended + # plist = plistlib.readPlist(fileName) + # readPlist called multiple times so getPlist(fileName) added # read in playlist - plist = plistlib.readPlist(fileName) + plist = getPlist(fileName) # get the tracks tracks = plist['Tracks'] # iterate through tracks @@ -57,8 +64,11 @@ def plotStats(fileName): """ Plot some statistics by readin track information from playlist. """ + # line below throws warning: deprecated in 3.4 load recommended + # plist = plistlib.readPlist(fileName) + # readPlist called multiple times so getPlist(fileName) added # read in playlist - plist = plistlib.readPlist(fileName) + plist = getPlist(fileName) # get the tracks tracks = plist['Tracks'] # create lists of ratings and duration @@ -104,8 +114,12 @@ def findDuplicates(fileName): Find duplicate tracks in given playlist. """ print('Finding duplicate tracks in %s...' % fileName) + # line below throws warning: deprecated in 3.4 load recommended + # plist = plistlib.readPlist(fileName) + # readPlist called multiple times so getPlist(fileName) added # read in playlist - plist = plistlib.readPlist(fileName) + plist = getPlist(fileName) + # get the tracks tracks = plist['Tracks'] # create a track name dict