2017-06-30 16:56:28 +02:00
|
|
|
import json
|
|
|
|
from random import choice
|
|
|
|
from sys import argv
|
2017-07-03 11:33:40 +02:00
|
|
|
from collections import OrderedDict
|
2017-06-30 16:56:28 +02:00
|
|
|
|
|
|
|
def generateFromJson(text):
|
|
|
|
with open(text) as data_file:
|
|
|
|
out_list = []
|
2017-07-03 11:33:40 +02:00
|
|
|
data = json.load(data_file, object_pairs_hook=OrderedDict)
|
|
|
|
out_string = " ".join(choice(data[keys])for keys in data)
|
2017-06-30 16:56:28 +02:00
|
|
|
return out_string
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if argv[1:]:
|
2017-07-03 11:33:40 +02:00
|
|
|
print(generateFromJson(argv[1]))
|
2017-06-30 16:56:28 +02:00
|
|
|
else:
|
|
|
|
print('Usage:', argv[0], 'something_antani.json')
|