diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2011-08-07 02:02:49 (GMT) |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2011-08-07 02:02:49 (GMT) |
commit | 351950fbfc2805f8ccef51b0bf28f9dbb6017898 (patch) | |
tree | 7a3440fbaf8b277f436ddc6f246eace378aafa7c | |
parent | e11af59e2a90934ff5472adf287d5f933301a9df (diff) | |
download | cpython-351950fbfc2805f8ccef51b0bf28f9dbb6017898.zip cpython-351950fbfc2805f8ccef51b0bf28f9dbb6017898.tar.gz cpython-351950fbfc2805f8ccef51b0bf28f9dbb6017898.tar.bz2 |
Remove the old dead test program within the module in 2.7.
-rw-r--r-- | Lib/urllib.py | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py index 1261ec1..0498a43 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -1600,65 +1600,3 @@ def reporthook(blocknum, blocksize, totalsize): print "Block number: %d, Block size: %d, Total size: %d" % ( blocknum, blocksize, totalsize) -# Test program -def test(args=[]): - if not args: - args = [ - '/etc/passwd', - 'file:/etc/passwd', - 'file://localhost/etc/passwd', - 'ftp://ftp.gnu.org/pub/README', - 'http://www.python.org/index.html', - ] - if hasattr(URLopener, "open_https"): - args.append('https://synergy.as.cmu.edu/~geek/') - try: - for url in args: - print '-'*10, url, '-'*10 - fn, h = urlretrieve(url, None, reporthook) - print fn - if h: - print '======' - for k in h.keys(): print k + ':', h[k] - print '======' - with open(fn, 'rb') as fp: - data = fp.read() - if '\r' in data: - table = string.maketrans("", "") - data = data.translate(table, "\r") - print data - fn, h = None, None - print '-'*40 - finally: - urlcleanup() - -def main(): - import getopt, sys - try: - opts, args = getopt.getopt(sys.argv[1:], "th") - except getopt.error, msg: - print msg - print "Use -h for help" - return - t = 0 - for o, a in opts: - if o == '-t': - t = t + 1 - if o == '-h': - print "Usage: python urllib.py [-t] [url ...]" - print "-t runs self-test;", - print "otherwise, contents of urls are printed" - return - if t: - if t > 1: - test1() - test(args) - else: - if not args: - print "Use -h for help" - for url in args: - print urlopen(url).read(), - -# Run test program when run as a script -if __name__ == '__main__': - main() |