#!/bin/env python # -*- coding: utf-8-*- # load api key keyfile = "APIKEY.txt" file = open(keyfile, "r") key = file.read().rstrip() from etherpad_lite import EtherpadLiteClient c = EtherpadLiteClient(base_params={'apikey':"{}".format(key)}) import glob #import re import string # iterate over files in org for filename in glob.iglob('org/*.org'): # pick relevant part from filename # option 1: https://docs.python.org/2/howto/regex.html #p = re.compile('\.org$') #id = 'pad-'+ p.sub('', filename) # option 2: id = string.replace(string.replace(filename, 'org/', ''), '.org', '') padid = "dox-"+ id file = open(filename, "r") text = file.read() # upload text print ("Updating https://irc.anarchyplanet.org/pad/p/"+ padid +" ["+ filename +"]") try: c.deletePad(padID="{}".format(padid)) except: print "(new)" c.createPad(padID="{}".format(padid), text="{}".format(text)) #import urllib2, ssl #response = urllib2.urlopen('https://irc.anarchyplanet.org/pad/p/'+ id +'/export/txt', context=ssl._create_unverified_context()) #txt = response.read() #print txt #writeFile = open("projex_out.txt", "w") #writeFile.write(txt) #writeFile.close() #+end_src #+begin_src python :results output # FUCK I hate white space syntax # C-c C-r to evaluate region #file = open("hello.org", "r") #localtxt = file.read() #print(localtxt) #+end_src