def _nodeprocessor_property(self, data, parent): """Node Processor: property""" name, value = ("", "") for property_type, property_item in data: if property_type == "propertyname": name = property_item.strip() elif property_type == "propertyvalue": if type(property_item) is list and len(property_item) == 1: if isinstance(property_item[0], basestring): property_item = property_item[0] if isinstance(property_item, basestring): value = property_item.strip() elif type(property_item) is list: all_str = True values = [] for p_item in property_item: if isinstance(p_item, (list, tuple)): result = self._process_node(p_item, parent=None) if isinstance(result, (list, tuple)): all_str = False values.extend(list(result)) else: values.append(result) else: values.append(p_item) if all_str: value = " ".join(values) else: value = values else: raise Unimplemented("Unrecognized value for parameter '%s', got '%s'" % ( name or '?', str(property_item) )) else: raise Unimplemented("Unknown property type '%s'" % ( property_type, )) if not name or not value: raise UnrecognizedParsedTree("Failure during property parsing: %s" % ( str(data), )) if isinstance(value, list): properties = [] for property in value: try: p_name, p_value = n_DeclarationBlock.get_property_parts(property) except ValueError: p_name = name p_value = property properties.append("%s%s%s" % ( p_name, skidmarkoutputs.OUTPUT_TEMPLATE_PROPERTY_VALUE_SEPARATOR[self.output_format], p_value )) return properties return "%s%s%s" % ( name, skidmarkoutputs.OUTPUT_TEMPLATE_PROPERTY_VALUE_SEPARATOR[self.output_format], value )
def _update_property(self, property): """Verifies the property to see if the value is a reference to a variable. Returns an updated property (or an unmodified property if it was not required.""" prop_name, prop_value = n_DeclarationBlock.get_property_parts(property) all_variables = SkidmarkCSS._get_variables_from_text(prop_value) for variable in all_variables: property = property.replace(variable, self._get_variable_value(variable)) return property