Skip to content

Instantly share code, notes, and snippets.

@HackToHell
Created September 17, 2016 04:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save HackToHell/9f261728f4ceda1605c9b3b1f46addbc to your computer and use it in GitHub Desktop.
Phabricator Phriction documentation exporter script
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