forked from modelica/fmi-standard.org
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimport_posts.py
More file actions
30 lines (20 loc) · 760 Bytes
/
Copy pathimport_posts.py
File metadata and controls
30 lines (20 loc) · 760 Bytes
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
import os
src = r'E:\Development\fmi-standard.org\jekyll\_posts'
dst = r'E:\Development\fmi-standard.org\content\news'
for filename in os.listdir(src):
f = os.path.join(src, filename)
s = filename.split('-')
if not os.path.isfile(f):
continue
alias = f'/news/{s[0]}/{s[1]}/{s[2]}/{filename[11:-3]}.html'
print(f)
with open(f, 'r') as ff:
lines = ff.readlines()
with open(os.path.join(dst, filename), 'w') as ff:
for line in lines:
if line.startswith(('categories:', 'layout:')):
continue
ff.write(line)
if line.startswith('title:'):
ff.write(f'date: {filename[:10]}\n')
ff.write(f'aliases: [{alias}]\n')