nwo
stringlengths 10
28
| sha
stringlengths 40
40
| path
stringlengths 11
97
| identifier
stringlengths 1
64
| parameters
stringlengths 2
2.24k
| return_statement
stringlengths 0
2.17k
| docstring
stringlengths 0
5.45k
| docstring_summary
stringlengths 0
3.83k
| func_begin
int64 1
13.4k
| func_end
int64 2
13.4k
| function
stringlengths 28
56.4k
| url
stringlengths 106
209
| project
int64 1
48
| executed_lines
list | executed_lines_pc
float64 0
153
| missing_lines
list | missing_lines_pc
float64 0
100
| covered
bool 2
classes | filecoverage
float64 2.53
100
| function_lines
int64 2
1.46k
| mccabe
int64 1
253
| coverage
float64 0
100
| docstring_lines
int64 0
112
| function_nodoc
stringlengths 9
56.4k
| id
int64 0
29.8k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_even_pseudo
|
(self, xpath)
|
return xpath
|
Matches even elements, zero-indexed::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><p></p><p class="last"></p></div>')
>>> d('p:even')
[<p>]
..
|
Matches even elements, zero-indexed::
| 78 | 90 |
def xpath_even_pseudo(self, xpath):
"""Matches even elements, zero-indexed::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><p></p><p class="last"></p></div>')
>>> d('p:even')
[<p>]
..
"""
# the first element is 1 in xpath and 0 in python and js
xpath.add_post_condition('position() mod 2 = 1')
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L78-L90
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12
] | 100 |
[] | 0 | true | 80.645161 | 13 | 1 | 100 | 8 |
def xpath_even_pseudo(self, xpath):
# the first element is 1 in xpath and 0 in python and js
xpath.add_post_condition('position() mod 2 = 1')
return xpath
| 21,661 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_odd_pseudo
|
(self, xpath)
|
return xpath
|
Matches odd elements, zero-indexed::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><p></p><p class="last"></p></div>')
>>> d('p:odd')
[<p.last>]
..
|
Matches odd elements, zero-indexed::
| 92 | 103 |
def xpath_odd_pseudo(self, xpath):
"""Matches odd elements, zero-indexed::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><p></p><p class="last"></p></div>')
>>> d('p:odd')
[<p.last>]
..
"""
xpath.add_post_condition('position() mod 2 = 0')
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L92-L103
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 83.333333 |
[
10,
11
] | 16.666667 | false | 80.645161 | 12 | 1 | 83.333333 | 8 |
def xpath_odd_pseudo(self, xpath):
xpath.add_post_condition('position() mod 2 = 0')
return xpath
| 21,662 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_checked_pseudo
|
(self, xpath)
|
return xpath
|
Matches odd elements, zero-indexed::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input checked="checked"/></div>')
>>> d('input:checked')
[<input>]
..
|
Matches odd elements, zero-indexed::
| 105 | 116 |
def xpath_checked_pseudo(self, xpath):
"""Matches odd elements, zero-indexed::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input checked="checked"/></div>')
>>> d('input:checked')
[<input>]
..
"""
xpath.add_condition("@checked and name(.) = 'input'")
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L105-L116
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 100 |
[] | 0 | true | 80.645161 | 12 | 1 | 100 | 8 |
def xpath_checked_pseudo(self, xpath):
xpath.add_condition("@checked and name(.) = 'input'")
return xpath
| 21,663 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_selected_pseudo
|
(self, xpath)
|
return xpath
|
Matches all elements that are selected::
>>> from pyquery import PyQuery
>>> d = PyQuery('<select><option selected="selected"/></select>')
>>> d('option:selected')
[<option>]
..
|
Matches all elements that are selected::
| 118 | 129 |
def xpath_selected_pseudo(self, xpath):
"""Matches all elements that are selected::
>>> from pyquery import PyQuery
>>> d = PyQuery('<select><option selected="selected"/></select>')
>>> d('option:selected')
[<option>]
..
"""
xpath.add_condition("@selected and name(.) = 'option'")
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L118-L129
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 100 |
[] | 0 | true | 80.645161 | 12 | 1 | 100 | 8 |
def xpath_selected_pseudo(self, xpath):
xpath.add_condition("@selected and name(.) = 'option'")
return xpath
| 21,664 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator._format_disabled_xpath
|
(self, disabled=True)
|
return '''(
((name(.) = 'button' or name(.) = 'input' or name(.) = 'select'
or name(.) = 'textarea' or name(.) = 'fieldset')
and %s(@disabled or (ancestor::fieldset[@disabled]
and not(ancestor::legend[not(preceding-sibling::legend)])))
)
or
((name(.) = 'option'
and %s(@disabled or ancestor::optgroup[@disabled]))
)
or
((name(.) = 'optgroup' and %s(@disabled)))
)''' % (bool_op, bool_op, bool_op)
|
Format XPath condition for :disabled or :enabled pseudo-classes
according to the WHATWG spec. See: https://html.spec.whatwg.org
/multipage/semantics-other.html#concept-element-disabled
|
Format XPath condition for :disabled or :enabled pseudo-classes
according to the WHATWG spec. See: https://html.spec.whatwg.org
/multipage/semantics-other.html#concept-element-disabled
| 131 | 149 |
def _format_disabled_xpath(self, disabled=True):
"""Format XPath condition for :disabled or :enabled pseudo-classes
according to the WHATWG spec. See: https://html.spec.whatwg.org
/multipage/semantics-other.html#concept-element-disabled
"""
bool_op = '' if disabled else 'not'
return '''(
((name(.) = 'button' or name(.) = 'input' or name(.) = 'select'
or name(.) = 'textarea' or name(.) = 'fieldset')
and %s(@disabled or (ancestor::fieldset[@disabled]
and not(ancestor::legend[not(preceding-sibling::legend)])))
)
or
((name(.) = 'option'
and %s(@disabled or ancestor::optgroup[@disabled]))
)
or
((name(.) = 'optgroup' and %s(@disabled)))
)''' % (bool_op, bool_op, bool_op)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L131-L149
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18
] | 100 |
[] | 0 | true | 80.645161 | 19 | 1 | 100 | 3 |
def _format_disabled_xpath(self, disabled=True):
bool_op = '' if disabled else 'not'
return '''(
((name(.) = 'button' or name(.) = 'input' or name(.) = 'select'
or name(.) = 'textarea' or name(.) = 'fieldset')
and %s(@disabled or (ancestor::fieldset[@disabled]
and not(ancestor::legend[not(preceding-sibling::legend)])))
)
or
((name(.) = 'option'
and %s(@disabled or ancestor::optgroup[@disabled]))
)
or
((name(.) = 'optgroup' and %s(@disabled)))
)''' % (bool_op, bool_op, bool_op)
| 21,665 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_disabled_pseudo
|
(self, xpath)
|
return xpath
|
Matches all elements that are disabled::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input disabled="disabled"/></div>')
>>> d('input:disabled')
[<input>]
..
|
Matches all elements that are disabled::
| 151 | 162 |
def xpath_disabled_pseudo(self, xpath):
"""Matches all elements that are disabled::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input disabled="disabled"/></div>')
>>> d('input:disabled')
[<input>]
..
"""
xpath.add_condition(self._format_disabled_xpath())
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L151-L162
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 100 |
[] | 0 | true | 80.645161 | 12 | 1 | 100 | 8 |
def xpath_disabled_pseudo(self, xpath):
xpath.add_condition(self._format_disabled_xpath())
return xpath
| 21,666 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_enabled_pseudo
|
(self, xpath)
|
return xpath
|
Matches all elements that are enabled::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input value="foo" /></div>')
>>> d('input:enabled')
[<input>]
..
|
Matches all elements that are enabled::
| 164 | 175 |
def xpath_enabled_pseudo(self, xpath):
"""Matches all elements that are enabled::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input value="foo" /></div>')
>>> d('input:enabled')
[<input>]
..
"""
xpath.add_condition(self._format_disabled_xpath(disabled=False))
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L164-L175
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 100 |
[] | 0 | true | 80.645161 | 12 | 1 | 100 | 8 |
def xpath_enabled_pseudo(self, xpath):
xpath.add_condition(self._format_disabled_xpath(disabled=False))
return xpath
| 21,667 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_file_pseudo
|
(self, xpath)
|
return xpath
|
Matches all input elements of type file::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input type="file"/></div>')
>>> d('input:file')
[<input>]
..
|
Matches all input elements of type file::
| 177 | 188 |
def xpath_file_pseudo(self, xpath):
"""Matches all input elements of type file::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input type="file"/></div>')
>>> d('input:file')
[<input>]
..
"""
xpath.add_condition("@type = 'file' and name(.) = 'input'")
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L177-L188
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 100 |
[] | 0 | true | 80.645161 | 12 | 1 | 100 | 8 |
def xpath_file_pseudo(self, xpath):
xpath.add_condition("@type = 'file' and name(.) = 'input'")
return xpath
| 21,668 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_input_pseudo
|
(self, xpath)
|
return xpath
|
Matches all input elements::
>>> from pyquery import PyQuery
>>> d = PyQuery(('<div><input type="file"/>'
... '<textarea></textarea></div>'))
>>> d(':input')
[<input>, <textarea>]
..
|
Matches all input elements::
| 190 | 204 |
def xpath_input_pseudo(self, xpath):
"""Matches all input elements::
>>> from pyquery import PyQuery
>>> d = PyQuery(('<div><input type="file"/>'
... '<textarea></textarea></div>'))
>>> d(':input')
[<input>, <textarea>]
..
"""
xpath.add_condition((
"(name(.) = 'input' or name(.) = 'select') "
"or (name(.) = 'textarea' or name(.) = 'button')"))
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L190-L204
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14
] | 100 |
[] | 0 | true | 80.645161 | 15 | 1 | 100 | 9 |
def xpath_input_pseudo(self, xpath):
xpath.add_condition((
"(name(.) = 'input' or name(.) = 'select') "
"or (name(.) = 'textarea' or name(.) = 'button')"))
return xpath
| 21,669 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_button_pseudo
|
(self, xpath)
|
return xpath
|
Matches all button input elements and the button element::
>>> from pyquery import PyQuery
>>> d = PyQuery(('<div><input type="button"/>'
... '<button></button></div>'))
>>> d(':button')
[<input>, <button>]
..
|
Matches all button input elements and the button element::
| 206 | 220 |
def xpath_button_pseudo(self, xpath):
"""Matches all button input elements and the button element::
>>> from pyquery import PyQuery
>>> d = PyQuery(('<div><input type="button"/>'
... '<button></button></div>'))
>>> d(':button')
[<input>, <button>]
..
"""
xpath.add_condition((
"(@type = 'button' and name(.) = 'input') "
"or name(.) = 'button'"))
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L206-L220
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14
] | 100 |
[] | 0 | true | 80.645161 | 15 | 1 | 100 | 9 |
def xpath_button_pseudo(self, xpath):
xpath.add_condition((
"(@type = 'button' and name(.) = 'input') "
"or name(.) = 'button'"))
return xpath
| 21,670 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_radio_pseudo
|
(self, xpath)
|
return xpath
|
Matches all radio input elements::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input type="radio"/></div>')
>>> d('input:radio')
[<input>]
..
|
Matches all radio input elements::
| 222 | 233 |
def xpath_radio_pseudo(self, xpath):
"""Matches all radio input elements::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input type="radio"/></div>')
>>> d('input:radio')
[<input>]
..
"""
xpath.add_condition("@type = 'radio' and name(.) = 'input'")
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L222-L233
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 100 |
[] | 0 | true | 80.645161 | 12 | 1 | 100 | 8 |
def xpath_radio_pseudo(self, xpath):
xpath.add_condition("@type = 'radio' and name(.) = 'input'")
return xpath
| 21,671 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_text_pseudo
|
(self, xpath)
|
return xpath
|
Matches all text input elements::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input type="text"/></div>')
>>> d('input:text')
[<input>]
..
|
Matches all text input elements::
| 235 | 246 |
def xpath_text_pseudo(self, xpath):
"""Matches all text input elements::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input type="text"/></div>')
>>> d('input:text')
[<input>]
..
"""
xpath.add_condition("@type = 'text' and name(.) = 'input'")
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L235-L246
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 83.333333 |
[
10,
11
] | 16.666667 | false | 80.645161 | 12 | 1 | 83.333333 | 8 |
def xpath_text_pseudo(self, xpath):
xpath.add_condition("@type = 'text' and name(.) = 'input'")
return xpath
| 21,672 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_checkbox_pseudo
|
(self, xpath)
|
return xpath
|
Matches all checkbox input elements::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input type="checkbox"/></div>')
>>> d('input:checkbox')
[<input>]
..
|
Matches all checkbox input elements::
| 248 | 259 |
def xpath_checkbox_pseudo(self, xpath):
"""Matches all checkbox input elements::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input type="checkbox"/></div>')
>>> d('input:checkbox')
[<input>]
..
"""
xpath.add_condition("@type = 'checkbox' and name(.) = 'input'")
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L248-L259
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 100 |
[] | 0 | true | 80.645161 | 12 | 1 | 100 | 8 |
def xpath_checkbox_pseudo(self, xpath):
xpath.add_condition("@type = 'checkbox' and name(.) = 'input'")
return xpath
| 21,673 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_password_pseudo
|
(self, xpath)
|
return xpath
|
Matches all password input elements::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input type="password"/></div>')
>>> d('input:password')
[<input>]
..
|
Matches all password input elements::
| 261 | 272 |
def xpath_password_pseudo(self, xpath):
"""Matches all password input elements::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input type="password"/></div>')
>>> d('input:password')
[<input>]
..
"""
xpath.add_condition("@type = 'password' and name(.) = 'input'")
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L261-L272
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 83.333333 |
[
10,
11
] | 16.666667 | false | 80.645161 | 12 | 1 | 83.333333 | 8 |
def xpath_password_pseudo(self, xpath):
xpath.add_condition("@type = 'password' and name(.) = 'input'")
return xpath
| 21,674 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_submit_pseudo
|
(self, xpath)
|
return xpath
|
Matches all submit input elements::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input type="submit"/></div>')
>>> d('input:submit')
[<input>]
..
|
Matches all submit input elements::
| 274 | 285 |
def xpath_submit_pseudo(self, xpath):
"""Matches all submit input elements::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input type="submit"/></div>')
>>> d('input:submit')
[<input>]
..
"""
xpath.add_condition("@type = 'submit' and name(.) = 'input'")
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L274-L285
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 83.333333 |
[
10,
11
] | 16.666667 | false | 80.645161 | 12 | 1 | 83.333333 | 8 |
def xpath_submit_pseudo(self, xpath):
xpath.add_condition("@type = 'submit' and name(.) = 'input'")
return xpath
| 21,675 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_hidden_pseudo
|
(self, xpath)
|
return xpath
|
Matches all hidden input elements::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input type="hidden"/></div>')
>>> d('input:hidden')
[<input>]
..
|
Matches all hidden input elements::
| 287 | 298 |
def xpath_hidden_pseudo(self, xpath):
"""Matches all hidden input elements::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input type="hidden"/></div>')
>>> d('input:hidden')
[<input>]
..
"""
xpath.add_condition("@type = 'hidden' and name(.) = 'input'")
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L287-L298
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 83.333333 |
[
10,
11
] | 16.666667 | false | 80.645161 | 12 | 1 | 83.333333 | 8 |
def xpath_hidden_pseudo(self, xpath):
xpath.add_condition("@type = 'hidden' and name(.) = 'input'")
return xpath
| 21,676 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_image_pseudo
|
(self, xpath)
|
return xpath
|
Matches all image input elements::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input type="image"/></div>')
>>> d('input:image')
[<input>]
..
|
Matches all image input elements::
| 300 | 311 |
def xpath_image_pseudo(self, xpath):
"""Matches all image input elements::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input type="image"/></div>')
>>> d('input:image')
[<input>]
..
"""
xpath.add_condition("@type = 'image' and name(.) = 'input'")
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L300-L311
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 83.333333 |
[
10,
11
] | 16.666667 | false | 80.645161 | 12 | 1 | 83.333333 | 8 |
def xpath_image_pseudo(self, xpath):
xpath.add_condition("@type = 'image' and name(.) = 'input'")
return xpath
| 21,677 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_reset_pseudo
|
(self, xpath)
|
return xpath
|
Matches all reset input elements::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input type="reset"/></div>')
>>> d('input:reset')
[<input>]
..
|
Matches all reset input elements::
| 313 | 324 |
def xpath_reset_pseudo(self, xpath):
"""Matches all reset input elements::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><input type="reset"/></div>')
>>> d('input:reset')
[<input>]
..
"""
xpath.add_condition("@type = 'reset' and name(.) = 'input'")
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L313-L324
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 83.333333 |
[
10,
11
] | 16.666667 | false | 80.645161 | 12 | 1 | 83.333333 | 8 |
def xpath_reset_pseudo(self, xpath):
xpath.add_condition("@type = 'reset' and name(.) = 'input'")
return xpath
| 21,678 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_header_pseudo
|
(self, xpath)
|
return xpath
|
Matches all header elements (h1, ..., h6)::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><h1>title</h1></div>')
>>> d(':header')
[<h1>]
..
|
Matches all header elements (h1, ..., h6)::
| 326 | 340 |
def xpath_header_pseudo(self, xpath):
"""Matches all header elements (h1, ..., h6)::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><h1>title</h1></div>')
>>> d(':header')
[<h1>]
..
"""
# this seems kind of brute-force, is there a better way?
xpath.add_condition((
"(name(.) = 'h1' or name(.) = 'h2' or name (.) = 'h3') "
"or (name(.) = 'h4' or name (.) = 'h5' or name(.) = 'h6')"))
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L326-L340
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14
] | 100 |
[] | 0 | true | 80.645161 | 15 | 1 | 100 | 8 |
def xpath_header_pseudo(self, xpath):
# this seems kind of brute-force, is there a better way?
xpath.add_condition((
"(name(.) = 'h1' or name(.) = 'h2' or name (.) = 'h3') "
"or (name(.) = 'h4' or name (.) = 'h5' or name(.) = 'h6')"))
return xpath
| 21,679 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_parent_pseudo
|
(self, xpath)
|
return xpath
|
Match all elements that contain other elements::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><h1><span>title</span></h1><h1/></div>')
>>> d('h1:parent')
[<h1>]
..
|
Match all elements that contain other elements::
| 342 | 353 |
def xpath_parent_pseudo(self, xpath):
"""Match all elements that contain other elements::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><h1><span>title</span></h1><h1/></div>')
>>> d('h1:parent')
[<h1>]
..
"""
xpath.add_condition("count(child::*) > 0")
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L342-L353
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 100 |
[] | 0 | true | 80.645161 | 12 | 1 | 100 | 8 |
def xpath_parent_pseudo(self, xpath):
xpath.add_condition("count(child::*) > 0")
return xpath
| 21,680 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_empty_pseudo
|
(self, xpath)
|
return xpath
|
Match all elements that do not contain other elements::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><h1><span>title</span></h1><h2/></div>')
>>> d(':empty')
[<h2>]
..
|
Match all elements that do not contain other elements::
| 355 | 366 |
def xpath_empty_pseudo(self, xpath):
"""Match all elements that do not contain other elements::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><h1><span>title</span></h1><h2/></div>')
>>> d(':empty')
[<h2>]
..
"""
xpath.add_condition("not(node())")
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L355-L366
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 100 |
[] | 0 | true | 80.645161 | 12 | 1 | 100 | 8 |
def xpath_empty_pseudo(self, xpath):
xpath.add_condition("not(node())")
return xpath
| 21,681 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_eq_function
|
(self, xpath, function)
|
return xpath
|
Matches a single element by its index::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><h1 class="first"/><h1 class="last"/></div>')
>>> d('h1:eq(0)')
[<h1.first>]
>>> d('h1:eq(1)')
[<h1.last>]
..
|
Matches a single element by its index::
| 368 | 386 |
def xpath_eq_function(self, xpath, function):
"""Matches a single element by its index::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><h1 class="first"/><h1 class="last"/></div>')
>>> d('h1:eq(0)')
[<h1.first>]
>>> d('h1:eq(1)')
[<h1.last>]
..
"""
if function.argument_types() != ['NUMBER']:
raise ExpressionError(
"Expected a single integer for :eq(), got %r" % (
function.arguments,))
value = int(function.arguments[0].value)
xpath.add_post_condition('position() = %s' % (value + 1))
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L368-L386
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
15,
16,
17,
18
] | 89.473684 |
[
13
] | 5.263158 | false | 80.645161 | 19 | 2 | 94.736842 | 10 |
def xpath_eq_function(self, xpath, function):
if function.argument_types() != ['NUMBER']:
raise ExpressionError(
"Expected a single integer for :eq(), got %r" % (
function.arguments,))
value = int(function.arguments[0].value)
xpath.add_post_condition('position() = %s' % (value + 1))
return xpath
| 21,682 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_gt_function
|
(self, xpath, function)
|
return xpath
|
Matches all elements with an index over the given one::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><h1 class="first"/><h1 class="last"/></div>')
>>> d('h1:gt(0)')
[<h1.last>]
..
|
Matches all elements with an index over the given one::
| 388 | 404 |
def xpath_gt_function(self, xpath, function):
"""Matches all elements with an index over the given one::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><h1 class="first"/><h1 class="last"/></div>')
>>> d('h1:gt(0)')
[<h1.last>]
..
"""
if function.argument_types() != ['NUMBER']:
raise ExpressionError(
"Expected a single integer for :gt(), got %r" % (
function.arguments,))
value = int(function.arguments[0].value)
xpath.add_post_condition('position() > %s' % (value + 1))
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L388-L404
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
13,
14,
15,
16
] | 88.235294 |
[
11
] | 5.882353 | false | 80.645161 | 17 | 2 | 94.117647 | 8 |
def xpath_gt_function(self, xpath, function):
if function.argument_types() != ['NUMBER']:
raise ExpressionError(
"Expected a single integer for :gt(), got %r" % (
function.arguments,))
value = int(function.arguments[0].value)
xpath.add_post_condition('position() > %s' % (value + 1))
return xpath
| 21,683 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_lt_function
|
(self, xpath, function)
|
return xpath
|
Matches all elements with an index below the given one::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><h1 class="first"/><h1 class="last"/></div>')
>>> d('h1:lt(1)')
[<h1.first>]
..
|
Matches all elements with an index below the given one::
| 406 | 423 |
def xpath_lt_function(self, xpath, function):
"""Matches all elements with an index below the given one::
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><h1 class="first"/><h1 class="last"/></div>')
>>> d('h1:lt(1)')
[<h1.first>]
..
"""
if function.argument_types() != ['NUMBER']:
raise ExpressionError(
"Expected a single integer for :gt(), got %r" % (
function.arguments,))
value = int(function.arguments[0].value)
xpath.add_post_condition('position() < %s' % (value + 1))
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L406-L423
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
14,
15,
16,
17
] | 83.333333 |
[
11
] | 5.555556 | false | 80.645161 | 18 | 2 | 94.444444 | 8 |
def xpath_lt_function(self, xpath, function):
if function.argument_types() != ['NUMBER']:
raise ExpressionError(
"Expected a single integer for :gt(), got %r" % (
function.arguments,))
value = int(function.arguments[0].value)
xpath.add_post_condition('position() < %s' % (value + 1))
return xpath
| 21,684 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_contains_function
|
(self, xpath, function)
|
return xpath
|
Matches all elements that contain the given text
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><h1/><h1 class="title">title</h1></div>')
>>> d('h1:contains("title")')
[<h1.title>]
..
|
Matches all elements that contain the given text
| 425 | 442 |
def xpath_contains_function(self, xpath, function):
"""Matches all elements that contain the given text
>>> from pyquery import PyQuery
>>> d = PyQuery('<div><h1/><h1 class="title">title</h1></div>')
>>> d('h1:contains("title")')
[<h1.title>]
..
"""
if function.argument_types() not in (['STRING'], ['IDENT']):
raise ExpressionError(
"Expected a single string or ident for :contains(), got %r" % (
function.arguments,))
value = self.xpath_literal(function.arguments[0].value)
xpath.add_post_condition('contains(., %s)' % value)
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L425-L442
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
14,
15,
16,
17
] | 83.333333 |
[
11
] | 5.555556 | false | 80.645161 | 18 | 2 | 94.444444 | 8 |
def xpath_contains_function(self, xpath, function):
if function.argument_types() not in (['STRING'], ['IDENT']):
raise ExpressionError(
"Expected a single string or ident for :contains(), got %r" % (
function.arguments,))
value = self.xpath_literal(function.arguments[0].value)
xpath.add_post_condition('contains(., %s)' % value)
return xpath
| 21,685 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/cssselectpatch.py
|
JQueryTranslator.xpath_has_function
|
(self, xpath, function)
|
return xpath
|
Matches elements which contain at least one element that matches
the specified selector. https://api.jquery.com/has-selector/
>>> from pyquery import PyQuery
>>> d = PyQuery('<div class="foo"><div class="bar"></div></div>')
>>> d('.foo:has(".baz")')
[]
>>> d('.foo:has(".foo")')
[]
>>> d('.foo:has(".bar")')
[<div.foo>]
>>> d('.foo:has(div)')
[<div.foo>]
..
|
Matches elements which contain at least one element that matches
the specified selector. https://api.jquery.com/has-selector/
| 444 | 469 |
def xpath_has_function(self, xpath, function):
"""Matches elements which contain at least one element that matches
the specified selector. https://api.jquery.com/has-selector/
>>> from pyquery import PyQuery
>>> d = PyQuery('<div class="foo"><div class="bar"></div></div>')
>>> d('.foo:has(".baz")')
[]
>>> d('.foo:has(".foo")')
[]
>>> d('.foo:has(".bar")')
[<div.foo>]
>>> d('.foo:has(div)')
[<div.foo>]
..
"""
if function.argument_types() not in (['STRING'], ['IDENT']):
raise ExpressionError(
"Expected a single string or ident for :has(), got %r" % (
function.arguments,))
value = self.css_to_xpath(
function.arguments[0].value, prefix='descendant::',
)
xpath.add_post_condition(value)
return xpath
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/cssselectpatch.py#L444-L469
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16
] | 65.384615 |
[
17,
18,
21,
24,
25
] | 19.230769 | false | 80.645161 | 26 | 2 | 80.769231 | 15 |
def xpath_has_function(self, xpath, function):
if function.argument_types() not in (['STRING'], ['IDENT']):
raise ExpressionError(
"Expected a single string or ident for :has(), got %r" % (
function.arguments,))
value = self.css_to_xpath(
function.arguments[0].value, prefix='descendant::',
)
xpath.add_post_condition(value)
return xpath
| 21,686 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
getargspec
|
(func)
|
return [p.name for p in args
if p.kind == p.POSITIONAL_OR_KEYWORD]
| 21 | 24 |
def getargspec(func):
args = inspect.signature(func).parameters.values()
return [p.name for p in args
if p.kind == p.POSITIONAL_OR_KEYWORD]
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L21-L24
| 32 |
[
0,
1,
2
] | 75 |
[] | 0 | false | 74.758454 | 4 | 2 | 100 | 0 |
def getargspec(func):
args = inspect.signature(func).parameters.values()
return [p.name for p in args
if p.kind == p.POSITIONAL_OR_KEYWORD]
| 21,687 |
||
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
with_camel_case_alias
|
(func)
|
return func
|
decorator for methods who required a camelcase alias
|
decorator for methods who required a camelcase alias
| 27 | 30 |
def with_camel_case_alias(func):
"""decorator for methods who required a camelcase alias"""
_camel_case_aliases.add(func.__name__)
return func
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L27-L30
| 32 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 74.758454 | 4 | 1 | 100 | 1 |
def with_camel_case_alias(func):
_camel_case_aliases.add(func.__name__)
return func
| 21,688 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
build_camel_case_aliases
|
(PyQuery)
|
add camelcase aliases to PyQuery
|
add camelcase aliases to PyQuery
| 36 | 46 |
def build_camel_case_aliases(PyQuery):
"""add camelcase aliases to PyQuery"""
for alias in _camel_case_aliases:
parts = list(alias.split('_'))
name = parts[0] + ''.join([p.title() for p in parts[1:]])
func = getattr(PyQuery, alias)
f = types.FunctionType(func.__code__, func.__globals__,
name, func.__defaults__)
f.__doc__ = (
'Alias for :func:`~pyquery.pyquery.PyQuery.%s`') % func.__name__
setattr(PyQuery, name, f.__get__(None, PyQuery))
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L36-L46
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
] | 100 |
[] | 0 | true | 74.758454 | 11 | 3 | 100 | 1 |
def build_camel_case_aliases(PyQuery):
for alias in _camel_case_aliases:
parts = list(alias.split('_'))
name = parts[0] + ''.join([p.title() for p in parts[1:]])
func = getattr(PyQuery, alias)
f = types.FunctionType(func.__code__, func.__globals__,
name, func.__defaults__)
f.__doc__ = (
'Alias for :func:`~pyquery.pyquery.PyQuery.%s`') % func.__name__
setattr(PyQuery, name, f.__get__(None, PyQuery))
| 21,689 |
|
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
fromstring
|
(context, parser=None, custom_parser=None)
|
use html parser if we don't have clean xml
|
use html parser if we don't have clean xml
| 49 | 91 |
def fromstring(context, parser=None, custom_parser=None):
"""use html parser if we don't have clean xml
"""
if hasattr(context, 'read') and hasattr(context.read, '__call__'):
meth = 'parse'
else:
meth = 'fromstring'
if custom_parser is None:
if parser is None:
try:
result = getattr(etree, meth)(context)
except etree.XMLSyntaxError:
if hasattr(context, 'seek'):
context.seek(0)
result = getattr(lxml.html, meth)(context)
if isinstance(result, etree._ElementTree):
return [result.getroot()]
else:
return [result]
elif parser == 'xml':
custom_parser = getattr(etree, meth)
elif parser == 'html':
custom_parser = getattr(lxml.html, meth)
elif parser == 'html5':
from lxml.html import html5parser
custom_parser = getattr(html5parser, meth)
elif parser == 'soup':
from lxml.html import soupparser
custom_parser = getattr(soupparser, meth)
elif parser == 'html_fragments':
custom_parser = lxml.html.fragments_fromstring
else:
raise ValueError('No such parser: "%s"' % parser)
result = custom_parser(context)
if type(result) is list:
return result
elif isinstance(result, etree._ElementTree):
return [result.getroot()]
elif result is not None:
return [result]
else:
return []
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L49-L91
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
33,
34,
35,
37,
38,
39,
40,
41
] | 72.093023 |
[
23,
24,
25,
26,
27,
28,
29,
30,
32,
36,
42
] | 25.581395 | false | 74.758454 | 43 | 16 | 74.418605 | 1 |
def fromstring(context, parser=None, custom_parser=None):
if hasattr(context, 'read') and hasattr(context.read, '__call__'):
meth = 'parse'
else:
meth = 'fromstring'
if custom_parser is None:
if parser is None:
try:
result = getattr(etree, meth)(context)
except etree.XMLSyntaxError:
if hasattr(context, 'seek'):
context.seek(0)
result = getattr(lxml.html, meth)(context)
if isinstance(result, etree._ElementTree):
return [result.getroot()]
else:
return [result]
elif parser == 'xml':
custom_parser = getattr(etree, meth)
elif parser == 'html':
custom_parser = getattr(lxml.html, meth)
elif parser == 'html5':
from lxml.html import html5parser
custom_parser = getattr(html5parser, meth)
elif parser == 'soup':
from lxml.html import soupparser
custom_parser = getattr(soupparser, meth)
elif parser == 'html_fragments':
custom_parser = lxml.html.fragments_fromstring
else:
raise ValueError('No such parser: "%s"' % parser)
result = custom_parser(context)
if type(result) is list:
return result
elif isinstance(result, etree._ElementTree):
return [result.getroot()]
elif result is not None:
return [result]
else:
return []
| 21,690 |
|
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
callback
|
(func, *args)
|
return func(*args[:func.__code__.co_argcount])
| 94 | 95 |
def callback(func, *args):
return func(*args[:func.__code__.co_argcount])
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L94-L95
| 32 |
[
0,
1
] | 100 |
[] | 0 | true | 74.758454 | 2 | 1 | 100 | 0 |
def callback(func, *args):
return func(*args[:func.__code__.co_argcount])
| 21,691 |
||
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
NoDefault.__repr__
|
(self)
|
return '<NoDefault>'
|
clean representation in Sphinx
|
clean representation in Sphinx
| 99 | 101 |
def __repr__(self):
"""clean representation in Sphinx"""
return '<NoDefault>'
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L99-L101
| 32 |
[
0,
1
] | 66.666667 |
[
2
] | 33.333333 | false | 74.758454 | 3 | 1 | 66.666667 | 1 |
def __repr__(self):
return '<NoDefault>'
| 21,692 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
FlexibleElement.__init__
|
(self, pget, pset=no_default, pdel=no_default)
| 110 | 113 |
def __init__(self, pget, pset=no_default, pdel=no_default):
self.pget = pget
self.pset = pset
self.pdel = pdel
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L110-L113
| 32 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 74.758454 | 4 | 1 | 100 | 0 |
def __init__(self, pget, pset=no_default, pdel=no_default):
self.pget = pget
self.pset = pset
self.pdel = pdel
| 21,693 |
|||
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
FlexibleElement.__get__
|
(self, instance, klass)
|
return _element()
| 115 | 132 |
def __get__(self, instance, klass):
class _element(object):
"""real element to support set/get/del attr and item and js call
style"""
def __call__(prop, *args, **kwargs):
return self.pget(instance, *args, **kwargs)
__getattr__ = __getitem__ = __setattr__ = __setitem__ = __call__
def __delitem__(prop, name):
if self.pdel is not no_default:
return self.pdel(instance, name)
else:
raise NotImplementedError()
__delattr__ = __delitem__
def __repr__(prop):
return '<flexible_element %s>' % self.pget.__name__
return _element()
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L115-L132
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
13,
14,
15,
17
] | 72.222222 |
[
9,
10,
12,
16
] | 22.222222 | false | 74.758454 | 18 | 5 | 77.777778 | 0 |
def __get__(self, instance, klass):
class _element(object):
def __call__(prop, *args, **kwargs):
return self.pget(instance, *args, **kwargs)
__getattr__ = __getitem__ = __setattr__ = __setitem__ = __call__
def __delitem__(prop, name):
if self.pdel is not no_default:
return self.pdel(instance, name)
else:
raise NotImplementedError()
__delattr__ = __delitem__
def __repr__(prop):
return '<flexible_element %s>' % self.pget.__name__
return _element()
| 21,694 |
||
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
FlexibleElement.__set__
|
(self, instance, value)
| 134 | 138 |
def __set__(self, instance, value):
if self.pset is not no_default:
self.pset(instance, value)
else:
raise NotImplementedError()
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L134-L138
| 32 |
[
0
] | 20 |
[
1,
2,
4
] | 60 | false | 74.758454 | 5 | 2 | 40 | 0 |
def __set__(self, instance, value):
if self.pset is not no_default:
self.pset(instance, value)
else:
raise NotImplementedError()
| 21,695 |
|||
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.__init__
|
(self, *args, **kwargs)
| 147 | 234 |
def __init__(self, *args, **kwargs):
html = None
elements = []
self._base_url = None
self.parser = kwargs.pop('parser', None)
if 'parent' in kwargs:
self._parent = kwargs.pop('parent')
else:
self._parent = no_default
if 'css_translator' in kwargs:
self._translator = kwargs.pop('css_translator')
elif self.parser in ('xml',):
self._translator = self._translator_class(xhtml=True)
elif self._parent is not no_default:
self._translator = self._parent._translator
else:
self._translator = self._translator_class(xhtml=False)
self.namespaces = kwargs.pop('namespaces', None)
if kwargs:
# specific case to get the dom
if 'filename' in kwargs:
html = open(kwargs['filename'],
encoding=kwargs.get('encoding'))
elif 'url' in kwargs:
url = kwargs.pop('url')
if 'opener' in kwargs:
opener = kwargs.pop('opener')
html = opener(url, **kwargs)
else:
html = url_opener(url, kwargs)
if not self.parser:
self.parser = 'html'
self._base_url = url
else:
raise ValueError('Invalid keyword arguments %s' % kwargs)
elements = fromstring(html, self.parser)
# close open descriptor if possible
if hasattr(html, 'close'):
try:
html.close()
except Exception:
pass
else:
# get nodes
# determine context and selector if any
selector = context = no_default
length = len(args)
if length == 1:
context = args[0]
elif length == 2:
selector, context = args
else:
raise ValueError(
"You can't do that. Please, provide arguments")
# get context
if isinstance(context, basestring):
try:
elements = fromstring(context, self.parser)
except Exception:
raise
elif isinstance(context, self.__class__):
# copy
elements = context[:]
elif isinstance(context, list):
elements = context
elif isinstance(context, etree._Element):
elements = [context]
else:
raise TypeError(context)
# select nodes
if elements and selector is not no_default:
xpath = self._css_to_xpath(selector)
results = []
for tag in elements:
results.extend(
tag.xpath(xpath, namespaces=self.namespaces))
elements = results
list.__init__(self, elements)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L147-L234
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
9,
10,
11,
13,
14,
15,
16,
18,
19,
20,
21,
22,
23,
24,
25,
27,
28,
29,
30,
31,
33,
34,
35,
36,
39,
40,
41,
42,
43,
44,
51,
52,
53,
54,
55,
56,
57,
62,
63,
64,
65,
68,
69,
70,
71,
72,
73,
74,
76,
77,
78,
79,
80,
81,
82,
83,
85,
86,
87
] | 76.136364 |
[
12,
38,
45,
46,
59,
66,
67
] | 7.954545 | false | 74.758454 | 88 | 22 | 92.045455 | 0 |
def __init__(self, *args, **kwargs):
html = None
elements = []
self._base_url = None
self.parser = kwargs.pop('parser', None)
if 'parent' in kwargs:
self._parent = kwargs.pop('parent')
else:
self._parent = no_default
if 'css_translator' in kwargs:
self._translator = kwargs.pop('css_translator')
elif self.parser in ('xml',):
self._translator = self._translator_class(xhtml=True)
elif self._parent is not no_default:
self._translator = self._parent._translator
else:
self._translator = self._translator_class(xhtml=False)
self.namespaces = kwargs.pop('namespaces', None)
if kwargs:
# specific case to get the dom
if 'filename' in kwargs:
html = open(kwargs['filename'],
encoding=kwargs.get('encoding'))
elif 'url' in kwargs:
url = kwargs.pop('url')
if 'opener' in kwargs:
opener = kwargs.pop('opener')
html = opener(url, **kwargs)
else:
html = url_opener(url, kwargs)
if not self.parser:
self.parser = 'html'
self._base_url = url
else:
raise ValueError('Invalid keyword arguments %s' % kwargs)
elements = fromstring(html, self.parser)
# close open descriptor if possible
if hasattr(html, 'close'):
try:
html.close()
except Exception:
pass
else:
# get nodes
# determine context and selector if any
selector = context = no_default
length = len(args)
if length == 1:
context = args[0]
elif length == 2:
selector, context = args
else:
raise ValueError(
"You can't do that. Please, provide arguments")
# get context
if isinstance(context, basestring):
try:
elements = fromstring(context, self.parser)
except Exception:
raise
elif isinstance(context, self.__class__):
# copy
elements = context[:]
elif isinstance(context, list):
elements = context
elif isinstance(context, etree._Element):
elements = [context]
else:
raise TypeError(context)
# select nodes
if elements and selector is not no_default:
xpath = self._css_to_xpath(selector)
results = []
for tag in elements:
results.extend(
tag.xpath(xpath, namespaces=self.namespaces))
elements = results
list.__init__(self, elements)
| 21,696 |
|||
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery._css_to_xpath
|
(self, selector, prefix='descendant-or-self::')
|
return self._translator.css_to_xpath(selector, prefix)
| 236 | 238 |
def _css_to_xpath(self, selector, prefix='descendant-or-self::'):
selector = selector.replace('[@', '[')
return self._translator.css_to_xpath(selector, prefix)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L236-L238
| 32 |
[
0,
1,
2
] | 100 |
[] | 0 | true | 74.758454 | 3 | 1 | 100 | 0 |
def _css_to_xpath(self, selector, prefix='descendant-or-self::'):
selector = selector.replace('[@', '[')
return self._translator.css_to_xpath(selector, prefix)
| 21,697 |
||
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery._copy
|
(self, *args, **kwargs)
|
return self.__class__(*args, **kwargs)
| 240 | 242 |
def _copy(self, *args, **kwargs):
kwargs.setdefault('namespaces', self.namespaces)
return self.__class__(*args, **kwargs)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L240-L242
| 32 |
[
0,
1,
2
] | 100 |
[] | 0 | true | 74.758454 | 3 | 1 | 100 | 0 |
def _copy(self, *args, **kwargs):
kwargs.setdefault('namespaces', self.namespaces)
return self.__class__(*args, **kwargs)
| 21,698 |
||
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.__call__
|
(self, *args, **kwargs)
|
return result
|
return a new PyQuery instance
|
return a new PyQuery instance
| 244 | 257 |
def __call__(self, *args, **kwargs):
"""return a new PyQuery instance
"""
length = len(args)
if length == 0:
raise ValueError('You must provide at least a selector')
if args[0] == '':
return self._copy([])
if (len(args) == 1 and
isinstance(args[0], str) and
not args[0].startswith('<')):
args += (self,)
result = self._copy(*args, parent=self, **kwargs)
return result
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L244-L257
| 32 |
[
0,
1,
2,
3,
4,
6,
7,
8,
9,
10,
11,
12,
13
] | 92.857143 |
[
5
] | 7.142857 | false | 74.758454 | 14 | 6 | 92.857143 | 1 |
def __call__(self, *args, **kwargs):
length = len(args)
if length == 0:
raise ValueError('You must provide at least a selector')
if args[0] == '':
return self._copy([])
if (len(args) == 1 and
isinstance(args[0], str) and
not args[0].startswith('<')):
args += (self,)
result = self._copy(*args, parent=self, **kwargs)
return result
| 21,699 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.__add__
|
(self, other)
|
return self._copy(self[:] + other[:])
| 264 | 266 |
def __add__(self, other):
assert isinstance(other, self.__class__)
return self._copy(self[:] + other[:])
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L264-L266
| 32 |
[
0
] | 33.333333 |
[
1,
2
] | 66.666667 | false | 74.758454 | 3 | 2 | 33.333333 | 0 |
def __add__(self, other):
assert isinstance(other, self.__class__)
return self._copy(self[:] + other[:])
| 21,700 |
||
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.extend
|
(self, other)
|
return self
|
Extend with another PyQuery object
|
Extend with another PyQuery object
| 268 | 272 |
def extend(self, other):
"""Extend with another PyQuery object"""
assert isinstance(other, self.__class__)
self._extend(other[:])
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L268-L272
| 32 |
[
0,
1,
2,
3,
4
] | 100 |
[] | 0 | true | 74.758454 | 5 | 2 | 100 | 1 |
def extend(self, other):
assert isinstance(other, self.__class__)
self._extend(other[:])
return self
| 21,701 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.items
|
(self, selector=None)
|
Iter over elements. Return PyQuery objects:
>>> d = PyQuery('<div><span>foo</span><span>bar</span></div>')
>>> [i.text() for i in d.items('span')]
['foo', 'bar']
>>> [i.text() for i in d('span').items()]
['foo', 'bar']
>>> list(d.items('a')) == list(d('a').items())
True
|
Iter over elements. Return PyQuery objects:
| 274 | 290 |
def items(self, selector=None):
"""Iter over elements. Return PyQuery objects:
>>> d = PyQuery('<div><span>foo</span><span>bar</span></div>')
>>> [i.text() for i in d.items('span')]
['foo', 'bar']
>>> [i.text() for i in d('span').items()]
['foo', 'bar']
>>> list(d.items('a')) == list(d('a').items())
True
"""
if selector:
elems = self(selector) or []
else:
elems = self
for elem in elems:
yield self._copy(elem, parent=self)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L274-L290
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
13,
14,
15,
16
] | 94.117647 |
[
12
] | 5.882353 | false | 74.758454 | 17 | 4 | 94.117647 | 9 |
def items(self, selector=None):
if selector:
elems = self(selector) or []
else:
elems = self
for elem in elems:
yield self._copy(elem, parent=self)
| 21,702 |
|
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.xhtml_to_html
|
(self)
|
return self
|
Remove xhtml namespace:
>>> doc = PyQuery(
... '<html xmlns="http://www.w3.org/1999/xhtml"></html>')
>>> doc
[<{http://www.w3.org/1999/xhtml}html>]
>>> doc.xhtml_to_html()
[<html>]
|
Remove xhtml namespace:
| 292 | 308 |
def xhtml_to_html(self):
"""Remove xhtml namespace:
>>> doc = PyQuery(
... '<html xmlns="http://www.w3.org/1999/xhtml"></html>')
>>> doc
[<{http://www.w3.org/1999/xhtml}html>]
>>> doc.xhtml_to_html()
[<html>]
"""
try:
root = self[0].getroottree()
except IndexError:
pass
else:
lxml.html.xhtml_to_html(root)
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L292-L308
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
14,
15,
16
] | 88.235294 |
[
12,
13
] | 11.764706 | false | 74.758454 | 17 | 2 | 88.235294 | 8 |
def xhtml_to_html(self):
try:
root = self[0].getroottree()
except IndexError:
pass
else:
lxml.html.xhtml_to_html(root)
return self
| 21,703 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.remove_namespaces
|
(self)
|
return self
|
Remove all namespaces:
>>> doc = PyQuery('<foo xmlns="http://example.com/foo"></foo>')
>>> doc
[<{http://example.com/foo}foo>]
>>> doc.remove_namespaces()
[<foo>]
|
Remove all namespaces:
| 310 | 327 |
def remove_namespaces(self):
"""Remove all namespaces:
>>> doc = PyQuery('<foo xmlns="http://example.com/foo"></foo>')
>>> doc
[<{http://example.com/foo}foo>]
>>> doc.remove_namespaces()
[<foo>]
"""
try:
root = self[0].getroottree()
except IndexError:
pass
else:
for el in root.iter('{*}*'):
if el.tag.startswith('{'):
el.tag = el.tag.split('}', 1)[1]
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L310-L327
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
13,
14,
15,
16,
17
] | 88.888889 |
[
11,
12
] | 11.111111 | false | 74.758454 | 18 | 4 | 88.888889 | 7 |
def remove_namespaces(self):
try:
root = self[0].getroottree()
except IndexError:
pass
else:
for el in root.iter('{*}*'):
if el.tag.startswith('{'):
el.tag = el.tag.split('}', 1)[1]
return self
| 21,704 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.__str__
|
(self)
|
return ''.join([etree.tostring(e, encoding=str) for e in self])
|
xml representation of current nodes::
>>> xml = PyQuery(
... '<script><![[CDATA[ ]></script>', parser='html_fragments')
>>> print(str(xml))
<script><![[CDATA[ ]></script>
|
xml representation of current nodes::
| 329 | 338 |
def __str__(self):
"""xml representation of current nodes::
>>> xml = PyQuery(
... '<script><![[CDATA[ ]></script>', parser='html_fragments')
>>> print(str(xml))
<script><![[CDATA[ ]></script>
"""
return ''.join([etree.tostring(e, encoding=str) for e in self])
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L329-L338
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 100 |
[] | 0 | true | 74.758454 | 10 | 2 | 100 | 6 |
def __str__(self):
return ''.join([etree.tostring(e, encoding=str) for e in self])
| 21,705 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.__unicode__
|
(self)
|
return u''.join([etree.tostring(e, encoding=str)
for e in self])
|
xml representation of current nodes
|
xml representation of current nodes
| 340 | 343 |
def __unicode__(self):
"""xml representation of current nodes"""
return u''.join([etree.tostring(e, encoding=str)
for e in self])
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L340-L343
| 32 |
[
0,
1
] | 50 |
[
2
] | 25 | false | 74.758454 | 4 | 2 | 75 | 1 |
def __unicode__(self):
return u''.join([etree.tostring(e, encoding=str)
for e in self])
| 21,706 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.__html__
|
(self)
|
return u''.join([lxml.html.tostring(e, encoding=str)
for e in self])
|
html representation of current nodes::
>>> html = PyQuery(
... '<script><![[CDATA[ ]></script>', parser='html_fragments')
>>> print(html.__html__())
<script><![[CDATA[ ]></script>
|
html representation of current nodes::
| 345 | 355 |
def __html__(self):
"""html representation of current nodes::
>>> html = PyQuery(
... '<script><![[CDATA[ ]></script>', parser='html_fragments')
>>> print(html.__html__())
<script><![[CDATA[ ]></script>
"""
return u''.join([lxml.html.tostring(e, encoding=str)
for e in self])
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L345-L355
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
] | 100 |
[] | 0 | true | 74.758454 | 11 | 2 | 100 | 6 |
def __html__(self):
return u''.join([lxml.html.tostring(e, encoding=str)
for e in self])
| 21,707 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.__repr__
|
(self)
| 357 | 368 |
def __repr__(self):
r = []
try:
for el in self:
c = el.get('class')
c = c and '.' + '.'.join(c.split(' ')) or ''
id = el.get('id')
id = id and '#' + id or ''
r.append('<%s%s%s>' % (el.tag, id, c))
return '[' + (', '.join(r)) + ']'
except AttributeError:
return list.__repr__(self)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L357-L368
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 83.333333 |
[
10,
11
] | 16.666667 | false | 74.758454 | 12 | 7 | 83.333333 | 0 |
def __repr__(self):
r = []
try:
for el in self:
c = el.get('class')
c = c and '.' + '.'.join(c.split(' ')) or ''
id = el.get('id')
id = id and '#' + id or ''
r.append('<%s%s%s>' % (el.tag, id, c))
return '[' + (', '.join(r)) + ']'
except AttributeError:
return list.__repr__(self)
| 21,708 |
|||
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.root
|
(self)
|
return self[0].getroottree()
|
return the xml root element
|
return the xml root element
| 371 | 376 |
def root(self):
"""return the xml root element
"""
if self._parent is not no_default:
return self._parent[0].getroottree()
return self[0].getroottree()
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L371-L376
| 32 |
[
0,
1,
2,
3,
4,
5
] | 100 |
[] | 0 | true | 74.758454 | 6 | 2 | 100 | 1 |
def root(self):
if self._parent is not no_default:
return self._parent[0].getroottree()
return self[0].getroottree()
| 21,709 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.encoding
|
(self)
|
return the xml encoding of the root element
|
return the xml encoding of the root element
| 379 | 384 |
def encoding(self):
"""return the xml encoding of the root element
"""
root = self.root
if root is not None:
return self.root.docinfo.encoding
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L379-L384
| 32 |
[
0,
1,
2,
3,
4,
5
] | 100 |
[] | 0 | true | 74.758454 | 6 | 2 | 100 | 1 |
def encoding(self):
root = self.root
if root is not None:
return self.root.docinfo.encoding
| 21,710 |
|
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery._filter_only
|
(self, selector, elements, reverse=False, unique=False)
|
return self._copy(results, parent=self)
|
Filters the selection set only, as opposed to also including
descendants.
|
Filters the selection set only, as opposed to also including
descendants.
| 390 | 409 |
def _filter_only(self, selector, elements, reverse=False, unique=False):
"""Filters the selection set only, as opposed to also including
descendants.
"""
if selector is None:
results = elements
else:
xpath = self._css_to_xpath(selector, 'self::')
results = []
for tag in elements:
results.extend(tag.xpath(xpath, namespaces=self.namespaces))
if reverse:
results.reverse()
if unique:
result_list = results
results = []
for item in result_list:
if item not in results:
results.append(item)
return self._copy(results, parent=self)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L390-L409
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
13,
19
] | 70 |
[
12,
14,
15,
16,
17,
18
] | 30 | false | 74.758454 | 20 | 7 | 70 | 2 |
def _filter_only(self, selector, elements, reverse=False, unique=False):
if selector is None:
results = elements
else:
xpath = self._css_to_xpath(selector, 'self::')
results = []
for tag in elements:
results.extend(tag.xpath(xpath, namespaces=self.namespaces))
if reverse:
results.reverse()
if unique:
result_list = results
results = []
for item in result_list:
if item not in results:
results.append(item)
return self._copy(results, parent=self)
| 21,711 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.parent
|
(self, selector=None)
|
return self._filter_only(
selector,
[e.getparent() for e in self if e.getparent() is not None],
unique=True)
| 411 | 415 |
def parent(self, selector=None):
return self._filter_only(
selector,
[e.getparent() for e in self if e.getparent() is not None],
unique=True)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L411-L415
| 32 |
[
0
] | 20 |
[
1
] | 20 | false | 74.758454 | 5 | 2 | 80 | 0 |
def parent(self, selector=None):
return self._filter_only(
selector,
[e.getparent() for e in self if e.getparent() is not None],
unique=True)
| 21,712 |
||
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.prev
|
(self, selector=None)
|
return self._filter_only(
selector,
[e.getprevious() for e in self if e.getprevious() is not None])
| 417 | 420 |
def prev(self, selector=None):
return self._filter_only(
selector,
[e.getprevious() for e in self if e.getprevious() is not None])
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L417-L420
| 32 |
[
0
] | 25 |
[
1
] | 25 | false | 74.758454 | 4 | 2 | 75 | 0 |
def prev(self, selector=None):
return self._filter_only(
selector,
[e.getprevious() for e in self if e.getprevious() is not None])
| 21,713 |
||
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.next
|
(self, selector=None)
|
return self._filter_only(
selector,
[e.getnext() for e in self if e.getnext() is not None])
| 422 | 425 |
def next(self, selector=None):
return self._filter_only(
selector,
[e.getnext() for e in self if e.getnext() is not None])
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L422-L425
| 32 |
[
0
] | 25 |
[
1
] | 25 | false | 74.758454 | 4 | 2 | 75 | 0 |
def next(self, selector=None):
return self._filter_only(
selector,
[e.getnext() for e in self if e.getnext() is not None])
| 21,714 |
||
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery._traverse
|
(self, method)
| 427 | 432 |
def _traverse(self, method):
for e in self:
current = getattr(e, method)()
while current is not None:
yield current
current = getattr(current, method)()
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L427-L432
| 32 |
[
0,
1,
2,
3,
4,
5
] | 100 |
[] | 0 | true | 74.758454 | 6 | 3 | 100 | 0 |
def _traverse(self, method):
for e in self:
current = getattr(e, method)()
while current is not None:
yield current
current = getattr(current, method)()
| 21,715 |
|||
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery._traverse_parent_topdown
|
(self)
| 434 | 443 |
def _traverse_parent_topdown(self):
for e in self:
this_list = []
current = e.getparent()
while current is not None:
this_list.append(current)
current = current.getparent()
this_list.reverse()
for j in this_list:
yield j
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L434-L443
| 32 |
[
0
] | 10 |
[
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 90 | false | 74.758454 | 10 | 4 | 10 | 0 |
def _traverse_parent_topdown(self):
for e in self:
this_list = []
current = e.getparent()
while current is not None:
this_list.append(current)
current = current.getparent()
this_list.reverse()
for j in this_list:
yield j
| 21,716 |
|||
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery._next_all
|
(self)
|
return [e for e in self._traverse('getnext')]
| 445 | 446 |
def _next_all(self):
return [e for e in self._traverse('getnext')]
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L445-L446
| 32 |
[
0,
1
] | 100 |
[] | 0 | true | 74.758454 | 2 | 2 | 100 | 0 |
def _next_all(self):
return [e for e in self._traverse('getnext')]
| 21,717 |
||
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.next_all
|
(self, selector=None)
|
return self._filter_only(selector, self._next_all())
|
>>> h = '<span><p class="hello">Hi</p><p>Bye</p><img scr=""/></span>'
>>> d = PyQuery(h)
>>> d('p:last').next_all()
[<img>]
>>> d('p:last').nextAll()
[<img>]
|
>>> h = '<span><p class="hello">Hi</p><p>Bye</p><img scr=""/></span>'
>>> d = PyQuery(h)
>>> d('p:last').next_all()
[<img>]
>>> d('p:last').nextAll()
[<img>]
| 449 | 458 |
def next_all(self, selector=None):
"""
>>> h = '<span><p class="hello">Hi</p><p>Bye</p><img scr=""/></span>'
>>> d = PyQuery(h)
>>> d('p:last').next_all()
[<img>]
>>> d('p:last').nextAll()
[<img>]
"""
return self._filter_only(selector, self._next_all())
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L449-L458
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 100 |
[] | 0 | true | 74.758454 | 10 | 1 | 100 | 6 |
def next_all(self, selector=None):
return self._filter_only(selector, self._next_all())
| 21,718 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.next_until
|
(self, selector, filter_=None)
|
return self._filter_only(
filter_, [
e
for q in itertools.takewhile(
lambda q: not q.is_(selector), self.next_all().items())
for e in q
]
)
|
>>> h = '''
... <h2>Greeting 1</h2>
... <p>Hello!</p><p>World!</p>
... <h2>Greeting 2</h2><p>Bye!</p>
... '''
>>> d = PyQuery(h)
>>> d('h2:first').nextUntil('h2')
[<p>, <p>]
|
>>> h = '''
... <h2>Greeting 1</h2>
... <p>Hello!</p><p>World!</p>
... <h2>Greeting 2</h2><p>Bye!</p>
... '''
>>> d = PyQuery(h)
>>> d('h2:first').nextUntil('h2')
[<p>, <p>]
| 461 | 479 |
def next_until(self, selector, filter_=None):
"""
>>> h = '''
... <h2>Greeting 1</h2>
... <p>Hello!</p><p>World!</p>
... <h2>Greeting 2</h2><p>Bye!</p>
... '''
>>> d = PyQuery(h)
>>> d('h2:first').nextUntil('h2')
[<p>, <p>]
"""
return self._filter_only(
filter_, [
e
for q in itertools.takewhile(
lambda q: not q.is_(selector), self.next_all().items())
for e in q
]
)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L461-L479
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18
] | 100 |
[] | 0 | true | 74.758454 | 19 | 2 | 100 | 8 |
def next_until(self, selector, filter_=None):
return self._filter_only(
filter_, [
e
for q in itertools.takewhile(
lambda q: not q.is_(selector), self.next_all().items())
for e in q
]
)
| 21,719 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery._prev_all
|
(self)
|
return [e for e in self._traverse('getprevious')]
| 481 | 482 |
def _prev_all(self):
return [e for e in self._traverse('getprevious')]
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L481-L482
| 32 |
[
0
] | 50 |
[
1
] | 50 | false | 74.758454 | 2 | 2 | 50 | 0 |
def _prev_all(self):
return [e for e in self._traverse('getprevious')]
| 21,720 |
||
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.prev_all
|
(self, selector=None)
|
return self._filter_only(selector, self._prev_all(), reverse=True)
|
>>> h = '<span><p class="hello">Hi</p><p>Bye</p><img scr=""/></span>'
>>> d = PyQuery(h)
>>> d('p:last').prev_all()
[<p.hello>]
>>> d('p:last').prevAll()
[<p.hello>]
|
>>> h = '<span><p class="hello">Hi</p><p>Bye</p><img scr=""/></span>'
>>> d = PyQuery(h)
>>> d('p:last').prev_all()
[<p.hello>]
>>> d('p:last').prevAll()
[<p.hello>]
| 485 | 494 |
def prev_all(self, selector=None):
"""
>>> h = '<span><p class="hello">Hi</p><p>Bye</p><img scr=""/></span>'
>>> d = PyQuery(h)
>>> d('p:last').prev_all()
[<p.hello>]
>>> d('p:last').prevAll()
[<p.hello>]
"""
return self._filter_only(selector, self._prev_all(), reverse=True)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L485-L494
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 90 |
[
9
] | 10 | false | 74.758454 | 10 | 1 | 90 | 6 |
def prev_all(self, selector=None):
return self._filter_only(selector, self._prev_all(), reverse=True)
| 21,721 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.siblings
|
(self, selector=None)
|
return self._filter_only(selector, self._prev_all() + self._next_all())
|
>>> h = '<span><p class="hello">Hi</p><p>Bye</p><img scr=""/></span>'
>>> d = PyQuery(h)
>>> d('.hello').siblings()
[<p>, <img>]
>>> d('.hello').siblings('img')
[<img>]
|
>>> h = '<span><p class="hello">Hi</p><p>Bye</p><img scr=""/></span>'
>>> d = PyQuery(h)
>>> d('.hello').siblings()
[<p>, <img>]
>>> d('.hello').siblings('img')
[<img>]
| 496 | 506 |
def siblings(self, selector=None):
"""
>>> h = '<span><p class="hello">Hi</p><p>Bye</p><img scr=""/></span>'
>>> d = PyQuery(h)
>>> d('.hello').siblings()
[<p>, <img>]
>>> d('.hello').siblings('img')
[<img>]
"""
return self._filter_only(selector, self._prev_all() + self._next_all())
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L496-L506
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 90.909091 |
[
10
] | 9.090909 | false | 74.758454 | 11 | 1 | 90.909091 | 6 |
def siblings(self, selector=None):
return self._filter_only(selector, self._prev_all() + self._next_all())
| 21,722 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.parents
|
(self, selector=None)
|
return self._filter_only(
selector,
[e for e in self._traverse_parent_topdown()],
unique=True
)
|
>>> d = PyQuery('<span><p class="hello">Hi</p><p>Bye</p></span>')
>>> d('p').parents()
[<span>]
>>> d('.hello').parents('span')
[<span>]
>>> d('.hello').parents('p')
[]
|
>>> d = PyQuery('<span><p class="hello">Hi</p><p>Bye</p></span>')
>>> d('p').parents()
[<span>]
>>> d('.hello').parents('span')
[<span>]
>>> d('.hello').parents('p')
[]
| 508 | 522 |
def parents(self, selector=None):
"""
>>> d = PyQuery('<span><p class="hello">Hi</p><p>Bye</p></span>')
>>> d('p').parents()
[<span>]
>>> d('.hello').parents('span')
[<span>]
>>> d('.hello').parents('p')
[]
"""
return self._filter_only(
selector,
[e for e in self._traverse_parent_topdown()],
unique=True
)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L508-L522
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 66.666667 |
[
10
] | 6.666667 | false | 74.758454 | 15 | 2 | 93.333333 | 7 |
def parents(self, selector=None):
return self._filter_only(
selector,
[e for e in self._traverse_parent_topdown()],
unique=True
)
| 21,723 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.children
|
(self, selector=None)
|
return self._filter_only(selector, elements)
|
Filter elements that are direct children of self using optional
selector:
>>> d = PyQuery('<span><p class="hello">Hi</p><p>Bye</p></span>')
>>> d
[<span>]
>>> d.children()
[<p.hello>, <p>]
>>> d.children('.hello')
[<p.hello>]
|
Filter elements that are direct children of self using optional
selector:
| 524 | 537 |
def children(self, selector=None):
"""Filter elements that are direct children of self using optional
selector:
>>> d = PyQuery('<span><p class="hello">Hi</p><p>Bye</p></span>')
>>> d
[<span>]
>>> d.children()
[<p.hello>, <p>]
>>> d.children('.hello')
[<p.hello>]
"""
elements = [child for tag in self for child in tag.getchildren()]
return self._filter_only(selector, elements)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L524-L537
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13
] | 100 |
[] | 0 | true | 74.758454 | 14 | 2 | 100 | 10 |
def children(self, selector=None):
elements = [child for tag in self for child in tag.getchildren()]
return self._filter_only(selector, elements)
| 21,724 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.closest
|
(self, selector=None)
|
return self._copy(result, parent=self)
|
>>> d = PyQuery(
... '<div class="hello"><p>This is a '
... '<strong class="hello">test</strong></p></div>')
>>> d('strong').closest('div')
[<div.hello>]
>>> d('strong').closest('.hello')
[<strong.hello>]
>>> d('strong').closest('form')
[]
|
>>> d = PyQuery(
... '<div class="hello"><p>This is a '
... '<strong class="hello">test</strong></p></div>')
>>> d('strong').closest('div')
[<div.hello>]
>>> d('strong').closest('.hello')
[<strong.hello>]
>>> d('strong').closest('form')
[]
| 539 | 558 |
def closest(self, selector=None):
"""
>>> d = PyQuery(
... '<div class="hello"><p>This is a '
... '<strong class="hello">test</strong></p></div>')
>>> d('strong').closest('div')
[<div.hello>]
>>> d('strong').closest('.hello')
[<strong.hello>]
>>> d('strong').closest('form')
[]
"""
result = []
for current in self:
while (current is not None and
not self._copy(current).is_(selector)):
current = current.getparent()
if current is not None:
result.append(current)
return self._copy(result, parent=self)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L539-L558
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19
] | 100 |
[] | 0 | true | 74.758454 | 20 | 5 | 100 | 9 |
def closest(self, selector=None):
result = []
for current in self:
while (current is not None and
not self._copy(current).is_(selector)):
current = current.getparent()
if current is not None:
result.append(current)
return self._copy(result, parent=self)
| 21,725 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.contents
|
(self)
|
return self._copy(results, parent=self)
|
Return contents (with text nodes):
>>> d = PyQuery('hello <b>bold</b>')
>>> d.contents() # doctest: +ELLIPSIS
['hello ', <Element b at ...>]
|
Return contents (with text nodes):
| 560 | 572 |
def contents(self):
"""
Return contents (with text nodes):
>>> d = PyQuery('hello <b>bold</b>')
>>> d.contents() # doctest: +ELLIPSIS
['hello ', <Element b at ...>]
"""
results = []
for elem in self:
results.extend(elem.xpath('child::text()|child::*',
namespaces=self.namespaces))
return self._copy(results, parent=self)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L560-L572
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7
] | 61.538462 |
[
8,
9,
10,
12
] | 30.769231 | false | 74.758454 | 13 | 2 | 69.230769 | 5 |
def contents(self):
results = []
for elem in self:
results.extend(elem.xpath('child::text()|child::*',
namespaces=self.namespaces))
return self._copy(results, parent=self)
| 21,726 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.filter
|
(self, selector)
|
Filter elements in self using selector (string or function):
>>> d = PyQuery('<p class="hello">Hi</p><p>Bye</p>')
>>> d('p')
[<p.hello>, <p>]
>>> d('p').filter('.hello')
[<p.hello>]
>>> d('p').filter(lambda i: i == 1)
[<p>]
>>> d('p').filter(lambda i: PyQuery(this).text() == 'Hi')
[<p.hello>]
>>> d('p').filter(lambda i, this: PyQuery(this).text() == 'Hi')
[<p.hello>]
|
Filter elements in self using selector (string or function):
| 574 | 604 |
def filter(self, selector):
"""Filter elements in self using selector (string or function):
>>> d = PyQuery('<p class="hello">Hi</p><p>Bye</p>')
>>> d('p')
[<p.hello>, <p>]
>>> d('p').filter('.hello')
[<p.hello>]
>>> d('p').filter(lambda i: i == 1)
[<p>]
>>> d('p').filter(lambda i: PyQuery(this).text() == 'Hi')
[<p.hello>]
>>> d('p').filter(lambda i, this: PyQuery(this).text() == 'Hi')
[<p.hello>]
"""
if not hasattr(selector, '__call__'):
return self._filter_only(selector, self)
else:
elements = []
args = getargspec(callback)
try:
for i, this in enumerate(self):
if len(args) == 1:
selector.__globals__['this'] = this
if callback(selector, i, this):
elements.append(this)
finally:
f_globals = selector.__globals__
if 'this' in f_globals:
del f_globals['this']
return self._copy(elements, parent=self)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L574-L604
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30
] | 100 |
[] | 0 | true | 74.758454 | 31 | 6 | 100 | 13 |
def filter(self, selector):
if not hasattr(selector, '__call__'):
return self._filter_only(selector, self)
else:
elements = []
args = getargspec(callback)
try:
for i, this in enumerate(self):
if len(args) == 1:
selector.__globals__['this'] = this
if callback(selector, i, this):
elements.append(this)
finally:
f_globals = selector.__globals__
if 'this' in f_globals:
del f_globals['this']
return self._copy(elements, parent=self)
| 21,727 |
|
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.not_
|
(self, selector)
|
return self._copy([e for e in self if e not in exclude],
parent=self)
|
Return elements that don't match the given selector:
>>> d = PyQuery('<p class="hello">Hi</p><p>Bye</p><div></div>')
>>> d('p').not_('.hello')
[<p>]
|
Return elements that don't match the given selector:
| 606 | 615 |
def not_(self, selector):
"""Return elements that don't match the given selector:
>>> d = PyQuery('<p class="hello">Hi</p><p>Bye</p><div></div>')
>>> d('p').not_('.hello')
[<p>]
"""
exclude = set(self._copy(selector, self))
return self._copy([e for e in self if e not in exclude],
parent=self)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L606-L615
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 100 |
[] | 0 | true | 74.758454 | 10 | 2 | 100 | 5 |
def not_(self, selector):
exclude = set(self._copy(selector, self))
return self._copy([e for e in self if e not in exclude],
parent=self)
| 21,728 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.is_
|
(self, selector)
|
return bool(self._filter_only(selector, self))
|
Returns True if selector matches at least one current element, else
False:
>>> d = PyQuery('<p class="hello"><span>Hi</span></p><p>Bye</p>')
>>> d('p').eq(0).is_('.hello')
True
>>> d('p').eq(0).is_('span')
False
>>> d('p').eq(1).is_('.hello')
False
..
|
Returns True if selector matches at least one current element, else
False:
| 617 | 633 |
def is_(self, selector):
"""Returns True if selector matches at least one current element, else
False:
>>> d = PyQuery('<p class="hello"><span>Hi</span></p><p>Bye</p>')
>>> d('p').eq(0).is_('.hello')
True
>>> d('p').eq(0).is_('span')
False
>>> d('p').eq(1).is_('.hello')
False
..
"""
return bool(self._filter_only(selector, self))
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L617-L633
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16
] | 100 |
[] | 0 | true | 74.758454 | 17 | 1 | 100 | 14 |
def is_(self, selector):
return bool(self._filter_only(selector, self))
| 21,729 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.find
|
(self, selector)
|
return self._copy(elements, parent=self)
|
Find elements using selector traversing down from self:
>>> m = '<p><span><em>Whoah!</em></span></p><p><em> there</em></p>'
>>> d = PyQuery(m)
>>> d('p').find('em')
[<em>, <em>]
>>> d('p').eq(1).find('em')
[<em>]
|
Find elements using selector traversing down from self:
| 635 | 653 |
def find(self, selector):
"""Find elements using selector traversing down from self:
>>> m = '<p><span><em>Whoah!</em></span></p><p><em> there</em></p>'
>>> d = PyQuery(m)
>>> d('p').find('em')
[<em>, <em>]
>>> d('p').eq(1).find('em')
[<em>]
"""
xpath = self._css_to_xpath(selector)
results = [child.xpath(xpath, namespaces=self.namespaces)
for tag in self
for child in tag.getchildren()]
# Flatten the results
elements = []
for r in results:
elements.extend(r)
return self._copy(elements, parent=self)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L635-L653
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18
] | 100 |
[] | 0 | true | 74.758454 | 19 | 3 | 100 | 8 |
def find(self, selector):
xpath = self._css_to_xpath(selector)
results = [child.xpath(xpath, namespaces=self.namespaces)
for tag in self
for child in tag.getchildren()]
# Flatten the results
elements = []
for r in results:
elements.extend(r)
return self._copy(elements, parent=self)
| 21,730 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.eq
|
(self, index)
|
return self._copy(items, parent=self)
|
Return PyQuery of only the element with the provided index::
>>> d = PyQuery('<p class="hello">Hi</p><p>Bye</p><div></div>')
>>> d('p').eq(0)
[<p.hello>]
>>> d('p').eq(1)
[<p>]
>>> d('p').eq(2)
[]
..
|
Return PyQuery of only the element with the provided index::
| 655 | 674 |
def eq(self, index):
"""Return PyQuery of only the element with the provided index::
>>> d = PyQuery('<p class="hello">Hi</p><p>Bye</p><div></div>')
>>> d('p').eq(0)
[<p.hello>]
>>> d('p').eq(1)
[<p>]
>>> d('p').eq(2)
[]
..
"""
# Slicing will return empty list when index=-1
# we should handle out of bound by ourselves
try:
items = self[index]
except IndexError:
items = []
return self._copy(items, parent=self)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L655-L674
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
19
] | 90 |
[
17,
18
] | 10 | false | 74.758454 | 20 | 2 | 90 | 11 |
def eq(self, index):
# Slicing will return empty list when index=-1
# we should handle out of bound by ourselves
try:
items = self[index]
except IndexError:
items = []
return self._copy(items, parent=self)
| 21,731 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.each
|
(self, func)
|
return self
|
apply func on each nodes
|
apply func on each nodes
| 676 | 688 |
def each(self, func):
"""apply func on each nodes
"""
try:
for i, element in enumerate(self):
func.__globals__['this'] = element
if callback(func, i, element) is False:
break
finally:
f_globals = func.__globals__
if 'this' in f_globals:
del f_globals['this']
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L676-L688
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
8,
9,
10,
11,
12
] | 92.307692 |
[
7
] | 7.692308 | false | 74.758454 | 13 | 4 | 92.307692 | 1 |
def each(self, func):
try:
for i, element in enumerate(self):
func.__globals__['this'] = element
if callback(func, i, element) is False:
break
finally:
f_globals = func.__globals__
if 'this' in f_globals:
del f_globals['this']
return self
| 21,732 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.map
|
(self, func)
|
return self._copy(items, parent=self)
|
Returns a new PyQuery after transforming current items with func.
func should take two arguments - 'index' and 'element'. Elements can
also be referred to as 'this' inside of func::
>>> d = PyQuery('<p class="hello">Hi there</p><p>Bye</p><br />')
>>> d('p').map(lambda i, e: PyQuery(e).text())
['Hi there', 'Bye']
>>> d('p').map(lambda i, e: len(PyQuery(this).text()))
[8, 3]
>>> d('p').map(lambda i, e: PyQuery(this).text().split())
['Hi', 'there', 'Bye']
|
Returns a new PyQuery after transforming current items with func.
| 690 | 721 |
def map(self, func):
"""Returns a new PyQuery after transforming current items with func.
func should take two arguments - 'index' and 'element'. Elements can
also be referred to as 'this' inside of func::
>>> d = PyQuery('<p class="hello">Hi there</p><p>Bye</p><br />')
>>> d('p').map(lambda i, e: PyQuery(e).text())
['Hi there', 'Bye']
>>> d('p').map(lambda i, e: len(PyQuery(this).text()))
[8, 3]
>>> d('p').map(lambda i, e: PyQuery(this).text().split())
['Hi', 'there', 'Bye']
"""
items = []
try:
for i, element in enumerate(self):
func.__globals__['this'] = element
result = callback(func, i, element)
if result is not None:
if not isinstance(result, list):
items.append(result)
else:
items.extend(result)
finally:
f_globals = func.__globals__
if 'this' in f_globals:
del f_globals['this']
return self._copy(items, parent=self)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L690-L721
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
27,
28,
29,
30,
31
] | 96.875 |
[
26
] | 3.125 | false | 74.758454 | 32 | 5 | 96.875 | 14 |
def map(self, func):
items = []
try:
for i, element in enumerate(self):
func.__globals__['this'] = element
result = callback(func, i, element)
if result is not None:
if not isinstance(result, list):
items.append(result)
else:
items.extend(result)
finally:
f_globals = func.__globals__
if 'this' in f_globals:
del f_globals['this']
return self._copy(items, parent=self)
| 21,733 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.length
|
(self)
|
return len(self)
| 724 | 725 |
def length(self):
return len(self)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L724-L725
| 32 |
[
0,
1
] | 100 |
[] | 0 | true | 74.758454 | 2 | 1 | 100 | 0 |
def length(self):
return len(self)
| 21,734 |
||
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.size
|
(self)
|
return len(self)
| 727 | 728 |
def size(self):
return len(self)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L727-L728
| 32 |
[
0
] | 50 |
[
1
] | 50 | false | 74.758454 | 2 | 1 | 50 | 0 |
def size(self):
return len(self)
| 21,735 |
||
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.end
|
(self)
|
return self._parent
|
Break out of a level of traversal and return to the parent level.
>>> m = '<p><span><em>Whoah!</em></span></p><p><em> there</em></p>'
>>> d = PyQuery(m)
>>> d('p').eq(1).find('em').end().end()
[<p>, <p>]
|
Break out of a level of traversal and return to the parent level.
| 730 | 738 |
def end(self):
"""Break out of a level of traversal and return to the parent level.
>>> m = '<p><span><em>Whoah!</em></span></p><p><em> there</em></p>'
>>> d = PyQuery(m)
>>> d('p').eq(1).find('em').end().end()
[<p>, <p>]
"""
return self._parent
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L730-L738
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 100 |
[] | 0 | true | 74.758454 | 9 | 1 | 100 | 6 |
def end(self):
return self._parent
| 21,736 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.attr
|
(self, *args, **kwargs)
|
return self
|
Attributes manipulation
|
Attributes manipulation
| 743 | 777 |
def attr(self, *args, **kwargs):
"""Attributes manipulation
"""
mapping = {'class_': 'class', 'for_': 'for'}
attr = value = no_default
length = len(args)
if length == 1:
attr = args[0]
attr = mapping.get(attr, attr)
elif length == 2:
attr, value = args
attr = mapping.get(attr, attr)
elif kwargs:
attr = {}
for k, v in kwargs.items():
attr[mapping.get(k, k)] = v
else:
raise ValueError('Invalid arguments %s %s' % (args, kwargs))
if not self:
return None
elif isinstance(attr, dict):
for tag in self:
for key, value in attr.items():
tag.set(key, value)
elif value is no_default:
return self[0].get(attr)
elif value is None:
return self.remove_attr(attr)
else:
for tag in self:
tag.set(attr, value)
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L743-L777
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
20,
21,
22,
23,
27,
28,
29,
31,
32,
33,
34
] | 71.428571 |
[
14,
15,
16,
17,
19,
24,
25,
26,
30
] | 25.714286 | false | 74.758454 | 35 | 12 | 74.285714 | 1 |
def attr(self, *args, **kwargs):
mapping = {'class_': 'class', 'for_': 'for'}
attr = value = no_default
length = len(args)
if length == 1:
attr = args[0]
attr = mapping.get(attr, attr)
elif length == 2:
attr, value = args
attr = mapping.get(attr, attr)
elif kwargs:
attr = {}
for k, v in kwargs.items():
attr[mapping.get(k, k)] = v
else:
raise ValueError('Invalid arguments %s %s' % (args, kwargs))
if not self:
return None
elif isinstance(attr, dict):
for tag in self:
for key, value in attr.items():
tag.set(key, value)
elif value is no_default:
return self[0].get(attr)
elif value is None:
return self.remove_attr(attr)
else:
for tag in self:
tag.set(attr, value)
return self
| 21,737 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.remove_attr
|
(self, name)
|
return self
|
Remove an attribute::
>>> d = PyQuery('<div id="myid"></div>')
>>> d.remove_attr('id')
[<div>]
>>> d.removeAttr('id')
[<div>]
..
|
Remove an attribute::
| 780 | 796 |
def remove_attr(self, name):
"""Remove an attribute::
>>> d = PyQuery('<div id="myid"></div>')
>>> d.remove_attr('id')
[<div>]
>>> d.removeAttr('id')
[<div>]
..
"""
for tag in self:
try:
del tag.attrib[name]
except KeyError:
pass
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L780-L796
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16
] | 100 |
[] | 0 | true | 74.758454 | 17 | 3 | 100 | 9 |
def remove_attr(self, name):
for tag in self:
try:
del tag.attrib[name]
except KeyError:
pass
return self
| 21,738 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.height
|
(self, value=no_default)
|
return self.attr('height', value)
|
set/get height of element
|
set/get height of element
| 803 | 806 |
def height(self, value=no_default):
"""set/get height of element
"""
return self.attr('height', value)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L803-L806
| 32 |
[
0,
1,
2
] | 75 |
[
3
] | 25 | false | 74.758454 | 4 | 1 | 75 | 1 |
def height(self, value=no_default):
return self.attr('height', value)
| 21,739 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.width
|
(self, value=no_default)
|
return self.attr('width', value)
|
set/get width of element
|
set/get width of element
| 808 | 811 |
def width(self, value=no_default):
"""set/get width of element
"""
return self.attr('width', value)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L808-L811
| 32 |
[
0,
1,
2
] | 75 |
[
3
] | 25 | false | 74.758454 | 4 | 1 | 75 | 1 |
def width(self, value=no_default):
return self.attr('width', value)
| 21,740 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.has_class
|
(self, name)
|
return self.is_('.%s' % name)
|
Return True if element has class::
>>> d = PyQuery('<div class="myclass"></div>')
>>> d.has_class('myclass')
True
>>> d.hasClass('myclass')
True
..
|
Return True if element has class::
| 814 | 825 |
def has_class(self, name):
"""Return True if element has class::
>>> d = PyQuery('<div class="myclass"></div>')
>>> d.has_class('myclass')
True
>>> d.hasClass('myclass')
True
..
"""
return self.is_('.%s' % name)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L814-L825
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
] | 91.666667 |
[
11
] | 8.333333 | false | 74.758454 | 12 | 1 | 91.666667 | 9 |
def has_class(self, name):
return self.is_('.%s' % name)
| 21,741 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.add_class
|
(self, value)
|
return self
|
Add a css class to elements::
>>> d = PyQuery('<div></div>')
>>> d.add_class('myclass')
[<div.myclass>]
>>> d.addClass('myclass')
[<div.myclass>]
..
|
Add a css class to elements::
| 828 | 844 |
def add_class(self, value):
"""Add a css class to elements::
>>> d = PyQuery('<div></div>')
>>> d.add_class('myclass')
[<div.myclass>]
>>> d.addClass('myclass')
[<div.myclass>]
..
"""
for tag in self:
values = value.split(' ')
classes = (tag.get('class') or '').split()
classes += [v for v in values if v not in classes]
tag.set('class', ' '.join(classes))
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L828-L844
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
] | 64.705882 |
[
11,
12,
13,
14,
15,
16
] | 35.294118 | false | 74.758454 | 17 | 4 | 64.705882 | 9 |
def add_class(self, value):
for tag in self:
values = value.split(' ')
classes = (tag.get('class') or '').split()
classes += [v for v in values if v not in classes]
tag.set('class', ' '.join(classes))
return self
| 21,742 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.remove_class
|
(self, value)
|
return self
|
Remove a css class to elements::
>>> d = PyQuery('<div class="myclass"></div>')
>>> d.remove_class('myclass')
[<div>]
>>> d.removeClass('myclass')
[<div>]
..
|
Remove a css class to elements::
| 847 | 868 |
def remove_class(self, value):
"""Remove a css class to elements::
>>> d = PyQuery('<div class="myclass"></div>')
>>> d.remove_class('myclass')
[<div>]
>>> d.removeClass('myclass')
[<div>]
..
"""
for tag in self:
values = value.split(' ')
classes = set((tag.get('class') or '').split())
classes.difference_update(values)
classes.difference_update([''])
classes = ' '.join(classes)
if classes.strip():
tag.set('class', classes)
elif tag.get('class'):
tag.set('class', classes)
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L847-L868
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
19,
21
] | 90.909091 |
[
18,
20
] | 9.090909 | false | 74.758454 | 22 | 5 | 90.909091 | 9 |
def remove_class(self, value):
for tag in self:
values = value.split(' ')
classes = set((tag.get('class') or '').split())
classes.difference_update(values)
classes.difference_update([''])
classes = ' '.join(classes)
if classes.strip():
tag.set('class', classes)
elif tag.get('class'):
tag.set('class', classes)
return self
| 21,743 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.toggle_class
|
(self, value)
|
return self
|
Toggle a css class to elements
>>> d = PyQuery('<div></div>')
>>> d.toggle_class('myclass')
[<div.myclass>]
>>> d.toggleClass('myclass')
[<div>]
|
Toggle a css class to elements
| 871 | 889 |
def toggle_class(self, value):
"""Toggle a css class to elements
>>> d = PyQuery('<div></div>')
>>> d.toggle_class('myclass')
[<div.myclass>]
>>> d.toggleClass('myclass')
[<div>]
"""
for tag in self:
values = value.split(' ')
classes = (tag.get('class') or '').split()
values_to_add = [v for v in values if v not in classes]
values_to_del = [v for v in values if v in classes]
classes = [v for v in classes if v not in values_to_del]
classes += values_to_add
tag.set('class', ' '.join(classes))
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L871-L889
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 52.631579 |
[
10,
11,
12,
13,
14,
15,
16,
17,
18
] | 47.368421 | false | 74.758454 | 19 | 6 | 52.631579 | 7 |
def toggle_class(self, value):
for tag in self:
values = value.split(' ')
classes = (tag.get('class') or '').split()
values_to_add = [v for v in values if v not in classes]
values_to_del = [v for v in values if v in classes]
classes = [v for v in classes if v not in values_to_del]
classes += values_to_add
tag.set('class', ' '.join(classes))
return self
| 21,744 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.css
|
(self, *args, **kwargs)
|
return self
|
css attributes manipulation
|
css attributes manipulation
| 891 | 928 |
def css(self, *args, **kwargs):
"""css attributes manipulation
"""
attr = value = no_default
length = len(args)
if length == 1:
attr = args[0]
elif length == 2:
attr, value = args
elif kwargs:
attr = kwargs
else:
raise ValueError('Invalid arguments %s %s' % (args, kwargs))
if isinstance(attr, dict):
for tag in self:
stripped_keys = [key.strip().replace('_', '-')
for key in attr.keys()]
current = [el.strip()
for el in (tag.get('style') or '').split(';')
if el.strip()
and not el.split(':')[0].strip() in stripped_keys]
for key, value in attr.items():
key = key.replace('_', '-')
current.append('%s: %s' % (key, value))
tag.set('style', '; '.join(current))
elif isinstance(value, basestring):
attr = attr.replace('_', '-')
for tag in self:
current = [
el.strip()
for el in (tag.get('style') or '').split(';')
if (el.strip() and
not el.split(':')[0].strip() == attr.strip())]
current.append('%s: %s' % (attr, value))
tag.set('style', '; '.join(current))
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L891-L928
| 32 |
[
0,
1,
2,
3
] | 10.526316 |
[
4,
5,
6,
7,
8,
9,
10,
11,
13,
15,
16,
17,
19,
23,
24,
25,
26,
27,
28,
29,
30,
35,
36,
37
] | 63.157895 | false | 74.758454 | 38 | 16 | 36.842105 | 1 |
def css(self, *args, **kwargs):
attr = value = no_default
length = len(args)
if length == 1:
attr = args[0]
elif length == 2:
attr, value = args
elif kwargs:
attr = kwargs
else:
raise ValueError('Invalid arguments %s %s' % (args, kwargs))
if isinstance(attr, dict):
for tag in self:
stripped_keys = [key.strip().replace('_', '-')
for key in attr.keys()]
current = [el.strip()
for el in (tag.get('style') or '').split(';')
if el.strip()
and not el.split(':')[0].strip() in stripped_keys]
for key, value in attr.items():
key = key.replace('_', '-')
current.append('%s: %s' % (key, value))
tag.set('style', '; '.join(current))
elif isinstance(value, basestring):
attr = attr.replace('_', '-')
for tag in self:
current = [
el.strip()
for el in (tag.get('style') or '').split(';')
if (el.strip() and
not el.split(':')[0].strip() == attr.strip())]
current.append('%s: %s' % (attr, value))
tag.set('style', '; '.join(current))
return self
| 21,745 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.hide
|
(self)
|
return self.css('display', 'none')
|
Add display:none to elements style:
>>> print(PyQuery('<div style="display:none;"/>').hide())
<div style="display: none"/>
|
Add display:none to elements style:
| 935 | 942 |
def hide(self):
"""Add display:none to elements style:
>>> print(PyQuery('<div style="display:none;"/>').hide())
<div style="display: none"/>
"""
return self.css('display', 'none')
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L935-L942
| 32 |
[
0,
1,
2,
3,
4,
5,
6
] | 87.5 |
[
7
] | 12.5 | false | 74.758454 | 8 | 1 | 87.5 | 4 |
def hide(self):
return self.css('display', 'none')
| 21,746 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.show
|
(self)
|
return self.css('display', 'block')
|
Add display:block to elements style:
>>> print(PyQuery('<div />').show())
<div style="display: block"/>
|
Add display:block to elements style:
| 944 | 951 |
def show(self):
"""Add display:block to elements style:
>>> print(PyQuery('<div />').show())
<div style="display: block"/>
"""
return self.css('display', 'block')
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L944-L951
| 32 |
[
0,
1,
2,
3,
4,
5,
6
] | 87.5 |
[
7
] | 12.5 | false | 74.758454 | 8 | 1 | 87.5 | 4 |
def show(self):
return self.css('display', 'block')
| 21,747 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.val
|
(self, value=no_default)
|
Set the attribute value::
>>> d = PyQuery('<input />')
>>> d.val('Youhou')
[<input>]
Get the attribute value::
>>> d.val()
'Youhou'
Set the selected values for a `select` element with the `multiple`
attribute::
>>> d = PyQuery('''
... <select multiple>
... <option value="you"><option value="hou">
... </select>
... ''')
>>> d.val(['you', 'hou'])
[<select>]
Get the selected values for a `select` element with the `multiple`
attribute::
>>> d.val()
['you', 'hou']
|
Set the attribute value::
| 956 | 1,051 |
def val(self, value=no_default):
"""Set the attribute value::
>>> d = PyQuery('<input />')
>>> d.val('Youhou')
[<input>]
Get the attribute value::
>>> d.val()
'Youhou'
Set the selected values for a `select` element with the `multiple`
attribute::
>>> d = PyQuery('''
... <select multiple>
... <option value="you"><option value="hou">
... </select>
... ''')
>>> d.val(['you', 'hou'])
[<select>]
Get the selected values for a `select` element with the `multiple`
attribute::
>>> d.val()
['you', 'hou']
"""
def _get_value(tag):
# <textarea>
if tag.tag == 'textarea':
return self._copy(tag).html()
# <select>
elif tag.tag == 'select':
if 'multiple' in tag.attrib:
# Only extract value if selected
selected = self._copy(tag)('option[selected]')
# Rebuild list to avoid serialization error
return list(selected.map(
lambda _, o: self._copy(o).attr('value')
))
selected_option = self._copy(tag)('option[selected]:last')
if selected_option:
return selected_option.attr('value')
else:
return self._copy(tag)('option').attr('value')
# <input type="checkbox"> or <input type="radio">
elif self.is_(':checkbox,:radio'):
val = self._copy(tag).attr('value')
if val is None:
return 'on'
else:
return val
# <input>
elif tag.tag == 'input':
val = self._copy(tag).attr('value')
return val.replace('\n', '') if val else ''
# everything else.
return self._copy(tag).attr('value') or ''
def _set_value(pq, value):
for tag in pq:
# <select>
if tag.tag == 'select':
if not isinstance(value, list):
value = [value]
def _make_option_selected(_, elem):
pq = self._copy(elem)
if pq.attr('value') in value:
pq.attr('selected', 'selected')
if 'multiple' not in tag.attrib:
del value[:] # Ensure it toggles first match
else:
pq.removeAttr('selected')
self._copy(tag)('option').each(_make_option_selected)
continue
# Stringify array
if isinstance(value, list):
value = ','.join(value)
# <textarea>
if tag.tag == 'textarea':
self._copy(tag).text(value)
continue
# <input> and everything else.
self._copy(tag).attr('value', value)
if value is no_default:
if len(self):
return _get_value(self[0])
else:
_set_value(self, value)
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L956-L1051
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59,
61,
62,
63,
64,
65,
66,
67,
68,
69,
70,
71,
72,
73,
74,
75,
76,
77,
78,
79,
80,
81,
82,
83,
84,
85,
86,
87,
88,
89,
90,
91,
92,
93,
94,
95
] | 98.958333 |
[
60
] | 1.041667 | false | 74.758454 | 96 | 21 | 98.958333 | 27 |
def val(self, value=no_default):
def _get_value(tag):
# <textarea>
if tag.tag == 'textarea':
return self._copy(tag).html()
# <select>
elif tag.tag == 'select':
if 'multiple' in tag.attrib:
# Only extract value if selected
selected = self._copy(tag)('option[selected]')
# Rebuild list to avoid serialization error
return list(selected.map(
lambda _, o: self._copy(o).attr('value')
))
selected_option = self._copy(tag)('option[selected]:last')
if selected_option:
return selected_option.attr('value')
else:
return self._copy(tag)('option').attr('value')
# <input type="checkbox"> or <input type="radio">
elif self.is_(':checkbox,:radio'):
val = self._copy(tag).attr('value')
if val is None:
return 'on'
else:
return val
# <input>
elif tag.tag == 'input':
val = self._copy(tag).attr('value')
return val.replace('\n', '') if val else ''
# everything else.
return self._copy(tag).attr('value') or ''
def _set_value(pq, value):
for tag in pq:
# <select>
if tag.tag == 'select':
if not isinstance(value, list):
value = [value]
def _make_option_selected(_, elem):
pq = self._copy(elem)
if pq.attr('value') in value:
pq.attr('selected', 'selected')
if 'multiple' not in tag.attrib:
del value[:] # Ensure it toggles first match
else:
pq.removeAttr('selected')
self._copy(tag)('option').each(_make_option_selected)
continue
# Stringify array
if isinstance(value, list):
value = ','.join(value)
# <textarea>
if tag.tag == 'textarea':
self._copy(tag).text(value)
continue
# <input> and everything else.
self._copy(tag).attr('value', value)
if value is no_default:
if len(self):
return _get_value(self[0])
else:
_set_value(self, value)
return self
| 21,748 |
|
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.html
|
(self, value=no_default, **kwargs)
|
return self
|
Get or set the html representation of sub nodes.
Get the text value::
>>> d = PyQuery('<div><span>toto</span></div>')
>>> print(d.html())
<span>toto</span>
Extra args are passed to ``lxml.etree.tostring``::
>>> d = PyQuery('<div><span></span></div>')
>>> print(d.html())
<span/>
>>> print(d.html(method='html'))
<span></span>
Set the text value::
>>> d.html('<span>Youhou !</span>')
[<div>]
>>> print(d)
<div><span>Youhou !</span></div>
|
Get or set the html representation of sub nodes.
| 1,053 | 1,110 |
def html(self, value=no_default, **kwargs):
"""Get or set the html representation of sub nodes.
Get the text value::
>>> d = PyQuery('<div><span>toto</span></div>')
>>> print(d.html())
<span>toto</span>
Extra args are passed to ``lxml.etree.tostring``::
>>> d = PyQuery('<div><span></span></div>')
>>> print(d.html())
<span/>
>>> print(d.html(method='html'))
<span></span>
Set the text value::
>>> d.html('<span>Youhou !</span>')
[<div>]
>>> print(d)
<div><span>Youhou !</span></div>
"""
if value is no_default:
if not self:
return None
tag = self[0]
children = tag.getchildren()
html = escape(tag.text or '', quote=False)
if not children:
return html
if 'encoding' not in kwargs:
kwargs['encoding'] = str
html += u''.join([etree.tostring(e, **kwargs)
for e in children])
return html
else:
if isinstance(value, self.__class__):
new_html = str(value)
elif isinstance(value, basestring):
new_html = value
elif not value:
new_html = ''
else:
raise ValueError(type(value))
for tag in self:
for child in tag.getchildren():
tag.remove(child)
root = fromstring(
u'<root>' + new_html + u'</root>',
self.parser)[0]
children = root.getchildren()
if children:
tag.extend(children)
tag.text = root.text
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L1053-L1110
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
40,
41,
46,
47,
48,
50,
51,
52,
53,
54,
55,
56,
57
] | 87.931034 |
[
26,
39,
42,
43,
45,
49
] | 10.344828 | false | 74.758454 | 58 | 13 | 89.655172 | 22 |
def html(self, value=no_default, **kwargs):
if value is no_default:
if not self:
return None
tag = self[0]
children = tag.getchildren()
html = escape(tag.text or '', quote=False)
if not children:
return html
if 'encoding' not in kwargs:
kwargs['encoding'] = str
html += u''.join([etree.tostring(e, **kwargs)
for e in children])
return html
else:
if isinstance(value, self.__class__):
new_html = str(value)
elif isinstance(value, basestring):
new_html = value
elif not value:
new_html = ''
else:
raise ValueError(type(value))
for tag in self:
for child in tag.getchildren():
tag.remove(child)
root = fromstring(
u'<root>' + new_html + u'</root>',
self.parser)[0]
children = root.getchildren()
if children:
tag.extend(children)
tag.text = root.text
return self
| 21,749 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.outer_html
|
(self, method="html")
|
return etree.tostring(e0, encoding=str, method=method)
|
Get the html representation of the first selected element::
>>> d = PyQuery('<div><span class="red">toto</span> rocks</div>')
>>> print(d('span'))
<span class="red">toto</span> rocks
>>> print(d('span').outer_html())
<span class="red">toto</span>
>>> print(d('span').outerHtml())
<span class="red">toto</span>
>>> S = PyQuery('<p>Only <b>me</b> & myself</p>')
>>> print(S('b').outer_html())
<b>me</b>
..
|
Get the html representation of the first selected element::
| 1,113 | 1,137 |
def outer_html(self, method="html"):
"""Get the html representation of the first selected element::
>>> d = PyQuery('<div><span class="red">toto</span> rocks</div>')
>>> print(d('span'))
<span class="red">toto</span> rocks
>>> print(d('span').outer_html())
<span class="red">toto</span>
>>> print(d('span').outerHtml())
<span class="red">toto</span>
>>> S = PyQuery('<p>Only <b>me</b> & myself</p>')
>>> print(S('b').outer_html())
<b>me</b>
..
"""
if not self:
return None
e0 = self[0]
if e0.tail:
e0 = deepcopy(e0)
e0.tail = ''
return etree.tostring(e0, encoding=str, method=method)
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L1113-L1137
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
20,
21,
22,
23,
24
] | 96 |
[
19
] | 4 | false | 74.758454 | 25 | 3 | 96 | 15 |
def outer_html(self, method="html"):
if not self:
return None
e0 = self[0]
if e0.tail:
e0 = deepcopy(e0)
e0.tail = ''
return etree.tostring(e0, encoding=str, method=method)
| 21,750 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.text
|
(self, value=no_default, **kwargs)
|
return self
|
Get or set the text representation of sub nodes.
Get the text value::
>>> doc = PyQuery('<div><span>toto</span><span>tata</span></div>')
>>> print(doc.text())
tototata
>>> doc = PyQuery('''<div><span>toto</span>
... <span>tata</span></div>''')
>>> print(doc.text())
toto tata
Get the text value, without squashing newlines::
>>> doc = PyQuery('''<div><span>toto</span>
... <span>tata</span></div>''')
>>> print(doc.text(squash_space=False))
toto
tata
Set the text value::
>>> doc.text('Youhou !')
[<div>]
>>> print(doc)
<div>Youhou !</div>
|
Get or set the text representation of sub nodes.
| 1,139 | 1,181 |
def text(self, value=no_default, **kwargs):
"""Get or set the text representation of sub nodes.
Get the text value::
>>> doc = PyQuery('<div><span>toto</span><span>tata</span></div>')
>>> print(doc.text())
tototata
>>> doc = PyQuery('''<div><span>toto</span>
... <span>tata</span></div>''')
>>> print(doc.text())
toto tata
Get the text value, without squashing newlines::
>>> doc = PyQuery('''<div><span>toto</span>
... <span>tata</span></div>''')
>>> print(doc.text(squash_space=False))
toto
tata
Set the text value::
>>> doc.text('Youhou !')
[<div>]
>>> print(doc)
<div>Youhou !</div>
"""
if value is no_default:
if not self:
return ''
return ' '.join(
self._copy(tag).html() if tag.tag == 'textarea' else
extract_text(tag, **kwargs) for tag in self
)
for tag in self:
for child in tag.getchildren():
tag.remove(child)
tag.text = value
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L1139-L1181
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42
] | 100 |
[] | 0 | true | 74.758454 | 43 | 5 | 100 | 26 |
def text(self, value=no_default, **kwargs):
if value is no_default:
if not self:
return ''
return ' '.join(
self._copy(tag).html() if tag.tag == 'textarea' else
extract_text(tag, **kwargs) for tag in self
)
for tag in self:
for child in tag.getchildren():
tag.remove(child)
tag.text = value
return self
| 21,751 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery._get_root
|
(self, value)
|
return root, root_text
| 1,187 | 1,202 |
def _get_root(self, value):
if isinstance(value, basestring):
root = fromstring(u'<root>' + value + u'</root>',
self.parser)[0]
elif isinstance(value, etree._Element):
root = self._copy(value)
elif isinstance(value, PyQuery):
root = value
else:
raise TypeError(
'Value must be string, PyQuery or Element. Got %r' % value)
if hasattr(root, 'text') and isinstance(root.text, basestring):
root_text = root.text
else:
root_text = ''
return root, root_text
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L1187-L1202
| 32 |
[
0,
1,
2,
11,
12,
14,
15
] | 43.75 |
[
4,
5,
6,
7,
9
] | 31.25 | false | 74.758454 | 16 | 6 | 68.75 | 0 |
def _get_root(self, value):
if isinstance(value, basestring):
root = fromstring(u'<root>' + value + u'</root>',
self.parser)[0]
elif isinstance(value, etree._Element):
root = self._copy(value)
elif isinstance(value, PyQuery):
root = value
else:
raise TypeError(
'Value must be string, PyQuery or Element. Got %r' % value)
if hasattr(root, 'text') and isinstance(root.text, basestring):
root_text = root.text
else:
root_text = ''
return root, root_text
| 21,752 |
||
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.append
|
(self, value)
|
return self
|
append value to each nodes
|
append value to each nodes
| 1,204 | 1,221 |
def append(self, value):
"""append value to each nodes
"""
root, root_text = self._get_root(value)
for i, tag in enumerate(self):
if len(tag) > 0: # if the tag has children
last_child = tag[-1]
if not last_child.tail:
last_child.tail = ''
last_child.tail += root_text
else:
if not tag.text:
tag.text = ''
tag.text += root_text
if i > 0:
root = deepcopy(list(root))
tag.extend(root)
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L1204-L1221
| 32 |
[
0,
1,
2
] | 16.666667 |
[
3,
4,
5,
6,
7,
8,
9,
11,
12,
13,
14,
15,
16,
17
] | 77.777778 | false | 74.758454 | 18 | 6 | 22.222222 | 1 |
def append(self, value):
root, root_text = self._get_root(value)
for i, tag in enumerate(self):
if len(tag) > 0: # if the tag has children
last_child = tag[-1]
if not last_child.tail:
last_child.tail = ''
last_child.tail += root_text
else:
if not tag.text:
tag.text = ''
tag.text += root_text
if i > 0:
root = deepcopy(list(root))
tag.extend(root)
return self
| 21,753 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.append_to
|
(self, value)
|
return self
|
append nodes to value
|
append nodes to value
| 1,224 | 1,228 |
def append_to(self, value):
"""append nodes to value
"""
value.append(self)
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L1224-L1228
| 32 |
[
0,
1,
2
] | 60 |
[
3,
4
] | 40 | false | 74.758454 | 5 | 1 | 60 | 1 |
def append_to(self, value):
value.append(self)
return self
| 21,754 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.prepend
|
(self, value)
|
return self
|
prepend value to nodes
|
prepend value to nodes
| 1,230 | 1,246 |
def prepend(self, value):
"""prepend value to nodes
"""
root, root_text = self._get_root(value)
for i, tag in enumerate(self):
if not tag.text:
tag.text = ''
if len(root) > 0:
root[-1].tail = tag.text
tag.text = root_text
else:
tag.text = root_text + tag.text
if i > 0:
root = deepcopy(list(root))
tag[:0] = root
root = tag[:len(root)]
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L1230-L1246
| 32 |
[
0,
1,
2
] | 17.647059 |
[
3,
4,
5,
6,
7,
8,
9,
11,
12,
13,
14,
15,
16
] | 76.470588 | false | 74.758454 | 17 | 5 | 23.529412 | 1 |
def prepend(self, value):
root, root_text = self._get_root(value)
for i, tag in enumerate(self):
if not tag.text:
tag.text = ''
if len(root) > 0:
root[-1].tail = tag.text
tag.text = root_text
else:
tag.text = root_text + tag.text
if i > 0:
root = deepcopy(list(root))
tag[:0] = root
root = tag[:len(root)]
return self
| 21,755 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.prepend_to
|
(self, value)
|
return self
|
prepend nodes to value
|
prepend nodes to value
| 1,249 | 1,253 |
def prepend_to(self, value):
"""prepend nodes to value
"""
value.prepend(self)
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L1249-L1253
| 32 |
[
0,
1,
2
] | 60 |
[
3,
4
] | 40 | false | 74.758454 | 5 | 1 | 60 | 1 |
def prepend_to(self, value):
value.prepend(self)
return self
| 21,756 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.after
|
(self, value)
|
return self
|
add value after nodes
|
add value after nodes
| 1,255 | 1,269 |
def after(self, value):
"""add value after nodes
"""
root, root_text = self._get_root(value)
for i, tag in enumerate(self):
if not tag.tail:
tag.tail = ''
tag.tail += root_text
if i > 0:
root = deepcopy(list(root))
parent = tag.getparent()
index = parent.index(tag) + 1
parent[index:index] = root
root = parent[index:len(root)]
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L1255-L1269
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
10,
11,
12,
13,
14
] | 93.333333 |
[
9
] | 6.666667 | false | 74.758454 | 15 | 4 | 93.333333 | 1 |
def after(self, value):
root, root_text = self._get_root(value)
for i, tag in enumerate(self):
if not tag.tail:
tag.tail = ''
tag.tail += root_text
if i > 0:
root = deepcopy(list(root))
parent = tag.getparent()
index = parent.index(tag) + 1
parent[index:index] = root
root = parent[index:len(root)]
return self
| 21,757 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.insert_after
|
(self, value)
|
return self
|
insert nodes after value
|
insert nodes after value
| 1,272 | 1,276 |
def insert_after(self, value):
"""insert nodes after value
"""
value.after(self)
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L1272-L1276
| 32 |
[
0,
1,
2
] | 60 |
[
3,
4
] | 40 | false | 74.758454 | 5 | 1 | 60 | 1 |
def insert_after(self, value):
value.after(self)
return self
| 21,758 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.before
|
(self, value)
|
return self
|
insert value before nodes
|
insert value before nodes
| 1,278 | 1,299 |
def before(self, value):
"""insert value before nodes
"""
root, root_text = self._get_root(value)
for i, tag in enumerate(self):
previous = tag.getprevious()
if previous is not None:
if not previous.tail:
previous.tail = ''
previous.tail += root_text
else:
parent = tag.getparent()
if not parent.text:
parent.text = ''
parent.text += root_text
if i > 0:
root = deepcopy(list(root))
parent = tag.getparent()
index = parent.index(tag)
parent[index:index] = root
root = parent[index:len(root)]
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L1278-L1299
| 32 |
[
0,
1,
2,
3,
4,
5,
6,
10,
11,
12,
14,
15,
17,
18,
19,
20,
21
] | 77.272727 |
[
7,
8,
9,
13,
16
] | 22.727273 | false | 74.758454 | 22 | 6 | 77.272727 | 1 |
def before(self, value):
root, root_text = self._get_root(value)
for i, tag in enumerate(self):
previous = tag.getprevious()
if previous is not None:
if not previous.tail:
previous.tail = ''
previous.tail += root_text
else:
parent = tag.getparent()
if not parent.text:
parent.text = ''
parent.text += root_text
if i > 0:
root = deepcopy(list(root))
parent = tag.getparent()
index = parent.index(tag)
parent[index:index] = root
root = parent[index:len(root)]
return self
| 21,759 |
gawel/pyquery
|
ca860115ee15ad30367b6386ed6abc8f8801600e
|
pyquery/pyquery.py
|
PyQuery.insert_before
|
(self, value)
|
return self
|
insert nodes before value
|
insert nodes before value
| 1,302 | 1,306 |
def insert_before(self, value):
"""insert nodes before value
"""
value.before(self)
return self
|
https://github.com/gawel/pyquery/blob/ca860115ee15ad30367b6386ed6abc8f8801600e/project32/pyquery/pyquery.py#L1302-L1306
| 32 |
[
0,
1,
2
] | 60 |
[
3,
4
] | 40 | false | 74.758454 | 5 | 1 | 60 | 1 |
def insert_before(self, value):
value.before(self)
return self
| 21,760 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.