from Translator import *
import SimpleList
class SSSDeclarationList(SimpleList.SSSSimpleList):
def __init__(self, parentObject = None):
super(SSSDeclarationList, self).__init__(parentObject)
def isDirective(self, cssText):
if (strpos(trim(cssText), '@') == 0):
return trim(substr(cssText, 0, strpos(cssText,' ')))
return False
def _insertRule(self, obj, index): #// returns value of index argument
return self.insertRule(obj, index)
def appendRule(self, obj):
return self.appendItem(obj)
def __call(self, method, args):
return super(SSSDeclarationList, self).__call(method, args)
def getPropertyText(self):
string = ''
#foreach (self.items as key=>$item):
for key in self.items:
if (get_class(self.items[key]) == 'SSSProperty'):
string += "\t" + item.cssText
return string
def getRuleText(self):
string = ''
#foreach (self.items as key=>$item):
for key in self.items:
if (get_class(self.items[key]) != 'SSSProperty'):
string += item.cssText
return string
def get_cssText(self):
return self.__str__()
cssText = property(get_cssText)
propertyText = property(getPropertyText)
ruleText = property(getRuleText)
def __str__(self):
string = ''
addLogMessage(get_class(self) + " __str__: Outputting SSSDeclarationList...")
for item in self.items:
string += item.cssText
addLogMessage(get_class(self) + " __str__: string = " + string)
return string
def getPropertyValue(self, propertyName):
item = self.getPropertyCSSValue(propertyName)
if (item):
return item.value
return None
def setProperty(self, propertyName, value, priority = ''):
item = self.getPropertyCSSValue(propertyName)
if (item): #// property currently exists...
item.setValue(value)
#// Need to add property and value
return self.appendItem(obj)