Skip to content

Instantly share code, notes, and snippets.

@harlowja
Created November 10, 2015 01:10
Show Gist options
  • Save harlowja/099cf904365d7fed31e7 to your computer and use it in GitHub Desktop.
Save harlowja/099cf904365d7fed31e7 to your computer and use it in GitHub Desktop.
import os
import random
import sys
import jinja2
import parawrap
def expand_template(contents, params):
if not params:
params = {}
tpl = jinja2.Template(source=contents, undefined=jinja2.StrictUndefined)
return tpl.render(**params)
chosen_how = [
'selected',
'picked',
'targeted',
]
new_oslo_core_tpl = """
Hi {{firstname}} {{lastname}},
You have been {{chosen_how}} to be a new {{project}} core (if you are
willing to accept this mission). We have been watching your commits and
reviews and have noticed that you may be interested in a core position
that would be granted to you (if you are willing to accept the
responsibility of being a new core member[1] in project {{project}}).
What do you think, are you able (and willing) to accept?
If you have any questions, please feel free to respond or jump on
freenode and chat with the team on channel #openstack-oslo (one of the
other cores in oslo usually around).
This message will self-destruct in 5 seconds.
Sincerely,
The Oslo Team
[1] http://docs.openstack.org/infra/manual/core.html
"""
firstname = sys.argv[1]
lastname = sys.argv[2]
tpl_args = {
'firstname': firstname,
'project': sys.argv[3],
'lastname': lastname,
'firstname_title': firstname.title(),
'lastname_title': lastname.title(),
'chosen_how': random.choice(chosen_how),
}
tpl_value = expand_template(new_oslo_core_tpl.lstrip(), tpl_args)
tpl_value = parawrap.fill(tpl_value)
print(tpl_value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment