Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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:
'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()
'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()
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,
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
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,
'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()
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
'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()
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