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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __docformat__ = 'restructuredtext'
  5. __version__ = '$Id: cssparse.py 1434 2008-08-13 10:12:45Z cthedot $'
  6. import cssutils
  7. import logging
  8. import optparse
  9. import sys
  10.  
  11. def main(args = None):
  12.     usage = 'usage: %prog [options] filename1.css [filename2.css ...]\n        [>filename_combined.css] [2>parserinfo.log] '
  13.     p = optparse.OptionParser(usage = usage)
  14.     p.add_option('-s', '--string', action = 'store_true', dest = 'string', help = 'parse given string')
  15.     p.add_option('-u', '--url', action = 'store', dest = 'url', help = 'parse given url')
  16.     p.add_option('-e', '--encoding', action = 'store', dest = 'encoding', help = 'encoding of the file or override encoding found')
  17.     p.add_option('-m', '--minify', action = 'store_true', dest = 'minify', help = 'minify parsed CSS', default = False)
  18.     p.add_option('-d', '--debug', action = 'store_true', dest = 'debug', help = 'activate debugging output')
  19.     (options, params) = p.parse_args(args)
  20.     if not params and not (options.url):
  21.         p.error('no filename given')
  22.     
  23.     if options.debug:
  24.         p = cssutils.CSSParser(loglevel = logging.DEBUG)
  25.     else:
  26.         p = cssutils.CSSParser()
  27.     if options.minify:
  28.         cssutils.ser.prefs.useMinified()
  29.     
  30.     if options.string:
  31.         sheet = p.parseString(u''.join(params), encoding = options.encoding)
  32.         print sheet.cssText
  33.     elif options.url:
  34.         sheet = p.parseUrl(options.url, encoding = options.encoding)
  35.         print sheet.cssText
  36.     else:
  37.         for filename in params:
  38.             sys.stderr.write('=== CSS FILE: "%s" ===\n' % filename)
  39.             sheet = p.parseFile(filename, encoding = options.encoding)
  40.             print sheet.cssText
  41.             print 
  42.             sys.stderr.write('\n')
  43.         
  44.  
  45. if __name__ == '__main__':
  46.     sys.exit(main())
  47.  
  48.