-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshuffleUtils.py
More file actions
36 lines (31 loc) · 1.03 KB
/
Copy pathshuffleUtils.py
File metadata and controls
36 lines (31 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import csv
import sys
FLAG_TRACK_FILE='flaggedTracks.csv'
def get_flagged_tracks():
forbidden_fruit = set()
current_to_next_map = {}
with open(FLAG_TRACK_FILE, 'r') as file:
flagreader = csv.reader(file)
for line in flagreader:
current_to_next_map[line[0]]=line[1]
forbidden_fruit.add(line[1])
return (forbidden_fruit, current_to_next_map)
def is_flagged(track_id):
reader = csv.reader(open(FLAG_TRACK_FILE))
for row in reader:
if row[0] == track_id:
return True
return False
def add(prev, next):
if not is_flagged(prev):
with open(FLAG_TRACK_FILE, 'a') as file:
flagwriter = csv.writer(file)
flagwriter.writerow([prev, next])
if __name__ == '__main__':
try:
previous_track = sys.argv[1]
next_track = sys.argv[2]
add(previous_track, next_track)
except IndexError:
print("Please provide tracks to flag. Usage: ")
print("python3 shuffleUtils.py <PREV_TRACK_ID> <NEXT_TRACK_ID>")