scrapy / parsel

@@ -14,7 +14,9 @@
Loading
14 14
15 15
    @classmethod
16 16
    def from_xpath(cls, xpath, textnode=False, attribute=None):
17 -
        x = cls(path=xpath.path, element=xpath.element, condition=xpath.condition)
17 +
        x = cls(
18 +
            path=xpath.path, element=xpath.element, condition=xpath.condition
19 +
        )
18 20
        x.textnode = textnode
19 21
        x.attribute = attribute
20 22
        return x
@@ -81,7 +83,9 @@
Loading
81 83
            raise ExpressionError(
82 84
                f"Expected a single string or ident for ::attr(), got {function.arguments!r}"
83 85
            )
84 -
        return XPathExpr.from_xpath(xpath, attribute=function.arguments[0].value)
86 +
        return XPathExpr.from_xpath(
87 +
            xpath, attribute=function.arguments[0].value
88 +
        )
85 89
86 90
    def xpath_text_simple_pseudo_element(self, xpath):
87 91
        """Support selecting text nodes using ::text pseudo-element"""

@@ -106,7 +106,9 @@
Loading
106 106
            selector.xpath('//a[href=$url]', url="http://www.example.com")
107 107
        """
108 108
        return self.__class__(
109 -
            flatten([x.xpath(xpath, namespaces=namespaces, **kwargs) for x in self])
109 +
            flatten(
110 +
                [x.xpath(xpath, namespaces=namespaces, **kwargs) for x in self]
111 +
            )
110 112
        )
111 113
112 114
    def css(self, query: str) -> "SelectorList[_SelectorType]":
@@ -130,7 +132,9 @@
Loading
130 132
        Passing ``replace_entities`` as ``False`` switches off these
131 133
        replacements.
132 134
        """
133 -
        return flatten([x.re(regex, replace_entities=replace_entities) for x in self])
135 +
        return flatten(
136 +
            [x.re(regex, replace_entities=replace_entities) for x in self]
137 +
        )
134 138
135 139
    @typing.overload
136 140
    def re_first(
@@ -325,7 +329,10 @@
Loading
325 329
            nsp.update(namespaces)
326 330
        try:
327 331
            result = xpathev(
328 -
                query, namespaces=nsp, smart_strings=self._lxml_smart_strings, **kwargs
332 +
                query,
333 +
                namespaces=nsp,
334 +
                smart_strings=self._lxml_smart_strings,
335 +
                **kwargs,
329 336
            )
330 337
        except etree.XPathError as exc:
331 338
            raise ValueError(f"XPath error: {exc} in {query}")
@@ -372,7 +379,9 @@
Loading
372 379
        Passing ``replace_entities`` as ``False`` switches off these
373 380
        replacements.
374 381
        """
375 -
        return extract_regex(regex, self.get(), replace_entities=replace_entities)
382 +
        return extract_regex(
383 +
            regex, self.get(), replace_entities=replace_entities
384 +
        )
376 385
377 386
    @typing.overload
378 387
    def re_first(
@@ -409,7 +418,8 @@
Loading
409 418
        replacements.
410 419
        """
411 420
        return next(
412 -
            iflatten(self.re(regex, replace_entities=replace_entities)), default
421 +
            iflatten(self.re(regex, replace_entities=replace_entities)),
422 +
            default,
413 423
        )
414 424
415 425
    def get(self) -> str:

@@ -40,10 +40,14 @@
Loading
40 40
    """
41 41
    if not context.eval_context.get("args_checked"):
42 42
        if not classes:
43 -
            raise ValueError("XPath error: has-class must have at least 1 argument")
43 +
            raise ValueError(
44 +
                "XPath error: has-class must have at least 1 argument"
45 +
            )
44 46
        for c in classes:
45 47
            if not isinstance(c, str):
46 -
                raise ValueError("XPath error: has-class arguments must be strings")
48 +
                raise ValueError(
49 +
                    "XPath error: has-class arguments must be strings"
50 +
                )
47 51
        context.eval_context["args_checked"] = True
48 52
49 53
    node_cls = context.context_node.get("class")
Files Coverage
parsel 100.00%
Project Totals (5 files) 100.00%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading