2015-07-08 07:22:54 +00:00
|
|
|
import utils
|
|
|
|
import datamine
|
|
|
|
import random
|
|
|
|
|
|
|
|
def main(fname, oname = None, verbose = True):
|
|
|
|
if verbose:
|
|
|
|
print 'Opening encoded card file: ' + fname
|
|
|
|
|
|
|
|
with open(fname, 'rt') as f:
|
|
|
|
text = f.read()
|
|
|
|
|
|
|
|
cardtexts = text.split(utils.cardsep)
|
|
|
|
|
|
|
|
# overkill
|
|
|
|
datamine.analyze(cardtexts)
|
|
|
|
|
|
|
|
multicards = []
|
2015-07-14 07:07:25 +00:00
|
|
|
reps = 10
|
2015-07-08 07:22:54 +00:00
|
|
|
|
|
|
|
for card in datamine.cards:
|
|
|
|
for i in range(reps):
|
|
|
|
multicards += [card.reencode(randomize = True)]
|
2015-07-14 07:07:25 +00:00
|
|
|
# multicards += [card.reencode(randomize = True)
|
|
|
|
# + card.cost.reencode(randomize = True) + utils.fieldsep]
|
2015-07-08 07:22:54 +00:00
|
|
|
|
|
|
|
random.shuffle(multicards)
|
|
|
|
|
|
|
|
if oname:
|
|
|
|
if verbose:
|
|
|
|
print 'Writing output to: ' + oname
|
|
|
|
with open(oname, 'w') as ofile:
|
|
|
|
for textcard in multicards:
|
|
|
|
ofile.write(textcard + utils.cardsep)
|
|
|
|
else:
|
|
|
|
for textcard in multicards:
|
|
|
|
print textcard + '\n'
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys
|
|
|
|
if len(sys.argv) == 2:
|
|
|
|
main(sys.argv[1])
|
|
|
|
elif len(sys.argv) == 3:
|
|
|
|
main(sys.argv[1], oname = sys.argv[2])
|
|
|
|
else:
|
|
|
|
print 'Usage: ' + sys.argv[0] + ' ' + '<encoded file> [output filename]'
|
|
|
|
exit(1)
|