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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Object.__init__
|
(self, doc_class=None, dynamic=None, properties=None, **kwargs)
|
:arg document.InnerDoc doc_class: base doc class that handles mapping.
If no `doc_class` is provided, new instance of `InnerDoc` will be created,
populated with `properties` and used. Can not be provided together with `properties`
:arg dynamic: whether new properties may be created dynamically.
Valid values are `True`, `False`, `'strict'`.
Can not be provided together with `doc_class`.
See https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic.html
for more details
:arg dict properties: used to construct underlying mapping if no `doc_class` is provided.
Can not be provided together with `doc_class`
|
:arg document.InnerDoc doc_class: base doc class that handles mapping.
If no `doc_class` is provided, new instance of `InnerDoc` will be created,
populated with `properties` and used. Can not be provided together with `properties`
:arg dynamic: whether new properties may be created dynamically.
Valid values are `True`, `False`, `'strict'`.
Can not be provided together with `doc_class`.
See https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic.html
for more details
:arg dict properties: used to construct underlying mapping if no `doc_class` is provided.
Can not be provided together with `doc_class`
| 143 | 174 |
def __init__(self, doc_class=None, dynamic=None, properties=None, **kwargs):
"""
:arg document.InnerDoc doc_class: base doc class that handles mapping.
If no `doc_class` is provided, new instance of `InnerDoc` will be created,
populated with `properties` and used. Can not be provided together with `properties`
:arg dynamic: whether new properties may be created dynamically.
Valid values are `True`, `False`, `'strict'`.
Can not be provided together with `doc_class`.
See https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic.html
for more details
:arg dict properties: used to construct underlying mapping if no `doc_class` is provided.
Can not be provided together with `doc_class`
"""
if doc_class and (properties or dynamic is not None):
raise ValidationException(
"doc_class and properties/dynamic should not be provided together"
)
if doc_class:
self._doc_class = doc_class
else:
# FIXME import
from .document import InnerDoc
# no InnerDoc subclass, creating one instead...
self._doc_class = type("InnerDoc", (InnerDoc,), {})
for name, field in (properties or {}).items():
self._doc_class._doc_type.mapping.field(name, field)
if dynamic is not None:
self._doc_class._doc_type.mapping.meta("dynamic", dynamic)
self._mapping = copy.deepcopy(self._doc_class._doc_type.mapping)
super().__init__(**kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L143-L174
| 37 |
[
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
] | 100 |
[] | 0 | true | 93.311037 | 32 | 8 | 100 | 10 |
def __init__(self, doc_class=None, dynamic=None, properties=None, **kwargs):
if doc_class and (properties or dynamic is not None):
raise ValidationException(
"doc_class and properties/dynamic should not be provided together"
)
if doc_class:
self._doc_class = doc_class
else:
# FIXME import
from .document import InnerDoc
# no InnerDoc subclass, creating one instead...
self._doc_class = type("InnerDoc", (InnerDoc,), {})
for name, field in (properties or {}).items():
self._doc_class._doc_type.mapping.field(name, field)
if dynamic is not None:
self._doc_class._doc_type.mapping.meta("dynamic", dynamic)
self._mapping = copy.deepcopy(self._doc_class._doc_type.mapping)
super().__init__(**kwargs)
| 22,716 |
|
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Object.__getitem__
|
(self, name)
|
return self._mapping[name]
| 176 | 177 |
def __getitem__(self, name):
return self._mapping[name]
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L176-L177
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 93.311037 | 2 | 1 | 100 | 0 |
def __getitem__(self, name):
return self._mapping[name]
| 22,717 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Object.__contains__
|
(self, name)
|
return name in self._mapping
| 179 | 180 |
def __contains__(self, name):
return name in self._mapping
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L179-L180
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 93.311037 | 2 | 1 | 100 | 0 |
def __contains__(self, name):
return name in self._mapping
| 22,718 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Object._empty
|
(self)
|
return self._wrap({})
| 182 | 183 |
def _empty(self):
return self._wrap({})
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L182-L183
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 93.311037 | 2 | 1 | 100 | 0 |
def _empty(self):
return self._wrap({})
| 22,719 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Object._wrap
|
(self, data)
|
return self._doc_class.from_es(data, data_only=True)
| 185 | 186 |
def _wrap(self, data):
return self._doc_class.from_es(data, data_only=True)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L185-L186
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 93.311037 | 2 | 1 | 100 | 0 |
def _wrap(self, data):
return self._doc_class.from_es(data, data_only=True)
| 22,720 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Object.empty
|
(self)
|
return self._empty()
| 188 | 191 |
def empty(self):
if self._multi:
return AttrList([], self._wrap)
return self._empty()
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L188-L191
| 37 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 93.311037 | 4 | 2 | 100 | 0 |
def empty(self):
if self._multi:
return AttrList([], self._wrap)
return self._empty()
| 22,721 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Object.to_dict
|
(self)
|
return d
| 193 | 196 |
def to_dict(self):
d = self._mapping.to_dict()
d.update(super().to_dict())
return d
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L193-L196
| 37 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 93.311037 | 4 | 1 | 100 | 0 |
def to_dict(self):
d = self._mapping.to_dict()
d.update(super().to_dict())
return d
| 22,722 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Object._collect_fields
|
(self)
|
return self._mapping.properties._collect_fields()
| 198 | 199 |
def _collect_fields(self):
return self._mapping.properties._collect_fields()
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L198-L199
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 93.311037 | 2 | 1 | 100 | 0 |
def _collect_fields(self):
return self._mapping.properties._collect_fields()
| 22,723 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Object._deserialize
|
(self, data)
|
return self._wrap(data)
| 201 | 209 |
def _deserialize(self, data):
# don't wrap already wrapped data
if isinstance(data, self._doc_class):
return data
if isinstance(data, AttrDict):
data = data._d_
return self._wrap(data)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L201-L209
| 37 |
[
0,
1,
2,
3,
4,
5,
7,
8
] | 88.888889 |
[
6
] | 11.111111 | false | 93.311037 | 9 | 3 | 88.888889 | 0 |
def _deserialize(self, data):
# don't wrap already wrapped data
if isinstance(data, self._doc_class):
return data
if isinstance(data, AttrDict):
data = data._d_
return self._wrap(data)
| 22,724 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Object._serialize
|
(self, data)
|
return data.to_dict()
| 211 | 219 |
def _serialize(self, data):
if data is None:
return None
# somebody assigned raw dict to the field, we should tolerate that
if isinstance(data, collections.abc.Mapping):
return data
return data.to_dict()
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L211-L219
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 100 |
[] | 0 | true | 93.311037 | 9 | 3 | 100 | 0 |
def _serialize(self, data):
if data is None:
return None
# somebody assigned raw dict to the field, we should tolerate that
if isinstance(data, collections.abc.Mapping):
return data
return data.to_dict()
| 22,725 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Object.clean
|
(self, data)
|
return data
| 221 | 230 |
def clean(self, data):
data = super().clean(data)
if data is None:
return None
if isinstance(data, (list, AttrList)):
for d in data:
d.full_clean()
else:
data.full_clean()
return data
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L221-L230
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
8,
9
] | 90 |
[] | 0 | false | 93.311037 | 10 | 4 | 100 | 0 |
def clean(self, data):
data = super().clean(data)
if data is None:
return None
if isinstance(data, (list, AttrList)):
for d in data:
d.full_clean()
else:
data.full_clean()
return data
| 22,726 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Object.update
|
(self, other, update_only=False)
| 232 | 237 |
def update(self, other, update_only=False):
if not isinstance(other, Object):
# not an inner/nested object, no merge possible
return
self._mapping.update(other._mapping, update_only)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L232-L237
| 37 |
[
0,
1,
2,
4,
5
] | 83.333333 |
[
3
] | 16.666667 | false | 93.311037 | 6 | 2 | 83.333333 | 0 |
def update(self, other, update_only=False):
if not isinstance(other, Object):
# not an inner/nested object, no merge possible
return
self._mapping.update(other._mapping, update_only)
| 22,727 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Nested.__init__
|
(self, *args, **kwargs)
| 243 | 245 |
def __init__(self, *args, **kwargs):
kwargs.setdefault("multi", True)
super().__init__(*args, **kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L243-L245
| 37 |
[
0,
1,
2
] | 100 |
[] | 0 | true | 93.311037 | 3 | 1 | 100 | 0 |
def __init__(self, *args, **kwargs):
kwargs.setdefault("multi", True)
super().__init__(*args, **kwargs)
| 22,728 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Date.__init__
|
(self, default_timezone=None, *args, **kwargs)
|
:arg default_timezone: timezone that will be automatically used for tz-naive values
May be instance of `datetime.tzinfo` or string containing TZ offset
|
:arg default_timezone: timezone that will be automatically used for tz-naive values
May be instance of `datetime.tzinfo` or string containing TZ offset
| 252 | 260 |
def __init__(self, default_timezone=None, *args, **kwargs):
"""
:arg default_timezone: timezone that will be automatically used for tz-naive values
May be instance of `datetime.tzinfo` or string containing TZ offset
"""
self._default_timezone = default_timezone
if isinstance(self._default_timezone, str):
self._default_timezone = tz.gettz(self._default_timezone)
super().__init__(*args, **kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L252-L260
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 100 |
[] | 0 | true | 93.311037 | 9 | 2 | 100 | 2 |
def __init__(self, default_timezone=None, *args, **kwargs):
self._default_timezone = default_timezone
if isinstance(self._default_timezone, str):
self._default_timezone = tz.gettz(self._default_timezone)
super().__init__(*args, **kwargs)
| 22,729 |
|
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Date._deserialize
|
(self, data)
| 262 | 281 |
def _deserialize(self, data):
if isinstance(data, str):
try:
data = parser.parse(data)
except Exception as e:
raise ValidationException(
f"Could not parse date from the value ({data!r})", e
)
if isinstance(data, datetime):
if self._default_timezone and data.tzinfo is None:
data = data.replace(tzinfo=self._default_timezone)
return data
if isinstance(data, date):
return data
if isinstance(data, int):
# Divide by a float to preserve milliseconds on the datetime.
return datetime.utcfromtimestamp(data / 1000.0)
raise ValidationException(f"Could not parse date from the value ({data!r})")
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L262-L281
| 37 |
[
0,
1,
2,
3,
4,
5,
8,
9,
10,
11,
12,
13,
15,
16,
17,
18
] | 80 |
[
14,
19
] | 10 | false | 93.311037 | 20 | 8 | 90 | 0 |
def _deserialize(self, data):
if isinstance(data, str):
try:
data = parser.parse(data)
except Exception as e:
raise ValidationException(
f"Could not parse date from the value ({data!r})", e
)
if isinstance(data, datetime):
if self._default_timezone and data.tzinfo is None:
data = data.replace(tzinfo=self._default_timezone)
return data
if isinstance(data, date):
return data
if isinstance(data, int):
# Divide by a float to preserve milliseconds on the datetime.
return datetime.utcfromtimestamp(data / 1000.0)
raise ValidationException(f"Could not parse date from the value ({data!r})")
| 22,730 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Boolean._deserialize
|
(self, data)
|
return bool(data)
| 320 | 323 |
def _deserialize(self, data):
if data == "false":
return False
return bool(data)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L320-L323
| 37 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 93.311037 | 4 | 2 | 100 | 0 |
def _deserialize(self, data):
if data == "false":
return False
return bool(data)
| 22,731 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Boolean.clean
|
(self, data)
|
return data
| 325 | 330 |
def clean(self, data):
if data is not None:
data = self.deserialize(data)
if data is None and self._required:
raise ValidationException("Value required for this field.")
return data
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L325-L330
| 37 |
[
0,
1,
2,
3,
4,
5
] | 100 |
[] | 0 | true | 93.311037 | 6 | 4 | 100 | 0 |
def clean(self, data):
if data is not None:
data = self.deserialize(data)
if data is None and self._required:
raise ValidationException("Value required for this field.")
return data
| 22,732 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Float._deserialize
|
(self, data)
|
return float(data)
| 337 | 338 |
def _deserialize(self, data):
return float(data)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L337-L338
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 93.311037 | 2 | 1 | 100 | 0 |
def _deserialize(self, data):
return float(data)
| 22,733 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
DenseVector.__init__
|
(self, dims, **kwargs)
| 344 | 346 |
def __init__(self, dims, **kwargs):
kwargs["multi"] = True
super().__init__(dims=dims, **kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L344-L346
| 37 |
[
0
] | 33.333333 |
[
1,
2
] | 66.666667 | false | 93.311037 | 3 | 1 | 33.333333 | 0 |
def __init__(self, dims, **kwargs):
kwargs["multi"] = True
super().__init__(dims=dims, **kwargs)
| 22,734 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
ScaledFloat.__init__
|
(self, scaling_factor, *args, **kwargs)
| 360 | 361 |
def __init__(self, scaling_factor, *args, **kwargs):
super().__init__(scaling_factor=scaling_factor, *args, **kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L360-L361
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 93.311037 | 2 | 1 | 100 | 0 |
def __init__(self, scaling_factor, *args, **kwargs):
super().__init__(scaling_factor=scaling_factor, *args, **kwargs)
| 22,735 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Integer._deserialize
|
(self, data)
|
return int(data)
| 380 | 381 |
def _deserialize(self, data):
return int(data)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L380-L381
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 93.311037 | 2 | 1 | 100 | 0 |
def _deserialize(self, data):
return int(data)
| 22,736 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Ip._deserialize
|
(self, data)
|
return ipaddress.ip_address(unicode(data))
| 400 | 402 |
def _deserialize(self, data):
# the ipaddress library for pypy only accepts unicode.
return ipaddress.ip_address(unicode(data))
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L400-L402
| 37 |
[
0,
1,
2
] | 100 |
[] | 0 | true | 93.311037 | 3 | 1 | 100 | 0 |
def _deserialize(self, data):
# the ipaddress library for pypy only accepts unicode.
return ipaddress.ip_address(unicode(data))
| 22,737 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Ip._serialize
|
(self, data)
|
return str(data)
| 404 | 407 |
def _serialize(self, data):
if data is None:
return None
return str(data)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L404-L407
| 37 |
[
0,
1,
3
] | 75 |
[
2
] | 25 | false | 93.311037 | 4 | 2 | 75 | 0 |
def _serialize(self, data):
if data is None:
return None
return str(data)
| 22,738 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Binary.clean
|
(self, data)
|
return data
| 414 | 417 |
def clean(self, data):
# Binary fields are opaque, so there's not much cleaning
# that can be done.
return data
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L414-L417
| 37 |
[
0,
1,
2
] | 75 |
[
3
] | 25 | false | 93.311037 | 4 | 1 | 75 | 0 |
def clean(self, data):
# Binary fields are opaque, so there's not much cleaning
# that can be done.
return data
| 22,739 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Binary._deserialize
|
(self, data)
|
return base64.b64decode(data)
| 419 | 420 |
def _deserialize(self, data):
return base64.b64decode(data)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L419-L420
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 93.311037 | 2 | 1 | 100 | 0 |
def _deserialize(self, data):
return base64.b64decode(data)
| 22,740 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Binary._serialize
|
(self, data)
|
return base64.b64encode(data).decode()
| 422 | 425 |
def _serialize(self, data):
if data is None:
return None
return base64.b64encode(data).decode()
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L422-L425
| 37 |
[
0,
1,
3
] | 75 |
[
2
] | 25 | false | 93.311037 | 4 | 2 | 75 | 0 |
def _serialize(self, data):
if data is None:
return None
return base64.b64encode(data).decode()
| 22,741 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Percolator._deserialize
|
(self, data)
|
return Q(data)
| 448 | 449 |
def _deserialize(self, data):
return Q(data)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L448-L449
| 37 |
[
0
] | 50 |
[
1
] | 50 | false | 93.311037 | 2 | 1 | 50 | 0 |
def _deserialize(self, data):
return Q(data)
| 22,742 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
Percolator._serialize
|
(self, data)
|
return data.to_dict()
| 451 | 454 |
def _serialize(self, data):
if data is None:
return None
return data.to_dict()
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L451-L454
| 37 |
[
0
] | 25 |
[
1,
2,
3
] | 75 | false | 93.311037 | 4 | 2 | 25 | 0 |
def _serialize(self, data):
if data is None:
return None
return data.to_dict()
| 22,743 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
RangeField._deserialize
|
(self, data)
|
return Range(data)
| 461 | 465 |
def _deserialize(self, data):
if isinstance(data, Range):
return data
data = {k: self._core_field.deserialize(v) for k, v in data.items()}
return Range(data)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L461-L465
| 37 |
[
0,
1,
3,
4
] | 80 |
[
2
] | 20 | false | 93.311037 | 5 | 2 | 80 | 0 |
def _deserialize(self, data):
if isinstance(data, Range):
return data
data = {k: self._core_field.deserialize(v) for k, v in data.items()}
return Range(data)
| 22,744 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/field.py
|
RangeField._serialize
|
(self, data)
|
return {k: self._core_field.serialize(v) for k, v in data.items()}
| 467 | 472 |
def _serialize(self, data):
if data is None:
return None
if not isinstance(data, collections.abc.Mapping):
data = data.to_dict()
return {k: self._core_field.serialize(v) for k, v in data.items()}
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/field.py#L467-L472
| 37 |
[
0,
1,
3,
4,
5
] | 83.333333 |
[
2
] | 16.666667 | false | 93.311037 | 6 | 3 | 83.333333 | 0 |
def _serialize(self, data):
if data is None:
return None
if not isinstance(data, collections.abc.Mapping):
data = data.to_dict()
return {k: self._core_field.serialize(v) for k, v in data.items()}
| 22,745 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/connections.py
|
Connections.__init__
|
(self)
| 29 | 31 |
def __init__(self):
self._kwargs = {}
self._conns = {}
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/connections.py#L29-L31
| 37 |
[
0,
1,
2
] | 100 |
[] | 0 | true | 95.454545 | 3 | 1 | 100 | 0 |
def __init__(self):
self._kwargs = {}
self._conns = {}
| 22,746 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/connections.py
|
Connections.configure
|
(self, **kwargs)
|
Configure multiple connections at once, useful for passing in config
dictionaries obtained from other sources, like Django's settings or a
configuration management tool.
Example::
connections.configure(
default={'hosts': 'localhost'},
dev={'hosts': ['esdev1.example.com:9200'], 'sniff_on_start': True},
)
Connections will only be constructed lazily when requested through
``get_connection``.
|
Configure multiple connections at once, useful for passing in config
dictionaries obtained from other sources, like Django's settings or a
configuration management tool.
| 33 | 54 |
def configure(self, **kwargs):
"""
Configure multiple connections at once, useful for passing in config
dictionaries obtained from other sources, like Django's settings or a
configuration management tool.
Example::
connections.configure(
default={'hosts': 'localhost'},
dev={'hosts': ['esdev1.example.com:9200'], 'sniff_on_start': True},
)
Connections will only be constructed lazily when requested through
``get_connection``.
"""
for k in list(self._conns):
# try and preserve existing client to keep the persistent connections alive
if k in self._kwargs and kwargs.get(k, None) == self._kwargs[k]:
continue
del self._conns[k]
self._kwargs = kwargs
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/connections.py#L33-L54
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21
] | 100 |
[] | 0 | true | 95.454545 | 22 | 4 | 100 | 13 |
def configure(self, **kwargs):
for k in list(self._conns):
# try and preserve existing client to keep the persistent connections alive
if k in self._kwargs and kwargs.get(k, None) == self._kwargs[k]:
continue
del self._conns[k]
self._kwargs = kwargs
| 22,747 |
|
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/connections.py
|
Connections.add_connection
|
(self, alias, conn)
|
Add a connection object, it will be passed through as-is.
|
Add a connection object, it will be passed through as-is.
| 56 | 60 |
def add_connection(self, alias, conn):
"""
Add a connection object, it will be passed through as-is.
"""
self._conns[alias] = conn
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/connections.py#L56-L60
| 37 |
[
0,
1,
2,
3,
4
] | 100 |
[] | 0 | true | 95.454545 | 5 | 1 | 100 | 1 |
def add_connection(self, alias, conn):
self._conns[alias] = conn
| 22,748 |
|
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/connections.py
|
Connections.remove_connection
|
(self, alias)
|
Remove connection from the registry. Raises ``KeyError`` if connection
wasn't found.
|
Remove connection from the registry. Raises ``KeyError`` if connection
wasn't found.
| 62 | 75 |
def remove_connection(self, alias):
"""
Remove connection from the registry. Raises ``KeyError`` if connection
wasn't found.
"""
errors = 0
for d in (self._conns, self._kwargs):
try:
del d[alias]
except KeyError:
errors += 1
if errors == 2:
raise KeyError(f"There is no connection with alias {alias!r}.")
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/connections.py#L62-L75
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12
] | 92.857143 |
[
13
] | 7.142857 | false | 95.454545 | 14 | 4 | 92.857143 | 2 |
def remove_connection(self, alias):
errors = 0
for d in (self._conns, self._kwargs):
try:
del d[alias]
except KeyError:
errors += 1
if errors == 2:
raise KeyError(f"There is no connection with alias {alias!r}.")
| 22,749 |
|
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/connections.py
|
Connections.create_connection
|
(self, alias="default", **kwargs)
|
return conn
|
Construct an instance of ``elasticsearch.Elasticsearch`` and register
it under given alias.
|
Construct an instance of ``elasticsearch.Elasticsearch`` and register
it under given alias.
| 77 | 84 |
def create_connection(self, alias="default", **kwargs):
"""
Construct an instance of ``elasticsearch.Elasticsearch`` and register
it under given alias.
"""
kwargs.setdefault("serializer", serializer)
conn = self._conns[alias] = Elasticsearch(**kwargs)
return conn
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/connections.py#L77-L84
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7
] | 100 |
[] | 0 | true | 95.454545 | 8 | 1 | 100 | 2 |
def create_connection(self, alias="default", **kwargs):
kwargs.setdefault("serializer", serializer)
conn = self._conns[alias] = Elasticsearch(**kwargs)
return conn
| 22,750 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/connections.py
|
Connections.get_connection
|
(self, alias="default")
|
Retrieve a connection, construct it if necessary (only configuration
was passed to us). If a non-string alias has been passed through we
assume it's already a client instance and will just return it as-is.
Raises ``KeyError`` if no client (or its definition) is registered
under the alias.
|
Retrieve a connection, construct it if necessary (only configuration
was passed to us). If a non-string alias has been passed through we
assume it's already a client instance and will just return it as-is.
| 86 | 111 |
def get_connection(self, alias="default"):
"""
Retrieve a connection, construct it if necessary (only configuration
was passed to us). If a non-string alias has been passed through we
assume it's already a client instance and will just return it as-is.
Raises ``KeyError`` if no client (or its definition) is registered
under the alias.
"""
# do not check isinstance(Elasticsearch) so that people can wrap their
# clients
if not isinstance(alias, str):
return alias
# connection already established
try:
return self._conns[alias]
except KeyError:
pass
# if not, try to create it
try:
return self.create_connection(alias, **self._kwargs[alias])
except KeyError:
# no connection and no kwargs to set one up
raise KeyError(f"There is no connection with alias {alias!r}.")
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/connections.py#L86-L111
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25
] | 92.307692 |
[
12
] | 3.846154 | false | 95.454545 | 26 | 4 | 96.153846 | 6 |
def get_connection(self, alias="default"):
# do not check isinstance(Elasticsearch) so that people can wrap their
# clients
if not isinstance(alias, str):
return alias
# connection already established
try:
return self._conns[alias]
except KeyError:
pass
# if not, try to create it
try:
return self.create_connection(alias, **self._kwargs[alias])
except KeyError:
# no connection and no kwargs to set one up
raise KeyError(f"There is no connection with alias {alias!r}.")
| 22,751 |
|
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/query.py
|
Q
|
(name_or_query="match_all", **params)
|
return Query.get_dsl_class(name_or_query)(**params)
| 28 | 54 |
def Q(name_or_query="match_all", **params):
# {"match": {"title": "python"}}
if isinstance(name_or_query, collections.abc.Mapping):
if params:
raise ValueError("Q() cannot accept parameters when passing in a dict.")
if len(name_or_query) != 1:
raise ValueError(
'Q() can only accept dict with a single query ({"match": {...}}). '
"Instead it got (%r)" % name_or_query
)
name, params = name_or_query.copy().popitem()
return Query.get_dsl_class(name)(_expand__to_dot=False, **params)
# MatchAll()
if isinstance(name_or_query, Query):
if params:
raise ValueError(
"Q() cannot accept parameters when passing in a Query object."
)
return name_or_query
# s.query = Q('filtered', query=s.query)
if hasattr(name_or_query, "_proxied"):
return name_or_query._proxied
# "match", title="python"
return Query.get_dsl_class(name_or_query)(**params)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/query.py#L28-L54
| 37 |
[
0,
1,
2,
3,
4,
5,
10,
11,
12,
13,
14,
15,
16,
19,
20,
21,
22,
23,
24,
25,
26
] | 77.777778 |
[
6
] | 3.703704 | false | 94.095941 | 27 | 7 | 96.296296 | 0 |
def Q(name_or_query="match_all", **params):
# {"match": {"title": "python"}}
if isinstance(name_or_query, collections.abc.Mapping):
if params:
raise ValueError("Q() cannot accept parameters when passing in a dict.")
if len(name_or_query) != 1:
raise ValueError(
'Q() can only accept dict with a single query ({"match": {...}}). '
"Instead it got (%r)" % name_or_query
)
name, params = name_or_query.copy().popitem()
return Query.get_dsl_class(name)(_expand__to_dot=False, **params)
# MatchAll()
if isinstance(name_or_query, Query):
if params:
raise ValueError(
"Q() cannot accept parameters when passing in a Query object."
)
return name_or_query
# s.query = Q('filtered', query=s.query)
if hasattr(name_or_query, "_proxied"):
return name_or_query._proxied
# "match", title="python"
return Query.get_dsl_class(name_or_query)(**params)
| 22,752 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/query.py
|
Query.__add__
|
(self, other)
|
return Bool(must=[self, other])
| 62 | 67 |
def __add__(self, other):
# make sure we give queries that know how to combine themselves
# preference
if hasattr(other, "__radd__"):
return other.__radd__(self)
return Bool(must=[self, other])
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/query.py#L62-L67
| 37 |
[
0,
1,
2
] | 50 |
[
3,
4,
5
] | 50 | false | 94.095941 | 6 | 2 | 50 | 0 |
def __add__(self, other):
# make sure we give queries that know how to combine themselves
# preference
if hasattr(other, "__radd__"):
return other.__radd__(self)
return Bool(must=[self, other])
| 22,753 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/query.py
|
Query.__invert__
|
(self)
|
return Bool(must_not=[self])
| 69 | 70 |
def __invert__(self):
return Bool(must_not=[self])
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/query.py#L69-L70
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 94.095941 | 2 | 1 | 100 | 0 |
def __invert__(self):
return Bool(must_not=[self])
| 22,754 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/query.py
|
Query.__or__
|
(self, other)
|
return Bool(should=[self, other])
| 72 | 77 |
def __or__(self, other):
# make sure we give queries that know how to combine themselves
# preference
if hasattr(other, "__ror__"):
return other.__ror__(self)
return Bool(should=[self, other])
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/query.py#L72-L77
| 37 |
[
0,
1,
2,
3,
4,
5
] | 100 |
[] | 0 | true | 94.095941 | 6 | 2 | 100 | 0 |
def __or__(self, other):
# make sure we give queries that know how to combine themselves
# preference
if hasattr(other, "__ror__"):
return other.__ror__(self)
return Bool(should=[self, other])
| 22,755 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/query.py
|
Query.__and__
|
(self, other)
|
return Bool(must=[self, other])
| 79 | 84 |
def __and__(self, other):
# make sure we give queries that know how to combine themselves
# preference
if hasattr(other, "__rand__"):
return other.__rand__(self)
return Bool(must=[self, other])
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/query.py#L79-L84
| 37 |
[
0,
1,
2,
3,
4,
5
] | 100 |
[] | 0 | true | 94.095941 | 6 | 2 | 100 | 0 |
def __and__(self, other):
# make sure we give queries that know how to combine themselves
# preference
if hasattr(other, "__rand__"):
return other.__rand__(self)
return Bool(must=[self, other])
| 22,756 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/query.py
|
MatchAll.__add__
|
(self, other)
|
return other._clone()
| 90 | 91 |
def __add__(self, other):
return other._clone()
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/query.py#L90-L91
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 94.095941 | 2 | 1 | 100 | 0 |
def __add__(self, other):
return other._clone()
| 22,757 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/query.py
|
MatchAll.__or__
|
(self, other)
|
return self
| 95 | 96 |
def __or__(self, other):
return self
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/query.py#L95-L96
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 94.095941 | 2 | 1 | 100 | 0 |
def __or__(self, other):
return self
| 22,758 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/query.py
|
MatchAll.__invert__
|
(self)
|
return MatchNone()
| 100 | 101 |
def __invert__(self):
return MatchNone()
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/query.py#L100-L101
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 94.095941 | 2 | 1 | 100 | 0 |
def __invert__(self):
return MatchNone()
| 22,759 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/query.py
|
MatchNone.__add__
|
(self, other)
|
return self
| 110 | 111 |
def __add__(self, other):
return self
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/query.py#L110-L111
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 94.095941 | 2 | 1 | 100 | 0 |
def __add__(self, other):
return self
| 22,760 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/query.py
|
MatchNone.__or__
|
(self, other)
|
return other._clone()
| 115 | 116 |
def __or__(self, other):
return other._clone()
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/query.py#L115-L116
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 94.095941 | 2 | 1 | 100 | 0 |
def __or__(self, other):
return other._clone()
| 22,761 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/query.py
|
MatchNone.__invert__
|
(self)
|
return MatchAll()
| 120 | 121 |
def __invert__(self):
return MatchAll()
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/query.py#L120-L121
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 94.095941 | 2 | 1 | 100 | 0 |
def __invert__(self):
return MatchAll()
| 22,762 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/query.py
|
Bool.__add__
|
(self, other)
|
return q
| 133 | 142 |
def __add__(self, other):
q = self._clone()
if isinstance(other, Bool):
q.must += other.must
q.should += other.should
q.must_not += other.must_not
q.filter += other.filter
else:
q.must.append(other)
return q
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/query.py#L133-L142
| 37 |
[
0
] | 10 |
[
1,
2,
3,
4,
5,
6,
8,
9
] | 80 | false | 94.095941 | 10 | 2 | 20 | 0 |
def __add__(self, other):
q = self._clone()
if isinstance(other, Bool):
q.must += other.must
q.should += other.should
q.must_not += other.must_not
q.filter += other.filter
else:
q.must.append(other)
return q
| 22,763 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/query.py
|
Bool.__or__
|
(self, other)
|
return Bool(should=[self, other])
| 146 | 166 |
def __or__(self, other):
for q in (self, other):
if isinstance(q, Bool) and not any(
(q.must, q.must_not, q.filter, getattr(q, "minimum_should_match", None))
):
other = self if q is other else other
q = q._clone()
if isinstance(other, Bool) and not any(
(
other.must,
other.must_not,
other.filter,
getattr(other, "minimum_should_match", None),
)
):
q.should.extend(other.should)
else:
q.should.append(other)
return q
return Bool(should=[self, other])
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/query.py#L146-L166
| 37 |
[
0,
1,
2,
5,
6,
7,
15,
17,
18,
19,
20
] | 52.380952 |
[] | 0 | false | 94.095941 | 21 | 6 | 100 | 0 |
def __or__(self, other):
for q in (self, other):
if isinstance(q, Bool) and not any(
(q.must, q.must_not, q.filter, getattr(q, "minimum_should_match", None))
):
other = self if q is other else other
q = q._clone()
if isinstance(other, Bool) and not any(
(
other.must,
other.must_not,
other.filter,
getattr(other, "minimum_should_match", None),
)
):
q.should.extend(other.should)
else:
q.should.append(other)
return q
return Bool(should=[self, other])
| 22,764 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/query.py
|
Bool._min_should_match
|
(self)
|
return getattr(
self,
"minimum_should_match",
0 if not self.should or (self.must or self.filter) else 1,
)
| 171 | 176 |
def _min_should_match(self):
return getattr(
self,
"minimum_should_match",
0 if not self.should or (self.must or self.filter) else 1,
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/query.py#L171-L176
| 37 |
[
0,
1
] | 33.333333 |
[] | 0 | false | 94.095941 | 6 | 3 | 100 | 0 |
def _min_should_match(self):
return getattr(
self,
"minimum_should_match",
0 if not self.should or (self.must or self.filter) else 1,
)
| 22,765 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/query.py
|
Bool.__invert__
|
(self)
|
return Bool(should=negations)
| 178 | 196 |
def __invert__(self):
# Because an empty Bool query is treated like
# MatchAll the inverse should be MatchNone
if not any(chain(self.must, self.filter, self.should, self.must_not)):
return MatchNone()
negations = []
for q in chain(self.must, self.filter):
negations.append(~q)
for q in self.must_not:
negations.append(q)
if self.should and self._min_should_match:
negations.append(Bool(must_not=self.should[:]))
if len(negations) == 1:
return negations[0]
return Bool(should=negations)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/query.py#L178-L196
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
15,
16,
17,
18
] | 94.736842 |
[
14
] | 5.263158 | false | 94.095941 | 19 | 7 | 94.736842 | 0 |
def __invert__(self):
# Because an empty Bool query is treated like
# MatchAll the inverse should be MatchNone
if not any(chain(self.must, self.filter, self.should, self.must_not)):
return MatchNone()
negations = []
for q in chain(self.must, self.filter):
negations.append(~q)
for q in self.must_not:
negations.append(q)
if self.should and self._min_should_match:
negations.append(Bool(must_not=self.should[:]))
if len(negations) == 1:
return negations[0]
return Bool(should=negations)
| 22,766 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/query.py
|
Bool.__and__
|
(self, other)
|
return q
| 198 | 232 |
def __and__(self, other):
q = self._clone()
if isinstance(other, Bool):
q.must += other.must
q.must_not += other.must_not
q.filter += other.filter
q.should = []
# reset minimum_should_match as it will get calculated below
if "minimum_should_match" in q._params:
del q._params["minimum_should_match"]
for qx in (self, other):
# TODO: percentages will fail here
min_should_match = qx._min_should_match
# all subqueries are required
if len(qx.should) <= min_should_match:
q.must.extend(qx.should)
# not all of them are required, use it and remember min_should_match
elif not q.should:
q.minimum_should_match = min_should_match
q.should = qx.should
# all queries are optional, just extend should
elif q._min_should_match == 0 and min_should_match == 0:
q.should.extend(qx.should)
# not all are required, add a should list to the must with proper min_should_match
else:
q.must.append(
Bool(should=qx.should, minimum_should_match=min_should_match)
)
else:
if not (q.must or q.filter) and q.should:
q._params.setdefault("minimum_should_match", 1)
q.must.append(other)
return q
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/query.py#L198-L232
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
31,
32,
33,
34
] | 77.142857 |
[
23,
24,
27
] | 8.571429 | false | 94.095941 | 35 | 11 | 91.428571 | 0 |
def __and__(self, other):
q = self._clone()
if isinstance(other, Bool):
q.must += other.must
q.must_not += other.must_not
q.filter += other.filter
q.should = []
# reset minimum_should_match as it will get calculated below
if "minimum_should_match" in q._params:
del q._params["minimum_should_match"]
for qx in (self, other):
# TODO: percentages will fail here
min_should_match = qx._min_should_match
# all subqueries are required
if len(qx.should) <= min_should_match:
q.must.extend(qx.should)
# not all of them are required, use it and remember min_should_match
elif not q.should:
q.minimum_should_match = min_should_match
q.should = qx.should
# all queries are optional, just extend should
elif q._min_should_match == 0 and min_should_match == 0:
q.should.extend(qx.should)
# not all are required, add a should list to the must with proper min_should_match
else:
q.must.append(
Bool(should=qx.should, minimum_should_match=min_should_match)
)
else:
if not (q.must or q.filter) and q.should:
q._params.setdefault("minimum_should_match", 1)
q.must.append(other)
return q
| 22,767 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/query.py
|
FunctionScore.__init__
|
(self, **kwargs)
| 245 | 253 |
def __init__(self, **kwargs):
if "functions" in kwargs:
pass
else:
fns = kwargs["functions"] = []
for name in ScoreFunction._classes:
if name in kwargs:
fns.append({name: kwargs.pop(name)})
super().__init__(**kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/query.py#L245-L253
| 37 |
[
0,
1,
2,
4,
5,
6,
7,
8
] | 88.888889 |
[] | 0 | false | 94.095941 | 9 | 4 | 100 | 0 |
def __init__(self, **kwargs):
if "functions" in kwargs:
pass
else:
fns = kwargs["functions"] = []
for name in ScoreFunction._classes:
if name in kwargs:
fns.append({name: kwargs.pop(name)})
super().__init__(**kwargs)
| 22,768 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/wrappers.py
|
Range.__init__
|
(self, *args, **kwargs)
| 33 | 50 |
def __init__(self, *args, **kwargs):
if args and (len(args) > 1 or kwargs or not isinstance(args[0], dict)):
raise ValueError(
"Range accepts a single dictionary or a set of keyword arguments."
)
data = args[0] if args else kwargs
for k in data:
if k not in self.OPS:
raise ValueError(f"Range received an unknown operator {k!r}")
if "gt" in data and "gte" in data:
raise ValueError("You cannot specify both gt and gte for Range.")
if "lt" in data and "lte" in data:
raise ValueError("You cannot specify both lt and lte for Range.")
super().__init__(args[0] if args else kwargs)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/wrappers.py#L33-L50
| 37 |
[
0,
1,
2,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17
] | 88.888889 |
[] | 0 | false | 95 | 18 | 11 | 100 | 0 |
def __init__(self, *args, **kwargs):
if args and (len(args) > 1 or kwargs or not isinstance(args[0], dict)):
raise ValueError(
"Range accepts a single dictionary or a set of keyword arguments."
)
data = args[0] if args else kwargs
for k in data:
if k not in self.OPS:
raise ValueError(f"Range received an unknown operator {k!r}")
if "gt" in data and "gte" in data:
raise ValueError("You cannot specify both gt and gte for Range.")
if "lt" in data and "lte" in data:
raise ValueError("You cannot specify both lt and lte for Range.")
super().__init__(args[0] if args else kwargs)
| 22,769 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/wrappers.py
|
Range.__repr__
|
(self)
|
return "Range(%s)" % ", ".join("%s=%r" % op for op in self._d_.items())
| 52 | 53 |
def __repr__(self):
return "Range(%s)" % ", ".join("%s=%r" % op for op in self._d_.items())
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/wrappers.py#L52-L53
| 37 |
[
0
] | 50 |
[
1
] | 50 | false | 95 | 2 | 1 | 50 | 0 |
def __repr__(self):
return "Range(%s)" % ", ".join("%s=%r" % op for op in self._d_.items())
| 22,770 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/wrappers.py
|
Range.__contains__
|
(self, item)
|
return True
| 55 | 62 |
def __contains__(self, item):
if isinstance(item, str):
return super().__contains__(item)
for op in self.OPS:
if op in self._d_ and not self.OPS[op](item, self._d_[op]):
return False
return True
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/wrappers.py#L55-L62
| 37 |
[
0,
1,
3,
4,
5,
6,
7
] | 87.5 |
[
2
] | 12.5 | false | 95 | 8 | 5 | 87.5 | 0 |
def __contains__(self, item):
if isinstance(item, str):
return super().__contains__(item)
for op in self.OPS:
if op in self._d_ and not self.OPS[op](item, self._d_[op]):
return False
return True
| 22,771 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/wrappers.py
|
Range.upper
|
(self)
|
return None, False
| 65 | 70 |
def upper(self):
if "lt" in self._d_:
return self._d_["lt"], False
if "lte" in self._d_:
return self._d_["lte"], True
return None, False
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/wrappers.py#L65-L70
| 37 |
[
0,
1,
2,
3,
4,
5
] | 100 |
[] | 0 | true | 95 | 6 | 3 | 100 | 0 |
def upper(self):
if "lt" in self._d_:
return self._d_["lt"], False
if "lte" in self._d_:
return self._d_["lte"], True
return None, False
| 22,772 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/wrappers.py
|
Range.lower
|
(self)
|
return None, False
| 73 | 78 |
def lower(self):
if "gt" in self._d_:
return self._d_["gt"], False
if "gte" in self._d_:
return self._d_["gte"], True
return None, False
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/wrappers.py#L73-L78
| 37 |
[
0,
1,
2,
3,
4,
5
] | 100 |
[] | 0 | true | 95 | 6 | 3 | 100 | 0 |
def lower(self):
if "gt" in self._d_:
return self._d_["gt"], False
if "gte" in self._d_:
return self._d_["gte"], True
return None, False
| 22,773 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
_wrap
|
(val, obj_wrapper=None)
|
return val
| 47 | 52 |
def _wrap(val, obj_wrapper=None):
if isinstance(val, collections.abc.Mapping):
return AttrDict(val) if obj_wrapper is None else obj_wrapper(val)
if isinstance(val, list):
return AttrList(val)
return val
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L47-L52
| 37 |
[
0,
1,
2,
3,
4,
5
] | 100 |
[] | 0 | true | 91.5625 | 6 | 3 | 100 | 0 |
def _wrap(val, obj_wrapper=None):
if isinstance(val, collections.abc.Mapping):
return AttrDict(val) if obj_wrapper is None else obj_wrapper(val)
if isinstance(val, list):
return AttrList(val)
return val
| 22,774 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
merge
|
(data, new_data, raise_on_conflict=False)
| 530 | 549 |
def merge(data, new_data, raise_on_conflict=False):
if not (
isinstance(data, (AttrDict, collections.abc.Mapping))
and isinstance(new_data, (AttrDict, collections.abc.Mapping))
):
raise ValueError(
f"You can only merge two dicts! Got {data!r} and {new_data!r} instead."
)
for key, value in new_data.items():
if (
key in data
and isinstance(data[key], (AttrDict, collections.abc.Mapping))
and isinstance(value, (AttrDict, collections.abc.Mapping))
):
merge(data[key], value, raise_on_conflict)
elif key in data and data[key] != value and raise_on_conflict:
raise ValueError(f"Incompatible data for key {key!r}, cannot be merged.")
else:
data[key] = value
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L530-L549
| 37 |
[
0,
1,
8,
9,
10,
15,
16,
17,
19
] | 45 |
[
5
] | 5 | false | 91.5625 | 20 | 10 | 95 | 0 |
def merge(data, new_data, raise_on_conflict=False):
if not (
isinstance(data, (AttrDict, collections.abc.Mapping))
and isinstance(new_data, (AttrDict, collections.abc.Mapping))
):
raise ValueError(
f"You can only merge two dicts! Got {data!r} and {new_data!r} instead."
)
for key, value in new_data.items():
if (
key in data
and isinstance(data[key], (AttrDict, collections.abc.Mapping))
and isinstance(value, (AttrDict, collections.abc.Mapping))
):
merge(data[key], value, raise_on_conflict)
elif key in data and data[key] != value and raise_on_conflict:
raise ValueError(f"Incompatible data for key {key!r}, cannot be merged.")
else:
data[key] = value
| 22,775 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
recursive_to_dict
|
(data)
|
return data
|
Recursively transform objects that potentially have .to_dict()
into dictionary literals by traversing AttrList, AttrDict, list,
tuple, and Mapping types.
|
Recursively transform objects that potentially have .to_dict()
into dictionary literals by traversing AttrList, AttrDict, list,
tuple, and Mapping types.
| 552 | 565 |
def recursive_to_dict(data):
"""Recursively transform objects that potentially have .to_dict()
into dictionary literals by traversing AttrList, AttrDict, list,
tuple, and Mapping types.
"""
if isinstance(data, AttrList):
data = list(data._l_)
elif hasattr(data, "to_dict"):
data = data.to_dict()
if isinstance(data, (list, tuple)):
return type(data)(recursive_to_dict(inner) for inner in data)
elif isinstance(data, collections.abc.Mapping):
return {key: recursive_to_dict(val) for key, val in data.items()}
return data
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L552-L565
| 37 |
[
0,
1,
2,
3,
4,
5,
7,
8,
9,
10,
11,
12,
13
] | 92.857143 |
[
6
] | 7.142857 | false | 91.5625 | 14 | 5 | 92.857143 | 3 |
def recursive_to_dict(data):
if isinstance(data, AttrList):
data = list(data._l_)
elif hasattr(data, "to_dict"):
data = data.to_dict()
if isinstance(data, (list, tuple)):
return type(data)(recursive_to_dict(inner) for inner in data)
elif isinstance(data, collections.abc.Mapping):
return {key: recursive_to_dict(val) for key, val in data.items()}
return data
| 22,776 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrList.__init__
|
(self, l, obj_wrapper=None)
| 56 | 61 |
def __init__(self, l, obj_wrapper=None):
# make iterables into lists
if not isinstance(l, list):
l = list(l)
self._l_ = l
self._obj_wrapper = obj_wrapper
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L56-L61
| 37 |
[
0,
1,
2,
3,
4,
5
] | 100 |
[] | 0 | true | 91.5625 | 6 | 2 | 100 | 0 |
def __init__(self, l, obj_wrapper=None):
# make iterables into lists
if not isinstance(l, list):
l = list(l)
self._l_ = l
self._obj_wrapper = obj_wrapper
| 22,777 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrList.__repr__
|
(self)
|
return repr(self._l_)
| 63 | 64 |
def __repr__(self):
return repr(self._l_)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L63-L64
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 91.5625 | 2 | 1 | 100 | 0 |
def __repr__(self):
return repr(self._l_)
| 22,778 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrList.__eq__
|
(self, other)
|
return other == self._l_
| 66 | 70 |
def __eq__(self, other):
if isinstance(other, AttrList):
return other._l_ == self._l_
# make sure we still equal to a dict with the same data
return other == self._l_
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L66-L70
| 37 |
[
0,
1,
2,
3,
4
] | 100 |
[] | 0 | true | 91.5625 | 5 | 2 | 100 | 0 |
def __eq__(self, other):
if isinstance(other, AttrList):
return other._l_ == self._l_
# make sure we still equal to a dict with the same data
return other == self._l_
| 22,779 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrList.__ne__
|
(self, other)
|
return not self == other
| 72 | 73 |
def __ne__(self, other):
return not self == other
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L72-L73
| 37 |
[
0
] | 50 |
[
1
] | 50 | false | 91.5625 | 2 | 1 | 50 | 0 |
def __ne__(self, other):
return not self == other
| 22,780 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrList.__getitem__
|
(self, k)
|
return _wrap(l, self._obj_wrapper)
| 75 | 79 |
def __getitem__(self, k):
l = self._l_[k]
if isinstance(k, slice):
return AttrList(l, obj_wrapper=self._obj_wrapper)
return _wrap(l, self._obj_wrapper)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L75-L79
| 37 |
[
0,
1,
2,
3,
4
] | 100 |
[] | 0 | true | 91.5625 | 5 | 2 | 100 | 0 |
def __getitem__(self, k):
l = self._l_[k]
if isinstance(k, slice):
return AttrList(l, obj_wrapper=self._obj_wrapper)
return _wrap(l, self._obj_wrapper)
| 22,781 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrList.__setitem__
|
(self, k, value)
| 81 | 82 |
def __setitem__(self, k, value):
self._l_[k] = value
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L81-L82
| 37 |
[
0
] | 50 |
[
1
] | 50 | false | 91.5625 | 2 | 1 | 50 | 0 |
def __setitem__(self, k, value):
self._l_[k] = value
| 22,782 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrList.__iter__
|
(self)
|
return map(lambda i: _wrap(i, self._obj_wrapper), self._l_)
| 84 | 85 |
def __iter__(self):
return map(lambda i: _wrap(i, self._obj_wrapper), self._l_)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L84-L85
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 91.5625 | 2 | 1 | 100 | 0 |
def __iter__(self):
return map(lambda i: _wrap(i, self._obj_wrapper), self._l_)
| 22,783 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrList.__len__
|
(self)
|
return len(self._l_)
| 87 | 88 |
def __len__(self):
return len(self._l_)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L87-L88
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 91.5625 | 2 | 1 | 100 | 0 |
def __len__(self):
return len(self._l_)
| 22,784 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrList.__nonzero__
|
(self)
|
return bool(self._l_)
| 90 | 91 |
def __nonzero__(self):
return bool(self._l_)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L90-L91
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 91.5625 | 2 | 1 | 100 | 0 |
def __nonzero__(self):
return bool(self._l_)
| 22,785 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrList.__getattr__
|
(self, name)
|
return getattr(self._l_, name)
| 95 | 96 |
def __getattr__(self, name):
return getattr(self._l_, name)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L95-L96
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 91.5625 | 2 | 1 | 100 | 0 |
def __getattr__(self, name):
return getattr(self._l_, name)
| 22,786 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrList.__getstate__
|
(self)
|
return self._l_, self._obj_wrapper
| 98 | 99 |
def __getstate__(self):
return self._l_, self._obj_wrapper
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L98-L99
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 91.5625 | 2 | 1 | 100 | 0 |
def __getstate__(self):
return self._l_, self._obj_wrapper
| 22,787 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrList.__setstate__
|
(self, state)
| 101 | 102 |
def __setstate__(self, state):
self._l_, self._obj_wrapper = state
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L101-L102
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 91.5625 | 2 | 1 | 100 | 0 |
def __setstate__(self, state):
self._l_, self._obj_wrapper = state
| 22,788 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrDict.__init__
|
(self, d)
| 112 | 114 |
def __init__(self, d):
# assign the inner dict manually to prevent __setattr__ from firing
super().__setattr__("_d_", d)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L112-L114
| 37 |
[
0,
1,
2
] | 100 |
[] | 0 | true | 91.5625 | 3 | 1 | 100 | 0 |
def __init__(self, d):
# assign the inner dict manually to prevent __setattr__ from firing
super().__setattr__("_d_", d)
| 22,789 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrDict.__contains__
|
(self, key)
|
return key in self._d_
| 116 | 117 |
def __contains__(self, key):
return key in self._d_
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L116-L117
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 91.5625 | 2 | 1 | 100 | 0 |
def __contains__(self, key):
return key in self._d_
| 22,790 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrDict.__nonzero__
|
(self)
|
return bool(self._d_)
| 119 | 120 |
def __nonzero__(self):
return bool(self._d_)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L119-L120
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 91.5625 | 2 | 1 | 100 | 0 |
def __nonzero__(self):
return bool(self._d_)
| 22,791 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrDict.__dir__
|
(self)
|
return list(self._d_.keys())
| 124 | 126 |
def __dir__(self):
# introspection for auto-complete in IPython etc
return list(self._d_.keys())
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L124-L126
| 37 |
[
0,
1,
2
] | 100 |
[] | 0 | true | 91.5625 | 3 | 1 | 100 | 0 |
def __dir__(self):
# introspection for auto-complete in IPython etc
return list(self._d_.keys())
| 22,792 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrDict.__eq__
|
(self, other)
|
return other == self._d_
| 128 | 132 |
def __eq__(self, other):
if isinstance(other, AttrDict):
return other._d_ == self._d_
# make sure we still equal to a dict with the same data
return other == self._d_
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L128-L132
| 37 |
[
0,
1,
2,
3,
4
] | 100 |
[] | 0 | true | 91.5625 | 5 | 2 | 100 | 0 |
def __eq__(self, other):
if isinstance(other, AttrDict):
return other._d_ == self._d_
# make sure we still equal to a dict with the same data
return other == self._d_
| 22,793 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrDict.__ne__
|
(self, other)
|
return not self == other
| 134 | 135 |
def __ne__(self, other):
return not self == other
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L134-L135
| 37 |
[
0
] | 50 |
[
1
] | 50 | false | 91.5625 | 2 | 1 | 50 | 0 |
def __ne__(self, other):
return not self == other
| 22,794 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrDict.__repr__
|
(self)
|
return r
| 137 | 141 |
def __repr__(self):
r = repr(self._d_)
if len(r) > 60:
r = r[:60] + "...}"
return r
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L137-L141
| 37 |
[
0,
1,
2,
3,
4
] | 100 |
[] | 0 | true | 91.5625 | 5 | 2 | 100 | 0 |
def __repr__(self):
r = repr(self._d_)
if len(r) > 60:
r = r[:60] + "...}"
return r
| 22,795 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrDict.__getstate__
|
(self)
|
return (self._d_,)
| 143 | 144 |
def __getstate__(self):
return (self._d_,)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L143-L144
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 91.5625 | 2 | 1 | 100 | 0 |
def __getstate__(self):
return (self._d_,)
| 22,796 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrDict.__setstate__
|
(self, state)
| 146 | 147 |
def __setstate__(self, state):
super().__setattr__("_d_", state[0])
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L146-L147
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 91.5625 | 2 | 1 | 100 | 0 |
def __setstate__(self, state):
super().__setattr__("_d_", state[0])
| 22,797 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrDict.__getattr__
|
(self, attr_name)
| 149 | 155 |
def __getattr__(self, attr_name):
try:
return self.__getitem__(attr_name)
except KeyError:
raise AttributeError(
f"{self.__class__.__name__!r} object has no attribute {attr_name!r}"
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L149-L155
| 37 |
[
0,
1,
2,
3,
4
] | 71.428571 |
[] | 0 | false | 91.5625 | 7 | 2 | 100 | 0 |
def __getattr__(self, attr_name):
try:
return self.__getitem__(attr_name)
except KeyError:
raise AttributeError(
f"{self.__class__.__name__!r} object has no attribute {attr_name!r}"
)
| 22,798 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrDict.__delattr__
|
(self, attr_name)
| 157 | 163 |
def __delattr__(self, attr_name):
try:
del self._d_[attr_name]
except KeyError:
raise AttributeError(
f"{self.__class__.__name__!r} object has no attribute {attr_name!r}"
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L157-L163
| 37 |
[
0,
1,
2
] | 42.857143 |
[
3,
4
] | 28.571429 | false | 91.5625 | 7 | 2 | 71.428571 | 0 |
def __delattr__(self, attr_name):
try:
del self._d_[attr_name]
except KeyError:
raise AttributeError(
f"{self.__class__.__name__!r} object has no attribute {attr_name!r}"
)
| 22,799 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrDict.__getitem__
|
(self, key)
|
return _wrap(self._d_[key])
| 165 | 166 |
def __getitem__(self, key):
return _wrap(self._d_[key])
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L165-L166
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 91.5625 | 2 | 1 | 100 | 0 |
def __getitem__(self, key):
return _wrap(self._d_[key])
| 22,800 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrDict.__setitem__
|
(self, key, value)
| 168 | 169 |
def __setitem__(self, key, value):
self._d_[key] = value
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L168-L169
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 91.5625 | 2 | 1 | 100 | 0 |
def __setitem__(self, key, value):
self._d_[key] = value
| 22,801 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrDict.__delitem__
|
(self, key)
| 171 | 172 |
def __delitem__(self, key):
del self._d_[key]
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L171-L172
| 37 |
[
0
] | 50 |
[
1
] | 50 | false | 91.5625 | 2 | 1 | 50 | 0 |
def __delitem__(self, key):
del self._d_[key]
| 22,802 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrDict.__setattr__
|
(self, name, value)
| 174 | 179 |
def __setattr__(self, name, value):
if name in self._d_ or not hasattr(self.__class__, name):
self._d_[name] = value
else:
# there is an attribute on the class (could be property, ..) - don't add it as field
super().__setattr__(name, value)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L174-L179
| 37 |
[
0,
1,
2,
4,
5
] | 83.333333 |
[] | 0 | false | 91.5625 | 6 | 3 | 100 | 0 |
def __setattr__(self, name, value):
if name in self._d_ or not hasattr(self.__class__, name):
self._d_[name] = value
else:
# there is an attribute on the class (could be property, ..) - don't add it as field
super().__setattr__(name, value)
| 22,803 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrDict.__iter__
|
(self)
|
return iter(self._d_)
| 181 | 182 |
def __iter__(self):
return iter(self._d_)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L181-L182
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 91.5625 | 2 | 1 | 100 | 0 |
def __iter__(self):
return iter(self._d_)
| 22,804 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
AttrDict.to_dict
|
(self)
|
return self._d_
| 184 | 185 |
def to_dict(self):
return self._d_
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L184-L185
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 91.5625 | 2 | 1 | 100 | 0 |
def to_dict(self):
return self._d_
| 22,805 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
DslMeta.__init__
|
(cls, name, bases, attrs)
| 203 | 216 |
def __init__(cls, name, bases, attrs):
super().__init__(name, bases, attrs)
# skip for DslBase
if not hasattr(cls, "_type_shortcut"):
return
if cls.name is None:
# abstract base class, register it's shortcut
cls._types[cls._type_name] = cls._type_shortcut
# and create a registry for subclasses
if not hasattr(cls, "_classes"):
cls._classes = {}
elif cls.name not in cls._classes:
# normal class, register it
cls._classes[cls.name] = cls
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L203-L216
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13
] | 100 |
[] | 0 | true | 91.5625 | 14 | 5 | 100 | 0 |
def __init__(cls, name, bases, attrs):
super().__init__(name, bases, attrs)
# skip for DslBase
if not hasattr(cls, "_type_shortcut"):
return
if cls.name is None:
# abstract base class, register it's shortcut
cls._types[cls._type_name] = cls._type_shortcut
# and create a registry for subclasses
if not hasattr(cls, "_classes"):
cls._classes = {}
elif cls.name not in cls._classes:
# normal class, register it
cls._classes[cls.name] = cls
| 22,806 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
DslMeta.get_dsl_type
|
(cls, name)
| 219 | 223 |
def get_dsl_type(cls, name):
try:
return cls._types[name]
except KeyError:
raise UnknownDslObject(f"DSL type {name} does not exist.")
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L219-L223
| 37 |
[
0,
1,
2
] | 60 |
[
3,
4
] | 40 | false | 91.5625 | 5 | 2 | 60 | 0 |
def get_dsl_type(cls, name):
try:
return cls._types[name]
except KeyError:
raise UnknownDslObject(f"DSL type {name} does not exist.")
| 22,807 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
DslBase.get_dsl_class
|
(cls, name, default=None)
| 245 | 253 |
def get_dsl_class(cls, name, default=None):
try:
return cls._classes[name]
except KeyError:
if default is not None:
return cls._classes[default]
raise UnknownDslObject(
f"DSL class `{name}` does not exist in {cls._type_name}."
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L245-L253
| 37 |
[
0,
1,
2,
3,
4,
5,
6
] | 77.777778 |
[] | 0 | false | 91.5625 | 9 | 3 | 100 | 0 |
def get_dsl_class(cls, name, default=None):
try:
return cls._classes[name]
except KeyError:
if default is not None:
return cls._classes[default]
raise UnknownDslObject(
f"DSL class `{name}` does not exist in {cls._type_name}."
)
| 22,808 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
DslBase.__init__
|
(self, _expand__to_dot=EXPAND__TO_DOT, **params)
| 255 | 260 |
def __init__(self, _expand__to_dot=EXPAND__TO_DOT, **params):
self._params = {}
for pname, pvalue in params.items():
if "__" in pname and _expand__to_dot:
pname = pname.replace("__", ".")
self._setattr(pname, pvalue)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L255-L260
| 37 |
[
0,
1,
2,
3,
4,
5
] | 100 |
[] | 0 | true | 91.5625 | 6 | 4 | 100 | 0 |
def __init__(self, _expand__to_dot=EXPAND__TO_DOT, **params):
self._params = {}
for pname, pvalue in params.items():
if "__" in pname and _expand__to_dot:
pname = pname.replace("__", ".")
self._setattr(pname, pvalue)
| 22,809 |
|||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
DslBase._repr_params
|
(self)
|
return ", ".join(
f"{n.replace('.', '__')}={v!r}"
for (n, v) in sorted(self._params.items())
# make sure we don't include empty typed params
if "type" not in self._param_defs.get(n, {}) or v
)
|
Produce a repr of all our parameters to be used in __repr__.
|
Produce a repr of all our parameters to be used in __repr__.
| 262 | 269 |
def _repr_params(self):
"""Produce a repr of all our parameters to be used in __repr__."""
return ", ".join(
f"{n.replace('.', '__')}={v!r}"
for (n, v) in sorted(self._params.items())
# make sure we don't include empty typed params
if "type" not in self._param_defs.get(n, {}) or v
)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L262-L269
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7
] | 100 |
[] | 0 | true | 91.5625 | 8 | 2 | 100 | 1 |
def _repr_params(self):
return ", ".join(
f"{n.replace('.', '__')}={v!r}"
for (n, v) in sorted(self._params.items())
# make sure we don't include empty typed params
if "type" not in self._param_defs.get(n, {}) or v
)
| 22,810 |
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
DslBase.__repr__
|
(self)
|
return f"{self.__class__.__name__}({self._repr_params()})"
| 271 | 272 |
def __repr__(self):
return f"{self.__class__.__name__}({self._repr_params()})"
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L271-L272
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 91.5625 | 2 | 1 | 100 | 0 |
def __repr__(self):
return f"{self.__class__.__name__}({self._repr_params()})"
| 22,811 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
DslBase.__eq__
|
(self, other)
|
return isinstance(other, self.__class__) and other.to_dict() == self.to_dict()
| 274 | 275 |
def __eq__(self, other):
return isinstance(other, self.__class__) and other.to_dict() == self.to_dict()
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L274-L275
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 91.5625 | 2 | 2 | 100 | 0 |
def __eq__(self, other):
return isinstance(other, self.__class__) and other.to_dict() == self.to_dict()
| 22,812 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
DslBase.__ne__
|
(self, other)
|
return not self == other
| 277 | 278 |
def __ne__(self, other):
return not self == other
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L277-L278
| 37 |
[
0,
1
] | 100 |
[] | 0 | true | 91.5625 | 2 | 1 | 100 | 0 |
def __ne__(self, other):
return not self == other
| 22,813 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
DslBase.__setattr__
|
(self, name, value)
|
return self._setattr(name, value)
| 280 | 283 |
def __setattr__(self, name, value):
if name.startswith("_"):
return super().__setattr__(name, value)
return self._setattr(name, value)
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L280-L283
| 37 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 91.5625 | 4 | 2 | 100 | 0 |
def __setattr__(self, name, value):
if name.startswith("_"):
return super().__setattr__(name, value)
return self._setattr(name, value)
| 22,814 |
||
elastic/elasticsearch-dsl-py
|
5874ff6bd5a7a77086539159f041eb979b5235cc
|
elasticsearch_dsl/utils.py
|
DslBase._setattr
|
(self, name, value)
| 285 | 313 |
def _setattr(self, name, value):
# if this attribute has special type assigned to it...
if name in self._param_defs:
pinfo = self._param_defs[name]
if "type" in pinfo:
# get the shortcut used to construct this type (query.Q, aggs.A, etc)
shortcut = self.__class__.get_dsl_type(pinfo["type"])
# list of dict(name -> DslBase)
if pinfo.get("multi") and pinfo.get("hash"):
if not isinstance(value, (tuple, list)):
value = (value,)
value = list(
{k: shortcut(v) for (k, v) in obj.items()} for obj in value
)
elif pinfo.get("multi"):
if not isinstance(value, (tuple, list)):
value = (value,)
value = list(map(shortcut, value))
# dict(name -> DslBase), make sure we pickup all the objs
elif pinfo.get("hash"):
value = {k: shortcut(v) for (k, v) in value.items()}
# single value object, just convert
else:
value = shortcut(value)
self._params[name] = value
|
https://github.com/elastic/elasticsearch-dsl-py/blob/5874ff6bd5a7a77086539159f041eb979b5235cc/project37/elasticsearch_dsl/utils.py#L285-L313
| 37 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
27,
28
] | 79.310345 |
[
11,
12,
13
] | 10.344828 | false | 91.5625 | 29 | 9 | 89.655172 | 0 |
def _setattr(self, name, value):
# if this attribute has special type assigned to it...
if name in self._param_defs:
pinfo = self._param_defs[name]
if "type" in pinfo:
# get the shortcut used to construct this type (query.Q, aggs.A, etc)
shortcut = self.__class__.get_dsl_type(pinfo["type"])
# list of dict(name -> DslBase)
if pinfo.get("multi") and pinfo.get("hash"):
if not isinstance(value, (tuple, list)):
value = (value,)
value = list(
{k: shortcut(v) for (k, v) in obj.items()} for obj in value
)
elif pinfo.get("multi"):
if not isinstance(value, (tuple, list)):
value = (value,)
value = list(map(shortcut, value))
# dict(name -> DslBase), make sure we pickup all the objs
elif pinfo.get("hash"):
value = {k: shortcut(v) for (k, v) in value.items()}
# single value object, just convert
else:
value = shortcut(value)
self._params[name] = value
| 22,815 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.