git ssb

2+

Zach! / onboarding-link-generator



Tree: ab68e4cb17bd0f1bda42fed9ccd8674bbfd4e406

Files: ab68e4cb17bd0f1bda42fed9ccd8674bbfd4e406 / steps / template.py

1294 bytesRaw
1import shutil
2import os
3
4def make_directory(details):
5 """Make a new folder specific for invitee within this directory, then add an index.html and
6 stylesheet.css file for it."""
7 name = details['recipient'].replace(" ","-").lower()
8 path = 'invites/{}'.format(name)
9 if not os.path.exists(path):
10 os.makedirs(path)
11 shutil.copy2('resources/stylesheet.css', path)
12 shutil.copy2('resources/index.html', path)
13
14
15def filled_out_template(details):
16 """Take the details entered in the script and add them to the index.html template."""
17 with open('resources/template.html', 'r') as template:
18 the_page = template.read()
19 return the_page.format(**details)
20
21def create_index_file(details):
22 """Convert the filled out template file into the invitees' index.html file"""
23 name = details['recipient'].replace(" ","-").lower()
24 index_file = 'invites/{}/index.html'.format(name)
25 with open(index_file, "w") as target_file:
26 target_file.write(filled_out_template(details))
27
28def main(details):
29 """Make a new directory for the invitee, then add a stylesheet and custom index.html file to
30 this directory."""
31 make_directory(details)
32 filled_out_template(details)
33 create_index_file(details)
34
35if __name__ == "__main__":
36 main()
37

Built with git-ssb-web