How to use the cssutils.profile function in cssutils

To help you get started, we’ve selected a few cssutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github palexu / send2kindle / cssutils / css / property.py View on Github external
else:
            if rule is not None:
                if rule.type == rule.FONT_FACE_RULE:
                    profiles = [cssutils.profile.CSS3_FONT_FACE]
                #TODO: same for @page

        if self.name and self.value:

            cv = self.propertyValue
            # TODO
#            if cv.cssValueType == cv.CSS_VARIABLE and not cv.value:
#                # TODO: false alarms too!
#                cssutils.log.warn(u'No value for variable "%s" found, keeping '
#                                  u'variable.' % cv.name, neverraise=True)

            if self.name in cssutils.profile.knownNames:
                # add valid, matching, validprofiles...
                valid, matching, validprofiles = \
                    cssutils.profile.validateWithProfile(self.name,
                                                         self.value,
                                                         profiles)

                if not valid:
                    self._log.error(u'Property: Invalid value for '
                                    u'"%s" property: %s'
                                    % (u'/'.join(validprofiles), self.value),
                                    token=self.__nametoken,
                                    neverraise=True)

                # TODO: remove logic to profiles!
                elif valid and not matching:#(profiles and profiles not in validprofiles):
                    if not profiles:
github nueverest / blowdrycss / blowdrycss / blowdrycss_settings.py View on Github external
'font-size': {'fsize-', 'f-size-', },
    'font-weight': {'fweight-', 'f-weight-', },
    'height': {'h-', },
    'margin': {'m-', },
    'margin-top': {'m-top-', },
    'margin-bottom': {'m-bot-', },
    'padding': {'p-', 'pad-', },
    'padding-top': {'p-top-', },
    'position': {'pos-', },
    'text-align': {'talign-', 't-align-', },
    'vertical-align': {'valign-', 'v-align-', },
    'width': {'w-', },
}

# Patches cssutils - Generally this does not need to be edited.
profile._MACROS['length'] = r'0|{num}(em|ex|px|in|cm|mm|pt|pc|q|ch|rem|vw|vh|vmin|vmax)'
profile._MACROS['positivelength'] = r'0|{positivenum}(em|ex|px|in|cm|mm|pt|pc|q|ch|rem|vw|vh|vmin|vmax)'
profile._MACROS['angle'] = r'0|{num}(deg|grad|rad|turn)'
profile._resetProperties()
github nueverest / blowdrycss / blowdrycss / blowdrycss_settings.py View on Github external
'margin': {'m-', },
    'margin-top': {'m-top-', },
    'margin-bottom': {'m-bot-', },
    'padding': {'p-', 'pad-', },
    'padding-top': {'p-top-', },
    'position': {'pos-', },
    'text-align': {'talign-', 't-align-', },
    'vertical-align': {'valign-', 'v-align-', },
    'width': {'w-', },
}

# Patches cssutils - Generally this does not need to be edited.
profile._MACROS['length'] = r'0|{num}(em|ex|px|in|cm|mm|pt|pc|q|ch|rem|vw|vh|vmin|vmax)'
profile._MACROS['positivelength'] = r'0|{positivenum}(em|ex|px|in|cm|mm|pt|pc|q|ch|rem|vw|vh|vmin|vmax)'
profile._MACROS['angle'] = r'0|{num}(deg|grad|rad|turn)'
profile._resetProperties()
github palexu / send2kindle / cssutils / css / property.py View on Github external
ERROR   Property: Invalid value for "CSS Color Module Level 3/CSS Level 2.1" property: 4 [3:9: color]
            WARNING Property: Not valid for profile "CSS Level 2.1" but valid "CSS Color Module Level 3" value: rgba(1, 2, 3, 4)  [4:9: color]
            DEBUG   Property: Found valid "CSS Level 2.1" value: red [5:9: color]
        """
        valid = False

        profiles = None
        try:
            # if @font-face use that profile
            rule = self.parent.parentRule
        except AttributeError:
            pass
        else:
            if rule is not None:
                if rule.type == rule.FONT_FACE_RULE:
                    profiles = [cssutils.profile.CSS3_FONT_FACE]
                #TODO: same for @page

        if self.name and self.value:

            cv = self.propertyValue
            # TODO
#            if cv.cssValueType == cv.CSS_VARIABLE and not cv.value:
#                # TODO: false alarms too!
#                cssutils.log.warn(u'No value for variable "%s" found, keeping '
#                                  u'variable.' % cv.name, neverraise=True)

            if self.name in cssutils.profile.knownNames:
                # add valid, matching, validprofiles...
                valid, matching, validprofiles = \
                    cssutils.profile.validateWithProfile(self.name,
                                                         self.value,
github norbusan / calibre-debian / src / calibre / ebooks / oeb / normalize_css.py View on Github external
def normalize_simple_composition(name, cssvalue, composition, check_inherit=True):
    if check_inherit and cssvalue.cssText == 'inherit':
        style = {k:'inherit' for k in composition}
    else:
        style = {k:DEFAULTS[k] for k in composition}
        try:
            primitives = [v.cssText for v in cssvalue]
        except TypeError:
            primitives = [cssvalue.cssText]
        while primitives:
            value = primitives.pop()
            for key in composition:
                if cssprofiles.validate(key, value):
                    style[key] = value
                    break
    return style
github mozilla / spade / vendor / cssutils / css / property.py View on Github external
ERROR   Property: Invalid value for "CSS Color Module Level 3/CSS Level 2.1" property: 4 [3:9: color]
            WARNING Property: Not valid for profile "CSS Level 2.1" but valid "CSS Color Module Level 3" value: rgba(1, 2, 3, 4)  [4:9: color]
            DEBUG   Property: Found valid "CSS Level 2.1" value: red [5:9: color]
        """
        valid = False

        profiles = None
        try:
            # if @font-face use that profile
            rule = self.parent.parentRule
        except AttributeError:
            pass
        else:
            if rule is not None:
                if rule.type == rule.FONT_FACE_RULE:
                    profiles = [cssutils.profile.CSS3_FONT_FACE]
                #TODO: same for @page

        if self.name and self.value:

            cv = self.propertyValue
            # TODO
#            if cv.cssValueType == cv.CSS_VARIABLE and not cv.value:
#                # TODO: false alarms too!
#                cssutils.log.warn(u'No value for variable "%s" found, keeping '
#                                  u'variable.' % cv.name, neverraise=True)

            if self.name in cssutils.profile.knownNames:
                # add valid, matching, validprofiles...
                valid, matching, validprofiles = \
                    cssutils.profile.validateWithProfile(self.name,
                                                         self.value,
github nueverest / blowdrycss / blowdrycss / blowdrycss_settings.py View on Github external
'font-size': {'fsize-', 'f-size-', },
    'font-weight': {'fweight-', 'f-weight-', },
    'height': {'h-', },
    'margin': {'m-', },
    'margin-top': {'m-top-', },
    'margin-bottom': {'m-bot-', },
    'padding': {'p-', 'pad-', },
    'padding-top': {'p-top-', },
    'position': {'pos-', },
    'text-align': {'talign-', 't-align-', },
    'vertical-align': {'valign-', 'v-align-', },
    'width': {'w-', },
}

# Patches cssutils - Generally this does not need to be edited.
profile._MACROS['length'] = r'0|{num}(em|ex|px|in|cm|mm|pt|pc|q|ch|rem|vw|vh|vmin|vmax)'
profile._MACROS['positivelength'] = r'0|{positivenum}(em|ex|px|in|cm|mm|pt|pc|q|ch|rem|vw|vh|vmin|vmax)'
profile._MACROS['angle'] = r'0|{num}(deg|grad|rad|turn)'
profile._resetProperties()
github kovidgoyal / calibre / src / cssutils / css / property.py View on Github external
profiles = None
        try:
            # if @font-face use that profile
            rule = self.parent.parentRule
            if rule.type == rule.FONT_FACE_RULE:
                profiles = [cssutils.profile.CSS3_FONT_FACE]
            #TODO: same for @page
        except AttributeError:
            pass
        
        if self.name and self.value:

            if self.name in cssutils.profile.knownNames:
                # add valid, matching, validprofiles...
                valid, matching, validprofiles = \
                    cssutils.profile.validateWithProfile(self.name,
                                                         self.value,
                                                         profiles)
                
                if not valid:
                    self._log.error(u'Property: Invalid value for '
                                    u'"%s" property: %s'
                                    % (u'/'.join(validprofiles), self.value),
                                    token=self.__nametoken,
                                    neverraise=True)
                    
                # TODO: remove logic to profiles!
                elif valid and not matching:#(profiles and profiles not in validprofiles):
                    if not profiles:
                        notvalidprofiles = u'/'.join(cssutils.profile.defaultProfiles)
                    else:
                        notvalidprofiles = profiles
github nueverest / blowdrycss / blowdrycss / blowdrycss_settings.py View on Github external
'margin': {'m-', },
    'margin-top': {'m-top-', },
    'margin-bottom': {'m-bot-', },
    'padding': {'p-', 'pad-', },
    'padding-top': {'p-top-', },
    'position': {'pos-', },
    'text-align': {'talign-', 't-align-', },
    'vertical-align': {'valign-', 'v-align-', },
    'width': {'w-', },
}

# Patches cssutils - Generally this does not need to be edited.
profile._MACROS['length'] = r'0|{num}(em|ex|px|in|cm|mm|pt|pc|q|ch|rem|vw|vh|vmin|vmax)'
profile._MACROS['positivelength'] = r'0|{positivenum}(em|ex|px|in|cm|mm|pt|pc|q|ch|rem|vw|vh|vmin|vmax)'
profile._MACROS['angle'] = r'0|{num}(deg|grad|rad|turn)'
profile._resetProperties()
github mozilla / spade / vendor / cssutils / css / property.py View on Github external
profiles = [cssutils.profile.CSS3_FONT_FACE]
                #TODO: same for @page

        if self.name and self.value:

            cv = self.propertyValue
            # TODO
#            if cv.cssValueType == cv.CSS_VARIABLE and not cv.value:
#                # TODO: false alarms too!
#                cssutils.log.warn(u'No value for variable "%s" found, keeping '
#                                  u'variable.' % cv.name, neverraise=True)

            if self.name in cssutils.profile.knownNames:
                # add valid, matching, validprofiles...
                valid, matching, validprofiles = \
                    cssutils.profile.validateWithProfile(self.name,
                                                         self.value,
                                                         profiles)

                if not valid:
                    self._log.error(u'Property: Invalid value for '
                                    u'"%s" property: %s'
                                    % (u'/'.join(validprofiles), self.value),
                                    token=self.__nametoken,
                                    neverraise=True)

                # TODO: remove logic to profiles!
                elif valid and not matching:#(profiles and profiles not in validprofiles):
                    if not profiles:
                        notvalidprofiles = u'/'.join(cssutils.profile.defaultProfiles)
                    else:
                        notvalidprofiles = profiles