|
1 | 1 | #!/usr/bin/env python |
2 | 2 |
|
| 3 | +from __future__ import print_function |
3 | 4 | import sys |
4 | 5 | import imageresolver |
5 | 6 | import logging |
|
10 | 11 | logger.addHandler(logging.StreamHandler(stream=sys.stdout)) |
11 | 12 |
|
12 | 13 | opts = OptionParser() |
13 | | -opts.add_option("-u","--url",dest="url",help="A url to parse") |
14 | | -opts.add_option("-d","--debug", action="store_true", dest="debug", help="enable debugging") |
15 | | -opts.add_option("-r","--max-read", dest="max_read",help="Set the max read size") |
16 | | -opts.add_option("-c","--chunk-size",dest="chunk_size",help="Chunk size to read on each pass") |
17 | | -opts.add_option("-a","--read-all",dest="read_all",help="Read the entire image before checking size. Useful for some JPGs. Overrides --max-read") |
18 | | -opts.add_option("-b","--adblock", action="store_true",dest="use_adblock_filters",help="Use adblock filters.") |
19 | | -opts.add_option("-s","--no-ruleset", action="store_true",dest="use_js_ruleset",help="Use a custom ruleset for scoring.") |
20 | | -opts.add_option("--benchmark", action="store_true",dest="benchmark",help="Benchmark the total time it takes for the script to return an image") |
21 | | -opts.add_option("-n","--no-load-images", action="store_true",dest="load_images",help="Do not load images") |
22 | | -opts.add_option("-p","--parser", dest="parser",help="Choose a parser to use") |
23 | | - |
24 | | -(options,args) = opts.parse_args() |
| 14 | +opts.add_option("-u", "--url", dest="url",help="A url to parse") |
| 15 | +opts.add_option("-d", "--debug", action="store_true", dest="debug", help="enable debugging") |
| 16 | +opts.add_option("-r", "--max-read", dest="max_read", help="Set the max read size") |
| 17 | +opts.add_option("-c", "--chunk-size", dest="chunk_size", help="Chunk size to read on each pass") |
| 18 | +opts.add_option("-a", "--read-all", dest="read_all", |
| 19 | + help="Read the entire image before checking size. Useful for some JPGs. Overrides --max-read") |
| 20 | +opts.add_option("-b", "--adblock", action="store_true", dest="use_adblock_filters", help="Use adblock filters.") |
| 21 | +opts.add_option("-s", "--no-ruleset", action="store_true", dest="use_js_ruleset", |
| 22 | + help="Use a custom ruleset for scoring.") |
| 23 | +opts.add_option("--benchmark", action="store_true",dest="benchmark", |
| 24 | + help="Benchmark the total time it takes for the script to return an image") |
| 25 | +opts.add_option("-n", "--no-load-images", action="store_true", dest="load_images", help="Do not load images") |
| 26 | +opts.add_option("-p", "--parser", dest="parser", help="Choose a parser to use") |
| 27 | + |
| 28 | +options, args = opts.parse_args() |
25 | 29 |
|
26 | 30 | kw_options = {} |
27 | 31 |
|
|
53 | 57 | url = options.url |
54 | 58 |
|
55 | 59 | if not url: |
56 | | - print "URL required. Please use the url option or pass a url as the first argument" |
| 60 | + print("URL required. Please use the url option or pass a url as the first argument") |
57 | 61 | sys.exit(-1) |
58 | 62 |
|
59 | 63 |
|
60 | 64 | if options.benchmark: |
61 | 65 | t1 = time.time() |
| 66 | +else: |
| 67 | + t1 = 0 |
62 | 68 |
|
63 | 69 | i = imageresolver.ImageResolver(**kw_options) |
64 | 70 | i.register(imageresolver.FileExtensionResolver()) |
65 | 71 | i.register(imageresolver.WebpageResolver(**kw_options)) |
66 | 72 |
|
67 | | -print i.resolve(url) |
| 73 | +print(i.resolve(url)) |
68 | 74 |
|
69 | 75 | if options.benchmark: |
70 | | - print 'TOTAL TIME', time.time() - t1 |
| 76 | + print('TOTAL TIME', time.time() - t1) |
71 | 77 |
|
0 commit comments