Archived
Initial commit
This commit is contained in:
commit
d89b82be4a
103 files changed
+23110
No files matched your search
@@ -0,0 +1,47 @@
|
||||
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)
|
||||
Reference in new issue
Block a user