Skip to content

Instantly share code, notes, and snippets.

@lukegb
Created May 23, 2011 16:24
Show Gist options
  • Save lukegb/986987 to your computer and use it in GitHub Desktop.
Save lukegb/986987 to your computer and use it in GitHub Desktop.
import os
import urllib, urllib2
pasteto = 'http://paste.ubuntu.com/'
pastedict = {'poster': user, 'syntax': 'python'}
pastekey = 'content'
def iterdir(dirn):
mydir = {}
for file in os.listdir(dirn):
fn = os.path.join(dirn, file)
if os.path.isdir(fn):
adder = iterdir(fn)
elif file.endswith('.py'):
adder = uploadf(open(fn,'r').read())
else:
adder = 'Not Uploaded'
mydir[file] = adder
return mydir
def uploadf(whut):
pastedict[pastekey] = whut
uri = urllib2.urlopen(pasteto, pastedict).url
return uri
savedat = {}
savedat[inp] = iterdir(inp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment