forked from ericholscher/ericholscher.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport.py
executable file
·30 lines (28 loc) · 1.08 KB
/
export.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
import psycopg2
import pdb
import os
conn = psycopg2.connect("dbname='ericholscher' user='postgres'")
cur = conn.cursor()
cur.execute("select title, slug, body, publish, tags from blog_posts where status=2;")
rows = cur.fetchall()
for row in rows:
title, slug, body, date, tags = row
print "Working on %s" % slug
in_file = open('%s.md' % slug, 'w+')
in_file.write(body)
in_file.close()
out_dir = 'blog/%s/%s/%s' % (date.year, date.strftime("%b").lower(), date.day)
os.system('mkdir -p %s' % out_dir)
os.system('pandoc --from=markdown --to=rst -o %s/%s.rst %s.md' % (out_dir, slug, slug))
cur = conn.cursor()
cur.execute("select title, slug, body, publish, tags from blog_posts where status=1;")
rows = cur.fetchall()
for row in rows:
title, slug, body, date, tags = row
print "Working on %s" % slug
in_file = open('%s.md' % slug, 'w+')
in_file.write(body)
in_file.close()
out_dir = 'unpublished/blog/%s/%s/%s' % (date.year, date.strftime("%b").lower(), date.day)
os.system('mkdir -p %s' % out_dir)
os.system('pandoc --from=markdown --to=rst -o %s/%s.rst %s.md' % (out_dir, slug, slug))