Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 import sys
00018
00019 import urllib
00020 import urllib2
00021
00022 URL_SHRINK_SAFE = "http://shrinksafe.dojotoolkit.org/shrinksafe.php"
00023
00024
00025 BOUNDARY_MARKER = "---------------------------72288400411964641492083565382"
00026
00027 if __name__ == "__main__":
00028
00029 try:
00030 sourceFilename = sys.argv[1]
00031 except:
00032 print "Usage: %s (<source filename>|-)" % sys.argv[0]
00033 raise SystemExit
00034
00035 if sourceFilename == "-":
00036 sourceCode = sys.stdin.read()
00037 sourceFilename = "stdin.js"
00038 else:
00039 sourceCode = open(sourceFilename).read()
00040
00041
00042 request = urllib2.Request(url=URL_SHRINK_SAFE)
00043 request.add_header("Content-Type",
00044 "multipart/form-data; boundary=%s" % BOUNDARY_MARKER)
00045 request.add_data("""
00046 --%s
00047 Content-Disposition: form-data; name="shrinkfile[]"; filename="%s"
00048 Content-Type: application/x-javascript
00049
00050 %s
00051 """ % (BOUNDARY_MARKER, sourceFilename, sourceCode))
00052
00053
00054 print urllib2.urlopen(request).read(),