You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.2 KiB
Python

6 years ago
#!/usr/bin/env python3
import json, random, textwrap
1 year ago
import yaml
from urllib.request import urlopen
6 years ago
1 year ago
# with open('terms.json', 'r') as f:
# terms = json.load(f)
# with open('terms.yaml', 'r') as f:
# terms = yaml.load(f)
f = urlopen("https://pad.xpub.nl/p/XPUB-promo-terms/export/txt")
terms = yaml.load(f)
6 years ago
def make_pub():
actor = random.choice(terms['actor'])
6 years ago
terms['actor'].remove(actor)
6 years ago
action = random.choice(terms['action'])
6 years ago
terms['action'].remove(action)
6 years ago
prefix = ''
sort = random.choice(terms['sort'])
6 years ago
terms['sort'].remove(sort)
6 years ago
media = random.choice(terms['media'])
6 years ago
terms['media'].remove(media)
6 years ago
if random.randint(0,2) == 0:
6 years ago
prefix = random.choice(terms['prefix'])
terms['prefix'].remove(prefix)
prefix += '-'
6 years ago
return actor + ' ' + action + ' ' + prefix + sort + ' ' + media
def make_call():
text = 'Calling all '
for _ in range(20):
text += make_pub() + ', '
text = text[:-2]
text += '.'
return text
6 years ago
call = '''
Sorry for >< please >>
///
Piet Zwart Institute Experimental Publishing (XPUB)
///
%s
///
Applications Deadline: May 15 2018
https://xpub.nl
///
''' % (textwrap.fill(make_call()))
print(call)