Created
May 23, 2011 16:24
-
-
Save lukegb/986987 to your computer and use it in GitHub Desktop.
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
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