Last active
October 6, 2015 11:59
-
-
Save comzeradd/887c52260630d50f4544 to your computer and use it in GitHub Desktop.
etherpad-lite push
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
#!/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