/usr/share/doc/python-cssutils/examples/serialize.py is in python-cssutils 0.9.10-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | import cssutils
import logging
cssutils.log.setLevel(logging.FATAL)
css = '''@import "example.css";
a {
color: blue !important;
c\olor: green !important;
c\olor: pink;
color: red;
}'''
sheet = cssutils.parseString(css)
print "\nORIGINAL CSS:"
print css
print "------------"
print repr(cssutils.ser.prefs)
print "\nCSS Serialized"
print sheet.cssText
print "\nCSS Serialized with ``keepAllProperties`` = False"
cssutils.ser.prefs.keepAllProperties = False
print sheet.cssText
print "\nCSS Serialized with ``defaultPropertyName`` = True"
cssutils.ser.prefs.defaultPropertyName = True
print sheet.cssText
print "\nCSS Serialized with ``defaultPropertyName`` = False"
cssutils.ser.prefs.defaultPropertyName = False
print sheet.cssText
print '\nBUT: Reading value programmatic uses normalized property'
print ' name and results in actual value only:'
print '\t.getPropertyValue("color") ==',
print sheet.cssRules[1].style.getPropertyValue('color')
print '\t.getPropertyValue("c\\olor") ==',
print sheet.cssRules[1].style.getPropertyValue('c\olor')
print '\t.getPropertyValue("c\\o\\l\\o\\r") ==',
print sheet.cssRules[1].style.getPropertyValue('c\\o\\l\\o\\r')
print
print '\nCSS Serialized with indent = 2*" ", importHrefFormat="string", lineNumbers=True'
cssutils.ser.prefs.indent = 2*' '
# used to set indentation string, default is 4*' '
cssutils.ser.prefs.importHrefFormat = 'string'
# or 'uri', defaults to the format used in parsed stylesheet
cssutils.ser.prefs.lineNumbers = True
print sheet.cssText
print '\nCSS Serialized with useMinified()'
cssutils.ser.prefs.useMinified()
print sheet.cssText
# OUTPUTS
#1: @import "example.css";
#2: body {
#3: color: red
#4: }
|