home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- __all__ = [
- 'CSSCapture']
- __docformat__ = 'restructuredtext'
- __version__ = '$Id: csscapture.py 1547 2008-12-10 20:42:26Z cthedot $'
- from cssutils.script import CSSCapture
- import logging
- import optparse
- import sys
-
- def main(args = None):
- usage = 'usage: %prog [options] URL'
- parser = optparse.OptionParser(usage = usage)
- parser.add_option('-d', '--debug', action = 'store_true', dest = 'debug', help = 'show debug messages during capturing')
- parser.add_option('-m', '--minified', action = 'store_true', dest = 'minified', help = 'saves minified version of captured files')
- parser.add_option('-n', '--notsave', action = 'store_true', dest = 'notsave', help = 'if given files are NOT saved, only log is written')
- parser.add_option('-s', '--saveto', action = 'store', dest = 'saveto', help = 'saving retrieved files to "saveto", defaults to "_CSSCapture_SAVED"')
- parser.add_option('-u', '--useragent', action = 'store', dest = 'ua', help = 'useragent to use for request of URL, default is urllib2s default')
- (options, url) = parser.parse_args()
- options.saveraw = False
- if not url:
- parser.error('no URL given')
- else:
- url = url[0]
- if options.debug:
- level = logging.DEBUG
- else:
- level = logging.INFO
- c = CSSCapture(ua = options.ua, defaultloglevel = level)
- stylesheetlist = c.capture(url)
- if options.notsave is None or not (options.notsave):
- if options.saveto:
- saveto = options.saveto
- else:
- saveto = u'_CSSCapture_SAVED'
- c.saveto(saveto, saveraw = options.saveraw, minified = options.minified)
- else:
- for i, s in enumerate(stylesheetlist):
- print u'%s.\n encoding: %r\n title: %r\n href: %r' % (i + 1, s.encoding, s.title, s.href)
-
-
- if __name__ == '__main__':
- sys.exit(main())
-
-