How to use the parsel.utils.shorten function in parsel

To help you get started, we’ve selected a few parsel 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 scrapy / parsel / tests / test_utils.py View on Github external
def test_shorten(width, expected):
    if isinstance(expected, six.string_types):
        assert shorten(u'foobar', width) == expected
    else:
        with raises(expected):
            shorten(u'foobar', width)
github scrapy / parsel / parsel / selector.py View on Github external
def __str__(self):
        data = repr(shorten(self.get(), width=40))
        return "<%s xpath=%r data=%s>" % (type(self).__name__, self._expr, data)
    __repr__ = __str__