Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _getNumDim(self, value=None):
"Split self._value in numerical and dimension part."
if value is None:
value = cssutils.helper.normalize(self._value[0])
try:
val, dim = CSSPrimitiveValue._reNumDim.findall(value)[0]
except IndexError:
val, dim = value, u''
try:
val = float(val)
if val == int(val):
val = int(val)
except ValueError:
raise xml.dom.InvalidAccessErr(
u'CSSPrimitiveValue: No float value %r' % self._value[0])
return val, dim
toSeq=lambda t, tokens: (CalcValue._functionName,
CalcValue(
cssutils.helper.pushtoken(t, tokens),
parent=self)
)
match=lambda t, v: t == self._prods.FUNCTION and (
cssutils.helper.normalize(v) in (u'expression(',
u'alpha(') or
v.startswith(u'progid:DXImageTransform.Microsoft.')
),
def itemValue(item):
"Reserialized simple item.value"
if self._prods.STRING == item.type:
return cssutils.helper.string(item.value)
elif self._prods.URI == item.type:
return cssutils.helper.uri(item.value)
elif self._prods.FUNCTION == item.type or\
'CSSVariable' == item.type:
return item.value.cssText
else:
return item.value
def __setStyleSheet(self):
"""Read new CSSStyleSheet cssText from href using parentStyleSheet.href
Indirectly called if setting ``href``. In case of any error styleSheet
is set to ``None``.
"""
# should simply fail so all errors are catched!
if self.parentStyleSheet and self.href:
# relative href
parentHref = self.parentStyleSheet.href
if parentHref is None:
# use cwd instead
#parentHref = u'file:' + urllib.pathname2url(os.getcwd()) + '/'
parentHref = cssutils.helper.path2url(os.getcwd()) + '/'
href = urlparse.urljoin(parentHref, self.href)
# all possible exceptions are ignored (styleSheet is None then)
try:
usedEncoding, enctype, cssText = self.parentStyleSheet._resolveImport(href)
if cssText is None:
# catched in next except below!
raise IOError('Cannot read Stylesheet.')
styleSheet = cssutils.css.CSSStyleSheet(href=href,
media=self.media,
ownerRule=self,
title=self.name)
# inherit fetcher for @imports in styleSheet
styleSheet._setFetcher(self.parentStyleSheet._fetcher)
# contentEncoding with parentStyleSheet.overrideEncoding,
# HTTP or parent
def itemValue(item):
"Reserialized simple item.value"
if self._prods.STRING == item.type:
return cssutils.helper.string(item.value)
elif self._prods.URI == item.type:
return cssutils.helper.uri(item.value)
elif self._prods.FUNCTION == item.type or\
'CSSVariable' == item.type:
return item.value.cssText
else:
return item.value
def itemValue(item):
"Reserialized simple item.value"
if self._prods.STRING == item.type:
return cssutils.helper.string(item.value)
elif self._prods.URI == item.type:
return cssutils.helper.uri(item.value)
else:
return item.value
def itemValue(item):
"Reserialized simple item.value"
if self._prods.STRING == item.type:
return cssutils.helper.string(item.value)
elif self._prods.URI == item.type:
return cssutils.helper.uri(item.value)
elif self._prods.FUNCTION == item.type or\
'CSSVariable' == item.type:
return item.value.cssText
else:
return item.value
def itemValue(item):
"Reserialized simple item.value"
if self._prods.STRING == item.type:
return cssutils.helper.string(item.value)
elif self._prods.URI == item.type:
return cssutils.helper.uri(item.value)
elif self._prods.FUNCTION == item.type or\
'CSSVariable' == item.type:
return item.value.cssText
else:
return item.value
toSeq=lambda t, tokens: (CSSFunction.name,
CSSFunction(cssutils.helper.pushtoken(t,
tokens)))),
Prod(name='part',