forked from pyconsk/2019.pycon.sk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfreezer.py
40 lines (28 loc) · 962 Bytes
/
freezer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
from flask_frozen import Freezer
from pycon import app
LANGUAGES = (
{'lang_code': 'sk'},
{'lang_code': 'en'}
)
app.config['FREEZER_DESTINATION'] = 'docs' # GitHub pages directory for static site
# app.config['APPLICATION_ROOT'] = '/2019.pycon.sk/'
freezer = Freezer(app)
@freezer.register_generator
def index():
for lang in LANGUAGES:
yield lang
def fix_calendar():
for f in os.listdir(freezer.root):
full_path = os.path.join(freezer.root, f)
if os.path.isdir(full_path):
cal = os.path.join(full_path, 'calendar.ics')
if os.path.exists(cal):
print('Replacing "\\n" with "\\r\\n" in {}'.format(cal))
with open(cal, 'r') as f:
cal_content = f.read()
with open(cal, 'w') as f:
f.write(cal_content.replace('\n', '\r\n'))
if __name__ == '__main__':
freezer.freeze()
# fix_calendar()