Commits

Anonymous committed c671a94

adjusted for new CSSStyleDeclaration + Property imple

Comments (0)

Files changed (3)

examples/properties_with_same_name.py

+"""shows CSSStyleDeclaration multivalue property examples
+"""
+import cssutils
+
+print "\n**SameNamePropertyList is replaced with style.getProperties() from 0.9.4**"
+cssutils.ser.prefs.keepComments = False # remove for now
+
+cssText='''    background: white url(paper.png) scroll; /* for all UAs */
+    background: white url(ledger.png) fixed; /* for UAs that do fixed backgrounds */
+'''
+print "\n>>> # cssText"
+print cssText
+
+
+print ">>> style = cssutils.css.CSSStyleDeclaration(cssText=cssText)"
+style = cssutils.css.CSSStyleDeclaration(cssText=cssText)
+print '>>> print style.cssText'
+print style.cssText
+
+print "\n>>> cssutils.ser.prefs.keepAllProperties = True # output all values"
+cssutils.ser.prefs.keepAllProperties = True # output all values
+print '>>> style.cssText # with keepAllProperties==True:'
+print style.cssText
+print
+
+print ">>> # NEW METHOD getProperties"
+print ">>> proplist = style.getProperties('background', all=True)"
+proplist = style.getProperties('background', all=True)
+print ">>> proplist\n", proplist
+print ">>> for prop in proplist: print '\\t', prop.value"
+for prop in proplist: print "\t", prop.value
+print
+
+print ">>> # overwrite the current property, to overwrite all iterate over proplist"
+print ">>> style.setProperty('background', 'red')"
+style.setProperty('background', 'red')
+print ">>> style.getPropertyValue('background')"
+print style.getPropertyValue('background')
+print ">>> style.cssText"
+print style.cssText

examples/samenamepropertylist.py

-"""shows CSSStyleDeclaration multivalue property examples
-"""
-
-import cssutils
-
-style = cssutils.css.CSSStyleDeclaration(cssText='''
-        background: white url(paper.png) scroll; /* for all UAs */
-        background: white url(ledger.png) fixed; /* for UAs that do fixed backgrounds */
-    ''')
-
-cssutils.ser.prefs.keepComments = False # does not work correctly yet
-
-print ">>> # SERIALIZING"
-print '>>> style.cssText'
-print style.cssText
-
-print ">>> cssutils.ser.prefs.keepAllProperties = True # output all values"
-cssutils.ser.prefs.keepAllProperties = True # output all values
-print '>>> style.cssText # with keepAllProperties==True:'
-print style.cssText
-print
-
-print ">>> # NEW METHOD getSameNamePropertyList"
-print ">>> proplist = style.getSameNamePropertyList('background')"
-proplist = style.getSameNamePropertyList('background')
-print ">>> proplist\n", proplist
-print ">>> for prop in proplist: print '\\t', prop.value"
-for prop in proplist: print "\t", prop.value
-print
-
-print ">>> # NEW PARAMETER overwrite"
-print ">>> style.setProperty('background', 'red', overwrite=False)"
-style.setProperty('background', 'red', overwrite=False)
-print ">>> style.getPropertyValue('background')"
-print style.getPropertyValue('background')
-print ">>> proplist\n", proplist
-print
-
-print ">>> style.setProperty('background', 'green', overwrite=True) # default"
-style.setProperty('background', 'green', overwrite=True) # default
-print ">>> style.getPropertyValue('background')"
-print style.getPropertyValue('background')
-print ">>> proplist\n", proplist
-print

examples/styledeclaration.py

     print "style.item(0) ==", style.item(0)
     print "style.item(1) ==", style.item(1)
     print "style.getSameNamePropertyList('color') == ["
-    for x in style.getSameNamePropertyList('color'):
+    for x in style.getProperties('color', all=True):
         print "\t", x
     print "\t]"
     print "style.getPropertyValue('color') ==", style.getPropertyValue('color'), '\n'
 print "------------"
 
 # overwrite in any case, even !important
-print "style.setProperty('color', 'green', '!important', overwrite=False)"
-style.setProperty('color', 'green', '!important', overwrite=False)
+print "style.setProperty('color', 'green', '!important')"
+style.setProperty('color', 'green', '!important')
 show(style)
 
 # overwrite in any case, even !important
-print "style.setProperty('color', 'blue', overwrite=False)"
-style.setProperty('color', 'blue', overwrite=False)
+print "style.setProperty('color', 'blue')"
+style.setProperty('color', 'blue')
 show(style)