Created
September 17, 2016 04:56
Star
You must be signed in to star a gist
Phabricator Phriction documentation exporter script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import os | |
from sqlalchemy import * | |
engine = create_engine('mysql://root:test@127.0.0.1/test') #Change me to the phriction database | |
df=pd.read_sql('select * from phriction_content',engine) | |
def get(x): | |
x=x.iloc[0] | |
try: | |
os.makedirs('data/'+x['slug']) | |
except OSError: | |
print 'k' | |
with open('data/'+x['slug']+x['title']+'.MD','w') as fp: | |
fp.write(x['content']) | |
for name,group in df.groupby('title'): | |
if len(group) > 1: | |
x=group[group['version'] == group['version'].max()] #Get only the latest version | |
get(x) | |
else: | |
get(group) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment