repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
iamteem/redisco | redisco/models/base.py | Model.key | def key(self, att=None):
"""Returns the Redis key where the values are stored."""
if att is not None:
return self._key[self.id][att]
else:
return self._key[self.id] | python | def key(self, att=None):
"""Returns the Redis key where the values are stored."""
if att is not None:
return self._key[self.id][att]
else:
return self._key[self.id] | [
"def",
"key",
"(",
"self",
",",
"att",
"=",
"None",
")",
":",
"if",
"att",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_key",
"[",
"self",
".",
"id",
"]",
"[",
"att",
"]",
"else",
":",
"return",
"self",
".",
"_key",
"[",
"self",
".",
"i... | Returns the Redis key where the values are stored. | [
"Returns",
"the",
"Redis",
"key",
"where",
"the",
"values",
"are",
"stored",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/models/base.py#L205-L210 |
iamteem/redisco | redisco/models/base.py | Model.delete | def delete(self):
"""Deletes the object from the datastore."""
pipeline = self.db.pipeline()
self._delete_from_indices(pipeline)
self._delete_membership(pipeline)
pipeline.delete(self.key())
pipeline.execute() | python | def delete(self):
"""Deletes the object from the datastore."""
pipeline = self.db.pipeline()
self._delete_from_indices(pipeline)
self._delete_membership(pipeline)
pipeline.delete(self.key())
pipeline.execute() | [
"def",
"delete",
"(",
"self",
")",
":",
"pipeline",
"=",
"self",
".",
"db",
".",
"pipeline",
"(",
")",
"self",
".",
"_delete_from_indices",
"(",
"pipeline",
")",
"self",
".",
"_delete_membership",
"(",
"pipeline",
")",
"pipeline",
".",
"delete",
"(",
"se... | Deletes the object from the datastore. | [
"Deletes",
"the",
"object",
"from",
"the",
"datastore",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/models/base.py#L212-L218 |
iamteem/redisco | redisco/models/base.py | Model.incr | def incr(self, att, val=1):
"""Increments a counter."""
if att not in self.counters:
raise ValueError("%s is not a counter.")
self.db.hincrby(self.key(), att, val) | python | def incr(self, att, val=1):
"""Increments a counter."""
if att not in self.counters:
raise ValueError("%s is not a counter.")
self.db.hincrby(self.key(), att, val) | [
"def",
"incr",
"(",
"self",
",",
"att",
",",
"val",
"=",
"1",
")",
":",
"if",
"att",
"not",
"in",
"self",
".",
"counters",
":",
"raise",
"ValueError",
"(",
"\"%s is not a counter.\"",
")",
"self",
".",
"db",
".",
"hincrby",
"(",
"self",
".",
"key",
... | Increments a counter. | [
"Increments",
"a",
"counter",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/models/base.py#L227-L231 |
iamteem/redisco | redisco/models/base.py | Model.attributes_dict | def attributes_dict(self):
"""Returns the mapping of the model attributes and their
values.
"""
h = {}
for k in self.attributes.keys():
h[k] = getattr(self, k)
for k in self.lists.keys():
h[k] = getattr(self, k)
for k in self.references.key... | python | def attributes_dict(self):
"""Returns the mapping of the model attributes and their
values.
"""
h = {}
for k in self.attributes.keys():
h[k] = getattr(self, k)
for k in self.lists.keys():
h[k] = getattr(self, k)
for k in self.references.key... | [
"def",
"attributes_dict",
"(",
"self",
")",
":",
"h",
"=",
"{",
"}",
"for",
"k",
"in",
"self",
".",
"attributes",
".",
"keys",
"(",
")",
":",
"h",
"[",
"k",
"]",
"=",
"getattr",
"(",
"self",
",",
"k",
")",
"for",
"k",
"in",
"self",
".",
"list... | Returns the mapping of the model attributes and their
values. | [
"Returns",
"the",
"mapping",
"of",
"the",
"model",
"attributes",
"and",
"their",
"values",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/models/base.py#L239-L250 |
iamteem/redisco | redisco/models/base.py | Model.fields | def fields(self):
"""Returns the list of field names of the model."""
return (self.attributes.values() + self.lists.values()
+ self.references.values()) | python | def fields(self):
"""Returns the list of field names of the model."""
return (self.attributes.values() + self.lists.values()
+ self.references.values()) | [
"def",
"fields",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"attributes",
".",
"values",
"(",
")",
"+",
"self",
".",
"lists",
".",
"values",
"(",
")",
"+",
"self",
".",
"references",
".",
"values",
"(",
")",
")"
] | Returns the list of field names of the model. | [
"Returns",
"the",
"list",
"of",
"field",
"names",
"of",
"the",
"model",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/models/base.py#L309-L312 |
iamteem/redisco | redisco/models/base.py | Model.exists | def exists(cls, id):
"""Checks if the model with id exists."""
return bool(redisco.get_client().exists(cls._key[str(id)]) or
redisco.get_client().sismember(cls._key['all'], str(id))) | python | def exists(cls, id):
"""Checks if the model with id exists."""
return bool(redisco.get_client().exists(cls._key[str(id)]) or
redisco.get_client().sismember(cls._key['all'], str(id))) | [
"def",
"exists",
"(",
"cls",
",",
"id",
")",
":",
"return",
"bool",
"(",
"redisco",
".",
"get_client",
"(",
")",
".",
"exists",
"(",
"cls",
".",
"_key",
"[",
"str",
"(",
"id",
")",
"]",
")",
"or",
"redisco",
".",
"get_client",
"(",
")",
".",
"s... | Checks if the model with id exists. | [
"Checks",
"if",
"the",
"model",
"with",
"id",
"exists",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/models/base.py#L324-L327 |
iamteem/redisco | redisco/models/base.py | Model._initialize_id | def _initialize_id(self):
"""Initializes the id of the instance."""
self.id = str(self.db.incr(self._key['id'])) | python | def _initialize_id(self):
"""Initializes the id of the instance."""
self.id = str(self.db.incr(self._key['id'])) | [
"def",
"_initialize_id",
"(",
"self",
")",
":",
"self",
".",
"id",
"=",
"str",
"(",
"self",
".",
"db",
".",
"incr",
"(",
"self",
".",
"_key",
"[",
"'id'",
"]",
")",
")"
] | Initializes the id of the instance. | [
"Initializes",
"the",
"id",
"of",
"the",
"instance",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/models/base.py#L333-L335 |
iamteem/redisco | redisco/models/base.py | Model._write | def _write(self, _new=False):
"""Writes the values of the attributes to the datastore.
This method also creates the indices and saves the lists
associated to the object.
"""
pipeline = self.db.pipeline()
self._create_membership(pipeline)
self._update_indices(pipe... | python | def _write(self, _new=False):
"""Writes the values of the attributes to the datastore.
This method also creates the indices and saves the lists
associated to the object.
"""
pipeline = self.db.pipeline()
self._create_membership(pipeline)
self._update_indices(pipe... | [
"def",
"_write",
"(",
"self",
",",
"_new",
"=",
"False",
")",
":",
"pipeline",
"=",
"self",
".",
"db",
".",
"pipeline",
"(",
")",
"self",
".",
"_create_membership",
"(",
"pipeline",
")",
"self",
".",
"_update_indices",
"(",
"pipeline",
")",
"h",
"=",
... | Writes the values of the attributes to the datastore.
This method also creates the indices and saves the lists
associated to the object. | [
"Writes",
"the",
"values",
"of",
"the",
"attributes",
"to",
"the",
"datastore",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/models/base.py#L337-L387 |
iamteem/redisco | redisco/models/base.py | Model._create_membership | def _create_membership(self, pipeline=None):
"""Adds the id of the object to the set of all objects of the same
class.
"""
Set(self._key['all'], pipeline=pipeline).add(self.id) | python | def _create_membership(self, pipeline=None):
"""Adds the id of the object to the set of all objects of the same
class.
"""
Set(self._key['all'], pipeline=pipeline).add(self.id) | [
"def",
"_create_membership",
"(",
"self",
",",
"pipeline",
"=",
"None",
")",
":",
"Set",
"(",
"self",
".",
"_key",
"[",
"'all'",
"]",
",",
"pipeline",
"=",
"pipeline",
")",
".",
"add",
"(",
"self",
".",
"id",
")"
] | Adds the id of the object to the set of all objects of the same
class. | [
"Adds",
"the",
"id",
"of",
"the",
"object",
"to",
"the",
"set",
"of",
"all",
"objects",
"of",
"the",
"same",
"class",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/models/base.py#L393-L397 |
iamteem/redisco | redisco/models/base.py | Model._delete_membership | def _delete_membership(self, pipeline=None):
"""Removes the id of the object to the set of all objects of the
same class.
"""
Set(self._key['all'], pipeline=pipeline).remove(self.id) | python | def _delete_membership(self, pipeline=None):
"""Removes the id of the object to the set of all objects of the
same class.
"""
Set(self._key['all'], pipeline=pipeline).remove(self.id) | [
"def",
"_delete_membership",
"(",
"self",
",",
"pipeline",
"=",
"None",
")",
":",
"Set",
"(",
"self",
".",
"_key",
"[",
"'all'",
"]",
",",
"pipeline",
"=",
"pipeline",
")",
".",
"remove",
"(",
"self",
".",
"id",
")"
] | Removes the id of the object to the set of all objects of the
same class. | [
"Removes",
"the",
"id",
"of",
"the",
"object",
"to",
"the",
"set",
"of",
"all",
"objects",
"of",
"the",
"same",
"class",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/models/base.py#L399-L403 |
iamteem/redisco | redisco/models/base.py | Model._add_to_indices | def _add_to_indices(self, pipeline):
"""Adds the base64 encoded values of the indices."""
for att in self.indices:
self._add_to_index(att, pipeline=pipeline) | python | def _add_to_indices(self, pipeline):
"""Adds the base64 encoded values of the indices."""
for att in self.indices:
self._add_to_index(att, pipeline=pipeline) | [
"def",
"_add_to_indices",
"(",
"self",
",",
"pipeline",
")",
":",
"for",
"att",
"in",
"self",
".",
"indices",
":",
"self",
".",
"_add_to_index",
"(",
"att",
",",
"pipeline",
"=",
"pipeline",
")"
] | Adds the base64 encoded values of the indices. | [
"Adds",
"the",
"base64",
"encoded",
"values",
"of",
"the",
"indices",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/models/base.py#L415-L418 |
iamteem/redisco | redisco/models/base.py | Model._add_to_index | def _add_to_index(self, att, val=None, pipeline=None):
"""
Adds the id to the index.
This also adds to the _indices set of the object.
"""
index = self._index_key_for(att)
if index is None:
return
t, index = index
if t == 'attribute':
... | python | def _add_to_index(self, att, val=None, pipeline=None):
"""
Adds the id to the index.
This also adds to the _indices set of the object.
"""
index = self._index_key_for(att)
if index is None:
return
t, index = index
if t == 'attribute':
... | [
"def",
"_add_to_index",
"(",
"self",
",",
"att",
",",
"val",
"=",
"None",
",",
"pipeline",
"=",
"None",
")",
":",
"index",
"=",
"self",
".",
"_index_key_for",
"(",
"att",
")",
"if",
"index",
"is",
"None",
":",
"return",
"t",
",",
"index",
"=",
"ind... | Adds the id to the index.
This also adds to the _indices set of the object. | [
"Adds",
"the",
"id",
"to",
"the",
"index",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/models/base.py#L420-L444 |
iamteem/redisco | redisco/models/base.py | Model._delete_from_indices | def _delete_from_indices(self, pipeline):
"""Deletes the object's id from the sets(indices) it has been added
to and removes its list of indices (used for housekeeping).
"""
s = Set(self.key()['_indices'])
z = Set(self.key()['_zindices'])
for index in s.members:
... | python | def _delete_from_indices(self, pipeline):
"""Deletes the object's id from the sets(indices) it has been added
to and removes its list of indices (used for housekeeping).
"""
s = Set(self.key()['_indices'])
z = Set(self.key()['_zindices'])
for index in s.members:
... | [
"def",
"_delete_from_indices",
"(",
"self",
",",
"pipeline",
")",
":",
"s",
"=",
"Set",
"(",
"self",
".",
"key",
"(",
")",
"[",
"'_indices'",
"]",
")",
"z",
"=",
"Set",
"(",
"self",
".",
"key",
"(",
")",
"[",
"'_zindices'",
"]",
")",
"for",
"inde... | Deletes the object's id from the sets(indices) it has been added
to and removes its list of indices (used for housekeeping). | [
"Deletes",
"the",
"object",
"s",
"id",
"from",
"the",
"sets",
"(",
"indices",
")",
"it",
"has",
"been",
"added",
"to",
"and",
"removes",
"its",
"list",
"of",
"indices",
"(",
"used",
"for",
"housekeeping",
")",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/models/base.py#L447-L458 |
iamteem/redisco | redisco/models/base.py | Model._index_key_for | def _index_key_for(self, att, value=None):
"""Returns a key based on the attribute and its value.
The key is used for indexing.
"""
if value is None:
value = getattr(self, att)
if callable(value):
value = value()
if value is None:
... | python | def _index_key_for(self, att, value=None):
"""Returns a key based on the attribute and its value.
The key is used for indexing.
"""
if value is None:
value = getattr(self, att)
if callable(value):
value = value()
if value is None:
... | [
"def",
"_index_key_for",
"(",
"self",
",",
"att",
",",
"value",
"=",
"None",
")",
":",
"if",
"value",
"is",
"None",
":",
"value",
"=",
"getattr",
"(",
"self",
",",
"att",
")",
"if",
"callable",
"(",
"value",
")",
":",
"value",
"=",
"value",
"(",
... | Returns a key based on the attribute and its value.
The key is used for indexing. | [
"Returns",
"a",
"key",
"based",
"on",
"the",
"attribute",
"and",
"its",
"value",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/models/base.py#L460-L474 |
iamteem/redisco | redisco/containers.py | Set.isdisjoint | def isdisjoint(self, other):
"""Return True if the set has no elements in common with other."""
return not bool(self.db.sinter([self.key, other.key])) | python | def isdisjoint(self, other):
"""Return True if the set has no elements in common with other."""
return not bool(self.db.sinter([self.key, other.key])) | [
"def",
"isdisjoint",
"(",
"self",
",",
"other",
")",
":",
"return",
"not",
"bool",
"(",
"self",
".",
"db",
".",
"sinter",
"(",
"[",
"self",
".",
"key",
",",
"other",
".",
"key",
"]",
")",
")"
] | Return True if the set has no elements in common with other. | [
"Return",
"True",
"if",
"the",
"set",
"has",
"no",
"elements",
"in",
"common",
"with",
"other",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/containers.py#L86-L88 |
iamteem/redisco | redisco/containers.py | Set.union | def union(self, key, *others):
"""Return a new set with elements from the set and all others."""
if not isinstance(key, str):
raise ValueError("String expected.")
self.db.sunionstore(key, [self.key] + [o.key for o in others])
return Set(key) | python | def union(self, key, *others):
"""Return a new set with elements from the set and all others."""
if not isinstance(key, str):
raise ValueError("String expected.")
self.db.sunionstore(key, [self.key] + [o.key for o in others])
return Set(key) | [
"def",
"union",
"(",
"self",
",",
"key",
",",
"*",
"others",
")",
":",
"if",
"not",
"isinstance",
"(",
"key",
",",
"str",
")",
":",
"raise",
"ValueError",
"(",
"\"String expected.\"",
")",
"self",
".",
"db",
".",
"sunionstore",
"(",
"key",
",",
"[",
... | Return a new set with elements from the set and all others. | [
"Return",
"a",
"new",
"set",
"with",
"elements",
"from",
"the",
"set",
"and",
"all",
"others",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/containers.py#L124-L129 |
iamteem/redisco | redisco/containers.py | Set.intersection | def intersection(self, key, *others):
"""Return a new set with elements common to the set and all others."""
if not isinstance(key, str):
raise ValueError("String expected.")
self.db.sinterstore(key, [self.key] + [o.key for o in others])
return Set(key) | python | def intersection(self, key, *others):
"""Return a new set with elements common to the set and all others."""
if not isinstance(key, str):
raise ValueError("String expected.")
self.db.sinterstore(key, [self.key] + [o.key for o in others])
return Set(key) | [
"def",
"intersection",
"(",
"self",
",",
"key",
",",
"*",
"others",
")",
":",
"if",
"not",
"isinstance",
"(",
"key",
",",
"str",
")",
":",
"raise",
"ValueError",
"(",
"\"String expected.\"",
")",
"self",
".",
"db",
".",
"sinterstore",
"(",
"key",
",",
... | Return a new set with elements common to the set and all others. | [
"Return",
"a",
"new",
"set",
"with",
"elements",
"common",
"to",
"the",
"set",
"and",
"all",
"others",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/containers.py#L131-L136 |
iamteem/redisco | redisco/containers.py | Set.difference | def difference(self, key, *others):
"""Return a new set with elements in the set that are not in the others."""
if not isinstance(key, str):
raise ValueError("String expected.")
self.db.sdiffstore(key, [self.key] + [o.key for o in others])
return Set(key) | python | def difference(self, key, *others):
"""Return a new set with elements in the set that are not in the others."""
if not isinstance(key, str):
raise ValueError("String expected.")
self.db.sdiffstore(key, [self.key] + [o.key for o in others])
return Set(key) | [
"def",
"difference",
"(",
"self",
",",
"key",
",",
"*",
"others",
")",
":",
"if",
"not",
"isinstance",
"(",
"key",
",",
"str",
")",
":",
"raise",
"ValueError",
"(",
"\"String expected.\"",
")",
"self",
".",
"db",
".",
"sdiffstore",
"(",
"key",
",",
"... | Return a new set with elements in the set that are not in the others. | [
"Return",
"a",
"new",
"set",
"with",
"elements",
"in",
"the",
"set",
"that",
"are",
"not",
"in",
"the",
"others",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/containers.py#L138-L143 |
iamteem/redisco | redisco/containers.py | Set.update | def update(self, *others):
"""Update the set, adding elements from all others."""
self.db.sunionstore(self.key, [self.key] + [o.key for o in others]) | python | def update(self, *others):
"""Update the set, adding elements from all others."""
self.db.sunionstore(self.key, [self.key] + [o.key for o in others]) | [
"def",
"update",
"(",
"self",
",",
"*",
"others",
")",
":",
"self",
".",
"db",
".",
"sunionstore",
"(",
"self",
".",
"key",
",",
"[",
"self",
".",
"key",
"]",
"+",
"[",
"o",
".",
"key",
"for",
"o",
"in",
"others",
"]",
")"
] | Update the set, adding elements from all others. | [
"Update",
"the",
"set",
"adding",
"elements",
"from",
"all",
"others",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/containers.py#L145-L147 |
iamteem/redisco | redisco/containers.py | Set.intersection_update | def intersection_update(self, *others):
"""Update the set, keeping only elements found in it and all others."""
self.db.sinterstore(self.key, [o.key for o in [self.key] + others]) | python | def intersection_update(self, *others):
"""Update the set, keeping only elements found in it and all others."""
self.db.sinterstore(self.key, [o.key for o in [self.key] + others]) | [
"def",
"intersection_update",
"(",
"self",
",",
"*",
"others",
")",
":",
"self",
".",
"db",
".",
"sinterstore",
"(",
"self",
".",
"key",
",",
"[",
"o",
".",
"key",
"for",
"o",
"in",
"[",
"self",
".",
"key",
"]",
"+",
"others",
"]",
")"
] | Update the set, keeping only elements found in it and all others. | [
"Update",
"the",
"set",
"keeping",
"only",
"elements",
"found",
"in",
"it",
"and",
"all",
"others",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/containers.py#L153-L155 |
iamteem/redisco | redisco/containers.py | Set.difference_update | def difference_update(self, *others):
"""Update the set, removing elements found in others."""
self.db.sdiffstore(self.key, [o.key for o in [self.key] + others]) | python | def difference_update(self, *others):
"""Update the set, removing elements found in others."""
self.db.sdiffstore(self.key, [o.key for o in [self.key] + others]) | [
"def",
"difference_update",
"(",
"self",
",",
"*",
"others",
")",
":",
"self",
".",
"db",
".",
"sdiffstore",
"(",
"self",
".",
"key",
",",
"[",
"o",
".",
"key",
"for",
"o",
"in",
"[",
"self",
".",
"key",
"]",
"+",
"others",
"]",
")"
] | Update the set, removing elements found in others. | [
"Update",
"the",
"set",
"removing",
"elements",
"found",
"in",
"others",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/containers.py#L161-L163 |
iamteem/redisco | redisco/containers.py | Set.copy | def copy(self, key):
"""Copy the set to another key and return the new Set.
WARNING: If the key exists, it overwrites it.
"""
copy = Set(key=key, db=self.db)
copy.clear()
copy |= self
return copy | python | def copy(self, key):
"""Copy the set to another key and return the new Set.
WARNING: If the key exists, it overwrites it.
"""
copy = Set(key=key, db=self.db)
copy.clear()
copy |= self
return copy | [
"def",
"copy",
"(",
"self",
",",
"key",
")",
":",
"copy",
"=",
"Set",
"(",
"key",
"=",
"key",
",",
"db",
"=",
"self",
".",
"db",
")",
"copy",
".",
"clear",
"(",
")",
"copy",
"|=",
"self",
"return",
"copy"
] | Copy the set to another key and return the new Set.
WARNING: If the key exists, it overwrites it. | [
"Copy",
"the",
"set",
"to",
"another",
"key",
"and",
"return",
"the",
"new",
"Set",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/containers.py#L173-L181 |
iamteem/redisco | redisco/containers.py | Set.sinter | def sinter(self, *other_sets):
"""Performs an intersection between Sets.
Returns a set of common members. Uses Redis.sinter.
"""
return self.db.sinter([self.key] + [s.key for s in other_sets]) | python | def sinter(self, *other_sets):
"""Performs an intersection between Sets.
Returns a set of common members. Uses Redis.sinter.
"""
return self.db.sinter([self.key] + [s.key for s in other_sets]) | [
"def",
"sinter",
"(",
"self",
",",
"*",
"other_sets",
")",
":",
"return",
"self",
".",
"db",
".",
"sinter",
"(",
"[",
"self",
".",
"key",
"]",
"+",
"[",
"s",
".",
"key",
"for",
"s",
"in",
"other_sets",
"]",
")"
] | Performs an intersection between Sets.
Returns a set of common members. Uses Redis.sinter. | [
"Performs",
"an",
"intersection",
"between",
"Sets",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/containers.py#L187-L192 |
iamteem/redisco | redisco/containers.py | Set.sunion | def sunion(self, *other_sets):
"""Union between Sets.
Returns a set of common members. Uses Redis.sunion.
"""
return self.db.sunion([self.key] + [s.key for s in other_sets]) | python | def sunion(self, *other_sets):
"""Union between Sets.
Returns a set of common members. Uses Redis.sunion.
"""
return self.db.sunion([self.key] + [s.key for s in other_sets]) | [
"def",
"sunion",
"(",
"self",
",",
"*",
"other_sets",
")",
":",
"return",
"self",
".",
"db",
".",
"sunion",
"(",
"[",
"self",
".",
"key",
"]",
"+",
"[",
"s",
".",
"key",
"for",
"s",
"in",
"other_sets",
"]",
")"
] | Union between Sets.
Returns a set of common members. Uses Redis.sunion. | [
"Union",
"between",
"Sets",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/containers.py#L194-L199 |
iamteem/redisco | redisco/containers.py | Set.sdiff | def sdiff(self, *other_sets):
"""Union between Sets.
Returns a set of common members. Uses Redis.sdiff.
"""
return self.db.sdiff([self.key] + [s.key for s in other_sets]) | python | def sdiff(self, *other_sets):
"""Union between Sets.
Returns a set of common members. Uses Redis.sdiff.
"""
return self.db.sdiff([self.key] + [s.key for s in other_sets]) | [
"def",
"sdiff",
"(",
"self",
",",
"*",
"other_sets",
")",
":",
"return",
"self",
".",
"db",
".",
"sdiff",
"(",
"[",
"self",
".",
"key",
"]",
"+",
"[",
"s",
".",
"key",
"for",
"s",
"in",
"other_sets",
"]",
")"
] | Union between Sets.
Returns a set of common members. Uses Redis.sdiff. | [
"Union",
"between",
"Sets",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/containers.py#L201-L206 |
iamteem/redisco | redisco/containers.py | List.reverse | def reverse(self):
"""Reverse in place."""
r = self[:]
r.reverse()
self.clear()
self.extend(r) | python | def reverse(self):
"""Reverse in place."""
r = self[:]
r.reverse()
self.clear()
self.extend(r) | [
"def",
"reverse",
"(",
"self",
")",
":",
"r",
"=",
"self",
"[",
":",
"]",
"r",
".",
"reverse",
"(",
")",
"self",
".",
"clear",
"(",
")",
"self",
".",
"extend",
"(",
"r",
")"
] | Reverse in place. | [
"Reverse",
"in",
"place",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/containers.py#L275-L280 |
iamteem/redisco | redisco/containers.py | List.copy | def copy(self, key):
"""Copy the list to a new list.
WARNING: If key exists, it clears it before copying.
"""
copy = List(key, self.db)
copy.clear()
copy.extend(self)
return copy | python | def copy(self, key):
"""Copy the list to a new list.
WARNING: If key exists, it clears it before copying.
"""
copy = List(key, self.db)
copy.clear()
copy.extend(self)
return copy | [
"def",
"copy",
"(",
"self",
",",
"key",
")",
":",
"copy",
"=",
"List",
"(",
"key",
",",
"self",
".",
"db",
")",
"copy",
".",
"clear",
"(",
")",
"copy",
".",
"extend",
"(",
"self",
")",
"return",
"copy"
] | Copy the list to a new list.
WARNING: If key exists, it clears it before copying. | [
"Copy",
"the",
"list",
"to",
"a",
"new",
"list",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/containers.py#L282-L290 |
iamteem/redisco | redisco/containers.py | SortedSet.lt | def lt(self, v, limit=None, offset=None):
"""Returns the list of the members of the set that have scores
less than v.
"""
if limit is not None and offset is None:
offset = 0
return self.zrangebyscore(self._min_score, "(%f" % v,
start=offset, num=limit) | python | def lt(self, v, limit=None, offset=None):
"""Returns the list of the members of the set that have scores
less than v.
"""
if limit is not None and offset is None:
offset = 0
return self.zrangebyscore(self._min_score, "(%f" % v,
start=offset, num=limit) | [
"def",
"lt",
"(",
"self",
",",
"v",
",",
"limit",
"=",
"None",
",",
"offset",
"=",
"None",
")",
":",
"if",
"limit",
"is",
"not",
"None",
"and",
"offset",
"is",
"None",
":",
"offset",
"=",
"0",
"return",
"self",
".",
"zrangebyscore",
"(",
"self",
... | Returns the list of the members of the set that have scores
less than v. | [
"Returns",
"the",
"list",
"of",
"the",
"members",
"of",
"the",
"set",
"that",
"have",
"scores",
"less",
"than",
"v",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/containers.py#L457-L464 |
iamteem/redisco | redisco/containers.py | SortedSet.gt | def gt(self, v, limit=None, offset=None):
"""Returns the list of the members of the set that have scores
greater than v.
"""
if limit is not None and offset is None:
offset = 0
return self.zrangebyscore("(%f" % v, self._max_score,
start=offset, num=lim... | python | def gt(self, v, limit=None, offset=None):
"""Returns the list of the members of the set that have scores
greater than v.
"""
if limit is not None and offset is None:
offset = 0
return self.zrangebyscore("(%f" % v, self._max_score,
start=offset, num=lim... | [
"def",
"gt",
"(",
"self",
",",
"v",
",",
"limit",
"=",
"None",
",",
"offset",
"=",
"None",
")",
":",
"if",
"limit",
"is",
"not",
"None",
"and",
"offset",
"is",
"None",
":",
"offset",
"=",
"0",
"return",
"self",
".",
"zrangebyscore",
"(",
"\"(%f\"",... | Returns the list of the members of the set that have scores
greater than v. | [
"Returns",
"the",
"list",
"of",
"the",
"members",
"of",
"the",
"set",
"that",
"have",
"scores",
"greater",
"than",
"v",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/containers.py#L475-L482 |
iamteem/redisco | redisco/containers.py | SortedSet.between | def between(self, min, max, limit=None, offset=None):
"""Returns the list of the members of the set that have scores
between min and max.
"""
if limit is not None and offset is None:
offset = 0
return self.zrangebyscore(min, max,
start=offset, num=limi... | python | def between(self, min, max, limit=None, offset=None):
"""Returns the list of the members of the set that have scores
between min and max.
"""
if limit is not None and offset is None:
offset = 0
return self.zrangebyscore(min, max,
start=offset, num=limi... | [
"def",
"between",
"(",
"self",
",",
"min",
",",
"max",
",",
"limit",
"=",
"None",
",",
"offset",
"=",
"None",
")",
":",
"if",
"limit",
"is",
"not",
"None",
"and",
"offset",
"is",
"None",
":",
"offset",
"=",
"0",
"return",
"self",
".",
"zrangebyscor... | Returns the list of the members of the set that have scores
between min and max. | [
"Returns",
"the",
"list",
"of",
"the",
"members",
"of",
"the",
"set",
"that",
"have",
"scores",
"between",
"min",
"and",
"max",
"."
] | train | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/containers.py#L493-L500 |
nakagami/pyfirebirdsql | firebirdsql/utils.py | hex_to_bytes | def hex_to_bytes(s):
"""
convert hex string to bytes
"""
if len(s) % 2:
s = b'0' + s
ia = [int(s[i:i+2], 16) for i in range(0, len(s), 2)] # int array
return bs(ia) if PYTHON_MAJOR_VER == 3 else b''.join([chr(c) for c in ia]) | python | def hex_to_bytes(s):
"""
convert hex string to bytes
"""
if len(s) % 2:
s = b'0' + s
ia = [int(s[i:i+2], 16) for i in range(0, len(s), 2)] # int array
return bs(ia) if PYTHON_MAJOR_VER == 3 else b''.join([chr(c) for c in ia]) | [
"def",
"hex_to_bytes",
"(",
"s",
")",
":",
"if",
"len",
"(",
"s",
")",
"%",
"2",
":",
"s",
"=",
"b'0'",
"+",
"s",
"ia",
"=",
"[",
"int",
"(",
"s",
"[",
"i",
":",
"i",
"+",
"2",
"]",
",",
"16",
")",
"for",
"i",
"in",
"range",
"(",
"0",
... | convert hex string to bytes | [
"convert",
"hex",
"string",
"to",
"bytes"
] | train | https://github.com/nakagami/pyfirebirdsql/blob/5ce366c2fc8318510444f4a89801442f3e9e52ca/firebirdsql/utils.py#L43-L50 |
nakagami/pyfirebirdsql | firebirdsql/srp.py | client_seed | def client_seed(a=random.randrange(0, 1 << SRP_KEY_SIZE)):
"""
A: Client public key
a: Client private key
"""
if DEBUG:
a = DEBUG_PRIVATE_KEY
N, g, k = get_prime()
A = pow(g, a, N)
if DEBUG_PRINT:
print('a=', binascii.b2a_hex(long2bytes(a)), end='\n')
prin... | python | def client_seed(a=random.randrange(0, 1 << SRP_KEY_SIZE)):
"""
A: Client public key
a: Client private key
"""
if DEBUG:
a = DEBUG_PRIVATE_KEY
N, g, k = get_prime()
A = pow(g, a, N)
if DEBUG_PRINT:
print('a=', binascii.b2a_hex(long2bytes(a)), end='\n')
prin... | [
"def",
"client_seed",
"(",
"a",
"=",
"random",
".",
"randrange",
"(",
"0",
",",
"1",
"<<",
"SRP_KEY_SIZE",
")",
")",
":",
"if",
"DEBUG",
":",
"a",
"=",
"DEBUG_PRIVATE_KEY",
"N",
",",
"g",
",",
"k",
"=",
"get_prime",
"(",
")",
"A",
"=",
"pow",
"("... | A: Client public key
a: Client private key | [
"A",
":",
"Client",
"public",
"key",
"a",
":",
"Client",
"private",
"key"
] | train | https://github.com/nakagami/pyfirebirdsql/blob/5ce366c2fc8318510444f4a89801442f3e9e52ca/firebirdsql/srp.py#L181-L193 |
nakagami/pyfirebirdsql | firebirdsql/srp.py | server_seed | def server_seed(v, b=random.randrange(0, 1 << SRP_KEY_SIZE)):
"""
B: Server public key
b: Server private key
"""
N, g, k = get_prime()
if DEBUG:
b = DEBUG_PRIVATE_KEY
gb = pow(g, b, N)
kv = (k * v) % N
B = (kv + gb) % N
if DEBUG_PRINT:
print("v", binascii.... | python | def server_seed(v, b=random.randrange(0, 1 << SRP_KEY_SIZE)):
"""
B: Server public key
b: Server private key
"""
N, g, k = get_prime()
if DEBUG:
b = DEBUG_PRIVATE_KEY
gb = pow(g, b, N)
kv = (k * v) % N
B = (kv + gb) % N
if DEBUG_PRINT:
print("v", binascii.... | [
"def",
"server_seed",
"(",
"v",
",",
"b",
"=",
"random",
".",
"randrange",
"(",
"0",
",",
"1",
"<<",
"SRP_KEY_SIZE",
")",
")",
":",
"N",
",",
"g",
",",
"k",
"=",
"get_prime",
"(",
")",
"if",
"DEBUG",
":",
"b",
"=",
"DEBUG_PRIVATE_KEY",
"gb",
"=",... | B: Server public key
b: Server private key | [
"B",
":",
"Server",
"public",
"key",
"b",
":",
"Server",
"private",
"key"
] | train | https://github.com/nakagami/pyfirebirdsql/blob/5ce366c2fc8318510444f4a89801442f3e9e52ca/firebirdsql/srp.py#L196-L215 |
nakagami/pyfirebirdsql | firebirdsql/srp.py | client_session | def client_session(user, password, salt, A, B, a):
"""
Client session secret
Both: u = H(A, B)
User: x = H(s, p) (user enters password)
User: S = (B - kg^x) ^ (a + ux) (computes session key)
User: K = H(S)
"""
N, g, k = get_prime()
u = get_scram... | python | def client_session(user, password, salt, A, B, a):
"""
Client session secret
Both: u = H(A, B)
User: x = H(s, p) (user enters password)
User: S = (B - kg^x) ^ (a + ux) (computes session key)
User: K = H(S)
"""
N, g, k = get_prime()
u = get_scram... | [
"def",
"client_session",
"(",
"user",
",",
"password",
",",
"salt",
",",
"A",
",",
"B",
",",
"a",
")",
":",
"N",
",",
"g",
",",
"k",
"=",
"get_prime",
"(",
")",
"u",
"=",
"get_scramble",
"(",
"A",
",",
"B",
")",
"x",
"=",
"getUserHash",
"(",
... | Client session secret
Both: u = H(A, B)
User: x = H(s, p) (user enters password)
User: S = (B - kg^x) ^ (a + ux) (computes session key)
User: K = H(S) | [
"Client",
"session",
"secret",
"Both",
":",
"u",
"=",
"H",
"(",
"A",
"B",
")"
] | train | https://github.com/nakagami/pyfirebirdsql/blob/5ce366c2fc8318510444f4a89801442f3e9e52ca/firebirdsql/srp.py#L218-L249 |
nakagami/pyfirebirdsql | firebirdsql/srp.py | server_session | def server_session(user, password, salt, A, B, b):
"""
Server session secret
Both: u = H(A, B)
Host: S = (Av^u) ^ b (computes session key)
Host: K = H(S)
"""
N, g, k = get_prime()
u = get_scramble(A, B)
v = get_verifier(user, password, salt)
vu = pow(... | python | def server_session(user, password, salt, A, B, b):
"""
Server session secret
Both: u = H(A, B)
Host: S = (Av^u) ^ b (computes session key)
Host: K = H(S)
"""
N, g, k = get_prime()
u = get_scramble(A, B)
v = get_verifier(user, password, salt)
vu = pow(... | [
"def",
"server_session",
"(",
"user",
",",
"password",
",",
"salt",
",",
"A",
",",
"B",
",",
"b",
")",
":",
"N",
",",
"g",
",",
"k",
"=",
"get_prime",
"(",
")",
"u",
"=",
"get_scramble",
"(",
"A",
",",
"B",
")",
"v",
"=",
"get_verifier",
"(",
... | Server session secret
Both: u = H(A, B)
Host: S = (Av^u) ^ b (computes session key)
Host: K = H(S) | [
"Server",
"session",
"secret",
"Both",
":",
"u",
"=",
"H",
"(",
"A",
"B",
")"
] | train | https://github.com/nakagami/pyfirebirdsql/blob/5ce366c2fc8318510444f4a89801442f3e9e52ca/firebirdsql/srp.py#L252-L271 |
nakagami/pyfirebirdsql | firebirdsql/srp.py | client_proof | def client_proof(user, password, salt, A, B, a, hash_algo):
"""
M = H(H(N) xor H(g), H(I), s, A, B, K)
"""
N, g, k = get_prime()
K = client_session(user, password, salt, A, B, a)
n1 = bytes2long(hash_digest(hashlib.sha1, N))
n2 = bytes2long(hash_digest(hashlib.sha1, g))
if DEBUG_PRINT:
... | python | def client_proof(user, password, salt, A, B, a, hash_algo):
"""
M = H(H(N) xor H(g), H(I), s, A, B, K)
"""
N, g, k = get_prime()
K = client_session(user, password, salt, A, B, a)
n1 = bytes2long(hash_digest(hashlib.sha1, N))
n2 = bytes2long(hash_digest(hashlib.sha1, g))
if DEBUG_PRINT:
... | [
"def",
"client_proof",
"(",
"user",
",",
"password",
",",
"salt",
",",
"A",
",",
"B",
",",
"a",
",",
"hash_algo",
")",
":",
"N",
",",
"g",
",",
"k",
"=",
"get_prime",
"(",
")",
"K",
"=",
"client_session",
"(",
"user",
",",
"password",
",",
"salt"... | M = H(H(N) xor H(g), H(I), s, A, B, K) | [
"M",
"=",
"H",
"(",
"H",
"(",
"N",
")",
"xor",
"H",
"(",
"g",
")",
"H",
"(",
"I",
")",
"s",
"A",
"B",
"K",
")"
] | train | https://github.com/nakagami/pyfirebirdsql/blob/5ce366c2fc8318510444f4a89801442f3e9e52ca/firebirdsql/srp.py#L274-L296 |
nakagami/pyfirebirdsql | firebirdsql/decfloat.py | dpd_to_int | def dpd_to_int(dpd):
"""
Convert DPD encodined value to int (0-999)
dpd: DPD encoded value. 10bit unsigned int
"""
b = [None] * 10
b[9] = 1 if dpd & 0b1000000000 else 0
b[8] = 1 if dpd & 0b0100000000 else 0
b[7] = 1 if dpd & 0b0010000000 else 0
b[6] = 1 if dpd & 0b0001000000 else 0
... | python | def dpd_to_int(dpd):
"""
Convert DPD encodined value to int (0-999)
dpd: DPD encoded value. 10bit unsigned int
"""
b = [None] * 10
b[9] = 1 if dpd & 0b1000000000 else 0
b[8] = 1 if dpd & 0b0100000000 else 0
b[7] = 1 if dpd & 0b0010000000 else 0
b[6] = 1 if dpd & 0b0001000000 else 0
... | [
"def",
"dpd_to_int",
"(",
"dpd",
")",
":",
"b",
"=",
"[",
"None",
"]",
"*",
"10",
"b",
"[",
"9",
"]",
"=",
"1",
"if",
"dpd",
"&",
"0b1000000000",
"else",
"0",
"b",
"[",
"8",
"]",
"=",
"1",
"if",
"dpd",
"&",
"0b0100000000",
"else",
"0",
"b",
... | Convert DPD encodined value to int (0-999)
dpd: DPD encoded value. 10bit unsigned int | [
"Convert",
"DPD",
"encodined",
"value",
"to",
"int",
"(",
"0",
"-",
"999",
")",
"dpd",
":",
"DPD",
"encoded",
"value",
".",
"10bit",
"unsigned",
"int"
] | train | https://github.com/nakagami/pyfirebirdsql/blob/5ce366c2fc8318510444f4a89801442f3e9e52ca/firebirdsql/decfloat.py#L47-L100 |
nakagami/pyfirebirdsql | firebirdsql/decfloat.py | calc_significand | def calc_significand(prefix, dpd_bits, num_bits):
"""
prefix: High bits integer value
dpd_bits: dpd encoded bits
num_bits: bit length of dpd_bits
"""
# https://en.wikipedia.org/wiki/Decimal128_floating-point_format#Densely_packed_decimal_significand_field
num_segments = num_bits // 10
se... | python | def calc_significand(prefix, dpd_bits, num_bits):
"""
prefix: High bits integer value
dpd_bits: dpd encoded bits
num_bits: bit length of dpd_bits
"""
# https://en.wikipedia.org/wiki/Decimal128_floating-point_format#Densely_packed_decimal_significand_field
num_segments = num_bits // 10
se... | [
"def",
"calc_significand",
"(",
"prefix",
",",
"dpd_bits",
",",
"num_bits",
")",
":",
"# https://en.wikipedia.org/wiki/Decimal128_floating-point_format#Densely_packed_decimal_significand_field",
"num_segments",
"=",
"num_bits",
"//",
"10",
"segments",
"=",
"[",
"]",
"for",
... | prefix: High bits integer value
dpd_bits: dpd encoded bits
num_bits: bit length of dpd_bits | [
"prefix",
":",
"High",
"bits",
"integer",
"value",
"dpd_bits",
":",
"dpd",
"encoded",
"bits",
"num_bits",
":",
"bit",
"length",
"of",
"dpd_bits"
] | train | https://github.com/nakagami/pyfirebirdsql/blob/5ce366c2fc8318510444f4a89801442f3e9e52ca/firebirdsql/decfloat.py#L103-L121 |
nakagami/pyfirebirdsql | firebirdsql/decfloat.py | decimal128_to_decimal | def decimal128_to_decimal(b):
"decimal128 bytes to Decimal"
v = decimal128_to_sign_digits_exponent(b)
if isinstance(v, Decimal):
return v
sign, digits, exponent = v
return Decimal((sign, Decimal(digits).as_tuple()[1], exponent)) | python | def decimal128_to_decimal(b):
"decimal128 bytes to Decimal"
v = decimal128_to_sign_digits_exponent(b)
if isinstance(v, Decimal):
return v
sign, digits, exponent = v
return Decimal((sign, Decimal(digits).as_tuple()[1], exponent)) | [
"def",
"decimal128_to_decimal",
"(",
"b",
")",
":",
"v",
"=",
"decimal128_to_sign_digits_exponent",
"(",
"b",
")",
"if",
"isinstance",
"(",
"v",
",",
"Decimal",
")",
":",
"return",
"v",
"sign",
",",
"digits",
",",
"exponent",
"=",
"v",
"return",
"Decimal",... | decimal128 bytes to Decimal | [
"decimal128",
"bytes",
"to",
"Decimal"
] | train | https://github.com/nakagami/pyfirebirdsql/blob/5ce366c2fc8318510444f4a89801442f3e9e52ca/firebirdsql/decfloat.py#L216-L222 |
bennylope/pygeocodio | geocodio/client.py | error_response | def error_response(response):
"""
Raises errors matching the response code
"""
if response.status_code >= 500:
raise exceptions.GeocodioServerError
elif response.status_code == 403:
raise exceptions.GeocodioAuthError
elif response.status_code == 422:
raise exceptions.Ge... | python | def error_response(response):
"""
Raises errors matching the response code
"""
if response.status_code >= 500:
raise exceptions.GeocodioServerError
elif response.status_code == 403:
raise exceptions.GeocodioAuthError
elif response.status_code == 422:
raise exceptions.Ge... | [
"def",
"error_response",
"(",
"response",
")",
":",
"if",
"response",
".",
"status_code",
">=",
"500",
":",
"raise",
"exceptions",
".",
"GeocodioServerError",
"elif",
"response",
".",
"status_code",
"==",
"403",
":",
"raise",
"exceptions",
".",
"GeocodioAuthErro... | Raises errors matching the response code | [
"Raises",
"errors",
"matching",
"the",
"response",
"code"
] | train | https://github.com/bennylope/pygeocodio/blob/4c33d3d34f6b63d4b8fe85fe571ae02b9f67d6c3/geocodio/client.py#L47-L63 |
bennylope/pygeocodio | geocodio/client.py | GeocodioClient._req | def _req(self, method="get", verb=None, headers={}, params={}, data={}):
"""
Method to wrap all request building
:return: a Response object based on the specified method and request values.
"""
url = self.BASE_URL.format(verb=verb)
request_headers = {"content-type": "app... | python | def _req(self, method="get", verb=None, headers={}, params={}, data={}):
"""
Method to wrap all request building
:return: a Response object based on the specified method and request values.
"""
url = self.BASE_URL.format(verb=verb)
request_headers = {"content-type": "app... | [
"def",
"_req",
"(",
"self",
",",
"method",
"=",
"\"get\"",
",",
"verb",
"=",
"None",
",",
"headers",
"=",
"{",
"}",
",",
"params",
"=",
"{",
"}",
",",
"data",
"=",
"{",
"}",
")",
":",
"url",
"=",
"self",
".",
"BASE_URL",
".",
"format",
"(",
"... | Method to wrap all request building
:return: a Response object based on the specified method and request values. | [
"Method",
"to",
"wrap",
"all",
"request",
"building"
] | train | https://github.com/bennylope/pygeocodio/blob/4c33d3d34f6b63d4b8fe85fe571ae02b9f67d6c3/geocodio/client.py#L94-L107 |
bennylope/pygeocodio | geocodio/client.py | GeocodioClient.parse | def parse(self, address):
"""
Returns an Address dictionary with the components of the queried
address.
>>> client = GeocodioClient('some_api_key')
>>> client.parse("1600 Pennsylvania Ave, Washington DC")
{
"address_components": {
"number": "1... | python | def parse(self, address):
"""
Returns an Address dictionary with the components of the queried
address.
>>> client = GeocodioClient('some_api_key')
>>> client.parse("1600 Pennsylvania Ave, Washington DC")
{
"address_components": {
"number": "1... | [
"def",
"parse",
"(",
"self",
",",
"address",
")",
":",
"response",
"=",
"self",
".",
"_req",
"(",
"verb",
"=",
"\"parse\"",
",",
"params",
"=",
"{",
"\"q\"",
":",
"address",
"}",
")",
"if",
"response",
".",
"status_code",
"!=",
"200",
":",
"return",
... | Returns an Address dictionary with the components of the queried
address.
>>> client = GeocodioClient('some_api_key')
>>> client.parse("1600 Pennsylvania Ave, Washington DC")
{
"address_components": {
"number": "1600",
"street": "Pennsylvania"... | [
"Returns",
"an",
"Address",
"dictionary",
"with",
"the",
"components",
"of",
"the",
"queried",
"address",
"."
] | train | https://github.com/bennylope/pygeocodio/blob/4c33d3d34f6b63d4b8fe85fe571ae02b9f67d6c3/geocodio/client.py#L109-L131 |
bennylope/pygeocodio | geocodio/client.py | GeocodioClient.batch_geocode | def batch_geocode(self, addresses, **kwargs):
"""
Returns an Address dictionary with the components of the queried
address.
"""
fields = ",".join(kwargs.pop("fields", []))
response = self._req(
"post",
verb="geocode",
params={"fields": ... | python | def batch_geocode(self, addresses, **kwargs):
"""
Returns an Address dictionary with the components of the queried
address.
"""
fields = ",".join(kwargs.pop("fields", []))
response = self._req(
"post",
verb="geocode",
params={"fields": ... | [
"def",
"batch_geocode",
"(",
"self",
",",
"addresses",
",",
"*",
"*",
"kwargs",
")",
":",
"fields",
"=",
"\",\"",
".",
"join",
"(",
"kwargs",
".",
"pop",
"(",
"\"fields\"",
",",
"[",
"]",
")",
")",
"response",
"=",
"self",
".",
"_req",
"(",
"\"post... | Returns an Address dictionary with the components of the queried
address. | [
"Returns",
"an",
"Address",
"dictionary",
"with",
"the",
"components",
"of",
"the",
"queried",
"address",
"."
] | train | https://github.com/bennylope/pygeocodio/blob/4c33d3d34f6b63d4b8fe85fe571ae02b9f67d6c3/geocodio/client.py#L134-L149 |
bennylope/pygeocodio | geocodio/client.py | GeocodioClient.geocode_address | def geocode_address(self, address, **kwargs):
"""
Returns a Location dictionary with the components of the queried
address and the geocoded location.
>>> client = GeocodioClient('some_api_key')
>>> client.geocode("1600 Pennsylvania Ave, Washington DC")
{
"input":... | python | def geocode_address(self, address, **kwargs):
"""
Returns a Location dictionary with the components of the queried
address and the geocoded location.
>>> client = GeocodioClient('some_api_key')
>>> client.geocode("1600 Pennsylvania Ave, Washington DC")
{
"input":... | [
"def",
"geocode_address",
"(",
"self",
",",
"address",
",",
"*",
"*",
"kwargs",
")",
":",
"fields",
"=",
"\",\"",
".",
"join",
"(",
"kwargs",
".",
"pop",
"(",
"\"fields\"",
",",
"[",
"]",
")",
")",
"response",
"=",
"self",
".",
"_req",
"(",
"verb",... | Returns a Location dictionary with the components of the queried
address and the geocoded location.
>>> client = GeocodioClient('some_api_key')
>>> client.geocode("1600 Pennsylvania Ave, Washington DC")
{
"input": {
"address_components": {
"number": "... | [
"Returns",
"a",
"Location",
"dictionary",
"with",
"the",
"components",
"of",
"the",
"queried",
"address",
"and",
"the",
"geocoded",
"location",
"."
] | train | https://github.com/bennylope/pygeocodio/blob/4c33d3d34f6b63d4b8fe85fe571ae02b9f67d6c3/geocodio/client.py#L152-L211 |
bennylope/pygeocodio | geocodio/client.py | GeocodioClient.geocode | def geocode(self, address_data, **kwargs):
"""
Returns geocoding data for either a list of addresses or a single
address represented as a string.
Provides a single point of access for end users.
"""
if isinstance(address_data, list):
return self.batch_geocode... | python | def geocode(self, address_data, **kwargs):
"""
Returns geocoding data for either a list of addresses or a single
address represented as a string.
Provides a single point of access for end users.
"""
if isinstance(address_data, list):
return self.batch_geocode... | [
"def",
"geocode",
"(",
"self",
",",
"address_data",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"address_data",
",",
"list",
")",
":",
"return",
"self",
".",
"batch_geocode",
"(",
"address_data",
",",
"*",
"*",
"kwargs",
")",
"return",
... | Returns geocoding data for either a list of addresses or a single
address represented as a string.
Provides a single point of access for end users. | [
"Returns",
"geocoding",
"data",
"for",
"either",
"a",
"list",
"of",
"addresses",
"or",
"a",
"single",
"address",
"represented",
"as",
"a",
"string",
"."
] | train | https://github.com/bennylope/pygeocodio/blob/4c33d3d34f6b63d4b8fe85fe571ae02b9f67d6c3/geocodio/client.py#L214-L224 |
bennylope/pygeocodio | geocodio/client.py | GeocodioClient.reverse_point | def reverse_point(self, latitude, longitude, **kwargs):
"""
Method for identifying an address from a geographic point
"""
fields = ",".join(kwargs.pop("fields", []))
point_param = "{0},{1}".format(latitude, longitude)
response = self._req(
verb="reverse", para... | python | def reverse_point(self, latitude, longitude, **kwargs):
"""
Method for identifying an address from a geographic point
"""
fields = ",".join(kwargs.pop("fields", []))
point_param = "{0},{1}".format(latitude, longitude)
response = self._req(
verb="reverse", para... | [
"def",
"reverse_point",
"(",
"self",
",",
"latitude",
",",
"longitude",
",",
"*",
"*",
"kwargs",
")",
":",
"fields",
"=",
"\",\"",
".",
"join",
"(",
"kwargs",
".",
"pop",
"(",
"\"fields\"",
",",
"[",
"]",
")",
")",
"point_param",
"=",
"\"{0},{1}\"",
... | Method for identifying an address from a geographic point | [
"Method",
"for",
"identifying",
"an",
"address",
"from",
"a",
"geographic",
"point"
] | train | https://github.com/bennylope/pygeocodio/blob/4c33d3d34f6b63d4b8fe85fe571ae02b9f67d6c3/geocodio/client.py#L227-L239 |
bennylope/pygeocodio | geocodio/client.py | GeocodioClient.batch_reverse | def batch_reverse(self, points, **kwargs):
"""
Method for identifying the addresses from a list of lat/lng tuples
"""
fields = ",".join(kwargs.pop("fields", []))
response = self._req(
"post", verb="reverse", params={"fields": fields}, data=json_points(points)
... | python | def batch_reverse(self, points, **kwargs):
"""
Method for identifying the addresses from a list of lat/lng tuples
"""
fields = ",".join(kwargs.pop("fields", []))
response = self._req(
"post", verb="reverse", params={"fields": fields}, data=json_points(points)
... | [
"def",
"batch_reverse",
"(",
"self",
",",
"points",
",",
"*",
"*",
"kwargs",
")",
":",
"fields",
"=",
"\",\"",
".",
"join",
"(",
"kwargs",
".",
"pop",
"(",
"\"fields\"",
",",
"[",
"]",
")",
")",
"response",
"=",
"self",
".",
"_req",
"(",
"\"post\""... | Method for identifying the addresses from a list of lat/lng tuples | [
"Method",
"for",
"identifying",
"the",
"addresses",
"from",
"a",
"list",
"of",
"lat",
"/",
"lng",
"tuples"
] | train | https://github.com/bennylope/pygeocodio/blob/4c33d3d34f6b63d4b8fe85fe571ae02b9f67d6c3/geocodio/client.py#L242-L254 |
bennylope/pygeocodio | geocodio/client.py | GeocodioClient.reverse | def reverse(self, points, **kwargs):
"""
General method for reversing addresses, either a single address or
multiple.
*args should either be a longitude/latitude pair or a list of
such pairs::
>>> multiple_locations = reverse([(40, -19), (43, 112)])
>>> single_l... | python | def reverse(self, points, **kwargs):
"""
General method for reversing addresses, either a single address or
multiple.
*args should either be a longitude/latitude pair or a list of
such pairs::
>>> multiple_locations = reverse([(40, -19), (43, 112)])
>>> single_l... | [
"def",
"reverse",
"(",
"self",
",",
"points",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"points",
",",
"list",
")",
":",
"return",
"self",
".",
"batch_reverse",
"(",
"points",
",",
"*",
"*",
"kwargs",
")",
"if",
"self",
".",
"orde... | General method for reversing addresses, either a single address or
multiple.
*args should either be a longitude/latitude pair or a list of
such pairs::
>>> multiple_locations = reverse([(40, -19), (43, 112)])
>>> single_location = reverse((40, -19)) | [
"General",
"method",
"for",
"reversing",
"addresses",
"either",
"a",
"single",
"address",
"or",
"multiple",
"."
] | train | https://github.com/bennylope/pygeocodio/blob/4c33d3d34f6b63d4b8fe85fe571ae02b9f67d6c3/geocodio/client.py#L257-L276 |
nakagami/pyfirebirdsql | firebirdsql/wireprotocol.py | WireProtocol.str_to_bytes | def str_to_bytes(self, s):
"convert str to bytes"
if (PYTHON_MAJOR_VER == 3 or
(PYTHON_MAJOR_VER == 2 and type(s) == unicode)):
return s.encode(charset_map.get(self.charset, self.charset))
return s | python | def str_to_bytes(self, s):
"convert str to bytes"
if (PYTHON_MAJOR_VER == 3 or
(PYTHON_MAJOR_VER == 2 and type(s) == unicode)):
return s.encode(charset_map.get(self.charset, self.charset))
return s | [
"def",
"str_to_bytes",
"(",
"self",
",",
"s",
")",
":",
"if",
"(",
"PYTHON_MAJOR_VER",
"==",
"3",
"or",
"(",
"PYTHON_MAJOR_VER",
"==",
"2",
"and",
"type",
"(",
"s",
")",
"==",
"unicode",
")",
")",
":",
"return",
"s",
".",
"encode",
"(",
"charset_map"... | convert str to bytes | [
"convert",
"str",
"to",
"bytes"
] | train | https://github.com/nakagami/pyfirebirdsql/blob/5ce366c2fc8318510444f4a89801442f3e9e52ca/firebirdsql/wireprotocol.py#L227-L232 |
nakagami/pyfirebirdsql | firebirdsql/wireprotocol.py | WireProtocol.bytes_to_str | def bytes_to_str(self, b):
"convert bytes array to raw string"
if PYTHON_MAJOR_VER == 3:
return b.decode(charset_map.get(self.charset, self.charset))
return b | python | def bytes_to_str(self, b):
"convert bytes array to raw string"
if PYTHON_MAJOR_VER == 3:
return b.decode(charset_map.get(self.charset, self.charset))
return b | [
"def",
"bytes_to_str",
"(",
"self",
",",
"b",
")",
":",
"if",
"PYTHON_MAJOR_VER",
"==",
"3",
":",
"return",
"b",
".",
"decode",
"(",
"charset_map",
".",
"get",
"(",
"self",
".",
"charset",
",",
"self",
".",
"charset",
")",
")",
"return",
"b"
] | convert bytes array to raw string | [
"convert",
"bytes",
"array",
"to",
"raw",
"string"
] | train | https://github.com/nakagami/pyfirebirdsql/blob/5ce366c2fc8318510444f4a89801442f3e9e52ca/firebirdsql/wireprotocol.py#L234-L238 |
nakagami/pyfirebirdsql | firebirdsql/wireprotocol.py | WireProtocol.bytes_to_ustr | def bytes_to_ustr(self, b):
"convert bytes array to unicode string"
return b.decode(charset_map.get(self.charset, self.charset)) | python | def bytes_to_ustr(self, b):
"convert bytes array to unicode string"
return b.decode(charset_map.get(self.charset, self.charset)) | [
"def",
"bytes_to_ustr",
"(",
"self",
",",
"b",
")",
":",
"return",
"b",
".",
"decode",
"(",
"charset_map",
".",
"get",
"(",
"self",
".",
"charset",
",",
"self",
".",
"charset",
")",
")"
] | convert bytes array to unicode string | [
"convert",
"bytes",
"array",
"to",
"unicode",
"string"
] | train | https://github.com/nakagami/pyfirebirdsql/blob/5ce366c2fc8318510444f4a89801442f3e9e52ca/firebirdsql/wireprotocol.py#L240-L242 |
nakagami/pyfirebirdsql | firebirdsql/wireprotocol.py | WireProtocol.params_to_blr | def params_to_blr(self, trans_handle, params):
"Convert parameter array to BLR and values format."
ln = len(params) * 2
blr = bs([5, 2, 4, 0, ln & 255, ln >> 8])
if self.accept_version < PROTOCOL_VERSION13:
values = bs([])
else:
# start with null indicator... | python | def params_to_blr(self, trans_handle, params):
"Convert parameter array to BLR and values format."
ln = len(params) * 2
blr = bs([5, 2, 4, 0, ln & 255, ln >> 8])
if self.accept_version < PROTOCOL_VERSION13:
values = bs([])
else:
# start with null indicator... | [
"def",
"params_to_blr",
"(",
"self",
",",
"trans_handle",
",",
"params",
")",
":",
"ln",
"=",
"len",
"(",
"params",
")",
"*",
"2",
"blr",
"=",
"bs",
"(",
"[",
"5",
",",
"2",
",",
"4",
",",
"0",
",",
"ln",
"&",
"255",
",",
"ln",
">>",
"8",
"... | Convert parameter array to BLR and values format. | [
"Convert",
"parameter",
"array",
"to",
"BLR",
"and",
"values",
"format",
"."
] | train | https://github.com/nakagami/pyfirebirdsql/blob/5ce366c2fc8318510444f4a89801442f3e9e52ca/firebirdsql/wireprotocol.py#L318-L417 |
bennylope/pygeocodio | geocodio/data.py | Address.coords | def coords(self):
"""
Returns a tuple representing the location of the address in a
GIS coords format, i.e. (longitude, latitude).
"""
x, y = ("lat", "lng") if self.order == "lat" else ("lng", "lat")
try:
return (self["location"][x], self["location"][y])
... | python | def coords(self):
"""
Returns a tuple representing the location of the address in a
GIS coords format, i.e. (longitude, latitude).
"""
x, y = ("lat", "lng") if self.order == "lat" else ("lng", "lat")
try:
return (self["location"][x], self["location"][y])
... | [
"def",
"coords",
"(",
"self",
")",
":",
"x",
",",
"y",
"=",
"(",
"\"lat\"",
",",
"\"lng\"",
")",
"if",
"self",
".",
"order",
"==",
"\"lat\"",
"else",
"(",
"\"lng\"",
",",
"\"lat\"",
")",
"try",
":",
"return",
"(",
"self",
"[",
"\"location\"",
"]",
... | Returns a tuple representing the location of the address in a
GIS coords format, i.e. (longitude, latitude). | [
"Returns",
"a",
"tuple",
"representing",
"the",
"location",
"of",
"the",
"address",
"in",
"a",
"GIS",
"coords",
"format",
"i",
".",
"e",
".",
"(",
"longitude",
"latitude",
")",
"."
] | train | https://github.com/bennylope/pygeocodio/blob/4c33d3d34f6b63d4b8fe85fe571ae02b9f67d6c3/geocodio/data.py#L16-L26 |
bennylope/pygeocodio | geocodio/data.py | LocationCollection.get | def get(self, key):
"""
Returns an individual Location by query lookup, e.g. address or point.
"""
if isinstance(key, tuple):
# TODO handle different ordering
try:
x, y = float(key[0]), float(key[1])
except IndexError:
... | python | def get(self, key):
"""
Returns an individual Location by query lookup, e.g. address or point.
"""
if isinstance(key, tuple):
# TODO handle different ordering
try:
x, y = float(key[0]), float(key[1])
except IndexError:
... | [
"def",
"get",
"(",
"self",
",",
"key",
")",
":",
"if",
"isinstance",
"(",
"key",
",",
"tuple",
")",
":",
"# TODO handle different ordering",
"try",
":",
"x",
",",
"y",
"=",
"float",
"(",
"key",
"[",
"0",
"]",
")",
",",
"float",
"(",
"key",
"[",
"... | Returns an individual Location by query lookup, e.g. address or point. | [
"Returns",
"an",
"individual",
"Location",
"by",
"query",
"lookup",
"e",
".",
"g",
".",
"address",
"or",
"point",
"."
] | train | https://github.com/bennylope/pygeocodio/blob/4c33d3d34f6b63d4b8fe85fe571ae02b9f67d6c3/geocodio/data.py#L107-L124 |
nakagami/pyfirebirdsql | firebirdsql/xsqlvar.py | calc_blr | def calc_blr(xsqlda):
"Calculate BLR from XSQLVAR array."
ln = len(xsqlda) * 2
blr = [5, 2, 4, 0, ln & 255, ln >> 8]
for x in xsqlda:
sqltype = x.sqltype
if sqltype == SQL_TYPE_VARYING:
blr += [37, x.sqllen & 255, x.sqllen >> 8]
elif sqltype == SQL_TYPE_TEXT:
... | python | def calc_blr(xsqlda):
"Calculate BLR from XSQLVAR array."
ln = len(xsqlda) * 2
blr = [5, 2, 4, 0, ln & 255, ln >> 8]
for x in xsqlda:
sqltype = x.sqltype
if sqltype == SQL_TYPE_VARYING:
blr += [37, x.sqllen & 255, x.sqllen >> 8]
elif sqltype == SQL_TYPE_TEXT:
... | [
"def",
"calc_blr",
"(",
"xsqlda",
")",
":",
"ln",
"=",
"len",
"(",
"xsqlda",
")",
"*",
"2",
"blr",
"=",
"[",
"5",
",",
"2",
",",
"4",
",",
"0",
",",
"ln",
"&",
"255",
",",
"ln",
">>",
"8",
"]",
"for",
"x",
"in",
"xsqlda",
":",
"sqltype",
... | Calculate BLR from XSQLVAR array. | [
"Calculate",
"BLR",
"from",
"XSQLVAR",
"array",
"."
] | train | https://github.com/nakagami/pyfirebirdsql/blob/5ce366c2fc8318510444f4a89801442f3e9e52ca/firebirdsql/xsqlvar.py#L216-L242 |
nakagami/pyfirebirdsql | firebirdsql/xsqlvar.py | XSQLVAR._parse_date | def _parse_date(self, raw_value):
"Convert raw data to datetime.date"
nday = bytes_to_bint(raw_value) + 678882
century = (4 * nday - 1) // 146097
nday = 4 * nday - 1 - 146097 * century
day = nday // 4
nday = (4 * day + 3) // 1461
day = 4 * day + 3 - 1461 * nday
... | python | def _parse_date(self, raw_value):
"Convert raw data to datetime.date"
nday = bytes_to_bint(raw_value) + 678882
century = (4 * nday - 1) // 146097
nday = 4 * nday - 1 - 146097 * century
day = nday // 4
nday = (4 * day + 3) // 1461
day = 4 * day + 3 - 1461 * nday
... | [
"def",
"_parse_date",
"(",
"self",
",",
"raw_value",
")",
":",
"nday",
"=",
"bytes_to_bint",
"(",
"raw_value",
")",
"+",
"678882",
"century",
"=",
"(",
"4",
"*",
"nday",
"-",
"1",
")",
"//",
"146097",
"nday",
"=",
"4",
"*",
"nday",
"-",
"1",
"-",
... | Convert raw data to datetime.date | [
"Convert",
"raw",
"data",
"to",
"datetime",
".",
"date"
] | train | https://github.com/nakagami/pyfirebirdsql/blob/5ce366c2fc8318510444f4a89801442f3e9e52ca/firebirdsql/xsqlvar.py#L118-L138 |
nakagami/pyfirebirdsql | firebirdsql/xsqlvar.py | XSQLVAR._parse_time | def _parse_time(self, raw_value):
"Convert raw data to datetime.time"
n = bytes_to_bint(raw_value)
s = n // 10000
m = s // 60
h = m // 60
m = m % 60
s = s % 60
return (h, m, s, (n % 10000) * 100) | python | def _parse_time(self, raw_value):
"Convert raw data to datetime.time"
n = bytes_to_bint(raw_value)
s = n // 10000
m = s // 60
h = m // 60
m = m % 60
s = s % 60
return (h, m, s, (n % 10000) * 100) | [
"def",
"_parse_time",
"(",
"self",
",",
"raw_value",
")",
":",
"n",
"=",
"bytes_to_bint",
"(",
"raw_value",
")",
"s",
"=",
"n",
"//",
"10000",
"m",
"=",
"s",
"//",
"60",
"h",
"=",
"m",
"//",
"60",
"m",
"=",
"m",
"%",
"60",
"s",
"=",
"s",
"%",... | Convert raw data to datetime.time | [
"Convert",
"raw",
"data",
"to",
"datetime",
".",
"time"
] | train | https://github.com/nakagami/pyfirebirdsql/blob/5ce366c2fc8318510444f4a89801442f3e9e52ca/firebirdsql/xsqlvar.py#L140-L148 |
pv8/noipy | noipy/main.py | execute_update | def execute_update(args):
"""Execute the update based on command line args and returns a dictionary
with 'execution result, ''response code', 'response info' and
'process friendly message'.
"""
provider_class = getattr(dnsupdater,
dnsupdater.AVAILABLE_PLUGINS.get(args.p... | python | def execute_update(args):
"""Execute the update based on command line args and returns a dictionary
with 'execution result, ''response code', 'response info' and
'process friendly message'.
"""
provider_class = getattr(dnsupdater,
dnsupdater.AVAILABLE_PLUGINS.get(args.p... | [
"def",
"execute_update",
"(",
"args",
")",
":",
"provider_class",
"=",
"getattr",
"(",
"dnsupdater",
",",
"dnsupdater",
".",
"AVAILABLE_PLUGINS",
".",
"get",
"(",
"args",
".",
"provider",
")",
")",
"updater_options",
"=",
"{",
"}",
"process_message",
"=",
"N... | Execute the update based on command line args and returns a dictionary
with 'execution result, ''response code', 'response info' and
'process friendly message'. | [
"Execute",
"the",
"update",
"based",
"on",
"command",
"line",
"args",
"and",
"returns",
"a",
"dictionary",
"with",
"execution",
"result",
"response",
"code",
"response",
"info",
"and",
"process",
"friendly",
"message",
"."
] | train | https://github.com/pv8/noipy/blob/e37342505a463d02ea81b18a060eb7d84a5d1c27/noipy/main.py#L37-L132 |
pv8/noipy | noipy/dnsupdater.py | DnsUpdaterPlugin.update_dns | def update_dns(self, new_ip):
"""Call No-IP API based on dict login_info and return the status code.
"""
headers = None
if self.auth_type == 'T':
api_call_url = self._base_url.format(hostname=self.hostname,
token=self.auth.tok... | python | def update_dns(self, new_ip):
"""Call No-IP API based on dict login_info and return the status code.
"""
headers = None
if self.auth_type == 'T':
api_call_url = self._base_url.format(hostname=self.hostname,
token=self.auth.tok... | [
"def",
"update_dns",
"(",
"self",
",",
"new_ip",
")",
":",
"headers",
"=",
"None",
"if",
"self",
".",
"auth_type",
"==",
"'T'",
":",
"api_call_url",
"=",
"self",
".",
"_base_url",
".",
"format",
"(",
"hostname",
"=",
"self",
".",
"hostname",
",",
"toke... | Call No-IP API based on dict login_info and return the status code. | [
"Call",
"No",
"-",
"IP",
"API",
"based",
"on",
"dict",
"login_info",
"and",
"return",
"the",
"status",
"code",
"."
] | train | https://github.com/pv8/noipy/blob/e37342505a463d02ea81b18a060eb7d84a5d1c27/noipy/dnsupdater.py#L79-L100 |
pv8/noipy | noipy/dnsupdater.py | DnsUpdaterPlugin.status_message | def status_message(self):
"""Return friendly response from API based on response code. """
msg = None
if self.last_ddns_response in response_messages.keys():
return response_messages.get(self.last_ddns_response)
if 'good' in self.last_ddns_response:
ip = re.sear... | python | def status_message(self):
"""Return friendly response from API based on response code. """
msg = None
if self.last_ddns_response in response_messages.keys():
return response_messages.get(self.last_ddns_response)
if 'good' in self.last_ddns_response:
ip = re.sear... | [
"def",
"status_message",
"(",
"self",
")",
":",
"msg",
"=",
"None",
"if",
"self",
".",
"last_ddns_response",
"in",
"response_messages",
".",
"keys",
"(",
")",
":",
"return",
"response_messages",
".",
"get",
"(",
"self",
".",
"last_ddns_response",
")",
"if",
... | Return friendly response from API based on response code. | [
"Return",
"friendly",
"response",
"from",
"API",
"based",
"on",
"response",
"code",
"."
] | train | https://github.com/pv8/noipy/blob/e37342505a463d02ea81b18a060eb7d84a5d1c27/noipy/dnsupdater.py#L103-L120 |
pv8/noipy | noipy/utils.py | get_ip | def get_ip():
"""Return machine's origin IP address.
"""
try:
r = requests.get(HTTPBIN_URL)
ip, _ = r.json()['origin'].split(',')
return ip if r.status_code == 200 else None
except requests.exceptions.ConnectionError:
return None | python | def get_ip():
"""Return machine's origin IP address.
"""
try:
r = requests.get(HTTPBIN_URL)
ip, _ = r.json()['origin'].split(',')
return ip if r.status_code == 200 else None
except requests.exceptions.ConnectionError:
return None | [
"def",
"get_ip",
"(",
")",
":",
"try",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"HTTPBIN_URL",
")",
"ip",
",",
"_",
"=",
"r",
".",
"json",
"(",
")",
"[",
"'origin'",
"]",
".",
"split",
"(",
"','",
")",
"return",
"ip",
"if",
"r",
".",
"stat... | Return machine's origin IP address. | [
"Return",
"machine",
"s",
"origin",
"IP",
"address",
"."
] | train | https://github.com/pv8/noipy/blob/e37342505a463d02ea81b18a060eb7d84a5d1c27/noipy/utils.py#L24-L32 |
pv8/noipy | noipy/authinfo.py | store | def store(auth, provider, config_location=DEFAULT_CONFIG_DIR):
"""Store auth info in file for specified provider """
auth_file = None
try:
# only for custom locations
_create_config_dir(config_location,
"Creating custom config directory [%s]... ")
config_... | python | def store(auth, provider, config_location=DEFAULT_CONFIG_DIR):
"""Store auth info in file for specified provider """
auth_file = None
try:
# only for custom locations
_create_config_dir(config_location,
"Creating custom config directory [%s]... ")
config_... | [
"def",
"store",
"(",
"auth",
",",
"provider",
",",
"config_location",
"=",
"DEFAULT_CONFIG_DIR",
")",
":",
"auth_file",
"=",
"None",
"try",
":",
"# only for custom locations",
"_create_config_dir",
"(",
"config_location",
",",
"\"Creating custom config directory [%s]... \... | Store auth info in file for specified provider | [
"Store",
"auth",
"info",
"in",
"file",
"for",
"specified",
"provider"
] | train | https://github.com/pv8/noipy/blob/e37342505a463d02ea81b18a060eb7d84a5d1c27/noipy/authinfo.py#L60-L81 |
pv8/noipy | noipy/authinfo.py | load | def load(provider, config_location=DEFAULT_CONFIG_DIR):
"""Load provider specific auth info from file """
auth = None
auth_file = None
try:
config_dir = os.path.join(config_location, NOIPY_CONFIG)
print("Loading stored auth info [%s]... " % config_dir, end="")
auth_file = os.pat... | python | def load(provider, config_location=DEFAULT_CONFIG_DIR):
"""Load provider specific auth info from file """
auth = None
auth_file = None
try:
config_dir = os.path.join(config_location, NOIPY_CONFIG)
print("Loading stored auth info [%s]... " % config_dir, end="")
auth_file = os.pat... | [
"def",
"load",
"(",
"provider",
",",
"config_location",
"=",
"DEFAULT_CONFIG_DIR",
")",
":",
"auth",
"=",
"None",
"auth_file",
"=",
"None",
"try",
":",
"config_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"config_location",
",",
"NOIPY_CONFIG",
")",
"pr... | Load provider specific auth info from file | [
"Load",
"provider",
"specific",
"auth",
"info",
"from",
"file"
] | train | https://github.com/pv8/noipy/blob/e37342505a463d02ea81b18a060eb7d84a5d1c27/noipy/authinfo.py#L84-L101 |
pv8/noipy | noipy/authinfo.py | exists | def exists(provider, config_location=DEFAULT_CONFIG_DIR):
"""Check whether provider info is already stored """
config_dir = os.path.join(config_location, NOIPY_CONFIG)
auth_file = os.path.join(config_dir, provider)
return os.path.exists(auth_file) | python | def exists(provider, config_location=DEFAULT_CONFIG_DIR):
"""Check whether provider info is already stored """
config_dir = os.path.join(config_location, NOIPY_CONFIG)
auth_file = os.path.join(config_dir, provider)
return os.path.exists(auth_file) | [
"def",
"exists",
"(",
"provider",
",",
"config_location",
"=",
"DEFAULT_CONFIG_DIR",
")",
":",
"config_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"config_location",
",",
"NOIPY_CONFIG",
")",
"auth_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"conf... | Check whether provider info is already stored | [
"Check",
"whether",
"provider",
"info",
"is",
"already",
"stored"
] | train | https://github.com/pv8/noipy/blob/e37342505a463d02ea81b18a060eb7d84a5d1c27/noipy/authinfo.py#L104-L109 |
pv8/noipy | noipy/authinfo.py | ApiAuth.get_instance | def get_instance(cls, encoded_key):
"""Return an ApiAuth instance from an encoded key """
login_str = base64.b64decode(encoded_key).decode('utf-8')
usertoken, password = login_str.strip().split(':', 1)
instance = cls(usertoken, password)
return instance | python | def get_instance(cls, encoded_key):
"""Return an ApiAuth instance from an encoded key """
login_str = base64.b64decode(encoded_key).decode('utf-8')
usertoken, password = login_str.strip().split(':', 1)
instance = cls(usertoken, password)
return instance | [
"def",
"get_instance",
"(",
"cls",
",",
"encoded_key",
")",
":",
"login_str",
"=",
"base64",
".",
"b64decode",
"(",
"encoded_key",
")",
".",
"decode",
"(",
"'utf-8'",
")",
"usertoken",
",",
"password",
"=",
"login_str",
".",
"strip",
"(",
")",
".",
"spli... | Return an ApiAuth instance from an encoded key | [
"Return",
"an",
"ApiAuth",
"instance",
"from",
"an",
"encoded",
"key"
] | train | https://github.com/pv8/noipy/blob/e37342505a463d02ea81b18a060eb7d84a5d1c27/noipy/authinfo.py#L36-L44 |
ChristopherRabotin/bungiesearch | bungiesearch/utils.py | update_index | def update_index(model_items, model_name, action='index', bulk_size=100, num_docs=-1, start_date=None, end_date=None, refresh=True):
'''
Updates the index for the provided model_items.
:param model_items: a list of model_items (django Model instances, or proxy instances) which are to be indexed/updated or d... | python | def update_index(model_items, model_name, action='index', bulk_size=100, num_docs=-1, start_date=None, end_date=None, refresh=True):
'''
Updates the index for the provided model_items.
:param model_items: a list of model_items (django Model instances, or proxy instances) which are to be indexed/updated or d... | [
"def",
"update_index",
"(",
"model_items",
",",
"model_name",
",",
"action",
"=",
"'index'",
",",
"bulk_size",
"=",
"100",
",",
"num_docs",
"=",
"-",
"1",
",",
"start_date",
"=",
"None",
",",
"end_date",
"=",
"None",
",",
"refresh",
"=",
"True",
")",
"... | Updates the index for the provided model_items.
:param model_items: a list of model_items (django Model instances, or proxy instances) which are to be indexed/updated or deleted.
If action is 'index', the model_items must be serializable objects. If action is 'delete', the model_items must be primary keys
c... | [
"Updates",
"the",
"index",
"for",
"the",
"provided",
"model_items",
".",
":",
"param",
"model_items",
":",
"a",
"list",
"of",
"model_items",
"(",
"django",
"Model",
"instances",
"or",
"proxy",
"instances",
")",
"which",
"are",
"to",
"be",
"indexed",
"/",
"... | train | https://github.com/ChristopherRabotin/bungiesearch/blob/13768342bc2698b214eb0003c2d113b6e273c30d/bungiesearch/utils.py#L15-L64 |
ChristopherRabotin/bungiesearch | bungiesearch/utils.py | delete_index_item | def delete_index_item(item, model_name, refresh=True):
'''
Deletes an item from the index.
:param item: must be a serializable object.
:param model_name: doctype, which must also be the model name.
:param refresh: a boolean that determines whether to refresh the index, making all operations performe... | python | def delete_index_item(item, model_name, refresh=True):
'''
Deletes an item from the index.
:param item: must be a serializable object.
:param model_name: doctype, which must also be the model name.
:param refresh: a boolean that determines whether to refresh the index, making all operations performe... | [
"def",
"delete_index_item",
"(",
"item",
",",
"model_name",
",",
"refresh",
"=",
"True",
")",
":",
"src",
"=",
"Bungiesearch",
"(",
")",
"logger",
".",
"info",
"(",
"'Getting index for model {}.'",
".",
"format",
"(",
"model_name",
")",
")",
"for",
"index_na... | Deletes an item from the index.
:param item: must be a serializable object.
:param model_name: doctype, which must also be the model name.
:param refresh: a boolean that determines whether to refresh the index, making all operations performed since the last refresh
immediately available for search, inst... | [
"Deletes",
"an",
"item",
"from",
"the",
"index",
".",
":",
"param",
"item",
":",
"must",
"be",
"a",
"serializable",
"object",
".",
":",
"param",
"model_name",
":",
"doctype",
"which",
"must",
"also",
"be",
"the",
"model",
"name",
".",
":",
"param",
"re... | train | https://github.com/ChristopherRabotin/bungiesearch/blob/13768342bc2698b214eb0003c2d113b6e273c30d/bungiesearch/utils.py#L67-L87 |
ChristopherRabotin/bungiesearch | bungiesearch/utils.py | create_indexed_document | def create_indexed_document(index_instance, model_items, action):
'''
Creates the document that will be passed into the bulk index function.
Either a list of serialized objects to index, or a a dictionary specifying the primary keys of items to be delete.
'''
data = []
if action == 'delete':
... | python | def create_indexed_document(index_instance, model_items, action):
'''
Creates the document that will be passed into the bulk index function.
Either a list of serialized objects to index, or a a dictionary specifying the primary keys of items to be delete.
'''
data = []
if action == 'delete':
... | [
"def",
"create_indexed_document",
"(",
"index_instance",
",",
"model_items",
",",
"action",
")",
":",
"data",
"=",
"[",
"]",
"if",
"action",
"==",
"'delete'",
":",
"for",
"pk",
"in",
"model_items",
":",
"data",
".",
"append",
"(",
"{",
"'_id'",
":",
"pk"... | Creates the document that will be passed into the bulk index function.
Either a list of serialized objects to index, or a a dictionary specifying the primary keys of items to be delete. | [
"Creates",
"the",
"document",
"that",
"will",
"be",
"passed",
"into",
"the",
"bulk",
"index",
"function",
".",
"Either",
"a",
"list",
"of",
"serialized",
"objects",
"to",
"index",
"or",
"a",
"a",
"dictionary",
"specifying",
"the",
"primary",
"keys",
"of",
... | train | https://github.com/ChristopherRabotin/bungiesearch/blob/13768342bc2698b214eb0003c2d113b6e273c30d/bungiesearch/utils.py#L90-L103 |
ChristopherRabotin/bungiesearch | bungiesearch/utils.py | filter_model_items | def filter_model_items(index_instance, model_items, model_name, start_date, end_date):
''' Filters the model items queryset based on start and end date.'''
if index_instance.updated_field is None:
logger.warning("No updated date field found for {} - not restricting with start and end date".format(model_... | python | def filter_model_items(index_instance, model_items, model_name, start_date, end_date):
''' Filters the model items queryset based on start and end date.'''
if index_instance.updated_field is None:
logger.warning("No updated date field found for {} - not restricting with start and end date".format(model_... | [
"def",
"filter_model_items",
"(",
"index_instance",
",",
"model_items",
",",
"model_name",
",",
"start_date",
",",
"end_date",
")",
":",
"if",
"index_instance",
".",
"updated_field",
"is",
"None",
":",
"logger",
".",
"warning",
"(",
"\"No updated date field found fo... | Filters the model items queryset based on start and end date. | [
"Filters",
"the",
"model",
"items",
"queryset",
"based",
"on",
"start",
"and",
"end",
"date",
"."
] | train | https://github.com/ChristopherRabotin/bungiesearch/blob/13768342bc2698b214eb0003c2d113b6e273c30d/bungiesearch/utils.py#L106-L116 |
ponty/EasyProcess | easyprocess/__init__.py | extract_version | def extract_version(txt):
"""This function tries to extract the version from the help text of any
program."""
words = txt.replace(',', ' ').split()
version = None
for x in reversed(words):
if len(x) > 2:
if x[0].lower() == 'v':
x = x[1:]
if '.' in x an... | python | def extract_version(txt):
"""This function tries to extract the version from the help text of any
program."""
words = txt.replace(',', ' ').split()
version = None
for x in reversed(words):
if len(x) > 2:
if x[0].lower() == 'v':
x = x[1:]
if '.' in x an... | [
"def",
"extract_version",
"(",
"txt",
")",
":",
"words",
"=",
"txt",
".",
"replace",
"(",
"','",
",",
"' '",
")",
".",
"split",
"(",
")",
"version",
"=",
"None",
"for",
"x",
"in",
"reversed",
"(",
"words",
")",
":",
"if",
"len",
"(",
"x",
")",
... | This function tries to extract the version from the help text of any
program. | [
"This",
"function",
"tries",
"to",
"extract",
"the",
"version",
"from",
"the",
"help",
"text",
"of",
"any",
"program",
"."
] | train | https://github.com/ponty/EasyProcess/blob/81c2923339e09a86b6a2b8c12dc960f1bc67db9c/easyprocess/__init__.py#L421-L433 |
ponty/EasyProcess | easyprocess/__init__.py | EasyProcess.check | def check(self, return_code=0):
"""Run command with arguments. Wait for command to complete. If the
exit code was as expected and there is no exception then return,
otherwise raise EasyProcessError.
:param return_code: int, expected return code
:rtype: self
"""
... | python | def check(self, return_code=0):
"""Run command with arguments. Wait for command to complete. If the
exit code was as expected and there is no exception then return,
otherwise raise EasyProcessError.
:param return_code: int, expected return code
:rtype: self
"""
... | [
"def",
"check",
"(",
"self",
",",
"return_code",
"=",
"0",
")",
":",
"ret",
"=",
"self",
".",
"call",
"(",
")",
".",
"return_code",
"ok",
"=",
"ret",
"==",
"return_code",
"if",
"not",
"ok",
":",
"raise",
"EasyProcessError",
"(",
"self",
",",
"'check ... | Run command with arguments. Wait for command to complete. If the
exit code was as expected and there is no exception then return,
otherwise raise EasyProcessError.
:param return_code: int, expected return code
:rtype: self | [
"Run",
"command",
"with",
"arguments",
".",
"Wait",
"for",
"command",
"to",
"complete",
".",
"If",
"the",
"exit",
"code",
"was",
"as",
"expected",
"and",
"there",
"is",
"no",
"exception",
"then",
"return",
"otherwise",
"raise",
"EasyProcessError",
"."
] | train | https://github.com/ponty/EasyProcess/blob/81c2923339e09a86b6a2b8c12dc960f1bc67db9c/easyprocess/__init__.py#L152-L166 |
ponty/EasyProcess | easyprocess/__init__.py | EasyProcess.call | def call(self, timeout=None):
"""Run command with arguments. Wait for command to complete.
same as:
1. :meth:`start`
2. :meth:`wait`
3. :meth:`stop`
:rtype: self
"""
self.start().wait(timeout=timeout)
if self.is_alive():
self.stop... | python | def call(self, timeout=None):
"""Run command with arguments. Wait for command to complete.
same as:
1. :meth:`start`
2. :meth:`wait`
3. :meth:`stop`
:rtype: self
"""
self.start().wait(timeout=timeout)
if self.is_alive():
self.stop... | [
"def",
"call",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"self",
".",
"start",
"(",
")",
".",
"wait",
"(",
"timeout",
"=",
"timeout",
")",
"if",
"self",
".",
"is_alive",
"(",
")",
":",
"self",
".",
"stop",
"(",
")",
"return",
"self"
] | Run command with arguments. Wait for command to complete.
same as:
1. :meth:`start`
2. :meth:`wait`
3. :meth:`stop`
:rtype: self | [
"Run",
"command",
"with",
"arguments",
".",
"Wait",
"for",
"command",
"to",
"complete",
"."
] | train | https://github.com/ponty/EasyProcess/blob/81c2923339e09a86b6a2b8c12dc960f1bc67db9c/easyprocess/__init__.py#L185-L199 |
ponty/EasyProcess | easyprocess/__init__.py | EasyProcess.start | def start(self):
"""start command in background and does not wait for it.
:rtype: self
"""
if self.is_started:
raise EasyProcessError(self, 'process was started twice!')
if self.use_temp_files:
self._stdout_file = tempfile.TemporaryFile(prefix='stdout_'... | python | def start(self):
"""start command in background and does not wait for it.
:rtype: self
"""
if self.is_started:
raise EasyProcessError(self, 'process was started twice!')
if self.use_temp_files:
self._stdout_file = tempfile.TemporaryFile(prefix='stdout_'... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_started",
":",
"raise",
"EasyProcessError",
"(",
"self",
",",
"'process was started twice!'",
")",
"if",
"self",
".",
"use_temp_files",
":",
"self",
".",
"_stdout_file",
"=",
"tempfile",
".",
"Tem... | start command in background and does not wait for it.
:rtype: self | [
"start",
"command",
"in",
"background",
"and",
"does",
"not",
"wait",
"for",
"it",
"."
] | train | https://github.com/ponty/EasyProcess/blob/81c2923339e09a86b6a2b8c12dc960f1bc67db9c/easyprocess/__init__.py#L201-L235 |
ponty/EasyProcess | easyprocess/__init__.py | EasyProcess.wait | def wait(self, timeout=None):
"""Wait for command to complete.
Timeout:
- discussion: http://stackoverflow.com/questions/1191374/subprocess-with-timeout
- implementation: threading
:rtype: self
"""
if timeout is not None:
if not self._thread:
... | python | def wait(self, timeout=None):
"""Wait for command to complete.
Timeout:
- discussion: http://stackoverflow.com/questions/1191374/subprocess-with-timeout
- implementation: threading
:rtype: self
"""
if timeout is not None:
if not self._thread:
... | [
"def",
"wait",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"timeout",
"is",
"not",
"None",
":",
"if",
"not",
"self",
".",
"_thread",
":",
"self",
".",
"_thread",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"self",
".",
"_wait... | Wait for command to complete.
Timeout:
- discussion: http://stackoverflow.com/questions/1191374/subprocess-with-timeout
- implementation: threading
:rtype: self | [
"Wait",
"for",
"command",
"to",
"complete",
"."
] | train | https://github.com/ponty/EasyProcess/blob/81c2923339e09a86b6a2b8c12dc960f1bc67db9c/easyprocess/__init__.py#L248-L272 |
ponty/EasyProcess | easyprocess/__init__.py | EasyProcess.sendstop | def sendstop(self):
'''
Kill process (:meth:`subprocess.Popen.terminate`).
Do not wait for command to complete.
:rtype: self
'''
if not self.is_started:
raise EasyProcessError(self, 'process was not started!')
log.debug('stopping process (pid=%s cmd=... | python | def sendstop(self):
'''
Kill process (:meth:`subprocess.Popen.terminate`).
Do not wait for command to complete.
:rtype: self
'''
if not self.is_started:
raise EasyProcessError(self, 'process was not started!')
log.debug('stopping process (pid=%s cmd=... | [
"def",
"sendstop",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_started",
":",
"raise",
"EasyProcessError",
"(",
"self",
",",
"'process was not started!'",
")",
"log",
".",
"debug",
"(",
"'stopping process (pid=%s cmd=\"%s\")'",
",",
"self",
".",
"pid",
... | Kill process (:meth:`subprocess.Popen.terminate`).
Do not wait for command to complete.
:rtype: self | [
"Kill",
"process",
"(",
":",
"meth",
":",
"subprocess",
".",
"Popen",
".",
"terminate",
")",
".",
"Do",
"not",
"wait",
"for",
"command",
"to",
"complete",
"."
] | train | https://github.com/ponty/EasyProcess/blob/81c2923339e09a86b6a2b8c12dc960f1bc67db9c/easyprocess/__init__.py#L343-L371 |
ponty/EasyProcess | easyprocess/__init__.py | EasyProcess.wrap | def wrap(self, func, delay=0):
'''
returns a function which:
1. start process
2. call func, save result
3. stop process
4. returns result
similar to :keyword:`with` statement
:rtype:
'''
def wrapped():
self.start()
... | python | def wrap(self, func, delay=0):
'''
returns a function which:
1. start process
2. call func, save result
3. stop process
4. returns result
similar to :keyword:`with` statement
:rtype:
'''
def wrapped():
self.start()
... | [
"def",
"wrap",
"(",
"self",
",",
"func",
",",
"delay",
"=",
"0",
")",
":",
"def",
"wrapped",
"(",
")",
":",
"self",
".",
"start",
"(",
")",
"if",
"delay",
":",
"self",
".",
"sleep",
"(",
"delay",
")",
"x",
"=",
"None",
"try",
":",
"x",
"=",
... | returns a function which:
1. start process
2. call func, save result
3. stop process
4. returns result
similar to :keyword:`with` statement
:rtype: | [
"returns",
"a",
"function",
"which",
":",
"1",
".",
"start",
"process",
"2",
".",
"call",
"func",
"save",
"result",
"3",
".",
"stop",
"process",
"4",
".",
"returns",
"result"
] | train | https://github.com/ponty/EasyProcess/blob/81c2923339e09a86b6a2b8c12dc960f1bc67db9c/easyprocess/__init__.py#L383-L409 |
Pipoline/rocket-python | rocketchat/api.py | RocketChatAPI.send_message | def send_message(self, message, room_id, **kwargs):
"""
Send a message to a given room
"""
return SendMessage(settings=self.settings, **kwargs).call(
message=message,
room_id=room_id,
**kwargs
) | python | def send_message(self, message, room_id, **kwargs):
"""
Send a message to a given room
"""
return SendMessage(settings=self.settings, **kwargs).call(
message=message,
room_id=room_id,
**kwargs
) | [
"def",
"send_message",
"(",
"self",
",",
"message",
",",
"room_id",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"SendMessage",
"(",
"settings",
"=",
"self",
".",
"settings",
",",
"*",
"*",
"kwargs",
")",
".",
"call",
"(",
"message",
"=",
"message",
... | Send a message to a given room | [
"Send",
"a",
"message",
"to",
"a",
"given",
"room"
] | train | https://github.com/Pipoline/rocket-python/blob/643ece8a9db106922e019984a859ca04283262ff/rocketchat/api.py#L29-L37 |
Pipoline/rocket-python | rocketchat/api.py | RocketChatAPI.get_private_rooms | def get_private_rooms(self, **kwargs):
"""
Get a listing of all private rooms with their names and IDs
"""
return GetPrivateRooms(settings=self.settings, **kwargs).call(**kwargs) | python | def get_private_rooms(self, **kwargs):
"""
Get a listing of all private rooms with their names and IDs
"""
return GetPrivateRooms(settings=self.settings, **kwargs).call(**kwargs) | [
"def",
"get_private_rooms",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"GetPrivateRooms",
"(",
"settings",
"=",
"self",
".",
"settings",
",",
"*",
"*",
"kwargs",
")",
".",
"call",
"(",
"*",
"*",
"kwargs",
")"
] | Get a listing of all private rooms with their names and IDs | [
"Get",
"a",
"listing",
"of",
"all",
"private",
"rooms",
"with",
"their",
"names",
"and",
"IDs"
] | train | https://github.com/Pipoline/rocket-python/blob/643ece8a9db106922e019984a859ca04283262ff/rocketchat/api.py#L39-L43 |
Pipoline/rocket-python | rocketchat/api.py | RocketChatAPI.get_private_room_history | def get_private_room_history(self, room_id, oldest=None, **kwargs):
"""
Get various history of specific private group in this case private
:param room_id:
:param kwargs:
:return:
"""
return GetPrivateRoomHistory(settings=self.settings, **kwargs).call(
... | python | def get_private_room_history(self, room_id, oldest=None, **kwargs):
"""
Get various history of specific private group in this case private
:param room_id:
:param kwargs:
:return:
"""
return GetPrivateRoomHistory(settings=self.settings, **kwargs).call(
... | [
"def",
"get_private_room_history",
"(",
"self",
",",
"room_id",
",",
"oldest",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"GetPrivateRoomHistory",
"(",
"settings",
"=",
"self",
".",
"settings",
",",
"*",
"*",
"kwargs",
")",
".",
"call",
"(... | Get various history of specific private group in this case private
:param room_id:
:param kwargs:
:return: | [
"Get",
"various",
"history",
"of",
"specific",
"private",
"group",
"in",
"this",
"case",
"private"
] | train | https://github.com/Pipoline/rocket-python/blob/643ece8a9db106922e019984a859ca04283262ff/rocketchat/api.py#L45-L57 |
Pipoline/rocket-python | rocketchat/api.py | RocketChatAPI.get_public_rooms | def get_public_rooms(self, **kwargs):
"""
Get a listing of all public rooms with their names and IDs
"""
return GetPublicRooms(settings=self.settings, **kwargs).call(**kwargs) | python | def get_public_rooms(self, **kwargs):
"""
Get a listing of all public rooms with their names and IDs
"""
return GetPublicRooms(settings=self.settings, **kwargs).call(**kwargs) | [
"def",
"get_public_rooms",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"GetPublicRooms",
"(",
"settings",
"=",
"self",
".",
"settings",
",",
"*",
"*",
"kwargs",
")",
".",
"call",
"(",
"*",
"*",
"kwargs",
")"
] | Get a listing of all public rooms with their names and IDs | [
"Get",
"a",
"listing",
"of",
"all",
"public",
"rooms",
"with",
"their",
"names",
"and",
"IDs"
] | train | https://github.com/Pipoline/rocket-python/blob/643ece8a9db106922e019984a859ca04283262ff/rocketchat/api.py#L59-L63 |
Pipoline/rocket-python | rocketchat/api.py | RocketChatAPI.get_room_info | def get_room_info(self, room_id, **kwargs):
"""
Get various information about a specific channel/room
:param room_id:
:param kwargs:
:return:
"""
return GetRoomInfo(settings=self.settings, **kwargs).call(
room_id=room_id,
**kwargs
... | python | def get_room_info(self, room_id, **kwargs):
"""
Get various information about a specific channel/room
:param room_id:
:param kwargs:
:return:
"""
return GetRoomInfo(settings=self.settings, **kwargs).call(
room_id=room_id,
**kwargs
... | [
"def",
"get_room_info",
"(",
"self",
",",
"room_id",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"GetRoomInfo",
"(",
"settings",
"=",
"self",
".",
"settings",
",",
"*",
"*",
"kwargs",
")",
".",
"call",
"(",
"room_id",
"=",
"room_id",
",",
"*",
"*",
... | Get various information about a specific channel/room
:param room_id:
:param kwargs:
:return: | [
"Get",
"various",
"information",
"about",
"a",
"specific",
"channel",
"/",
"room"
] | train | https://github.com/Pipoline/rocket-python/blob/643ece8a9db106922e019984a859ca04283262ff/rocketchat/api.py#L65-L76 |
Pipoline/rocket-python | rocketchat/api.py | RocketChatAPI.upload_file | def upload_file(self, room_id, description, file, message, **kwargs):
"""
Upload file to room
:param room_id:
:param description:
:param file:
:param kwargs:
:return:
"""
return UploadFile(settings=self.settings, **kwargs).call(
room_id... | python | def upload_file(self, room_id, description, file, message, **kwargs):
"""
Upload file to room
:param room_id:
:param description:
:param file:
:param kwargs:
:return:
"""
return UploadFile(settings=self.settings, **kwargs).call(
room_id... | [
"def",
"upload_file",
"(",
"self",
",",
"room_id",
",",
"description",
",",
"file",
",",
"message",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"UploadFile",
"(",
"settings",
"=",
"self",
".",
"settings",
",",
"*",
"*",
"kwargs",
")",
".",
"call",
"... | Upload file to room
:param room_id:
:param description:
:param file:
:param kwargs:
:return: | [
"Upload",
"file",
"to",
"room",
":",
"param",
"room_id",
":",
":",
"param",
"description",
":",
":",
"param",
"file",
":",
":",
"param",
"kwargs",
":",
":",
"return",
":"
] | train | https://github.com/Pipoline/rocket-python/blob/643ece8a9db106922e019984a859ca04283262ff/rocketchat/api.py#L78-L93 |
Pipoline/rocket-python | rocketchat/api.py | RocketChatAPI.get_private_room_info | def get_private_room_info(self, room_id, **kwargs):
"""
Get various information about a specific private group
:param room_id:
:param kwargs:
:return:
"""
return GetPrivateRoomInfo(settings=self.settings, **kwargs).call(
room_id=room_id,
*... | python | def get_private_room_info(self, room_id, **kwargs):
"""
Get various information about a specific private group
:param room_id:
:param kwargs:
:return:
"""
return GetPrivateRoomInfo(settings=self.settings, **kwargs).call(
room_id=room_id,
*... | [
"def",
"get_private_room_info",
"(",
"self",
",",
"room_id",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"GetPrivateRoomInfo",
"(",
"settings",
"=",
"self",
".",
"settings",
",",
"*",
"*",
"kwargs",
")",
".",
"call",
"(",
"room_id",
"=",
"room_id",
",",... | Get various information about a specific private group
:param room_id:
:param kwargs:
:return: | [
"Get",
"various",
"information",
"about",
"a",
"specific",
"private",
"group"
] | train | https://github.com/Pipoline/rocket-python/blob/643ece8a9db106922e019984a859ca04283262ff/rocketchat/api.py#L95-L106 |
Pipoline/rocket-python | rocketchat/api.py | RocketChatAPI.get_room_id | def get_room_id(self, room_name, **kwargs):
"""
Get room ID
:param room_name:
:param kwargs:
:return:
"""
return GetRoomId(settings=self.settings, **kwargs).call(
room_name=room_name,
**kwargs
) | python | def get_room_id(self, room_name, **kwargs):
"""
Get room ID
:param room_name:
:param kwargs:
:return:
"""
return GetRoomId(settings=self.settings, **kwargs).call(
room_name=room_name,
**kwargs
) | [
"def",
"get_room_id",
"(",
"self",
",",
"room_name",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"GetRoomId",
"(",
"settings",
"=",
"self",
".",
"settings",
",",
"*",
"*",
"kwargs",
")",
".",
"call",
"(",
"room_name",
"=",
"room_name",
",",
"*",
"*"... | Get room ID
:param room_name:
:param kwargs:
:return: | [
"Get",
"room",
"ID",
":",
"param",
"room_name",
":",
":",
"param",
"kwargs",
":",
":",
"return",
":"
] | train | https://github.com/Pipoline/rocket-python/blob/643ece8a9db106922e019984a859ca04283262ff/rocketchat/api.py#L108-L118 |
Pipoline/rocket-python | rocketchat/api.py | RocketChatAPI.get_room_history | def get_room_history(
self,
room_id,
oldest=None,
latest=datetime.now(),
inclusive=False,
count=20,
unreads=False,
**kwa... | python | def get_room_history(
self,
room_id,
oldest=None,
latest=datetime.now(),
inclusive=False,
count=20,
unreads=False,
**kwa... | [
"def",
"get_room_history",
"(",
"self",
",",
"room_id",
",",
"oldest",
"=",
"None",
",",
"latest",
"=",
"datetime",
".",
"now",
"(",
")",
",",
"inclusive",
"=",
"False",
",",
"count",
"=",
"20",
",",
"unreads",
"=",
"False",
",",
"*",
"*",
"kwargs",
... | Get various history of specific channel/room
:param room_id:
:param kwargs:
:return: | [
"Get",
"various",
"history",
"of",
"specific",
"channel",
"/",
"room"
] | train | https://github.com/Pipoline/rocket-python/blob/643ece8a9db106922e019984a859ca04283262ff/rocketchat/api.py#L120-L145 |
Pipoline/rocket-python | rocketchat/api.py | RocketChatAPI.create_public_room | def create_public_room(self, name, **kwargs):
"""
Create room with given name
:param name: Room name
:param kwargs:
members: The users to add to the channel when it is created.
Optional; Ex.: ["rocket.cat"], Default: []
read_only: Set if the channel is read on... | python | def create_public_room(self, name, **kwargs):
"""
Create room with given name
:param name: Room name
:param kwargs:
members: The users to add to the channel when it is created.
Optional; Ex.: ["rocket.cat"], Default: []
read_only: Set if the channel is read on... | [
"def",
"create_public_room",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"CreatePublicRoom",
"(",
"settings",
"=",
"self",
".",
"settings",
",",
"*",
"*",
"kwargs",
")",
".",
"call",
"(",
"name",
"=",
"name",
",",
"*",
"*",... | Create room with given name
:param name: Room name
:param kwargs:
members: The users to add to the channel when it is created.
Optional; Ex.: ["rocket.cat"], Default: []
read_only: Set if the channel is read only or not.
Optional; Ex.: True, Default: False
... | [
"Create",
"room",
"with",
"given",
"name",
":",
"param",
"name",
":",
"Room",
"name",
":",
"param",
"kwargs",
":",
"members",
":",
"The",
"users",
"to",
"add",
"to",
"the",
"channel",
"when",
"it",
"is",
"created",
".",
"Optional",
";",
"Ex",
".",
":... | train | https://github.com/Pipoline/rocket-python/blob/643ece8a9db106922e019984a859ca04283262ff/rocketchat/api.py#L147-L158 |
Pipoline/rocket-python | rocketchat/api.py | RocketChatAPI.delete_public_room | def delete_public_room(self, room_id, **kwargs):
"""
Delete room with given ID
:param room_id: Room ID
:param kwargs:
:return:
"""
return DeletePublicRoom(settings=self.settings, **kwargs).call(room_id=room_id, **kwargs) | python | def delete_public_room(self, room_id, **kwargs):
"""
Delete room with given ID
:param room_id: Room ID
:param kwargs:
:return:
"""
return DeletePublicRoom(settings=self.settings, **kwargs).call(room_id=room_id, **kwargs) | [
"def",
"delete_public_room",
"(",
"self",
",",
"room_id",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"DeletePublicRoom",
"(",
"settings",
"=",
"self",
".",
"settings",
",",
"*",
"*",
"kwargs",
")",
".",
"call",
"(",
"room_id",
"=",
"room_id",
",",
"*... | Delete room with given ID
:param room_id: Room ID
:param kwargs:
:return: | [
"Delete",
"room",
"with",
"given",
"ID",
":",
"param",
"room_id",
":",
"Room",
"ID",
":",
"param",
"kwargs",
":",
":",
"return",
":"
] | train | https://github.com/Pipoline/rocket-python/blob/643ece8a9db106922e019984a859ca04283262ff/rocketchat/api.py#L160-L167 |
Pipoline/rocket-python | rocketchat/api.py | RocketChatAPI.get_users | def get_users(self, **kwargs):
"""
Gets all of the users in the system and their information
:param kwargs:
:return:
"""
return GetUsers(settings=self.settings, **kwargs).call(**kwargs) | python | def get_users(self, **kwargs):
"""
Gets all of the users in the system and their information
:param kwargs:
:return:
"""
return GetUsers(settings=self.settings, **kwargs).call(**kwargs) | [
"def",
"get_users",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"GetUsers",
"(",
"settings",
"=",
"self",
".",
"settings",
",",
"*",
"*",
"kwargs",
")",
".",
"call",
"(",
"*",
"*",
"kwargs",
")"
] | Gets all of the users in the system and their information
:param kwargs:
:return: | [
"Gets",
"all",
"of",
"the",
"users",
"in",
"the",
"system",
"and",
"their",
"information",
":",
"param",
"kwargs",
":",
":",
"return",
":"
] | train | https://github.com/Pipoline/rocket-python/blob/643ece8a9db106922e019984a859ca04283262ff/rocketchat/api.py#L172-L178 |
Pipoline/rocket-python | rocketchat/api.py | RocketChatAPI.get_user_info | def get_user_info(self, user_id, **kwargs):
"""
Retrieves information about a user,
the result is only limited to what the callee has access to view.
:param user_id:
:param kwargs:
:return:
"""
return GetUserInfo(settings=self.settings, **kwargs).call(
... | python | def get_user_info(self, user_id, **kwargs):
"""
Retrieves information about a user,
the result is only limited to what the callee has access to view.
:param user_id:
:param kwargs:
:return:
"""
return GetUserInfo(settings=self.settings, **kwargs).call(
... | [
"def",
"get_user_info",
"(",
"self",
",",
"user_id",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"GetUserInfo",
"(",
"settings",
"=",
"self",
".",
"settings",
",",
"*",
"*",
"kwargs",
")",
".",
"call",
"(",
"user_id",
"=",
"user_id",
",",
"*",
"*",
... | Retrieves information about a user,
the result is only limited to what the callee has access to view.
:param user_id:
:param kwargs:
:return: | [
"Retrieves",
"information",
"about",
"a",
"user",
"the",
"result",
"is",
"only",
"limited",
"to",
"what",
"the",
"callee",
"has",
"access",
"to",
"view",
".",
":",
"param",
"user_id",
":",
":",
"param",
"kwargs",
":",
":",
"return",
":"
] | train | https://github.com/Pipoline/rocket-python/blob/643ece8a9db106922e019984a859ca04283262ff/rocketchat/api.py#L180-L191 |
Pipoline/rocket-python | rocketchat/api.py | RocketChatAPI.create_user | def create_user(self, email, name, password, username, **kwargs):
"""
Create user
:param email: E-mail
:param name: Full name
:param password: Password
:param username: Username
:param kwargs:
active:
roles:
join_default_channels:
r... | python | def create_user(self, email, name, password, username, **kwargs):
"""
Create user
:param email: E-mail
:param name: Full name
:param password: Password
:param username: Username
:param kwargs:
active:
roles:
join_default_channels:
r... | [
"def",
"create_user",
"(",
"self",
",",
"email",
",",
"name",
",",
"password",
",",
"username",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"CreateUser",
"(",
"settings",
"=",
"self",
".",
"settings",
",",
"*",
"*",
"kwargs",
")",
".",
"call",
"(",
... | Create user
:param email: E-mail
:param name: Full name
:param password: Password
:param username: Username
:param kwargs:
active:
roles:
join_default_channels:
require_password_change:
send_welcome_email:
verified:
custom_f... | [
"Create",
"user",
":",
"param",
"email",
":",
"E",
"-",
"mail",
":",
"param",
"name",
":",
"Full",
"name",
":",
"param",
"password",
":",
"Password",
":",
"param",
"username",
":",
"Username",
":",
"param",
"kwargs",
":",
"active",
":",
"roles",
":",
... | train | https://github.com/Pipoline/rocket-python/blob/643ece8a9db106922e019984a859ca04283262ff/rocketchat/api.py#L193-L216 |
Pipoline/rocket-python | rocketchat/api.py | RocketChatAPI.delete_user | def delete_user(self, user_id, **kwargs):
"""
Delete user
:param user_id: User ID
:param kwargs:
:return:
"""
return DeleteUser(settings=self.settings, **kwargs).call(user_id=user_id, **kwargs) | python | def delete_user(self, user_id, **kwargs):
"""
Delete user
:param user_id: User ID
:param kwargs:
:return:
"""
return DeleteUser(settings=self.settings, **kwargs).call(user_id=user_id, **kwargs) | [
"def",
"delete_user",
"(",
"self",
",",
"user_id",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"DeleteUser",
"(",
"settings",
"=",
"self",
".",
"settings",
",",
"*",
"*",
"kwargs",
")",
".",
"call",
"(",
"user_id",
"=",
"user_id",
",",
"*",
"*",
"... | Delete user
:param user_id: User ID
:param kwargs:
:return: | [
"Delete",
"user",
":",
"param",
"user_id",
":",
"User",
"ID",
":",
"param",
"kwargs",
":",
":",
"return",
":"
] | train | https://github.com/Pipoline/rocket-python/blob/643ece8a9db106922e019984a859ca04283262ff/rocketchat/api.py#L218-L225 |
ChristopherRabotin/bungiesearch | bungiesearch/__init__.py | Bungiesearch.get_index | def get_index(cls, model, via_class=False):
'''
Returns the index name (as a string) for the given model as a class or a string.
:param model: model name or model class if via_class set to True.
:param via_class: set to True if parameter model is a class.
:raise KeyError: If the ... | python | def get_index(cls, model, via_class=False):
'''
Returns the index name (as a string) for the given model as a class or a string.
:param model: model name or model class if via_class set to True.
:param via_class: set to True if parameter model is a class.
:raise KeyError: If the ... | [
"def",
"get_index",
"(",
"cls",
",",
"model",
",",
"via_class",
"=",
"False",
")",
":",
"try",
":",
"return",
"cls",
".",
"_model_to_index",
"[",
"model",
"]",
"if",
"via_class",
"else",
"cls",
".",
"_model_name_to_index",
"[",
"model",
"]",
"except",
"K... | Returns the index name (as a string) for the given model as a class or a string.
:param model: model name or model class if via_class set to True.
:param via_class: set to True if parameter model is a class.
:raise KeyError: If the provided model does not have any index associated. | [
"Returns",
"the",
"index",
"name",
"(",
"as",
"a",
"string",
")",
"for",
"the",
"given",
"model",
"as",
"a",
"class",
"or",
"a",
"string",
".",
":",
"param",
"model",
":",
"model",
"name",
"or",
"model",
"class",
"if",
"via_class",
"set",
"to",
"True... | train | https://github.com/ChristopherRabotin/bungiesearch/blob/13768342bc2698b214eb0003c2d113b6e273c30d/bungiesearch/__init__.py#L98-L108 |
ChristopherRabotin/bungiesearch | bungiesearch/__init__.py | Bungiesearch.get_model_index | def get_model_index(cls, model, default=True):
'''
Returns the default model index for the given model, or the list of indices if default is False.
:param model: model name as a string.
:raise KeyError: If the provided model does not have any index associated.
'''
try:
... | python | def get_model_index(cls, model, default=True):
'''
Returns the default model index for the given model, or the list of indices if default is False.
:param model: model name as a string.
:raise KeyError: If the provided model does not have any index associated.
'''
try:
... | [
"def",
"get_model_index",
"(",
"cls",
",",
"model",
",",
"default",
"=",
"True",
")",
":",
"try",
":",
"if",
"default",
":",
"return",
"cls",
".",
"_model_name_to_default_index",
"[",
"model",
"]",
"return",
"cls",
".",
"_model_name_to_model_idx",
"[",
"mode... | Returns the default model index for the given model, or the list of indices if default is False.
:param model: model name as a string.
:raise KeyError: If the provided model does not have any index associated. | [
"Returns",
"the",
"default",
"model",
"index",
"for",
"the",
"given",
"model",
"or",
"the",
"list",
"of",
"indices",
"if",
"default",
"is",
"False",
".",
":",
"param",
"model",
":",
"model",
"name",
"as",
"a",
"string",
".",
":",
"raise",
"KeyError",
"... | train | https://github.com/ChristopherRabotin/bungiesearch/blob/13768342bc2698b214eb0003c2d113b6e273c30d/bungiesearch/__init__.py#L111-L122 |
ChristopherRabotin/bungiesearch | bungiesearch/__init__.py | Bungiesearch.get_models | def get_models(cls, index, as_class=False):
'''
Returns the list of models defined for this index.
:param index: index name.
:param as_class: set to True to return the model as a model object instead of as a string.
'''
try:
return cls._index_to_model[index] i... | python | def get_models(cls, index, as_class=False):
'''
Returns the list of models defined for this index.
:param index: index name.
:param as_class: set to True to return the model as a model object instead of as a string.
'''
try:
return cls._index_to_model[index] i... | [
"def",
"get_models",
"(",
"cls",
",",
"index",
",",
"as_class",
"=",
"False",
")",
":",
"try",
":",
"return",
"cls",
".",
"_index_to_model",
"[",
"index",
"]",
"if",
"as_class",
"else",
"cls",
".",
"_idx_name_to_mdl_to_mdlidx",
"[",
"index",
"]",
".",
"k... | Returns the list of models defined for this index.
:param index: index name.
:param as_class: set to True to return the model as a model object instead of as a string. | [
"Returns",
"the",
"list",
"of",
"models",
"defined",
"for",
"this",
"index",
".",
":",
"param",
"index",
":",
"index",
"name",
".",
":",
"param",
"as_class",
":",
"set",
"to",
"True",
"to",
"return",
"the",
"model",
"as",
"a",
"model",
"object",
"inste... | train | https://github.com/ChristopherRabotin/bungiesearch/blob/13768342bc2698b214eb0003c2d113b6e273c30d/bungiesearch/__init__.py#L132-L141 |
ChristopherRabotin/bungiesearch | bungiesearch/__init__.py | Bungiesearch.get_model_indices | def get_model_indices(cls, index):
'''
Returns the list of model indices (i.e. ModelIndex objects) defined for this index.
:param index: index name.
'''
try:
return cls._idx_name_to_mdl_to_mdlidx[index].values()
except KeyError:
raise KeyError('Cou... | python | def get_model_indices(cls, index):
'''
Returns the list of model indices (i.e. ModelIndex objects) defined for this index.
:param index: index name.
'''
try:
return cls._idx_name_to_mdl_to_mdlidx[index].values()
except KeyError:
raise KeyError('Cou... | [
"def",
"get_model_indices",
"(",
"cls",
",",
"index",
")",
":",
"try",
":",
"return",
"cls",
".",
"_idx_name_to_mdl_to_mdlidx",
"[",
"index",
"]",
".",
"values",
"(",
")",
"except",
"KeyError",
":",
"raise",
"KeyError",
"(",
"'Could not find any index named {}. ... | Returns the list of model indices (i.e. ModelIndex objects) defined for this index.
:param index: index name. | [
"Returns",
"the",
"list",
"of",
"model",
"indices",
"(",
"i",
".",
"e",
".",
"ModelIndex",
"objects",
")",
"defined",
"for",
"this",
"index",
".",
":",
"param",
"index",
":",
"index",
"name",
"."
] | train | https://github.com/ChristopherRabotin/bungiesearch/blob/13768342bc2698b214eb0003c2d113b6e273c30d/bungiesearch/__init__.py#L144-L152 |
ChristopherRabotin/bungiesearch | bungiesearch/__init__.py | Bungiesearch.map_raw_results | def map_raw_results(cls, raw_results, instance=None):
'''
Maps raw results to database model objects.
:param raw_results: list raw results as returned from elasticsearch-dsl-py.
:param instance: Bungiesearch instance if you want to make use of `.only()` or `optmize_queries` as defined in... | python | def map_raw_results(cls, raw_results, instance=None):
'''
Maps raw results to database model objects.
:param raw_results: list raw results as returned from elasticsearch-dsl-py.
:param instance: Bungiesearch instance if you want to make use of `.only()` or `optmize_queries` as defined in... | [
"def",
"map_raw_results",
"(",
"cls",
",",
"raw_results",
",",
"instance",
"=",
"None",
")",
":",
"# Let's iterate over the results and determine the appropriate mapping.",
"model_results",
"=",
"defaultdict",
"(",
"list",
")",
"# Initializing the list to the number of returned... | Maps raw results to database model objects.
:param raw_results: list raw results as returned from elasticsearch-dsl-py.
:param instance: Bungiesearch instance if you want to make use of `.only()` or `optmize_queries` as defined in the ModelIndex.
:return: list of mapped results in the *same* ord... | [
"Maps",
"raw",
"results",
"to",
"database",
"model",
"objects",
".",
":",
"param",
"raw_results",
":",
"list",
"raw",
"results",
"as",
"returned",
"from",
"elasticsearch",
"-",
"dsl",
"-",
"py",
".",
":",
"param",
"instance",
":",
"Bungiesearch",
"instance",... | train | https://github.com/ChristopherRabotin/bungiesearch/blob/13768342bc2698b214eb0003c2d113b6e273c30d/bungiesearch/__init__.py#L155-L210 |
ChristopherRabotin/bungiesearch | bungiesearch/__init__.py | Bungiesearch._clone | def _clone(self):
'''
Must clone additional fields to those cloned by elasticsearch-dsl-py.
'''
instance = super(Bungiesearch, self)._clone()
instance._raw_results_only = self._raw_results_only
return instance | python | def _clone(self):
'''
Must clone additional fields to those cloned by elasticsearch-dsl-py.
'''
instance = super(Bungiesearch, self)._clone()
instance._raw_results_only = self._raw_results_only
return instance | [
"def",
"_clone",
"(",
"self",
")",
":",
"instance",
"=",
"super",
"(",
"Bungiesearch",
",",
"self",
")",
".",
"_clone",
"(",
")",
"instance",
".",
"_raw_results_only",
"=",
"self",
".",
"_raw_results_only",
"return",
"instance"
] | Must clone additional fields to those cloned by elasticsearch-dsl-py. | [
"Must",
"clone",
"additional",
"fields",
"to",
"those",
"cloned",
"by",
"elasticsearch",
"-",
"dsl",
"-",
"py",
"."
] | train | https://github.com/ChristopherRabotin/bungiesearch/blob/13768342bc2698b214eb0003c2d113b6e273c30d/bungiesearch/__init__.py#L266-L272 |
ChristopherRabotin/bungiesearch | bungiesearch/__init__.py | Bungiesearch.execute | def execute(self, return_results=True):
'''
Executes the query and attempts to create model objects from results.
'''
if self.results:
return self.results if return_results else None
self.execute_raw()
if self._raw_results_only:
self.results = se... | python | def execute(self, return_results=True):
'''
Executes the query and attempts to create model objects from results.
'''
if self.results:
return self.results if return_results else None
self.execute_raw()
if self._raw_results_only:
self.results = se... | [
"def",
"execute",
"(",
"self",
",",
"return_results",
"=",
"True",
")",
":",
"if",
"self",
".",
"results",
":",
"return",
"self",
".",
"results",
"if",
"return_results",
"else",
"None",
"self",
".",
"execute_raw",
"(",
")",
"if",
"self",
".",
"_raw_resul... | Executes the query and attempts to create model objects from results. | [
"Executes",
"the",
"query",
"and",
"attempts",
"to",
"create",
"model",
"objects",
"from",
"results",
"."
] | train | https://github.com/ChristopherRabotin/bungiesearch/blob/13768342bc2698b214eb0003c2d113b6e273c30d/bungiesearch/__init__.py#L283-L298 |
ChristopherRabotin/bungiesearch | bungiesearch/__init__.py | Bungiesearch.only | def only(self, *fields):
'''
Restricts the fields to be fetched when mapping. Set to `__model` to fetch all fields define in the ModelIndex.
'''
s = self._clone()
if len(fields) == 1 and fields[0] == '__model':
s._only = '__model'
else:
s._only = f... | python | def only(self, *fields):
'''
Restricts the fields to be fetched when mapping. Set to `__model` to fetch all fields define in the ModelIndex.
'''
s = self._clone()
if len(fields) == 1 and fields[0] == '__model':
s._only = '__model'
else:
s._only = f... | [
"def",
"only",
"(",
"self",
",",
"*",
"fields",
")",
":",
"s",
"=",
"self",
".",
"_clone",
"(",
")",
"if",
"len",
"(",
"fields",
")",
"==",
"1",
"and",
"fields",
"[",
"0",
"]",
"==",
"'__model'",
":",
"s",
".",
"_only",
"=",
"'__model'",
"else"... | Restricts the fields to be fetched when mapping. Set to `__model` to fetch all fields define in the ModelIndex. | [
"Restricts",
"the",
"fields",
"to",
"be",
"fetched",
"when",
"mapping",
".",
"Set",
"to",
"__model",
"to",
"fetch",
"all",
"fields",
"define",
"in",
"the",
"ModelIndex",
"."
] | train | https://github.com/ChristopherRabotin/bungiesearch/blob/13768342bc2698b214eb0003c2d113b6e273c30d/bungiesearch/__init__.py#L306-L315 |
ChristopherRabotin/bungiesearch | bungiesearch/__init__.py | Bungiesearch.hook_alias | def hook_alias(self, alias, model_obj=None):
'''
Returns the alias function, if it exists and if it can be applied to this model.
'''
try:
search_alias = self._alias_hooks[alias]
except KeyError:
raise AttributeError('Could not find search alias named {}. ... | python | def hook_alias(self, alias, model_obj=None):
'''
Returns the alias function, if it exists and if it can be applied to this model.
'''
try:
search_alias = self._alias_hooks[alias]
except KeyError:
raise AttributeError('Could not find search alias named {}. ... | [
"def",
"hook_alias",
"(",
"self",
",",
"alias",
",",
"model_obj",
"=",
"None",
")",
":",
"try",
":",
"search_alias",
"=",
"self",
".",
"_alias_hooks",
"[",
"alias",
"]",
"except",
"KeyError",
":",
"raise",
"AttributeError",
"(",
"'Could not find search alias n... | Returns the alias function, if it exists and if it can be applied to this model. | [
"Returns",
"the",
"alias",
"function",
"if",
"it",
"exists",
"and",
"if",
"it",
"can",
"be",
"applied",
"to",
"this",
"model",
"."
] | train | https://github.com/ChristopherRabotin/bungiesearch/blob/13768342bc2698b214eb0003c2d113b6e273c30d/bungiesearch/__init__.py#L358-L371 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.