How to use the cssutils.helper 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 / cssvalue.py View on Github external
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
github palexu / send2kindle / cssutils / css / cssvalue.py View on Github external
toSeq=lambda t, tokens: (CalcValue._functionName,
                                                           CalcValue(
                                        cssutils.helper.pushtoken(t, tokens),
                                        parent=self)
                                                           )
github kovidgoyal / calibre / src / cssutils / css / cssvalue.py View on Github external
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.')                                 
                           ),
github mozilla / spade / vendor / cssutils / css / cssvalue.py View on Github external
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
github kovidgoyal / calibre / src / cssutils / css / cssimportrule.py View on Github external
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
github palexu / send2kindle / cssutils / css / cssvalue.py View on Github external
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
github tito / pymt / pymt / lib / cssutils / css / cssvalue.py View on Github external
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
github mozilla / spade / vendor / cssutils / css / cssvalue.py View on Github external
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
github kovidgoyal / calibre / src / cssutils / css / cssvalue.py View on Github external
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
github tito / pymt / pymt / lib / cssutils / css / cssvalue.py View on Github external
toSeq=lambda t, tokens: (CSSFunction.name,
                                                                           CSSFunction(cssutils.helper.pushtoken(t,
                                                                                                                 tokens)))),
                                             Prod(name='part',