diff --git a/assn3/cddb b/assn3/cddb
index 932c3fdc000558ecf1dea420433f62b7d1c122e1..379f643aa3aead2a9d885df4e969da484eeb2e85 100755
--- a/assn3/cddb
+++ b/assn3/cddb
@@ -3,10 +3,6 @@
import sys
import argparse
import os
-#from . import classDef
-
-#from classDef import Album
-
class Album():
@@ -68,9 +64,6 @@ for i in inBlank[::-1]:
inBlank.pop(inBlank.index(i))
lineList.pop(i-1)
-#print(f'updated inBlank: {inBlank}')
-
-
#Iterate through list of index of blank lines and store info in album class data structure
count = 0
for index in inBlank[0:-1]:
@@ -90,10 +83,6 @@ for index in inBlank[0:-1]:
count += 1
-#for artist in albumDict.keys():
-# for album in albumDict[artist]:
-# print(album)
-
for artist in albumDict.keys():
albumDict[artist] = sorted(albumDict[artist], key=lambda album: album.date)
@@ -130,13 +119,7 @@ def artistMenu(albumDict, purpose):
except ValueError:
print(f'Invalid input: Please enter an integer between 1 and {len(albumDict.keys())}')
- #elif isinstance(artistChosen, int):
- #if artistChosen < (len(albumDict.keys())+1) and artistChosen > 0 :
- #err = False
- #return artistList[int(artistChosen) - 1] #name of artist chosen
- #else:
- #print(f'Invalid input: Please enter an integer between 1 and {len(albumDict.keys())}')
-
+
def listAlbums(res, albumDict, purpose):
albumList = sorted(albumDict[res], key=lambda album: album.date) #sorted list of albums by artist chosen
@@ -166,20 +149,6 @@ def listAlbums(res, albumDict, purpose):
-# if str(albumchosen) != 'a': #used to be == a
-# if isinstance(albumchosen, int):
-# if albumchosen < (len(albumList)+1) and albumchosen > 0 :
-# err = False
-# return albumchosen #res is the string of name of artistchosen
-# else:
-# print(f'Invalid input: please enter an interger between 1 and {len(albumList)}')
-# else:
-# print(f'Invalid input: Your input is not an integer. Please enter an integer between 1 and {len(albumList)})')
-# else:
-# err = False
-# return 0
-
-
def lUti(albumDict):
albumchosen = 0
@@ -195,9 +164,9 @@ def lUti(albumDict):
for song in albumList[int(albumchosen)-1].songs:
print(song)
res3 = input(str('Return to the previous (the album) menu or quit? (press any key = return, 0 = quit)\n'))
- if res3 == '0': ########EXIT HERE!!!!!! REMEMBER TO CHECK AGAIN
+ if res3 == '0':
sys.exit()
- else: ################### res3 invalid key
+ else:
albumchosen = listAlbums(artistchosen, albumDict, 'song listing')
while albumchosen == 0:
artistchosen= artistMenu(albumDict, 'listing')
@@ -206,7 +175,6 @@ def lUti(albumDict):
albumchosen = listAlbums(artistchosen, albumDict, 'song listing')
-#the Delete function
def delete(albumDict):
albumchosen = 0
while albumchosen == 0:
@@ -218,10 +186,6 @@ def delete(albumDict):
albumchosen = listAlbums(artistchosen, albumDict, 'album deletion')
del albumDict[artistchosen][int(albumchosen) -1]
- #for k in albumDict.keys():
- #for album in albumDict[k]:
- #print(album)
-
def add(albumDict):
@@ -251,11 +215,6 @@ def add(albumDict):
albumDict[new.artist].append(new)
- #for k in albumDict.keys():
- # for album in albumDict[k]:
- # print(album)
-
-
def helpmsg():
print('usage: parseCDDB.py [-h] -F\n')
print('Purpose: To manage a CD database')
@@ -267,6 +226,11 @@ def helpmsg():
print('-h : Display official help message')
print('PLEASE REFER TO THE -h OPTION FOR OFFICIAL HELP MESSAGE!!!')
+
+
+
+
+#after processing information all within the scope of this script, thinsg need to be written out in temp_cddb, then eventually replacing cddb
def update(albumDict):
temp = open('temp_cddb', 'a')
for key in albumDict.keys():
@@ -289,18 +253,10 @@ def update(albumDict):
for line in tempLines:
cddb.write("%s" % line)
- with open("temp_old", 'a') as old:
+ with open("temp_old", 'w') as old:
for line in cdLine:
old.write("%s" % line)
-
-
-
-
-
-#lUti(albumDict)
-#add(albumDict)
-#update(albumDict)
def main():