Browse Source

old dump history, started reorg as package

add-quote-import
Michael Murtaugh 9 years ago
parent
commit
c00e9d89f6
  1. 38
      dump_history.py
  2. 0
      etherdump.py
  3. 8
      padinfo.sample.json
  4. 36
      setup.py

38
dump_history.py

@ -0,0 +1,38 @@
#!/usr/bin/env python
from __future__ import print_function
from argparse import ArgumentParser
import json, sys
from urllib import urlencode
from urllib2 import urlopen, HTTPError, URLError
p = ArgumentParser("")
p.add_argument("padid", help="the padid")
p.add_argument("--startrev", type=int, default=2, help="starting revision")
p.add_argument("--endrev", type=int, default=None, help="ending revision, default: last")
p.add_argument("--padinfo", default="padinfo.json", help="padinfo, default: padinfo.json")
p.add_argument("--dir", default="out")
args = p.parse_args()
with open(args.padinfo) as f:
info = json.load(f)
apiurl = "{0[protocol]}://{0[hostname]}:{0[port]}{0[apiurl]}{0[apiversion]}/".format(info)
data = {}
data['apikey'] = info['apikey']
data['padID'] = args.padid.encode("utf-8")
total_revisions = apiurl+'getRevisionsCount?'+urlencode(data)
total_revisions = json.load(urlopen(total_revisions))['data']['revisions']
rev = args.startrev
print ("Dumping {0} revisions...".format(total_revisions), file=sys.stderr)
data['startRev'] = "1"
while rev <= total_revisions:
data['endRev'] = "{0}".format(rev)
requesturl = apiurl+'createDiffHTML?'+urlencode(data)
html = json.load(urlopen(requesturl))['data']['html']
out = "{0}/{1}_{2:06d}.html".format(args.dir, args.padid, rev)
print ("writing {0}".format(out), file=sys.stderr)
with open(out, "w") as f:
f.write(html.encode("utf-8"))
rev += 1

0
etherdump → etherdump.py

8
padinfo.sample.json

@ -1,8 +0,0 @@
{
"protocol": "http",
"hostname": "localhost",
"port": 9001,
"apiurl": "/api/",
"apiversion": "1.2.9",
"apikey": "XXXXXXXXXXXXXXXXXXXXXXXXX"
}

36
setup.py

@ -0,0 +1,36 @@
#!/usr/bin/env python
import distutils.command.install_lib
from distutils.core import setup
import os
def find (p, d):
ret = []
for b, dd, ff in os.walk(os.path.join(p, d)):
for f in ff:
if not f.startswith("."):
fp = os.path.join(b, f)
ret.append(os.path.relpath(fp, p))
ret.sort()
# for x in ret[:10]:
# print "**", x
return ret
setup(
name='etherdump',
version='0.3.0',
author='Michael Murtaugh',
author_email='mm@automatist.org',
packages=['etherdump'],
package_dir={'etherdump': 'etherdump'},
#package_data={'activearchives': find("activearchives", "templates/") + find("activearchives", "data/")},
package_data={'etherdump': find("etherdump", "data/")},
scripts=['bin/etherdump'],
url='http://activearchives.org/wiki/Etherdump/',
license='LICENSE.txt',
description='Etherdump an etherpad publishing & archiving system',
# long_description=open('README.md').read(),
install_requires=[
"html5lib", "jinja2"
]
)
Loading…
Cancel
Save