This repository has been archived on 2026-10-21. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
2026-09-22 11:52:03 +02:00

48 lines
943 B
Python

import numpy as np
import os
import pickle
global groups
groups = []
groupsPkl = os.path.join('../other/', 'groups.pkl')
def rewritePkl(arr, filePath):
with open(filePath, 'w') as f:
pickle.dump(arr, f)
def readPkl(filePath):
with open(filePath, 'r') as f:
loaded = pickle.load(f)
return loaded
def getPkl():
global groups
if os.path.exists(groupsPkl):
groups = readPkl(groupsPkl)
print groups
else:
for _ in range(10):
groups.append("Sam")
groups.append("Laptop")
np.random.shuffle(groups)
# rewritePkl(groups, groupsPkl)
if __name__ == '__main__':
getPkl()
try:
subject = groups.pop()
print "\nParticipant will be starting with: \n\n\t" + subject + "\n\n"
except IndexError:
os.remove(groupsPkl)
print '-- Regenerating file -- '
getPkl()
rewritePkl(groups, groupsPkl)