home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1540 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  2.1 KB  |  47 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __all__ = [
  5.     'CSSCapture']
  6. __docformat__ = 'restructuredtext'
  7. __version__ = '$Id: csscapture.py 1547 2008-12-10 20:42:26Z cthedot $'
  8. from cssutils.script import CSSCapture
  9. import logging
  10. import optparse
  11. import sys
  12.  
  13. def main(args = None):
  14.     usage = 'usage: %prog [options] URL'
  15.     parser = optparse.OptionParser(usage = usage)
  16.     parser.add_option('-d', '--debug', action = 'store_true', dest = 'debug', help = 'show debug messages during capturing')
  17.     parser.add_option('-m', '--minified', action = 'store_true', dest = 'minified', help = 'saves minified version of captured files')
  18.     parser.add_option('-n', '--notsave', action = 'store_true', dest = 'notsave', help = 'if given files are NOT saved, only log is written')
  19.     parser.add_option('-s', '--saveto', action = 'store', dest = 'saveto', help = 'saving retrieved files to "saveto", defaults to "_CSSCapture_SAVED"')
  20.     parser.add_option('-u', '--useragent', action = 'store', dest = 'ua', help = 'useragent to use for request of URL, default is urllib2s default')
  21.     (options, url) = parser.parse_args()
  22.     options.saveraw = False
  23.     if not url:
  24.         parser.error('no URL given')
  25.     else:
  26.         url = url[0]
  27.     if options.debug:
  28.         level = logging.DEBUG
  29.     else:
  30.         level = logging.INFO
  31.     c = CSSCapture(ua = options.ua, defaultloglevel = level)
  32.     stylesheetlist = c.capture(url)
  33.     if options.notsave is None or not (options.notsave):
  34.         if options.saveto:
  35.             saveto = options.saveto
  36.         else:
  37.             saveto = u'_CSSCapture_SAVED'
  38.         c.saveto(saveto, saveraw = options.saveraw, minified = options.minified)
  39.     else:
  40.         for i, s in enumerate(stylesheetlist):
  41.             print u'%s.\n    encoding: %r\n    title: %r\n    href: %r' % (i + 1, s.encoding, s.title, s.href)
  42.         
  43.  
  44. if __name__ == '__main__':
  45.     sys.exit(main())
  46.  
  47.