def cleanStyleAttribute(self, value):
     '''p_value contains some CSS attributes from a "style" attribute. We
        keep those that pod can manage.'''
     res = []
     for name, v in parseStyleAttribute(value):
         if name in self.cssAttrsToKeep:
             res.append('%s: %s' % (name, v))
     return '; '.join(res)
Exemple #2
0
 def cleanStyleAttribute(self, value):
     '''p_value contains some CSS attributes from a "style" attribute. We
        keep those that pod can manage.'''
     res = []
     for name, v in parseStyleAttribute(value):
         if name in self.cssAttrsToKeep:
             res.append('%s: %s' % (name, v))
     return '; '.join(res)
 def getStyleFromMapping(self, elem, attrs, styles):
     '''p_styles is a Style instance or a list of (cssParams, Style) tuples.
        Depending on CSS attributes found in p_attrs, this method returns
        the relevant Style instance.'''
     if isinstance(styles, Style): return styles
     hasStyleInfo = attrs and ('style' in attrs)
     if not hasStyleInfo:
         # If I have, at the last position in p_styles, the style related to
         # no attribute at all, I return it.
         lastAttrs, lastStyle = styles[-1]
         if lastAttrs == None: return lastStyle
         else: return
     # If I am here, I have style info. Check if it corresponds to some style
     # in p_styles.
     styleInfo = parseStyleAttribute(attrs['style'], asDict=True)
     for matchingAttrs, style in styles:
         if self.styleMatch(styleInfo, matchingAttrs):
             return style
 def getStyleFromMapping(self, elem, attrs, styles):
     '''p_styles is a Style instance or a list of (cssParams, Style) tuples.
        Depending on CSS attributes found in p_attrs, this method returns
        the relevant Style instance.'''
     if isinstance(styles, Style): return styles
     hasStyleInfo = attrs and ('style' in attrs)
     if not hasStyleInfo:
         # If I have, at the last position in p_styles, the style related to
         # no attribute at all, I return it.
         lastAttrs, lastStyle = styles[-1]
         if lastAttrs == None: return lastStyle
         else: return
     # If I am here, I have style info. Check if it corresponds to some style
     # in p_styles.
     styleInfo = parseStyleAttribute(attrs['style'], asDict=True)
     for matchingAttrs, style in styles:
         if self.styleMatch(styleInfo, matchingAttrs):
             return style
Exemple #5
0
 def getStyleFromMapping(self, elem, attrs, styles):
     '''p_styles is a value from a styles mapping as transformed by
        m_checkStylesMapping above. If it represents a list of styles
        (see case (ii) in m_checkStylesMapping), this method must return the
        relevant Style instance form this list, depending on CSS attributes
        found in p_attrs.'''
     if not isinstance(styles, list): return styles
     hasStyleInfo = attrs and ('style' in attrs)
     if not hasStyleInfo:
         # If I have, at the last position in p_styles, the style related to
         # no attribute at all, I return it.
         lastAttrs, lastStyle = styles[-1]
         if lastAttrs == None: return lastStyle
         else: return
     # If I am here, I have style info. Check if it corresponds to some style
     # in p_styles.
     styleInfo = parseStyleAttribute(attrs['style'], asDict=True)
     for matchingAttrs, style in styles:
         if self.styleMatch(styleInfo, matchingAttrs):
             return style