Skip to content

Instantly share code, notes, and snippets.

@comzeradd
Last active October 6, 2015 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save comzeradd/887c52260630d50f4544 to your computer and use it in GitHub Desktop.
Save comzeradd/887c52260630d50f4544 to your computer and use it in GitHub Desktop.
etherpad-lite push
#!/usr/bin/env python
# Using https://github.com/comzeradd/python-etherpad_lite
from etherpad_lite import EtherpadLiteClient, EtherpadException
import os
# Etherpad-lite API key and url
apikey = ''
base_url = ''
# Directory of old pad txt dumps
txt_dir = 'remo-dumps/'
# Prefix to create new pads
prefix = 'remo'
c = EtherpadLiteClient(base_params={'apikey': apikey}, base_url=base_url)
# Iterate through the given directory and create/overwrite the pad
for counter, filename in enumerate(os.listdir(txt_dir)):
text = open(os.path.join(txt_dir, filename), "r").read()
padid = '{0}-{1}'.format(prefix, filename).split('.txt')[0]
print 'Pushing pad {0}: {1}'.format(counter, padid)
try:
c.createPad(padID=padid, text=text)
except EtherpadException:
c.setText(padID=padid, text=text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment