-
Notifications
You must be signed in to change notification settings - Fork 1
/
make_entry_rst.py
44 lines (34 loc) · 1.04 KB
/
make_entry_rst.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
41
42
43
44
import sys
from datetime import datetime
# copied from http://nafiulis.me/making-a-static-blog-with-pelican.html
TEMPLATE = """
{title}
{hashes}
:date: {year}-{month}-{day} {hour}:{minute:02d}
:tags:
:category:
:slug: {slug}
:summary:
:status: draft
:authors: Keith Kelly
"""
def make_entry(title):
today = datetime.today()
slug = title.lower().strip().replace(' ', '-')
f_create = "content/blog/{}/post.rst".format(slug)
t = TEMPLATE.strip().format(title=title,
hashes='#' * len(title),
year=today.year,
month=today.month,
day=today.day,
hour=today.hour,
minute=today.minute,
slug=slug)
with open(f_create, 'w') as w:
w.write(t)
print("File created -> " + f_create)
if __name__ == '__main__':
if len(sys.argv) > 1:
make_entry(sys.argv[1])
else:
print("No title given")