fixed bug

This commit is contained in:
Elray02 2017-07-03 11:33:40 +02:00
parent 824396191c
commit edad51c72d

View File

@ -1,21 +1,18 @@
import json import json
from pprint import pprint
from random import choice from random import choice
from sys import argv from sys import argv
from collections import OrderedDict
def generateFromJson(text): def generateFromJson(text):
with open(text) as data_file: with open(text) as data_file:
out_list = [] out_list = []
data = json.load(data_file) data = json.load(data_file, object_pairs_hook=OrderedDict)
for i in data: out_string = " ".join(choice(data[keys])for keys in data)
out_list.append(choice(data[i]))
out_string = " ".join(out_list)
return out_string return out_string
if __name__ == '__main__': if __name__ == '__main__':
if argv[1:]: if argv[1:]:
print(generateFromJson(str(argv[1]))) print(generateFromJson(argv[1]))
else: else:
print('Usage:', argv[0], 'something_antani.json') print('Usage:', argv[0], 'something_antani.json')