Last active
August 28, 2015 06:46
-
-
Save tnarihi/03f45d9591756c9f4a34 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import argparse | |
import random | |
parser = argparse.ArgumentParser() | |
parser.add_argument('text_input', help='Path to input file') | |
parser.add_argument('--seed', type=int, default=313, | |
help='Seed of random') | |
parser.add_argument('--stack', type=int, default=9, | |
help='Number of stack (default: 9)'), | |
args = parser.parse_args() | |
with open(args.text_input, 'r') as fd: | |
s = 0 | |
slines = [] | |
while True: | |
lines = [] | |
for i in xrange(args.stack): | |
line = fd.readline() | |
if line == '': | |
break | |
lines += [line] | |
if len(lines) == 0: | |
break | |
elif len(lines) == args.stack: | |
slines += [lines] | |
else: | |
raise ValueError( | |
"The text must have number of lines" | |
"with multiple of stack={}".format(args.stack)) | |
random.seed(args.seed) | |
random.shuffle(slines) | |
for lines in slines: | |
for line in lines: | |
print(line, end='') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment