partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | Pong.ack | Override this and do some customer message handler. | lib/stomper/examples/stomper_usage.py | def ack(self, msg):
"""Override this and do some customer message handler.
"""
print("Got a message:\n%s\n" % msg['body'])
# do something with the message...
# Generate the ack or not if you subscribed with ack='auto'
return super(Pong, self).ack(msg) | def ack(self, msg):
"""Override this and do some customer message handler.
"""
print("Got a message:\n%s\n" % msg['body'])
# do something with the message...
# Generate the ack or not if you subscribed with ack='auto'
return super(Pong, self).ack(msg) | [
"Override",
"this",
"and",
"do",
"some",
"customer",
"message",
"handler",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/stomper_usage.py#L87-L95 | [
"def",
"ack",
"(",
"self",
",",
"msg",
")",
":",
"print",
"(",
"\"Got a message:\\n%s\\n\"",
"%",
"msg",
"[",
"'body'",
"]",
")",
"# do something with the message...",
"# Generate the ack or not if you subscribed with ack='auto'",
"return",
"super",
"(",
"Pong",
",",
... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | transaction_atomic_with_retry | This is a decorator that will wrap the decorated method in an atomic transaction and
retry the transaction a given number of times
:param num_retries: How many times should we retry before we give up
:param backoff: How long should we wait after each try | entity/sync.py | def transaction_atomic_with_retry(num_retries=5, backoff=0.1):
"""
This is a decorator that will wrap the decorated method in an atomic transaction and
retry the transaction a given number of times
:param num_retries: How many times should we retry before we give up
:param backoff: How long should ... | def transaction_atomic_with_retry(num_retries=5, backoff=0.1):
"""
This is a decorator that will wrap the decorated method in an atomic transaction and
retry the transaction a given number of times
:param num_retries: How many times should we retry before we give up
:param backoff: How long should ... | [
"This",
"is",
"a",
"decorator",
"that",
"will",
"wrap",
"the",
"decorated",
"method",
"in",
"an",
"atomic",
"transaction",
"and",
"retry",
"the",
"transaction",
"a",
"given",
"number",
"of",
"times"
] | ambitioninc/django-entity | python | https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/sync.py#L23-L55 | [
"def",
"transaction_atomic_with_retry",
"(",
"num_retries",
"=",
"5",
",",
"backoff",
"=",
"0.1",
")",
":",
"# Create the decorator",
"@",
"wrapt",
".",
"decorator",
"def",
"wrapper",
"(",
"wrapped",
",",
"instance",
",",
"args",
",",
"kwargs",
")",
":",
"# ... | ebc61f34313c52f4ef5819eb1da25b2ad837e80c |
train | defer_entity_syncing | A decorator that can be used to defer the syncing of entities until after the method has been run
This is being introduced to help avoid deadlocks in the meantime as we attempt to better understand
why they are happening | entity/sync.py | def defer_entity_syncing(wrapped, instance, args, kwargs):
"""
A decorator that can be used to defer the syncing of entities until after the method has been run
This is being introduced to help avoid deadlocks in the meantime as we attempt to better understand
why they are happening
"""
# Defer... | def defer_entity_syncing(wrapped, instance, args, kwargs):
"""
A decorator that can be used to defer the syncing of entities until after the method has been run
This is being introduced to help avoid deadlocks in the meantime as we attempt to better understand
why they are happening
"""
# Defer... | [
"A",
"decorator",
"that",
"can",
"be",
"used",
"to",
"defer",
"the",
"syncing",
"of",
"entities",
"until",
"after",
"the",
"method",
"has",
"been",
"run",
"This",
"is",
"being",
"introduced",
"to",
"help",
"avoid",
"deadlocks",
"in",
"the",
"meantime",
"as... | ambitioninc/django-entity | python | https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/sync.py#L59-L91 | [
"def",
"defer_entity_syncing",
"(",
"wrapped",
",",
"instance",
",",
"args",
",",
"kwargs",
")",
":",
"# Defer entity syncing while we run our method",
"sync_entities",
".",
"defer",
"=",
"True",
"# Run the method",
"try",
":",
"return",
"wrapped",
"(",
"*",
"args",... | ebc61f34313c52f4ef5819eb1da25b2ad837e80c |
train | _get_super_entities_by_ctype | Given model objects organized by content type and a dictionary of all model IDs that need
to be synced, organize all super entity relationships that need to be synced.
Ensure that the model_ids_to_sync dict is updated with any new super entities
that need to be part of the overall entity sync | entity/sync.py | def _get_super_entities_by_ctype(model_objs_by_ctype, model_ids_to_sync, sync_all):
"""
Given model objects organized by content type and a dictionary of all model IDs that need
to be synced, organize all super entity relationships that need to be synced.
Ensure that the model_ids_to_sync dict is updat... | def _get_super_entities_by_ctype(model_objs_by_ctype, model_ids_to_sync, sync_all):
"""
Given model objects organized by content type and a dictionary of all model IDs that need
to be synced, organize all super entity relationships that need to be synced.
Ensure that the model_ids_to_sync dict is updat... | [
"Given",
"model",
"objects",
"organized",
"by",
"content",
"type",
"and",
"a",
"dictionary",
"of",
"all",
"model",
"IDs",
"that",
"need",
"to",
"be",
"synced",
"organize",
"all",
"super",
"entity",
"relationships",
"that",
"need",
"to",
"be",
"synced",
"."
] | ambitioninc/django-entity | python | https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/sync.py#L94-L117 | [
"def",
"_get_super_entities_by_ctype",
"(",
"model_objs_by_ctype",
",",
"model_ids_to_sync",
",",
"sync_all",
")",
":",
"super_entities_by_ctype",
"=",
"defaultdict",
"(",
"lambda",
":",
"defaultdict",
"(",
"list",
")",
")",
"# pragma: no cover",
"for",
"ctype",
",",
... | ebc61f34313c52f4ef5819eb1da25b2ad837e80c |
train | _get_model_objs_to_sync | Given the model IDs to sync, fetch all model objects to sync | entity/sync.py | def _get_model_objs_to_sync(model_ids_to_sync, model_objs_map, sync_all):
"""
Given the model IDs to sync, fetch all model objects to sync
"""
model_objs_to_sync = {}
for ctype, model_ids_to_sync_for_ctype in model_ids_to_sync.items():
model_qset = entity_registry.entity_registry.get(ctype.m... | def _get_model_objs_to_sync(model_ids_to_sync, model_objs_map, sync_all):
"""
Given the model IDs to sync, fetch all model objects to sync
"""
model_objs_to_sync = {}
for ctype, model_ids_to_sync_for_ctype in model_ids_to_sync.items():
model_qset = entity_registry.entity_registry.get(ctype.m... | [
"Given",
"the",
"model",
"IDs",
"to",
"sync",
"fetch",
"all",
"model",
"objects",
"to",
"sync"
] | ambitioninc/django-entity | python | https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/sync.py#L120-L135 | [
"def",
"_get_model_objs_to_sync",
"(",
"model_ids_to_sync",
",",
"model_objs_map",
",",
"sync_all",
")",
":",
"model_objs_to_sync",
"=",
"{",
"}",
"for",
"ctype",
",",
"model_ids_to_sync_for_ctype",
"in",
"model_ids_to_sync",
".",
"items",
"(",
")",
":",
"model_qset... | ebc61f34313c52f4ef5819eb1da25b2ad837e80c |
train | sync_entities | Syncs entities
Args:
model_objs (List[Model]): The model objects to sync. If empty, all entities will be synced | entity/sync.py | def sync_entities(*model_objs):
"""
Syncs entities
Args:
model_objs (List[Model]): The model objects to sync. If empty, all entities will be synced
"""
# Check if we are deferring processing
if sync_entities.defer:
# If we dont have any model objects passed add a none to let us... | def sync_entities(*model_objs):
"""
Syncs entities
Args:
model_objs (List[Model]): The model objects to sync. If empty, all entities will be synced
"""
# Check if we are deferring processing
if sync_entities.defer:
# If we dont have any model objects passed add a none to let us... | [
"Syncs",
"entities"
] | ambitioninc/django-entity | python | https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/sync.py#L138-L160 | [
"def",
"sync_entities",
"(",
"*",
"model_objs",
")",
":",
"# Check if we are deferring processing",
"if",
"sync_entities",
".",
"defer",
":",
"# If we dont have any model objects passed add a none to let us know that we need to sync all",
"if",
"not",
"model_objs",
":",
"sync_ent... | ebc61f34313c52f4ef5819eb1da25b2ad837e80c |
train | sync_entities_watching | Syncs entities watching changes of a model instance. | entity/sync.py | def sync_entities_watching(instance):
"""
Syncs entities watching changes of a model instance.
"""
for entity_model, entity_model_getter in entity_registry.entity_watching[instance.__class__]:
model_objs = list(entity_model_getter(instance))
if model_objs:
sync_entities(*mode... | def sync_entities_watching(instance):
"""
Syncs entities watching changes of a model instance.
"""
for entity_model, entity_model_getter in entity_registry.entity_watching[instance.__class__]:
model_objs = list(entity_model_getter(instance))
if model_objs:
sync_entities(*mode... | [
"Syncs",
"entities",
"watching",
"changes",
"of",
"a",
"model",
"instance",
"."
] | ambitioninc/django-entity | python | https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/sync.py#L169-L176 | [
"def",
"sync_entities_watching",
"(",
"instance",
")",
":",
"for",
"entity_model",
",",
"entity_model_getter",
"in",
"entity_registry",
".",
"entity_watching",
"[",
"instance",
".",
"__class__",
"]",
":",
"model_objs",
"=",
"list",
"(",
"entity_model_getter",
"(",
... | ebc61f34313c52f4ef5819eb1da25b2ad837e80c |
train | EntitySyncer.upsert_entity_kinds | Given a list of entity kinds ensure they are synced properly to the database.
This will ensure that only unchanged entity kinds are synced and will still return all
updated entity kinds
:param entity_kinds: The list of entity kinds to sync | entity/sync.py | def upsert_entity_kinds(self, entity_kinds):
"""
Given a list of entity kinds ensure they are synced properly to the database.
This will ensure that only unchanged entity kinds are synced and will still return all
updated entity kinds
:param entity_kinds: The list of entity kind... | def upsert_entity_kinds(self, entity_kinds):
"""
Given a list of entity kinds ensure they are synced properly to the database.
This will ensure that only unchanged entity kinds are synced and will still return all
updated entity kinds
:param entity_kinds: The list of entity kind... | [
"Given",
"a",
"list",
"of",
"entity",
"kinds",
"ensure",
"they",
"are",
"synced",
"properly",
"to",
"the",
"database",
".",
"This",
"will",
"ensure",
"that",
"only",
"unchanged",
"entity",
"kinds",
"are",
"synced",
"and",
"will",
"still",
"return",
"all",
... | ambitioninc/django-entity | python | https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/sync.py#L323-L373 | [
"def",
"upsert_entity_kinds",
"(",
"self",
",",
"entity_kinds",
")",
":",
"# Filter out unchanged entity kinds",
"unchanged_entity_kinds",
"=",
"{",
"}",
"if",
"entity_kinds",
":",
"unchanged_entity_kinds",
"=",
"{",
"(",
"entity_kind",
".",
"name",
",",
"entity_kind"... | ebc61f34313c52f4ef5819eb1da25b2ad837e80c |
train | EntitySyncer.upsert_entities | Upsert a list of entities to the database
:param entities: The entities to sync
:param sync: Do a sync instead of an upsert | entity/sync.py | def upsert_entities(self, entities, sync=False):
"""
Upsert a list of entities to the database
:param entities: The entities to sync
:param sync: Do a sync instead of an upsert
"""
# Select the entities we are upserting for update to reduce deadlocks
if entities:... | def upsert_entities(self, entities, sync=False):
"""
Upsert a list of entities to the database
:param entities: The entities to sync
:param sync: Do a sync instead of an upsert
"""
# Select the entities we are upserting for update to reduce deadlocks
if entities:... | [
"Upsert",
"a",
"list",
"of",
"entities",
"to",
"the",
"database",
":",
"param",
"entities",
":",
"The",
"entities",
"to",
"sync",
":",
"param",
"sync",
":",
"Do",
"a",
"sync",
"instead",
"of",
"an",
"upsert"
] | ambitioninc/django-entity | python | https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/sync.py#L376-L435 | [
"def",
"upsert_entities",
"(",
"self",
",",
"entities",
",",
"sync",
"=",
"False",
")",
":",
"# Select the entities we are upserting for update to reduce deadlocks",
"if",
"entities",
":",
"# Default select for update query when syncing all",
"select_for_update_query",
"=",
"("... | ebc61f34313c52f4ef5819eb1da25b2ad837e80c |
train | EntitySyncer.upsert_entity_relationships | Upsert entity relationships to the database
:param queryset: The base queryset to use
:param entity_relationships: The entity relationships to ensure exist in the database | entity/sync.py | def upsert_entity_relationships(self, queryset, entity_relationships):
"""
Upsert entity relationships to the database
:param queryset: The base queryset to use
:param entity_relationships: The entity relationships to ensure exist in the database
"""
# Select the relatio... | def upsert_entity_relationships(self, queryset, entity_relationships):
"""
Upsert entity relationships to the database
:param queryset: The base queryset to use
:param entity_relationships: The entity relationships to ensure exist in the database
"""
# Select the relatio... | [
"Upsert",
"entity",
"relationships",
"to",
"the",
"database",
":",
"param",
"queryset",
":",
"The",
"base",
"queryset",
"to",
"use",
":",
"param",
"entity_relationships",
":",
"The",
"entity",
"relationships",
"to",
"ensure",
"exist",
"in",
"the",
"database"
] | ambitioninc/django-entity | python | https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/sync.py#L438-L459 | [
"def",
"upsert_entity_relationships",
"(",
"self",
",",
"queryset",
",",
"entity_relationships",
")",
":",
"# Select the relationships for update",
"if",
"entity_relationships",
":",
"list",
"(",
"queryset",
".",
"select_for_update",
"(",
")",
".",
"values_list",
"(",
... | ebc61f34313c52f4ef5819eb1da25b2ad837e80c |
train | EntityConfig.get_entity_kind | Returns a tuple for a kind name and kind display name of an entity.
By default, uses the app_label and model of the model object's content
type as the kind. | entity/config.py | def get_entity_kind(self, model_obj):
"""
Returns a tuple for a kind name and kind display name of an entity.
By default, uses the app_label and model of the model object's content
type as the kind.
"""
model_obj_ctype = ContentType.objects.get_for_model(self.queryset.mod... | def get_entity_kind(self, model_obj):
"""
Returns a tuple for a kind name and kind display name of an entity.
By default, uses the app_label and model of the model object's content
type as the kind.
"""
model_obj_ctype = ContentType.objects.get_for_model(self.queryset.mod... | [
"Returns",
"a",
"tuple",
"for",
"a",
"kind",
"name",
"and",
"kind",
"display",
"name",
"of",
"an",
"entity",
".",
"By",
"default",
"uses",
"the",
"app_label",
"and",
"model",
"of",
"the",
"model",
"object",
"s",
"content",
"type",
"as",
"the",
"kind",
... | ambitioninc/django-entity | python | https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/config.py#L36-L43 | [
"def",
"get_entity_kind",
"(",
"self",
",",
"model_obj",
")",
":",
"model_obj_ctype",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"self",
".",
"queryset",
".",
"model",
")",
"return",
"(",
"u'{0}.{1}'",
".",
"format",
"(",
"model_obj_ctype",... | ebc61f34313c52f4ef5819eb1da25b2ad837e80c |
train | EntityRegistry.register_entity | Registers an entity config | entity/config.py | def register_entity(self, entity_config):
"""
Registers an entity config
"""
if not issubclass(entity_config, EntityConfig):
raise ValueError('Must register entity config class of subclass EntityConfig')
if entity_config.queryset is None:
raise ValueError... | def register_entity(self, entity_config):
"""
Registers an entity config
"""
if not issubclass(entity_config, EntityConfig):
raise ValueError('Must register entity config class of subclass EntityConfig')
if entity_config.queryset is None:
raise ValueError... | [
"Registers",
"an",
"entity",
"config"
] | ambitioninc/django-entity | python | https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/config.py#L96-L112 | [
"def",
"register_entity",
"(",
"self",
",",
"entity_config",
")",
":",
"if",
"not",
"issubclass",
"(",
"entity_config",
",",
"EntityConfig",
")",
":",
"raise",
"ValueError",
"(",
"'Must register entity config class of subclass EntityConfig'",
")",
"if",
"entity_config",... | ebc61f34313c52f4ef5819eb1da25b2ad837e80c |
train | start | Start twisted event loop and the fun should begin... | lib/stomper/examples/stompbuffer-tx.py | def start(host='localhost', port=61613, username='', password=''):
"""Start twisted event loop and the fun should begin...
"""
StompClientFactory.username = username
StompClientFactory.password = password
reactor.connectTCP(host, port, StompClientFactory())
reactor.run() | def start(host='localhost', port=61613, username='', password=''):
"""Start twisted event loop and the fun should begin...
"""
StompClientFactory.username = username
StompClientFactory.password = password
reactor.connectTCP(host, port, StompClientFactory())
reactor.run() | [
"Start",
"twisted",
"event",
"loop",
"and",
"the",
"fun",
"should",
"begin",
"..."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/stompbuffer-tx.py#L131-L137 | [
"def",
"start",
"(",
"host",
"=",
"'localhost'",
",",
"port",
"=",
"61613",
",",
"username",
"=",
"''",
",",
"password",
"=",
"''",
")",
":",
"StompClientFactory",
".",
"username",
"=",
"username",
"StompClientFactory",
".",
"password",
"=",
"password",
"r... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | StompProtocol.connected | Once I've connected I want to subscribe to my the message queue. | lib/stomper/examples/stompbuffer-tx.py | def connected(self, msg):
"""Once I've connected I want to subscribe to my the message queue.
"""
stomper.Engine.connected(self, msg)
self.log.info("Connected: session %s. Beginning say hello." % msg['headers']['session'])
def setup_looping_call():
lc = Loop... | def connected(self, msg):
"""Once I've connected I want to subscribe to my the message queue.
"""
stomper.Engine.connected(self, msg)
self.log.info("Connected: session %s. Beginning say hello." % msg['headers']['session'])
def setup_looping_call():
lc = Loop... | [
"Once",
"I",
"ve",
"connected",
"I",
"want",
"to",
"subscribe",
"to",
"my",
"the",
"message",
"queue",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/stompbuffer-tx.py#L35-L56 | [
"def",
"connected",
"(",
"self",
",",
"msg",
")",
":",
"stomper",
".",
"Engine",
".",
"connected",
"(",
"self",
",",
"msg",
")",
"self",
".",
"log",
".",
"info",
"(",
"\"Connected: session %s. Beginning say hello.\"",
"%",
"msg",
"[",
"'headers'",
"]",
"["... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | StompProtocol.send | Send out a hello message periodically. | lib/stomper/examples/stompbuffer-tx.py | def send(self):
"""Send out a hello message periodically.
"""
self.log.info("Saying hello (%d)." % self.counter)
f = stomper.Frame()
f.unpack(stomper.send(DESTINATION, 'hello there (%d)' % self.counter))
self.counter += 1
# ActiveMQ specific headers:
... | def send(self):
"""Send out a hello message periodically.
"""
self.log.info("Saying hello (%d)." % self.counter)
f = stomper.Frame()
f.unpack(stomper.send(DESTINATION, 'hello there (%d)' % self.counter))
self.counter += 1
# ActiveMQ specific headers:
... | [
"Send",
"out",
"a",
"hello",
"message",
"periodically",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/stompbuffer-tx.py#L68-L82 | [
"def",
"send",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"Saying hello (%d).\"",
"%",
"self",
".",
"counter",
")",
"f",
"=",
"stomper",
".",
"Frame",
"(",
")",
"f",
".",
"unpack",
"(",
"stomper",
".",
"send",
"(",
"DESTINATION",
... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | StompProtocol.connectionMade | Register with stomp server. | lib/stomper/examples/stompbuffer-tx.py | def connectionMade(self):
"""Register with stomp server.
"""
cmd = stomper.connect(self.username, self.password)
self.transport.write(cmd) | def connectionMade(self):
"""Register with stomp server.
"""
cmd = stomper.connect(self.username, self.password)
self.transport.write(cmd) | [
"Register",
"with",
"stomp",
"server",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/stompbuffer-tx.py#L85-L89 | [
"def",
"connectionMade",
"(",
"self",
")",
":",
"cmd",
"=",
"stomper",
".",
"connect",
"(",
"self",
".",
"username",
",",
"self",
".",
"password",
")",
"self",
".",
"transport",
".",
"write",
"(",
"cmd",
")"
] | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | StompProtocol.dataReceived | Use stompbuffer to determine when a complete message has been received. | lib/stomper/examples/stompbuffer-tx.py | def dataReceived(self, data):
"""Use stompbuffer to determine when a complete message has been received.
"""
self.stompBuffer.appendData(data)
while True:
msg = self.stompBuffer.getOneMessage()
if msg is None:
break
returned = self.react... | def dataReceived(self, data):
"""Use stompbuffer to determine when a complete message has been received.
"""
self.stompBuffer.appendData(data)
while True:
msg = self.stompBuffer.getOneMessage()
if msg is None:
break
returned = self.react... | [
"Use",
"stompbuffer",
"to",
"determine",
"when",
"a",
"complete",
"message",
"has",
"been",
"received",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/stompbuffer-tx.py#L92-L104 | [
"def",
"dataReceived",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"stompBuffer",
".",
"appendData",
"(",
"data",
")",
"while",
"True",
":",
"msg",
"=",
"self",
".",
"stompBuffer",
".",
"getOneMessage",
"(",
")",
"if",
"msg",
"is",
"None",
":",
... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | StompClientFactory.clientConnectionFailed | Connection failed | lib/stomper/examples/stompbuffer-tx.py | def clientConnectionFailed(self, connector, reason):
"""Connection failed
"""
print('Connection failed. Reason:', reason)
ReconnectingClientFactory.clientConnectionFailed(self, connector, reason) | def clientConnectionFailed(self, connector, reason):
"""Connection failed
"""
print('Connection failed. Reason:', reason)
ReconnectingClientFactory.clientConnectionFailed(self, connector, reason) | [
"Connection",
"failed"
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/stompbuffer-tx.py#L124-L128 | [
"def",
"clientConnectionFailed",
"(",
"self",
",",
"connector",
",",
"reason",
")",
":",
"print",
"(",
"'Connection failed. Reason:'",
",",
"reason",
")",
"ReconnectingClientFactory",
".",
"clientConnectionFailed",
"(",
"self",
",",
"connector",
",",
"reason",
")"
] | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | MyStomp.ack | Process the message and determine what to do with it. | lib/stomper/examples/receiver.py | def ack(self, msg):
"""Process the message and determine what to do with it.
"""
self.log.info("receiverId <%s> Received: <%s> " % (self.receiverId, msg['body']))
#return super(MyStomp, self).ack(msg)
return stomper.NO_REPONSE_NEEDED | def ack(self, msg):
"""Process the message and determine what to do with it.
"""
self.log.info("receiverId <%s> Received: <%s> " % (self.receiverId, msg['body']))
#return super(MyStomp, self).ack(msg)
return stomper.NO_REPONSE_NEEDED | [
"Process",
"the",
"message",
"and",
"determine",
"what",
"to",
"do",
"with",
"it",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/receiver.py#L51-L57 | [
"def",
"ack",
"(",
"self",
",",
"msg",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"receiverId <%s> Received: <%s> \"",
"%",
"(",
"self",
".",
"receiverId",
",",
"msg",
"[",
"'body'",
"]",
")",
")",
"#return super(MyStomp, self).ack(msg) ",
"return",
"... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | StompProtocol.connectionMade | Register with the stomp server. | lib/stomper/examples/receiver.py | def connectionMade(self):
"""Register with the stomp server.
"""
cmd = self.sm.connect()
self.transport.write(cmd) | def connectionMade(self):
"""Register with the stomp server.
"""
cmd = self.sm.connect()
self.transport.write(cmd) | [
"Register",
"with",
"the",
"stomp",
"server",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/receiver.py#L67-L71 | [
"def",
"connectionMade",
"(",
"self",
")",
":",
"cmd",
"=",
"self",
".",
"sm",
".",
"connect",
"(",
")",
"self",
".",
"transport",
".",
"write",
"(",
"cmd",
")"
] | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | StompProtocol.dataReceived | Data received, react to it and respond if needed. | lib/stomper/examples/receiver.py | def dataReceived(self, data):
"""Data received, react to it and respond if needed.
"""
# print "receiver dataReceived: <%s>" % data
msg = stomper.unpack_frame(data)
returned = self.sm.react(msg)
# print "receiver returned <%s>" % returned
... | def dataReceived(self, data):
"""Data received, react to it and respond if needed.
"""
# print "receiver dataReceived: <%s>" % data
msg = stomper.unpack_frame(data)
returned = self.sm.react(msg)
# print "receiver returned <%s>" % returned
... | [
"Data",
"received",
"react",
"to",
"it",
"and",
"respond",
"if",
"needed",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/receiver.py#L74-L86 | [
"def",
"dataReceived",
"(",
"self",
",",
"data",
")",
":",
"# print \"receiver dataReceived: <%s>\" % data",
"msg",
"=",
"stomper",
".",
"unpack_frame",
"(",
"data",
")",
"returned",
"=",
"self",
".",
"sm",
".",
"react",
"(",
"msg",
")",
"# print \... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | BoxSession.find_id_in_folder | Find a folder or a file ID from its name, inside a given folder.
Args:
name (str): Name of the folder or the file to find.
parent_folder_id (int): ID of the folder where to search.
Returns:
int. ID of the file or folder found. None if not found.
Raises:
... | boxpython/session.py | def find_id_in_folder(self, name, parent_folder_id=0):
"""Find a folder or a file ID from its name, inside a given folder.
Args:
name (str): Name of the folder or the file to find.
parent_folder_id (int): ID of the folder where to search.
Returns:
int. ID o... | def find_id_in_folder(self, name, parent_folder_id=0):
"""Find a folder or a file ID from its name, inside a given folder.
Args:
name (str): Name of the folder or the file to find.
parent_folder_id (int): ID of the folder where to search.
Returns:
int. ID o... | [
"Find",
"a",
"folder",
"or",
"a",
"file",
"ID",
"from",
"its",
"name",
"inside",
"a",
"given",
"folder",
"."
] | wesleyfr/boxpython | python | https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/session.py#L135-L169 | [
"def",
"find_id_in_folder",
"(",
"self",
",",
"name",
",",
"parent_folder_id",
"=",
"0",
")",
":",
"if",
"name",
"is",
"None",
"or",
"len",
"(",
"name",
")",
"==",
"0",
":",
"return",
"parent_folder_id",
"offset",
"=",
"0",
"resp",
"=",
"self",
".",
... | f00a8ada6dff2c7ffc88bf89d4e15965c5adb422 |
train | BoxSession.create_folder | Create a folder
If the folder exists, a BoxError will be raised.
Args:
folder_id (int): Name of the folder.
parent_folder_id (int): ID of the folder where to create the new one.
Returns:
dict. Response from Box.
Raises:
BoxError: An er... | boxpython/session.py | def create_folder(self, name, parent_folder_id=0):
"""Create a folder
If the folder exists, a BoxError will be raised.
Args:
folder_id (int): Name of the folder.
parent_folder_id (int): ID of the folder where to create the new one.
Returns:
dict. R... | def create_folder(self, name, parent_folder_id=0):
"""Create a folder
If the folder exists, a BoxError will be raised.
Args:
folder_id (int): Name of the folder.
parent_folder_id (int): ID of the folder where to create the new one.
Returns:
dict. R... | [
"Create",
"a",
"folder"
] | wesleyfr/boxpython | python | https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/session.py#L195-L217 | [
"def",
"create_folder",
"(",
"self",
",",
"name",
",",
"parent_folder_id",
"=",
"0",
")",
":",
"return",
"self",
".",
"__request",
"(",
"\"POST\"",
",",
"\"folders\"",
",",
"data",
"=",
"{",
"\"name\"",
":",
"name",
",",
"\"parent\"",
":",
"{",
"\"id\"",... | f00a8ada6dff2c7ffc88bf89d4e15965c5adb422 |
train | BoxSession.delete_folder | Delete an existing folder
Args:
folder_id (int): ID of the folder to delete.
recursive (bool): Delete all subfolder if True.
Returns:
dict. Response from Box.
Raises:
BoxError: An error response is returned from Box (status_code >= 400).
... | boxpython/session.py | def delete_folder(self, folder_id, recursive=True):
"""Delete an existing folder
Args:
folder_id (int): ID of the folder to delete.
recursive (bool): Delete all subfolder if True.
Returns:
dict. Response from Box.
Raises:
BoxError: An er... | def delete_folder(self, folder_id, recursive=True):
"""Delete an existing folder
Args:
folder_id (int): ID of the folder to delete.
recursive (bool): Delete all subfolder if True.
Returns:
dict. Response from Box.
Raises:
BoxError: An er... | [
"Delete",
"an",
"existing",
"folder"
] | wesleyfr/boxpython | python | https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/session.py#L219-L237 | [
"def",
"delete_folder",
"(",
"self",
",",
"folder_id",
",",
"recursive",
"=",
"True",
")",
":",
"return",
"self",
".",
"__request",
"(",
"\"DELETE\"",
",",
"\"folders/%s\"",
"%",
"(",
"folder_id",
",",
")",
",",
"querystring",
"=",
"{",
"'recursive'",
":",... | f00a8ada6dff2c7ffc88bf89d4e15965c5adb422 |
train | BoxSession.get_folder_items | Get files and folders inside a given folder
Args:
folder_id (int): Where to get files and folders info.
limit (int): The number of items to return.
offset (int): The item at which to begin the response.
fields_list (list): List of attributes to get. All attrib... | boxpython/session.py | def get_folder_items(self, folder_id,
limit=100, offset=0, fields_list=None):
"""Get files and folders inside a given folder
Args:
folder_id (int): Where to get files and folders info.
limit (int): The number of items to return.
offset (... | def get_folder_items(self, folder_id,
limit=100, offset=0, fields_list=None):
"""Get files and folders inside a given folder
Args:
folder_id (int): Where to get files and folders info.
limit (int): The number of items to return.
offset (... | [
"Get",
"files",
"and",
"folders",
"inside",
"a",
"given",
"folder"
] | wesleyfr/boxpython | python | https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/session.py#L239-L267 | [
"def",
"get_folder_items",
"(",
"self",
",",
"folder_id",
",",
"limit",
"=",
"100",
",",
"offset",
"=",
"0",
",",
"fields_list",
"=",
"None",
")",
":",
"qs",
"=",
"{",
"\"limit\"",
":",
"limit",
",",
"\"offset\"",
":",
"offset",
"}",
"if",
"fields_list... | f00a8ada6dff2c7ffc88bf89d4e15965c5adb422 |
train | BoxSession.upload_file | Upload a file into a folder.
Use function for small file otherwise there is the chunk_upload_file() function
Args::
name (str): Name of the file on your Box storage.
folder_id (int): ID of the folder where to upload the file.
file_path (str): Local path of the fil... | boxpython/session.py | def upload_file(self, name, folder_id, file_path):
"""Upload a file into a folder.
Use function for small file otherwise there is the chunk_upload_file() function
Args::
name (str): Name of the file on your Box storage.
folder_id (int): ID of the folder where to upload... | def upload_file(self, name, folder_id, file_path):
"""Upload a file into a folder.
Use function for small file otherwise there is the chunk_upload_file() function
Args::
name (str): Name of the file on your Box storage.
folder_id (int): ID of the folder where to upload... | [
"Upload",
"a",
"file",
"into",
"a",
"folder",
"."
] | wesleyfr/boxpython | python | https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/session.py#L269-L297 | [
"def",
"upload_file",
"(",
"self",
",",
"name",
",",
"folder_id",
",",
"file_path",
")",
":",
"try",
":",
"return",
"self",
".",
"__do_upload_file",
"(",
"name",
",",
"folder_id",
",",
"file_path",
")",
"except",
"BoxError",
",",
"ex",
":",
"if",
"ex",
... | f00a8ada6dff2c7ffc88bf89d4e15965c5adb422 |
train | BoxSession.upload_new_file_version | Upload a new version of a file into a folder.
Use function for small file otherwise there is the chunk_upload_file() function.
Args::
name (str): Name of the file on your Box storage.
folder_id (int): ID of the folder where to upload the file.
file_id (int): ID of... | boxpython/session.py | def upload_new_file_version(self, name, folder_id, file_id, file_path):
"""Upload a new version of a file into a folder.
Use function for small file otherwise there is the chunk_upload_file() function.
Args::
name (str): Name of the file on your Box storage.
folder_id ... | def upload_new_file_version(self, name, folder_id, file_id, file_path):
"""Upload a new version of a file into a folder.
Use function for small file otherwise there is the chunk_upload_file() function.
Args::
name (str): Name of the file on your Box storage.
folder_id ... | [
"Upload",
"a",
"new",
"version",
"of",
"a",
"file",
"into",
"a",
"folder",
"."
] | wesleyfr/boxpython | python | https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/session.py#L299-L329 | [
"def",
"upload_new_file_version",
"(",
"self",
",",
"name",
",",
"folder_id",
",",
"file_id",
",",
"file_path",
")",
":",
"try",
":",
"return",
"self",
".",
"__do_upload_file",
"(",
"name",
",",
"folder_id",
",",
"file_path",
",",
"file_id",
")",
"except",
... | f00a8ada6dff2c7ffc88bf89d4e15965c5adb422 |
train | BoxSession.chunk_upload_file | Upload a file chunk by chunk.
The whole file is never loaded in memory.
Use this function for big file.
The callback(transferred, total) to let you know the upload progress.
Upload can be cancelled if the callback raise an Exception.
>>> def progress_callback(transferred, tota... | boxpython/session.py | def chunk_upload_file(self, name, folder_id, file_path,
progress_callback=None,
chunk_size=1024*1024*1):
"""Upload a file chunk by chunk.
The whole file is never loaded in memory.
Use this function for big file.
The callback(trans... | def chunk_upload_file(self, name, folder_id, file_path,
progress_callback=None,
chunk_size=1024*1024*1):
"""Upload a file chunk by chunk.
The whole file is never loaded in memory.
Use this function for big file.
The callback(trans... | [
"Upload",
"a",
"file",
"chunk",
"by",
"chunk",
"."
] | wesleyfr/boxpython | python | https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/session.py#L346-L394 | [
"def",
"chunk_upload_file",
"(",
"self",
",",
"name",
",",
"folder_id",
",",
"file_path",
",",
"progress_callback",
"=",
"None",
",",
"chunk_size",
"=",
"1024",
"*",
"1024",
"*",
"1",
")",
":",
"try",
":",
"return",
"self",
".",
"__do_chunk_upload_file",
"... | f00a8ada6dff2c7ffc88bf89d4e15965c5adb422 |
train | BoxSession.copy_file | Copy file to new destination
Args:
file_id (int): ID of the folder.
dest_folder_id (int): ID of parent folder you are copying to.
Returns:
dict. Response from Box.
Raises:
BoxError: An error response is returned from Box (status_code >= 400).
... | boxpython/session.py | def copy_file(self, file_id, dest_folder_id):
"""Copy file to new destination
Args:
file_id (int): ID of the folder.
dest_folder_id (int): ID of parent folder you are copying to.
Returns:
dict. Response from Box.
Raises:
BoxError: An er... | def copy_file(self, file_id, dest_folder_id):
"""Copy file to new destination
Args:
file_id (int): ID of the folder.
dest_folder_id (int): ID of parent folder you are copying to.
Returns:
dict. Response from Box.
Raises:
BoxError: An er... | [
"Copy",
"file",
"to",
"new",
"destination"
] | wesleyfr/boxpython | python | https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/session.py#L432-L456 | [
"def",
"copy_file",
"(",
"self",
",",
"file_id",
",",
"dest_folder_id",
")",
":",
"return",
"self",
".",
"__request",
"(",
"\"POST\"",
",",
"\"/files/\"",
"+",
"unicode",
"(",
"file_id",
")",
"+",
"\"/copy\"",
",",
"data",
"=",
"{",
"\"parent\"",
":",
"{... | f00a8ada6dff2c7ffc88bf89d4e15965c5adb422 |
train | BoxSession.download_file | Download a file.
The whole file is never loaded in memory.
The callback(transferred, total) to let you know the download progress.
Download can be cancelled if the callback raise an Exception.
>>> def progress_callback(transferred, total):
... print 'Downloaded %i bytes of ... | boxpython/session.py | def download_file(self, file_id, dest_file_path,
progress_callback=None,
chunk_size=1024*1024*1):
"""Download a file.
The whole file is never loaded in memory.
The callback(transferred, total) to let you know the download progress.
... | def download_file(self, file_id, dest_file_path,
progress_callback=None,
chunk_size=1024*1024*1):
"""Download a file.
The whole file is never loaded in memory.
The callback(transferred, total) to let you know the download progress.
... | [
"Download",
"a",
"file",
"."
] | wesleyfr/boxpython | python | https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/session.py#L458-L509 | [
"def",
"download_file",
"(",
"self",
",",
"file_id",
",",
"dest_file_path",
",",
"progress_callback",
"=",
"None",
",",
"chunk_size",
"=",
"1024",
"*",
"1024",
"*",
"1",
")",
":",
"with",
"open",
"(",
"dest_file_path",
",",
"'wb'",
")",
"as",
"fp",
":",
... | f00a8ada6dff2c7ffc88bf89d4e15965c5adb422 |
train | BoxSession.search | Searches for files/folders
Args:
\*\*kwargs (dict): A dictionary containing necessary parameters
(check https://developers.box.com/docs/#search for
list of parameters)
Returns:
dict. Response from Box.
Raises:
... | boxpython/session.py | def search(self, **kwargs):
"""Searches for files/folders
Args:
\*\*kwargs (dict): A dictionary containing necessary parameters
(check https://developers.box.com/docs/#search for
list of parameters)
Returns:
dict. ... | def search(self, **kwargs):
"""Searches for files/folders
Args:
\*\*kwargs (dict): A dictionary containing necessary parameters
(check https://developers.box.com/docs/#search for
list of parameters)
Returns:
dict. ... | [
"Searches",
"for",
"files",
"/",
"folders"
] | wesleyfr/boxpython | python | https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/session.py#L529-L550 | [
"def",
"search",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"query_string",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"kwargs",
".",
"iteritems",
"(",
")",
":",
"query_string",
"[",
"key",
"]",
"=",
"value",
"return",
"self",
".",
"__re... | f00a8ada6dff2c7ffc88bf89d4e15965c5adb422 |
train | Dict.getmany | Return a list of values corresponding to the keys in the iterable of
*keys*.
If a key is not present in the collection, its corresponding value will
be :obj:`None`.
.. note::
This method is not implemented by standard Python dictionary
classes. | redis_collections/dicts.py | def getmany(self, *keys):
"""
Return a list of values corresponding to the keys in the iterable of
*keys*.
If a key is not present in the collection, its corresponding value will
be :obj:`None`.
.. note::
This method is not implemented by standard Python dict... | def getmany(self, *keys):
"""
Return a list of values corresponding to the keys in the iterable of
*keys*.
If a key is not present in the collection, its corresponding value will
be :obj:`None`.
.. note::
This method is not implemented by standard Python dict... | [
"Return",
"a",
"list",
"of",
"values",
"corresponding",
"to",
"the",
"keys",
"in",
"the",
"iterable",
"of",
"*",
"keys",
"*",
".",
"If",
"a",
"key",
"is",
"not",
"present",
"in",
"the",
"collection",
"its",
"corresponding",
"value",
"will",
"be",
":",
... | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L125-L144 | [
"def",
"getmany",
"(",
"self",
",",
"*",
"keys",
")",
":",
"pickled_keys",
"=",
"(",
"self",
".",
"_pickle_key",
"(",
"k",
")",
"for",
"k",
"in",
"keys",
")",
"pickled_values",
"=",
"self",
".",
"redis",
".",
"hmget",
"(",
"self",
".",
"key",
",",
... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | Dict._data | Returns a Python dictionary with the same values as this object
(without checking the local cache). | redis_collections/dicts.py | def _data(self, pipe=None):
"""
Returns a Python dictionary with the same values as this object
(without checking the local cache).
"""
pipe = self.redis if pipe is None else pipe
items = pipe.hgetall(self.key).items()
return {self._unpickle_key(k): self._unpickl... | def _data(self, pipe=None):
"""
Returns a Python dictionary with the same values as this object
(without checking the local cache).
"""
pipe = self.redis if pipe is None else pipe
items = pipe.hgetall(self.key).items()
return {self._unpickle_key(k): self._unpickl... | [
"Returns",
"a",
"Python",
"dictionary",
"with",
"the",
"same",
"values",
"as",
"this",
"object",
"(",
"without",
"checking",
"the",
"local",
"cache",
")",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L192-L200 | [
"def",
"_data",
"(",
"self",
",",
"pipe",
"=",
"None",
")",
":",
"pipe",
"=",
"self",
".",
"redis",
"if",
"pipe",
"is",
"None",
"else",
"pipe",
"items",
"=",
"pipe",
".",
"hgetall",
"(",
"self",
".",
"key",
")",
".",
"items",
"(",
")",
"return",
... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | Dict.iteritems | Return an iterator over the dictionary's ``(key, value)`` pairs. | redis_collections/dicts.py | def iteritems(self, pipe=None):
"""Return an iterator over the dictionary's ``(key, value)`` pairs."""
pipe = self.redis if pipe is None else pipe
for k, v in self._data(pipe).items():
yield k, self.cache.get(k, v) | def iteritems(self, pipe=None):
"""Return an iterator over the dictionary's ``(key, value)`` pairs."""
pipe = self.redis if pipe is None else pipe
for k, v in self._data(pipe).items():
yield k, self.cache.get(k, v) | [
"Return",
"an",
"iterator",
"over",
"the",
"dictionary",
"s",
"(",
"key",
"value",
")",
"pairs",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L206-L210 | [
"def",
"iteritems",
"(",
"self",
",",
"pipe",
"=",
"None",
")",
":",
"pipe",
"=",
"self",
".",
"redis",
"if",
"pipe",
"is",
"None",
"else",
"pipe",
"for",
"k",
",",
"v",
"in",
"self",
".",
"_data",
"(",
"pipe",
")",
".",
"items",
"(",
")",
":",... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | Dict.pop | If *key* is in the dictionary, remove it and return its value,
else return *default*. If *default* is not given and *key* is not
in the dictionary, a :exc:`KeyError` is raised. | redis_collections/dicts.py | def pop(self, key, default=__marker):
"""If *key* is in the dictionary, remove it and return its value,
else return *default*. If *default* is not given and *key* is not
in the dictionary, a :exc:`KeyError` is raised.
"""
pickled_key = self._pickle_key(key)
if key in sel... | def pop(self, key, default=__marker):
"""If *key* is in the dictionary, remove it and return its value,
else return *default*. If *default* is not given and *key* is not
in the dictionary, a :exc:`KeyError` is raised.
"""
pickled_key = self._pickle_key(key)
if key in sel... | [
"If",
"*",
"key",
"*",
"is",
"in",
"the",
"dictionary",
"remove",
"it",
"and",
"return",
"its",
"value",
"else",
"return",
"*",
"default",
"*",
".",
"If",
"*",
"default",
"*",
"is",
"not",
"given",
"and",
"*",
"key",
"*",
"is",
"not",
"in",
"the",
... | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L234-L258 | [
"def",
"pop",
"(",
"self",
",",
"key",
",",
"default",
"=",
"__marker",
")",
":",
"pickled_key",
"=",
"self",
".",
"_pickle_key",
"(",
"key",
")",
"if",
"key",
"in",
"self",
".",
"cache",
":",
"self",
".",
"redis",
".",
"hdel",
"(",
"self",
".",
... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | Dict.popitem | Remove and return an arbitrary ``(key, value)`` pair from
the dictionary.
:func:`popitem` is useful to destructively iterate over
a dictionary, as often used in set algorithms. If
the dictionary is empty, calling :func:`popitem` raises
a :exc:`KeyError`. | redis_collections/dicts.py | def popitem(self):
"""Remove and return an arbitrary ``(key, value)`` pair from
the dictionary.
:func:`popitem` is useful to destructively iterate over
a dictionary, as often used in set algorithms. If
the dictionary is empty, calling :func:`popitem` raises
a :exc:`KeyEr... | def popitem(self):
"""Remove and return an arbitrary ``(key, value)`` pair from
the dictionary.
:func:`popitem` is useful to destructively iterate over
a dictionary, as often used in set algorithms. If
the dictionary is empty, calling :func:`popitem` raises
a :exc:`KeyEr... | [
"Remove",
"and",
"return",
"an",
"arbitrary",
"(",
"key",
"value",
")",
"pair",
"from",
"the",
"dictionary",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L260-L287 | [
"def",
"popitem",
"(",
"self",
")",
":",
"def",
"popitem_trans",
"(",
"pipe",
")",
":",
"try",
":",
"pickled_key",
"=",
"pipe",
".",
"hkeys",
"(",
"self",
".",
"key",
")",
"[",
"0",
"]",
"except",
"IndexError",
":",
"raise",
"KeyError",
"# pop its valu... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | Dict.setdefault | If *key* is in the dictionary, return its value.
If not, insert *key* with a value of *default* and
return *default*. *default* defaults to :obj:`None`. | redis_collections/dicts.py | def setdefault(self, key, default=None):
"""If *key* is in the dictionary, return its value.
If not, insert *key* with a value of *default* and
return *default*. *default* defaults to :obj:`None`.
"""
if key in self.cache:
return self.cache[key]
def setdefaul... | def setdefault(self, key, default=None):
"""If *key* is in the dictionary, return its value.
If not, insert *key* with a value of *default* and
return *default*. *default* defaults to :obj:`None`.
"""
if key in self.cache:
return self.cache[key]
def setdefaul... | [
"If",
"*",
"key",
"*",
"is",
"in",
"the",
"dictionary",
"return",
"its",
"value",
".",
"If",
"not",
"insert",
"*",
"key",
"*",
"with",
"a",
"value",
"of",
"*",
"default",
"*",
"and",
"return",
"*",
"default",
"*",
".",
"*",
"default",
"*",
"default... | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L289-L312 | [
"def",
"setdefault",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"if",
"key",
"in",
"self",
".",
"cache",
":",
"return",
"self",
".",
"cache",
"[",
"key",
"]",
"def",
"setdefault_trans",
"(",
"pipe",
")",
":",
"pickled_key",
"=",
... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | Dict.update | Update the dictionary with the key/value pairs from *other*,
overwriting existing keys. Return :obj:`None`.
:func:`update` accepts either another dictionary object or
an iterable of key/value pairs (as tuples or other iterables
of length two). If keyword arguments are specified, the
... | redis_collections/dicts.py | def update(self, other=None, **kwargs):
"""Update the dictionary with the key/value pairs from *other*,
overwriting existing keys. Return :obj:`None`.
:func:`update` accepts either another dictionary object or
an iterable of key/value pairs (as tuples or other iterables
of lengt... | def update(self, other=None, **kwargs):
"""Update the dictionary with the key/value pairs from *other*,
overwriting existing keys. Return :obj:`None`.
:func:`update` accepts either another dictionary object or
an iterable of key/value pairs (as tuples or other iterables
of lengt... | [
"Update",
"the",
"dictionary",
"with",
"the",
"key",
"/",
"value",
"pairs",
"from",
"*",
"other",
"*",
"overwriting",
"existing",
"keys",
".",
"Return",
":",
"obj",
":",
"None",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L341-L360 | [
"def",
"update",
"(",
"self",
",",
"other",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"other",
"is",
"not",
"None",
":",
"if",
"self",
".",
"_same_redis",
"(",
"other",
",",
"RedisCollection",
")",
":",
"self",
".",
"_update_helper",
"(",... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | Dict.copy | Return a new collection with the same items as this one.
If *key* is specified, create the new collection with the given
Redis key. | redis_collections/dicts.py | def copy(self, key=None):
"""
Return a new collection with the same items as this one.
If *key* is specified, create the new collection with the given
Redis key.
"""
other = self.__class__(redis=self.redis, key=key)
other.update(self)
return other | def copy(self, key=None):
"""
Return a new collection with the same items as this one.
If *key* is specified, create the new collection with the given
Redis key.
"""
other = self.__class__(redis=self.redis, key=key)
other.update(self)
return other | [
"Return",
"a",
"new",
"collection",
"with",
"the",
"same",
"items",
"as",
"this",
"one",
".",
"If",
"*",
"key",
"*",
"is",
"specified",
"create",
"the",
"new",
"collection",
"with",
"the",
"given",
"Redis",
"key",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L362-L371 | [
"def",
"copy",
"(",
"self",
",",
"key",
"=",
"None",
")",
":",
"other",
"=",
"self",
".",
"__class__",
"(",
"redis",
"=",
"self",
".",
"redis",
",",
"key",
"=",
"key",
")",
"other",
".",
"update",
"(",
"self",
")",
"return",
"other"
] | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | Dict.fromkeys | Create a new dictionary with keys from *seq* and values set to
*value*.
.. note::
:func:`fromkeys` is a class method that returns a new dictionary.
It is possible to specify additional keyword arguments to be passed
to :func:`__init__` of the new object. | redis_collections/dicts.py | def fromkeys(cls, seq, value=None, **kwargs):
"""Create a new dictionary with keys from *seq* and values set to
*value*.
.. note::
:func:`fromkeys` is a class method that returns a new dictionary.
It is possible to specify additional keyword arguments to be passed
... | def fromkeys(cls, seq, value=None, **kwargs):
"""Create a new dictionary with keys from *seq* and values set to
*value*.
.. note::
:func:`fromkeys` is a class method that returns a new dictionary.
It is possible to specify additional keyword arguments to be passed
... | [
"Create",
"a",
"new",
"dictionary",
"with",
"keys",
"from",
"*",
"seq",
"*",
"and",
"values",
"set",
"to",
"*",
"value",
"*",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L380-L390 | [
"def",
"fromkeys",
"(",
"cls",
",",
"seq",
",",
"value",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"values",
"=",
"(",
"(",
"key",
",",
"value",
")",
"for",
"key",
"in",
"seq",
")",
"return",
"cls",
"(",
"values",
",",
"*",
"*",
"kwargs",... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | Dict.scan_items | Yield each of the ``(key, value)`` pairs from the collection, without
pulling them all into memory.
.. warning::
This method is not available on the dictionary collections provided
by Python.
This method may return the same (key, value) pair multiple times.
... | redis_collections/dicts.py | def scan_items(self):
"""
Yield each of the ``(key, value)`` pairs from the collection, without
pulling them all into memory.
.. warning::
This method is not available on the dictionary collections provided
by Python.
This method may return the same ... | def scan_items(self):
"""
Yield each of the ``(key, value)`` pairs from the collection, without
pulling them all into memory.
.. warning::
This method is not available on the dictionary collections provided
by Python.
This method may return the same ... | [
"Yield",
"each",
"of",
"the",
"(",
"key",
"value",
")",
"pairs",
"from",
"the",
"collection",
"without",
"pulling",
"them",
"all",
"into",
"memory",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L392-L406 | [
"def",
"scan_items",
"(",
"self",
")",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"redis",
".",
"hscan_iter",
"(",
"self",
".",
"key",
")",
":",
"yield",
"self",
".",
"_unpickle_key",
"(",
"k",
")",
",",
"self",
".",
"_unpickle",
"(",
"v",
")"... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | Counter.update | Elements are counted from an *iterable* or added-in from another
*mapping* (or counter). Like :func:`dict.update` but adds counts
instead of replacing them. Also, the *iterable* is expected to be
a sequence of elements, not a sequence of ``(key, value)`` pairs. | redis_collections/dicts.py | def update(self, other=None, **kwargs):
"""Elements are counted from an *iterable* or added-in from another
*mapping* (or counter). Like :func:`dict.update` but adds counts
instead of replacing them. Also, the *iterable* is expected to be
a sequence of elements, not a sequence of ``(key,... | def update(self, other=None, **kwargs):
"""Elements are counted from an *iterable* or added-in from another
*mapping* (or counter). Like :func:`dict.update` but adds counts
instead of replacing them. Also, the *iterable* is expected to be
a sequence of elements, not a sequence of ``(key,... | [
"Elements",
"are",
"counted",
"from",
"an",
"*",
"iterable",
"*",
"or",
"added",
"-",
"in",
"from",
"another",
"*",
"mapping",
"*",
"(",
"or",
"counter",
")",
".",
"Like",
":",
"func",
":",
"dict",
".",
"update",
"but",
"adds",
"counts",
"instead",
"... | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L519-L534 | [
"def",
"update",
"(",
"self",
",",
"other",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"other",
"is",
"not",
"None",
":",
"if",
"self",
".",
"_same_redis",
"(",
"other",
",",
"RedisCollection",
")",
":",
"self",
".",
"_update_helper",
"(",... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | Counter.subtract | Elements are subtracted from an *iterable* or from another
*mapping* (or counter). Like :func:`dict.update` but subtracts
counts instead of replacing them. | redis_collections/dicts.py | def subtract(self, other=None, **kwargs):
"""Elements are subtracted from an *iterable* or from another
*mapping* (or counter). Like :func:`dict.update` but subtracts
counts instead of replacing them.
"""
if other is not None:
if self._same_redis(other, RedisCollectio... | def subtract(self, other=None, **kwargs):
"""Elements are subtracted from an *iterable* or from another
*mapping* (or counter). Like :func:`dict.update` but subtracts
counts instead of replacing them.
"""
if other is not None:
if self._same_redis(other, RedisCollectio... | [
"Elements",
"are",
"subtracted",
"from",
"an",
"*",
"iterable",
"*",
"or",
"from",
"another",
"*",
"mapping",
"*",
"(",
"or",
"counter",
")",
".",
"Like",
":",
"func",
":",
"dict",
".",
"update",
"but",
"subtracts",
"counts",
"instead",
"of",
"replacing"... | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/dicts.py#L536-L550 | [
"def",
"subtract",
"(",
"self",
",",
"other",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"other",
"is",
"not",
"None",
":",
"if",
"self",
".",
"_same_redis",
"(",
"other",
",",
"RedisCollection",
")",
":",
"self",
".",
"_update_helper",
"(... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | StompProtocol.ack | Processes the received message. I don't need to
generate an ack message. | lib/stomper/examples/sender.py | def ack(self, msg):
"""Processes the received message. I don't need to
generate an ack message.
"""
self.log.info("senderID:%s Received: %s " % (self.senderID, msg['body']))
return stomper.NO_REPONSE_NEEDED | def ack(self, msg):
"""Processes the received message. I don't need to
generate an ack message.
"""
self.log.info("senderID:%s Received: %s " % (self.senderID, msg['body']))
return stomper.NO_REPONSE_NEEDED | [
"Processes",
"the",
"received",
"message",
".",
"I",
"don",
"t",
"need",
"to",
"generate",
"an",
"ack",
"message",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/sender.py#L68-L74 | [
"def",
"ack",
"(",
"self",
",",
"msg",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"senderID:%s Received: %s \"",
"%",
"(",
"self",
".",
"senderID",
",",
"msg",
"[",
"'body'",
"]",
")",
")",
"return",
"stomper",
".",
"NO_REPONSE_NEEDED"
] | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | RedisCollection._clear | Helper for clear operations.
:param pipe: Redis pipe in case update is performed as a part
of transaction.
:type pipe: :class:`redis.client.StrictPipeline` or
:class:`redis.client.StrictRedis` | redis_collections/base.py | def _clear(self, pipe=None):
"""Helper for clear operations.
:param pipe: Redis pipe in case update is performed as a part
of transaction.
:type pipe: :class:`redis.client.StrictPipeline` or
:class:`redis.client.StrictRedis`
"""
redis = s... | def _clear(self, pipe=None):
"""Helper for clear operations.
:param pipe: Redis pipe in case update is performed as a part
of transaction.
:type pipe: :class:`redis.client.StrictPipeline` or
:class:`redis.client.StrictRedis`
"""
redis = s... | [
"Helper",
"for",
"clear",
"operations",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/base.py#L116-L125 | [
"def",
"_clear",
"(",
"self",
",",
"pipe",
"=",
"None",
")",
":",
"redis",
"=",
"self",
".",
"redis",
"if",
"pipe",
"is",
"None",
"else",
"pipe",
"redis",
".",
"delete",
"(",
"self",
".",
"key",
")"
] | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | RedisCollection._normalize_index | Convert negative indexes into their positive equivalents. | redis_collections/base.py | def _normalize_index(self, index, pipe=None):
"""Convert negative indexes into their positive equivalents."""
pipe = self.redis if pipe is None else pipe
len_self = self.__len__(pipe)
positive_index = index if index >= 0 else len_self + index
return len_self, positive_index | def _normalize_index(self, index, pipe=None):
"""Convert negative indexes into their positive equivalents."""
pipe = self.redis if pipe is None else pipe
len_self = self.__len__(pipe)
positive_index = index if index >= 0 else len_self + index
return len_self, positive_index | [
"Convert",
"negative",
"indexes",
"into",
"their",
"positive",
"equivalents",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/base.py#L152-L158 | [
"def",
"_normalize_index",
"(",
"self",
",",
"index",
",",
"pipe",
"=",
"None",
")",
":",
"pipe",
"=",
"self",
".",
"redis",
"if",
"pipe",
"is",
"None",
"else",
"pipe",
"len_self",
"=",
"self",
".",
"__len__",
"(",
"pipe",
")",
"positive_index",
"=",
... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | RedisCollection._normalize_slice | Given a :obj:`slice` *index*, return a 4-tuple
``(start, stop, step, fowrward)``. The first three items can be used
with the ``range`` function to retrieve the values associated with the
slice; the last item indicates the direction. | redis_collections/base.py | def _normalize_slice(self, index, pipe=None):
"""Given a :obj:`slice` *index*, return a 4-tuple
``(start, stop, step, fowrward)``. The first three items can be used
with the ``range`` function to retrieve the values associated with the
slice; the last item indicates the direction.
... | def _normalize_slice(self, index, pipe=None):
"""Given a :obj:`slice` *index*, return a 4-tuple
``(start, stop, step, fowrward)``. The first three items can be used
with the ``range`` function to retrieve the values associated with the
slice; the last item indicates the direction.
... | [
"Given",
"a",
":",
"obj",
":",
"slice",
"*",
"index",
"*",
"return",
"a",
"4",
"-",
"tuple",
"(",
"start",
"stop",
"step",
"fowrward",
")",
".",
"The",
"first",
"three",
"items",
"can",
"be",
"used",
"with",
"the",
"range",
"function",
"to",
"retriev... | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/base.py#L160-L193 | [
"def",
"_normalize_slice",
"(",
"self",
",",
"index",
",",
"pipe",
"=",
"None",
")",
":",
"if",
"index",
".",
"step",
"==",
"0",
":",
"raise",
"ValueError",
"pipe",
"=",
"self",
".",
"redis",
"if",
"pipe",
"is",
"None",
"else",
"pipe",
"len_self",
"=... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | RedisCollection._transaction | Helper simplifying code within watched transaction.
Takes *fn*, function treated as a transaction. Returns whatever
*fn* returns. ``self.key`` is watched. *fn* takes *pipe* as the
only argument.
:param fn: Closure treated as a transaction.
:type fn: function *fn(pipe)*
... | redis_collections/base.py | def _transaction(self, fn, *extra_keys):
"""Helper simplifying code within watched transaction.
Takes *fn*, function treated as a transaction. Returns whatever
*fn* returns. ``self.key`` is watched. *fn* takes *pipe* as the
only argument.
:param fn: Closure treated as a transac... | def _transaction(self, fn, *extra_keys):
"""Helper simplifying code within watched transaction.
Takes *fn*, function treated as a transaction. Returns whatever
*fn* returns. ``self.key`` is watched. *fn* takes *pipe* as the
only argument.
:param fn: Closure treated as a transac... | [
"Helper",
"simplifying",
"code",
"within",
"watched",
"transaction",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/base.py#L195-L214 | [
"def",
"_transaction",
"(",
"self",
",",
"fn",
",",
"*",
"extra_keys",
")",
":",
"results",
"=",
"[",
"]",
"def",
"trans",
"(",
"pipe",
")",
":",
"results",
".",
"append",
"(",
"fn",
"(",
"pipe",
")",
")",
"self",
".",
"redis",
".",
"transaction",
... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | recursive_path | Find paths recursively | setup.py | def recursive_path(pack, path):
"""Find paths recursively"""
matches = []
for root, _, filenames in os.walk(os.path.join(pack, path)):
for filename in filenames:
matches.append(os.path.join(root, filename)[len(pack) + 1:])
return matches | def recursive_path(pack, path):
"""Find paths recursively"""
matches = []
for root, _, filenames in os.walk(os.path.join(pack, path)):
for filename in filenames:
matches.append(os.path.join(root, filename)[len(pack) + 1:])
return matches | [
"Find",
"paths",
"recursively"
] | JoaoFelipe/ipython-unittest | python | https://github.com/JoaoFelipe/ipython-unittest/blob/2a1708e1fa575ce80e0ee2092d280979c1a77885/setup.py#L7-L13 | [
"def",
"recursive_path",
"(",
"pack",
",",
"path",
")",
":",
"matches",
"=",
"[",
"]",
"for",
"root",
",",
"_",
",",
"filenames",
"in",
"os",
".",
"walk",
"(",
"os",
".",
"path",
".",
"join",
"(",
"pack",
",",
"path",
")",
")",
":",
"for",
"fil... | 2a1708e1fa575ce80e0ee2092d280979c1a77885 |
train | nack | STOMP negative acknowledge command.
NACK is the opposite of ACK. It is used to tell the server that the client
did not consume the message. The server can then either send the message to
a different client, discard it, or put it in a dead letter queue. The exact
behavior is server specific.
messag... | lib/stomper/stomp_11.py | def nack(messageid, subscriptionid, transactionid=None):
"""STOMP negative acknowledge command.
NACK is the opposite of ACK. It is used to tell the server that the client
did not consume the message. The server can then either send the message to
a different client, discard it, or put it in a dead lett... | def nack(messageid, subscriptionid, transactionid=None):
"""STOMP negative acknowledge command.
NACK is the opposite of ACK. It is used to tell the server that the client
did not consume the message. The server can then either send the message to
a different client, discard it, or put it in a dead lett... | [
"STOMP",
"negative",
"acknowledge",
"command",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_11.py#L275-L301 | [
"def",
"nack",
"(",
"messageid",
",",
"subscriptionid",
",",
"transactionid",
"=",
"None",
")",
":",
"header",
"=",
"'subscription:%s\\nmessage-id:%s'",
"%",
"(",
"subscriptionid",
",",
"messageid",
")",
"if",
"transactionid",
":",
"header",
"+=",
"'\\ntransaction... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | connect | STOMP connect command.
username, password:
These are the needed auth details to connect to the
message server.
After sending this we will receive a CONNECTED
message which will contain our session id. | lib/stomper/stomp_11.py | def connect(username, password, host, heartbeats=(0,0)):
"""STOMP connect command.
username, password:
These are the needed auth details to connect to the
message server.
After sending this we will receive a CONNECTED
message which will contain our session id.
"""
if len(heart... | def connect(username, password, host, heartbeats=(0,0)):
"""STOMP connect command.
username, password:
These are the needed auth details to connect to the
message server.
After sending this we will receive a CONNECTED
message which will contain our session id.
"""
if len(heart... | [
"STOMP",
"connect",
"command",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_11.py#L335-L349 | [
"def",
"connect",
"(",
"username",
",",
"password",
",",
"host",
",",
"heartbeats",
"=",
"(",
"0",
",",
"0",
")",
")",
":",
"if",
"len",
"(",
"heartbeats",
")",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"'Invalid heartbeat %r'",
"%",
"heartbeats",
")... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | Engine.ack | Called when a MESSAGE has been received.
Override this method to handle received messages.
This function will generate an acknowledge message
for the given message and transaction (if present). | lib/stomper/stomp_11.py | def ack(self, msg):
"""Called when a MESSAGE has been received.
Override this method to handle received messages.
This function will generate an acknowledge message
for the given message and transaction (if present).
"""
message_id = msg['headers']['message-id']
... | def ack(self, msg):
"""Called when a MESSAGE has been received.
Override this method to handle received messages.
This function will generate an acknowledge message
for the given message and transaction (if present).
"""
message_id = msg['headers']['message-id']
... | [
"Called",
"when",
"a",
"MESSAGE",
"has",
"been",
"received",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_11.py#L489-L507 | [
"def",
"ack",
"(",
"self",
",",
"msg",
")",
":",
"message_id",
"=",
"msg",
"[",
"'headers'",
"]",
"[",
"'message-id'",
"]",
"subscription",
"=",
"msg",
"[",
"'headers'",
"]",
"[",
"'subscription'",
"]",
"transaction_id",
"=",
"None",
"if",
"'transaction-id... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | StompBuffer.getOneMessage | I pull one complete message off the buffer and return it decoded
as a dict. If there is no complete message in the buffer, I
return None.
Note that the buffer can contain more than once message. You
should therefore call me in a loop until I return None. | lib/stomper/stompbuffer.py | def getOneMessage ( self ):
"""
I pull one complete message off the buffer and return it decoded
as a dict. If there is no complete message in the buffer, I
return None.
Note that the buffer can contain more than once message. You
should therefore call me in a loop until... | def getOneMessage ( self ):
"""
I pull one complete message off the buffer and return it decoded
as a dict. If there is no complete message in the buffer, I
return None.
Note that the buffer can contain more than once message. You
should therefore call me in a loop until... | [
"I",
"pull",
"one",
"complete",
"message",
"off",
"the",
"buffer",
"and",
"return",
"it",
"decoded",
"as",
"a",
"dict",
".",
"If",
"there",
"is",
"no",
"complete",
"message",
"in",
"the",
"buffer",
"I",
"return",
"None",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stompbuffer.py#L69-L109 | [
"def",
"getOneMessage",
"(",
"self",
")",
":",
"(",
"mbytes",
",",
"hbytes",
")",
"=",
"self",
".",
"_findMessageBytes",
"(",
"self",
".",
"buffer",
")",
"if",
"not",
"mbytes",
":",
"return",
"None",
"msgdata",
"=",
"self",
".",
"buffer",
"[",
":",
"... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | StompBuffer._findMessageBytes | I examine the data passed to me and return a 2-tuple of the form:
( message_length, header_length )
where message_length is the length in bytes of the first complete
message, if it contains at least one message, or 0 if it
contains no message.
If me... | lib/stomper/stompbuffer.py | def _findMessageBytes ( self, data ):
"""
I examine the data passed to me and return a 2-tuple of the form:
( message_length, header_length )
where message_length is the length in bytes of the first complete
message, if it contains at least one message, or 0... | def _findMessageBytes ( self, data ):
"""
I examine the data passed to me and return a 2-tuple of the form:
( message_length, header_length )
where message_length is the length in bytes of the first complete
message, if it contains at least one message, or 0... | [
"I",
"examine",
"the",
"data",
"passed",
"to",
"me",
"and",
"return",
"a",
"2",
"-",
"tuple",
"of",
"the",
"form",
":",
"(",
"message_length",
"header_length",
")",
"where",
"message_length",
"is",
"the",
"length",
"in",
"bytes",
"of",
"the",
"first",
"c... | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stompbuffer.py#L112-L195 | [
"def",
"_findMessageBytes",
"(",
"self",
",",
"data",
")",
":",
"# Sanity check. See the docstring for the method to see what it",
"# does an why we need it.",
"self",
".",
"syncBuffer",
"(",
")",
"# If the string '\\n\\n' does not exist, we don't even have the complete",
"# header y... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | StompBuffer.syncBuffer | I detect and correct corruption in the buffer.
Corruption in the buffer is defined as the following conditions
both being true:
1. The buffer contains at least one newline;
2. The text until the first newline is not a STOMP command.
In this case... | lib/stomper/stompbuffer.py | def syncBuffer( self ):
"""
I detect and correct corruption in the buffer.
Corruption in the buffer is defined as the following conditions
both being true:
1. The buffer contains at least one newline;
2. The text until the first newline is not a ... | def syncBuffer( self ):
"""
I detect and correct corruption in the buffer.
Corruption in the buffer is defined as the following conditions
both being true:
1. The buffer contains at least one newline;
2. The text until the first newline is not a ... | [
"I",
"detect",
"and",
"correct",
"corruption",
"in",
"the",
"buffer",
".",
"Corruption",
"in",
"the",
"buffer",
"is",
"defined",
"as",
"the",
"following",
"conditions",
"both",
"being",
"true",
":",
"1",
".",
"The",
"buffer",
"contains",
"at",
"least",
"on... | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stompbuffer.py#L198-L263 | [
"def",
"syncBuffer",
"(",
"self",
")",
":",
"while",
"True",
":",
"if",
"not",
"self",
".",
"buffer",
":",
"# Buffer is empty; no need to do anything.",
"break",
"m",
"=",
"command_re",
".",
"match",
"(",
"self",
".",
"buffer",
")",
"if",
"m",
"is",
"None"... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | MyStomp.connected | Once I've connected I want to subscribe to my the message queue. | lib/stomper/examples/stompbuffer-rx.py | def connected(self, msg):
"""Once I've connected I want to subscribe to my the message queue.
"""
super(MyStomp, self).connected(msg)
self.log.info("connected: session %s" % msg['headers']['session'])
f = stomper.Frame()
f.unpack(stomper.subscribe(DESTINATION))
r... | def connected(self, msg):
"""Once I've connected I want to subscribe to my the message queue.
"""
super(MyStomp, self).connected(msg)
self.log.info("connected: session %s" % msg['headers']['session'])
f = stomper.Frame()
f.unpack(stomper.subscribe(DESTINATION))
r... | [
"Once",
"I",
"ve",
"connected",
"I",
"want",
"to",
"subscribe",
"to",
"my",
"the",
"message",
"queue",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/examples/stompbuffer-rx.py#L37-L45 | [
"def",
"connected",
"(",
"self",
",",
"msg",
")",
":",
"super",
"(",
"MyStomp",
",",
"self",
")",
".",
"connected",
"(",
"msg",
")",
"self",
".",
"log",
".",
"info",
"(",
"\"connected: session %s\"",
"%",
"msg",
"[",
"'headers'",
"]",
"[",
"'session'",... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | delete_entity_signal_handler | Defines a signal handler for syncing an individual entity. Called when
an entity is saved or deleted. | entity/signal_handlers.py | def delete_entity_signal_handler(sender, instance, **kwargs):
"""
Defines a signal handler for syncing an individual entity. Called when
an entity is saved or deleted.
"""
if instance.__class__ in entity_registry.entity_registry:
Entity.all_objects.delete_for_obj(instance) | def delete_entity_signal_handler(sender, instance, **kwargs):
"""
Defines a signal handler for syncing an individual entity. Called when
an entity is saved or deleted.
"""
if instance.__class__ in entity_registry.entity_registry:
Entity.all_objects.delete_for_obj(instance) | [
"Defines",
"a",
"signal",
"handler",
"for",
"syncing",
"an",
"individual",
"entity",
".",
"Called",
"when",
"an",
"entity",
"is",
"saved",
"or",
"deleted",
"."
] | ambitioninc/django-entity | python | https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/signal_handlers.py#L9-L15 | [
"def",
"delete_entity_signal_handler",
"(",
"sender",
",",
"instance",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"instance",
".",
"__class__",
"in",
"entity_registry",
".",
"entity_registry",
":",
"Entity",
".",
"all_objects",
".",
"delete_for_obj",
"(",
"instanc... | ebc61f34313c52f4ef5819eb1da25b2ad837e80c |
train | save_entity_signal_handler | Defines a signal handler for saving an entity. Syncs the entity to
the entity mirror table. | entity/signal_handlers.py | def save_entity_signal_handler(sender, instance, **kwargs):
"""
Defines a signal handler for saving an entity. Syncs the entity to
the entity mirror table.
"""
if instance.__class__ in entity_registry.entity_registry:
sync_entities(instance)
if instance.__class__ in entity_registry.enti... | def save_entity_signal_handler(sender, instance, **kwargs):
"""
Defines a signal handler for saving an entity. Syncs the entity to
the entity mirror table.
"""
if instance.__class__ in entity_registry.entity_registry:
sync_entities(instance)
if instance.__class__ in entity_registry.enti... | [
"Defines",
"a",
"signal",
"handler",
"for",
"saving",
"an",
"entity",
".",
"Syncs",
"the",
"entity",
"to",
"the",
"entity",
"mirror",
"table",
"."
] | ambitioninc/django-entity | python | https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/signal_handlers.py#L18-L27 | [
"def",
"save_entity_signal_handler",
"(",
"sender",
",",
"instance",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"instance",
".",
"__class__",
"in",
"entity_registry",
".",
"entity_registry",
":",
"sync_entities",
"(",
"instance",
")",
"if",
"instance",
".",
"__c... | ebc61f34313c52f4ef5819eb1da25b2ad837e80c |
train | m2m_changed_entity_signal_handler | Defines a signal handler for a manytomany changed signal. Only listens for the
post actions so that entities are synced once (rather than twice for a pre and post action). | entity/signal_handlers.py | def m2m_changed_entity_signal_handler(sender, instance, action, **kwargs):
"""
Defines a signal handler for a manytomany changed signal. Only listens for the
post actions so that entities are synced once (rather than twice for a pre and post action).
"""
if action == 'post_add' or action == 'post_re... | def m2m_changed_entity_signal_handler(sender, instance, action, **kwargs):
"""
Defines a signal handler for a manytomany changed signal. Only listens for the
post actions so that entities are synced once (rather than twice for a pre and post action).
"""
if action == 'post_add' or action == 'post_re... | [
"Defines",
"a",
"signal",
"handler",
"for",
"a",
"manytomany",
"changed",
"signal",
".",
"Only",
"listens",
"for",
"the",
"post",
"actions",
"so",
"that",
"entities",
"are",
"synced",
"once",
"(",
"rather",
"than",
"twice",
"for",
"a",
"pre",
"and",
"post"... | ambitioninc/django-entity | python | https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/signal_handlers.py#L30-L36 | [
"def",
"m2m_changed_entity_signal_handler",
"(",
"sender",
",",
"instance",
",",
"action",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"action",
"==",
"'post_add'",
"or",
"action",
"==",
"'post_remove'",
"or",
"action",
"==",
"'post_clear'",
":",
"save_entity_signa... | ebc61f34313c52f4ef5819eb1da25b2ad837e80c |
train | turn_off_syncing | Disables all of the signals for syncing entities. By default, everything is turned off. If the user wants
to turn off everything but one signal, for example the post_save signal, they would do:
turn_off_sync(for_post_save=False) | entity/signal_handlers.py | def turn_off_syncing(for_post_save=True, for_post_delete=True, for_m2m_changed=True, for_post_bulk_operation=True):
"""
Disables all of the signals for syncing entities. By default, everything is turned off. If the user wants
to turn off everything but one signal, for example the post_save signal, they woul... | def turn_off_syncing(for_post_save=True, for_post_delete=True, for_m2m_changed=True, for_post_bulk_operation=True):
"""
Disables all of the signals for syncing entities. By default, everything is turned off. If the user wants
to turn off everything but one signal, for example the post_save signal, they woul... | [
"Disables",
"all",
"of",
"the",
"signals",
"for",
"syncing",
"entities",
".",
"By",
"default",
"everything",
"is",
"turned",
"off",
".",
"If",
"the",
"user",
"wants",
"to",
"turn",
"off",
"everything",
"but",
"one",
"signal",
"for",
"example",
"the",
"post... | ambitioninc/django-entity | python | https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/signal_handlers.py#L51-L65 | [
"def",
"turn_off_syncing",
"(",
"for_post_save",
"=",
"True",
",",
"for_post_delete",
"=",
"True",
",",
"for_m2m_changed",
"=",
"True",
",",
"for_post_bulk_operation",
"=",
"True",
")",
":",
"if",
"for_post_save",
":",
"post_save",
".",
"disconnect",
"(",
"save_... | ebc61f34313c52f4ef5819eb1da25b2ad837e80c |
train | turn_on_syncing | Enables all of the signals for syncing entities. Everything is True by default, except for the post_bulk_operation
signal. The reason for this is because when any bulk operation occurs on any mirrored entity model, it will
result in every single entity being synced again. This is not a desired behavior by the m... | entity/signal_handlers.py | def turn_on_syncing(for_post_save=True, for_post_delete=True, for_m2m_changed=True, for_post_bulk_operation=False):
"""
Enables all of the signals for syncing entities. Everything is True by default, except for the post_bulk_operation
signal. The reason for this is because when any bulk operation occurs on ... | def turn_on_syncing(for_post_save=True, for_post_delete=True, for_m2m_changed=True, for_post_bulk_operation=False):
"""
Enables all of the signals for syncing entities. Everything is True by default, except for the post_bulk_operation
signal. The reason for this is because when any bulk operation occurs on ... | [
"Enables",
"all",
"of",
"the",
"signals",
"for",
"syncing",
"entities",
".",
"Everything",
"is",
"True",
"by",
"default",
"except",
"for",
"the",
"post_bulk_operation",
"signal",
".",
"The",
"reason",
"for",
"this",
"is",
"because",
"when",
"any",
"bulk",
"o... | ambitioninc/django-entity | python | https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/signal_handlers.py#L68-L82 | [
"def",
"turn_on_syncing",
"(",
"for_post_save",
"=",
"True",
",",
"for_post_delete",
"=",
"True",
",",
"for_m2m_changed",
"=",
"True",
",",
"for_post_bulk_operation",
"=",
"False",
")",
":",
"if",
"for_post_save",
":",
"post_save",
".",
"connect",
"(",
"save_ent... | ebc61f34313c52f4ef5819eb1da25b2ad837e80c |
train | Set.add | Add element *value* to the set. | redis_collections/sets.py | def add(self, value):
"""Add element *value* to the set."""
# Raise TypeError if value is not hashable
hash(value)
self.redis.sadd(self.key, self._pickle(value)) | def add(self, value):
"""Add element *value* to the set."""
# Raise TypeError if value is not hashable
hash(value)
self.redis.sadd(self.key, self._pickle(value)) | [
"Add",
"element",
"*",
"value",
"*",
"to",
"the",
"set",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sets.py#L78-L83 | [
"def",
"add",
"(",
"self",
",",
"value",
")",
":",
"# Raise TypeError if value is not hashable",
"hash",
"(",
"value",
")",
"self",
".",
"redis",
".",
"sadd",
"(",
"self",
".",
"key",
",",
"self",
".",
"_pickle",
"(",
"value",
")",
")"
] | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | Set.discard | Remove element *value* from the set if it is present. | redis_collections/sets.py | def discard(self, value):
"""Remove element *value* from the set if it is present."""
# Raise TypeError if value is not hashable
hash(value)
self.redis.srem(self.key, self._pickle(value)) | def discard(self, value):
"""Remove element *value* from the set if it is present."""
# Raise TypeError if value is not hashable
hash(value)
self.redis.srem(self.key, self._pickle(value)) | [
"Remove",
"element",
"*",
"value",
"*",
"from",
"the",
"set",
"if",
"it",
"is",
"present",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sets.py#L95-L100 | [
"def",
"discard",
"(",
"self",
",",
"value",
")",
":",
"# Raise TypeError if value is not hashable",
"hash",
"(",
"value",
")",
"self",
".",
"redis",
".",
"srem",
"(",
"self",
".",
"key",
",",
"self",
".",
"_pickle",
"(",
"value",
")",
")"
] | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | Set.isdisjoint | Return ``True`` if the set has no elements in common with *other*.
Sets are disjoint if and only if their intersection is the empty set.
:param other: Any kind of iterable.
:rtype: boolean | redis_collections/sets.py | def isdisjoint(self, other):
"""
Return ``True`` if the set has no elements in common with *other*.
Sets are disjoint if and only if their intersection is the empty set.
:param other: Any kind of iterable.
:rtype: boolean
"""
def isdisjoint_trans_pure(pipe):
... | def isdisjoint(self, other):
"""
Return ``True`` if the set has no elements in common with *other*.
Sets are disjoint if and only if their intersection is the empty set.
:param other: Any kind of iterable.
:rtype: boolean
"""
def isdisjoint_trans_pure(pipe):
... | [
"Return",
"True",
"if",
"the",
"set",
"has",
"no",
"elements",
"in",
"common",
"with",
"*",
"other",
"*",
".",
"Sets",
"are",
"disjoint",
"if",
"and",
"only",
"if",
"their",
"intersection",
"is",
"the",
"empty",
"set",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sets.py#L102-L129 | [
"def",
"isdisjoint",
"(",
"self",
",",
"other",
")",
":",
"def",
"isdisjoint_trans_pure",
"(",
"pipe",
")",
":",
"return",
"not",
"pipe",
".",
"sinter",
"(",
"self",
".",
"key",
",",
"other",
".",
"key",
")",
"def",
"isdisjoint_trans_mixed",
"(",
"pipe",... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | Set.pop | Remove and return an arbitrary element from the set.
Raises :exc:`KeyError` if the set is empty. | redis_collections/sets.py | def pop(self):
"""
Remove and return an arbitrary element from the set.
Raises :exc:`KeyError` if the set is empty.
"""
result = self.redis.spop(self.key)
if result is None:
raise KeyError
return self._unpickle(result) | def pop(self):
"""
Remove and return an arbitrary element from the set.
Raises :exc:`KeyError` if the set is empty.
"""
result = self.redis.spop(self.key)
if result is None:
raise KeyError
return self._unpickle(result) | [
"Remove",
"and",
"return",
"an",
"arbitrary",
"element",
"from",
"the",
"set",
".",
"Raises",
":",
"exc",
":",
"KeyError",
"if",
"the",
"set",
"is",
"empty",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sets.py#L131-L140 | [
"def",
"pop",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"redis",
".",
"spop",
"(",
"self",
".",
"key",
")",
"if",
"result",
"is",
"None",
":",
"raise",
"KeyError",
"return",
"self",
".",
"_unpickle",
"(",
"result",
")"
] | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | Set.random_sample | Return a *k* length list of unique elements chosen from the Set.
Elements are not removed. Similar to :func:`random.sample` function
from standard library.
:param k: Size of the sample, defaults to 1.
:rtype: :class:`list` | redis_collections/sets.py | def random_sample(self, k=1):
"""
Return a *k* length list of unique elements chosen from the Set.
Elements are not removed. Similar to :func:`random.sample` function
from standard library.
:param k: Size of the sample, defaults to 1.
:rtype: :class:`list`
"""
... | def random_sample(self, k=1):
"""
Return a *k* length list of unique elements chosen from the Set.
Elements are not removed. Similar to :func:`random.sample` function
from standard library.
:param k: Size of the sample, defaults to 1.
:rtype: :class:`list`
"""
... | [
"Return",
"a",
"*",
"k",
"*",
"length",
"list",
"of",
"unique",
"elements",
"chosen",
"from",
"the",
"Set",
".",
"Elements",
"are",
"not",
"removed",
".",
"Similar",
"to",
":",
"func",
":",
"random",
".",
"sample",
"function",
"from",
"standard",
"librar... | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sets.py#L142-L162 | [
"def",
"random_sample",
"(",
"self",
",",
"k",
"=",
"1",
")",
":",
"# k == 0: no work to do",
"if",
"k",
"==",
"0",
":",
"results",
"=",
"[",
"]",
"# k == 1: same behavior on all versions of Redis",
"elif",
"k",
"==",
"1",
":",
"results",
"=",
"[",
"self",
... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | Set.remove | Remove element *value* from the set. Raises :exc:`KeyError` if it
is not contained in the set. | redis_collections/sets.py | def remove(self, value):
"""
Remove element *value* from the set. Raises :exc:`KeyError` if it
is not contained in the set.
"""
# Raise TypeError if value is not hashable
hash(value)
result = self.redis.srem(self.key, self._pickle(value))
if not result:
... | def remove(self, value):
"""
Remove element *value* from the set. Raises :exc:`KeyError` if it
is not contained in the set.
"""
# Raise TypeError if value is not hashable
hash(value)
result = self.redis.srem(self.key, self._pickle(value))
if not result:
... | [
"Remove",
"element",
"*",
"value",
"*",
"from",
"the",
"set",
".",
"Raises",
":",
"exc",
":",
"KeyError",
"if",
"it",
"is",
"not",
"contained",
"in",
"the",
"set",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sets.py#L164-L174 | [
"def",
"remove",
"(",
"self",
",",
"value",
")",
":",
"# Raise TypeError if value is not hashable",
"hash",
"(",
"value",
")",
"result",
"=",
"self",
".",
"redis",
".",
"srem",
"(",
"self",
".",
"key",
",",
"self",
".",
"_pickle",
"(",
"value",
")",
")",... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | Set.scan_elements | Yield each of the elements from the collection, without pulling them
all into memory.
.. warning::
This method is not available on the set collections provided
by Python.
This method may return the element multiple times.
See the `Redis SCAN documentatio... | redis_collections/sets.py | def scan_elements(self):
"""
Yield each of the elements from the collection, without pulling them
all into memory.
.. warning::
This method is not available on the set collections provided
by Python.
This method may return the element multiple times.... | def scan_elements(self):
"""
Yield each of the elements from the collection, without pulling them
all into memory.
.. warning::
This method is not available on the set collections provided
by Python.
This method may return the element multiple times.... | [
"Yield",
"each",
"of",
"the",
"elements",
"from",
"the",
"collection",
"without",
"pulling",
"them",
"all",
"into",
"memory",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sets.py#L176-L190 | [
"def",
"scan_elements",
"(",
"self",
")",
":",
"for",
"x",
"in",
"self",
".",
"redis",
".",
"sscan_iter",
"(",
"self",
".",
"key",
")",
":",
"yield",
"self",
".",
"_unpickle",
"(",
"x",
")"
] | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | Set.intersection_update | Update the set, keeping only elements found in it and all *others*.
:param others: Iterables, each one as a single positional argument.
:rtype: None
.. note::
The same behavior as at :func:`difference_update` applies. | redis_collections/sets.py | def intersection_update(self, *others):
"""
Update the set, keeping only elements found in it and all *others*.
:param others: Iterables, each one as a single positional argument.
:rtype: None
.. note::
The same behavior as at :func:`difference_update` applies.
... | def intersection_update(self, *others):
"""
Update the set, keeping only elements found in it and all *others*.
:param others: Iterables, each one as a single positional argument.
:rtype: None
.. note::
The same behavior as at :func:`difference_update` applies.
... | [
"Update",
"the",
"set",
"keeping",
"only",
"elements",
"found",
"in",
"it",
"and",
"all",
"*",
"others",
"*",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sets.py#L387-L399 | [
"def",
"intersection_update",
"(",
"self",
",",
"*",
"others",
")",
":",
"return",
"self",
".",
"_op_update_helper",
"(",
"tuple",
"(",
"others",
")",
",",
"operator",
".",
"and_",
",",
"'sinterstore'",
",",
"update",
"=",
"True",
")"
] | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | Set.update | Update the set, adding elements from all *others*.
:param others: Iterables, each one as a single positional argument.
:rtype: None
.. note::
If all *others* are :class:`Set` instances, the operation
is performed completely in Redis. Otherwise, values are retrieved
... | redis_collections/sets.py | def update(self, *others):
"""
Update the set, adding elements from all *others*.
:param others: Iterables, each one as a single positional argument.
:rtype: None
.. note::
If all *others* are :class:`Set` instances, the operation
is performed completely... | def update(self, *others):
"""
Update the set, adding elements from all *others*.
:param others: Iterables, each one as a single positional argument.
:rtype: None
.. note::
If all *others* are :class:`Set` instances, the operation
is performed completely... | [
"Update",
"the",
"set",
"adding",
"elements",
"from",
"all",
"*",
"others",
"*",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sets.py#L466-L480 | [
"def",
"update",
"(",
"self",
",",
"*",
"others",
")",
":",
"return",
"self",
".",
"_op_update_helper",
"(",
"tuple",
"(",
"others",
")",
",",
"operator",
".",
"or_",
",",
"'sunionstore'",
",",
"update",
"=",
"True",
")"
] | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | Set.difference_update | Update the set, removing elements found in *others*.
:param others: Iterables, each one as a single positional argument.
:rtype: None
.. note::
The same behavior as at :func:`update` applies. | redis_collections/sets.py | def difference_update(self, *others):
"""
Update the set, removing elements found in *others*.
:param others: Iterables, each one as a single positional argument.
:rtype: None
.. note::
The same behavior as at :func:`update` applies.
"""
return self.... | def difference_update(self, *others):
"""
Update the set, removing elements found in *others*.
:param others: Iterables, each one as a single positional argument.
:rtype: None
.. note::
The same behavior as at :func:`update` applies.
"""
return self.... | [
"Update",
"the",
"set",
"removing",
"elements",
"found",
"in",
"*",
"others",
"*",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sets.py#L510-L522 | [
"def",
"difference_update",
"(",
"self",
",",
"*",
"others",
")",
":",
"return",
"self",
".",
"_op_update_helper",
"(",
"tuple",
"(",
"others",
")",
",",
"operator",
".",
"sub",
",",
"'sdiffstore'",
",",
"update",
"=",
"True",
")"
] | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | SortedSetBase.discard_member | Remove *member* from the collection, unconditionally. | redis_collections/sortedsets.py | def discard_member(self, member, pipe=None):
"""
Remove *member* from the collection, unconditionally.
"""
pipe = self.redis if pipe is None else pipe
pipe.zrem(self.key, self._pickle(member)) | def discard_member(self, member, pipe=None):
"""
Remove *member* from the collection, unconditionally.
"""
pipe = self.redis if pipe is None else pipe
pipe.zrem(self.key, self._pickle(member)) | [
"Remove",
"*",
"member",
"*",
"from",
"the",
"collection",
"unconditionally",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sortedsets.py#L59-L64 | [
"def",
"discard_member",
"(",
"self",
",",
"member",
",",
"pipe",
"=",
"None",
")",
":",
"pipe",
"=",
"self",
".",
"redis",
"if",
"pipe",
"is",
"None",
"else",
"pipe",
"pipe",
".",
"zrem",
"(",
"self",
".",
"key",
",",
"self",
".",
"_pickle",
"(",
... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | SortedSetBase.scan_items | Yield each of the ``(member, score)`` tuples from the collection,
without pulling them all into memory.
.. warning::
This method may return the same (member, score) tuple multiple
times.
See the `Redis SCAN documentation
<http://redis.io/commands/scan#sca... | redis_collections/sortedsets.py | def scan_items(self):
"""
Yield each of the ``(member, score)`` tuples from the collection,
without pulling them all into memory.
.. warning::
This method may return the same (member, score) tuple multiple
times.
See the `Redis SCAN documentation
... | def scan_items(self):
"""
Yield each of the ``(member, score)`` tuples from the collection,
without pulling them all into memory.
.. warning::
This method may return the same (member, score) tuple multiple
times.
See the `Redis SCAN documentation
... | [
"Yield",
"each",
"of",
"the",
"(",
"member",
"score",
")",
"tuples",
"from",
"the",
"collection",
"without",
"pulling",
"them",
"all",
"into",
"memory",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sortedsets.py#L66-L78 | [
"def",
"scan_items",
"(",
"self",
")",
":",
"for",
"m",
",",
"s",
"in",
"self",
".",
"redis",
".",
"zscan_iter",
"(",
"self",
".",
"key",
")",
":",
"yield",
"self",
".",
"_unpickle",
"(",
"m",
")",
",",
"s"
] | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | SortedSetBase.update | Update the collection with items from *other*. Accepts other
:class:`SortedSetBase` instances, dictionaries mapping members to
numeric scores, or sequences of ``(member, score)`` tuples. | redis_collections/sortedsets.py | def update(self, other):
"""
Update the collection with items from *other*. Accepts other
:class:`SortedSetBase` instances, dictionaries mapping members to
numeric scores, or sequences of ``(member, score)`` tuples.
"""
def update_trans(pipe):
other_items = me... | def update(self, other):
"""
Update the collection with items from *other*. Accepts other
:class:`SortedSetBase` instances, dictionaries mapping members to
numeric scores, or sequences of ``(member, score)`` tuples.
"""
def update_trans(pipe):
other_items = me... | [
"Update",
"the",
"collection",
"with",
"items",
"from",
"*",
"other",
"*",
".",
"Accepts",
"other",
":",
"class",
":",
"SortedSetBase",
"instances",
"dictionaries",
"mapping",
"members",
"to",
"numeric",
"scores",
"or",
"sequences",
"of",
"(",
"member",
"score... | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sortedsets.py#L80-L105 | [
"def",
"update",
"(",
"self",
",",
"other",
")",
":",
"def",
"update_trans",
"(",
"pipe",
")",
":",
"other_items",
"=",
"method",
"(",
"pipe",
"=",
"pipe",
")",
"if",
"use_redis",
"else",
"method",
"(",
")",
"pipe",
".",
"multi",
"(",
")",
"for",
"... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | SortedSetCounter.count_between | Returns the number of members whose score is between *min_score* and
*max_score* (inclusive). | redis_collections/sortedsets.py | def count_between(self, min_score=None, max_score=None):
"""
Returns the number of members whose score is between *min_score* and
*max_score* (inclusive).
"""
min_score = float('-inf') if min_score is None else float(min_score)
max_score = float('inf') if max_score is Non... | def count_between(self, min_score=None, max_score=None):
"""
Returns the number of members whose score is between *min_score* and
*max_score* (inclusive).
"""
min_score = float('-inf') if min_score is None else float(min_score)
max_score = float('inf') if max_score is Non... | [
"Returns",
"the",
"number",
"of",
"members",
"whose",
"score",
"is",
"between",
"*",
"min_score",
"*",
"and",
"*",
"max_score",
"*",
"(",
"inclusive",
")",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sortedsets.py#L178-L186 | [
"def",
"count_between",
"(",
"self",
",",
"min_score",
"=",
"None",
",",
"max_score",
"=",
"None",
")",
":",
"min_score",
"=",
"float",
"(",
"'-inf'",
")",
"if",
"min_score",
"is",
"None",
"else",
"float",
"(",
"min_score",
")",
"max_score",
"=",
"float"... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | SortedSetCounter.discard_between | Remove members whose ranking is between *min_rank* and *max_rank*
OR whose score is between *min_score* and *max_score* (both ranges
inclusive). If no bounds are specified, no members will be removed. | redis_collections/sortedsets.py | def discard_between(
self,
min_rank=None,
max_rank=None,
min_score=None,
max_score=None,
):
"""
Remove members whose ranking is between *min_rank* and *max_rank*
OR whose score is between *min_score* and *max_score* (both ranges
inclusive). If ... | def discard_between(
self,
min_rank=None,
max_rank=None,
min_score=None,
max_score=None,
):
"""
Remove members whose ranking is between *min_rank* and *max_rank*
OR whose score is between *min_score* and *max_score* (both ranges
inclusive). If ... | [
"Remove",
"members",
"whose",
"ranking",
"is",
"between",
"*",
"min_rank",
"*",
"and",
"*",
"max_rank",
"*",
"OR",
"whose",
"score",
"is",
"between",
"*",
"min_score",
"*",
"and",
"*",
"max_score",
"*",
"(",
"both",
"ranges",
"inclusive",
")",
".",
"If",... | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sortedsets.py#L204-L235 | [
"def",
"discard_between",
"(",
"self",
",",
"min_rank",
"=",
"None",
",",
"max_rank",
"=",
"None",
",",
"min_score",
"=",
"None",
",",
"max_score",
"=",
"None",
",",
")",
":",
"no_ranks",
"=",
"(",
"min_rank",
"is",
"None",
")",
"and",
"(",
"max_rank",... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | SortedSetCounter.get_score | Return the score of *member*, or *default* if it is not in the
collection. | redis_collections/sortedsets.py | def get_score(self, member, default=None, pipe=None):
"""
Return the score of *member*, or *default* if it is not in the
collection.
"""
pipe = self.redis if pipe is None else pipe
score = pipe.zscore(self.key, self._pickle(member))
if (score is None) and (defaul... | def get_score(self, member, default=None, pipe=None):
"""
Return the score of *member*, or *default* if it is not in the
collection.
"""
pipe = self.redis if pipe is None else pipe
score = pipe.zscore(self.key, self._pickle(member))
if (score is None) and (defaul... | [
"Return",
"the",
"score",
"of",
"*",
"member",
"*",
"or",
"*",
"default",
"*",
"if",
"it",
"is",
"not",
"in",
"the",
"collection",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sortedsets.py#L237-L248 | [
"def",
"get_score",
"(",
"self",
",",
"member",
",",
"default",
"=",
"None",
",",
"pipe",
"=",
"None",
")",
":",
"pipe",
"=",
"self",
".",
"redis",
"if",
"pipe",
"is",
"None",
"else",
"pipe",
"score",
"=",
"pipe",
".",
"zscore",
"(",
"self",
".",
... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | SortedSetCounter.get_or_set_score | If *member* is in the collection, return its value. If not, store it
with a score of *default* and return *default*. *default* defaults to
0. | redis_collections/sortedsets.py | def get_or_set_score(self, member, default=0):
"""
If *member* is in the collection, return its value. If not, store it
with a score of *default* and return *default*. *default* defaults to
0.
"""
default = float(default)
def get_or_set_score_trans(pipe):
... | def get_or_set_score(self, member, default=0):
"""
If *member* is in the collection, return its value. If not, store it
with a score of *default* and return *default*. *default* defaults to
0.
"""
default = float(default)
def get_or_set_score_trans(pipe):
... | [
"If",
"*",
"member",
"*",
"is",
"in",
"the",
"collection",
"return",
"its",
"value",
".",
"If",
"not",
"store",
"it",
"with",
"a",
"score",
"of",
"*",
"default",
"*",
"and",
"return",
"*",
"default",
"*",
".",
"*",
"default",
"*",
"defaults",
"to",
... | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sortedsets.py#L250-L268 | [
"def",
"get_or_set_score",
"(",
"self",
",",
"member",
",",
"default",
"=",
"0",
")",
":",
"default",
"=",
"float",
"(",
"default",
")",
"def",
"get_or_set_score_trans",
"(",
"pipe",
")",
":",
"pickled_member",
"=",
"self",
".",
"_pickle",
"(",
"member",
... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | SortedSetCounter.get_rank | Return the rank of *member* in the collection.
By default, the member with the lowest score has rank 0.
If *reverse* is ``True``, the member with the highest score has rank 0. | redis_collections/sortedsets.py | def get_rank(self, member, reverse=False, pipe=None):
"""
Return the rank of *member* in the collection.
By default, the member with the lowest score has rank 0.
If *reverse* is ``True``, the member with the highest score has rank 0.
"""
pipe = self.redis if pipe is None ... | def get_rank(self, member, reverse=False, pipe=None):
"""
Return the rank of *member* in the collection.
By default, the member with the lowest score has rank 0.
If *reverse* is ``True``, the member with the highest score has rank 0.
"""
pipe = self.redis if pipe is None ... | [
"Return",
"the",
"rank",
"of",
"*",
"member",
"*",
"in",
"the",
"collection",
".",
"By",
"default",
"the",
"member",
"with",
"the",
"lowest",
"score",
"has",
"rank",
"0",
".",
"If",
"*",
"reverse",
"*",
"is",
"True",
"the",
"member",
"with",
"the",
"... | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sortedsets.py#L270-L280 | [
"def",
"get_rank",
"(",
"self",
",",
"member",
",",
"reverse",
"=",
"False",
",",
"pipe",
"=",
"None",
")",
":",
"pipe",
"=",
"self",
".",
"redis",
"if",
"pipe",
"is",
"None",
"else",
"pipe",
"method",
"=",
"getattr",
"(",
"pipe",
",",
"'zrevrank'",
... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | SortedSetCounter.increment_score | Adjust the score of *member* by *amount*. If *member* is not in the
collection it will be stored with a score of *amount*. | redis_collections/sortedsets.py | def increment_score(self, member, amount=1):
"""
Adjust the score of *member* by *amount*. If *member* is not in the
collection it will be stored with a score of *amount*.
"""
return self.redis.zincrby(
self.key, float(amount), self._pickle(member)
) | def increment_score(self, member, amount=1):
"""
Adjust the score of *member* by *amount*. If *member* is not in the
collection it will be stored with a score of *amount*.
"""
return self.redis.zincrby(
self.key, float(amount), self._pickle(member)
) | [
"Adjust",
"the",
"score",
"of",
"*",
"member",
"*",
"by",
"*",
"amount",
"*",
".",
"If",
"*",
"member",
"*",
"is",
"not",
"in",
"the",
"collection",
"it",
"will",
"be",
"stored",
"with",
"a",
"score",
"of",
"*",
"amount",
"*",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sortedsets.py#L282-L289 | [
"def",
"increment_score",
"(",
"self",
",",
"member",
",",
"amount",
"=",
"1",
")",
":",
"return",
"self",
".",
"redis",
".",
"zincrby",
"(",
"self",
".",
"key",
",",
"float",
"(",
"amount",
")",
",",
"self",
".",
"_pickle",
"(",
"member",
")",
")"... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | SortedSetCounter.items | Return a list of ``(member, score)`` tuples whose ranking is between
*min_rank* and *max_rank* AND whose score is between *min_score* and
*max_score* (both ranges inclusive). If no bounds are specified, all
items will be returned. | redis_collections/sortedsets.py | def items(
self,
min_rank=None,
max_rank=None,
min_score=None,
max_score=None,
reverse=False,
pipe=None,
):
"""
Return a list of ``(member, score)`` tuples whose ranking is between
*min_rank* and *max_rank* AND whose score is between *m... | def items(
self,
min_rank=None,
max_rank=None,
min_score=None,
max_score=None,
reverse=False,
pipe=None,
):
"""
Return a list of ``(member, score)`` tuples whose ranking is between
*min_rank* and *max_rank* AND whose score is between *m... | [
"Return",
"a",
"list",
"of",
"(",
"member",
"score",
")",
"tuples",
"whose",
"ranking",
"is",
"between",
"*",
"min_rank",
"*",
"and",
"*",
"max_rank",
"*",
"AND",
"whose",
"score",
"is",
"between",
"*",
"min_score",
"*",
"and",
"*",
"max_score",
"*",
"... | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sortedsets.py#L329-L369 | [
"def",
"items",
"(",
"self",
",",
"min_rank",
"=",
"None",
",",
"max_rank",
"=",
"None",
",",
"min_score",
"=",
"None",
",",
"max_score",
"=",
"None",
",",
"reverse",
"=",
"False",
",",
"pipe",
"=",
"None",
",",
")",
":",
"pipe",
"=",
"self",
".",
... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | SortedSetCounter.set_score | Set the score of *member* to *score*. | redis_collections/sortedsets.py | def set_score(self, member, score, pipe=None):
"""
Set the score of *member* to *score*.
"""
pipe = self.redis if pipe is None else pipe
pipe.zadd(self.key, {self._pickle(member): float(score)}) | def set_score(self, member, score, pipe=None):
"""
Set the score of *member* to *score*.
"""
pipe = self.redis if pipe is None else pipe
pipe.zadd(self.key, {self._pickle(member): float(score)}) | [
"Set",
"the",
"score",
"of",
"*",
"member",
"*",
"to",
"*",
"score",
"*",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sortedsets.py#L371-L376 | [
"def",
"set_score",
"(",
"self",
",",
"member",
",",
"score",
",",
"pipe",
"=",
"None",
")",
":",
"pipe",
"=",
"self",
".",
"redis",
"if",
"pipe",
"is",
"None",
"else",
"pipe",
"pipe",
".",
"zadd",
"(",
"self",
".",
"key",
",",
"{",
"self",
".",
... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | GeoDB.distance_between | Return the great-circle distance between *place_1* and *place_2*,
in the *unit* specified.
The default unit is ``'km'``, but ``'m'``, ``'mi'``, and ``'ft'`` can
also be specified. | redis_collections/sortedsets.py | def distance_between(self, place_1, place_2, unit='km'):
"""
Return the great-circle distance between *place_1* and *place_2*,
in the *unit* specified.
The default unit is ``'km'``, but ``'m'``, ``'mi'``, and ``'ft'`` can
also be specified.
"""
pickled_place_1 = ... | def distance_between(self, place_1, place_2, unit='km'):
"""
Return the great-circle distance between *place_1* and *place_2*,
in the *unit* specified.
The default unit is ``'km'``, but ``'m'``, ``'mi'``, and ``'ft'`` can
also be specified.
"""
pickled_place_1 = ... | [
"Return",
"the",
"great",
"-",
"circle",
"distance",
"between",
"*",
"place_1",
"*",
"and",
"*",
"place_2",
"*",
"in",
"the",
"*",
"unit",
"*",
"specified",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sortedsets.py#L428-L443 | [
"def",
"distance_between",
"(",
"self",
",",
"place_1",
",",
"place_2",
",",
"unit",
"=",
"'km'",
")",
":",
"pickled_place_1",
"=",
"self",
".",
"_pickle",
"(",
"place_1",
")",
"pickled_place_2",
"=",
"self",
".",
"_pickle",
"(",
"place_2",
")",
"try",
"... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | GeoDB.get_hash | Return the Geohash of *place*.
If it's not present in the collection, ``None`` will be returned
instead. | redis_collections/sortedsets.py | def get_hash(self, place):
"""
Return the Geohash of *place*.
If it's not present in the collection, ``None`` will be returned
instead.
"""
pickled_place = self._pickle(place)
try:
return self.redis.geohash(self.key, pickled_place)[0]
except (A... | def get_hash(self, place):
"""
Return the Geohash of *place*.
If it's not present in the collection, ``None`` will be returned
instead.
"""
pickled_place = self._pickle(place)
try:
return self.redis.geohash(self.key, pickled_place)[0]
except (A... | [
"Return",
"the",
"Geohash",
"of",
"*",
"place",
"*",
".",
"If",
"it",
"s",
"not",
"present",
"in",
"the",
"collection",
"None",
"will",
"be",
"returned",
"instead",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sortedsets.py#L445-L455 | [
"def",
"get_hash",
"(",
"self",
",",
"place",
")",
":",
"pickled_place",
"=",
"self",
".",
"_pickle",
"(",
"place",
")",
"try",
":",
"return",
"self",
".",
"redis",
".",
"geohash",
"(",
"self",
".",
"key",
",",
"pickled_place",
")",
"[",
"0",
"]",
... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | GeoDB.get_location | Return a dict with the coordinates *place*. The dict's keys are
``'latitude'`` and ``'longitude'``.
If it's not present in the collection, ``None`` will be returned
instead. | redis_collections/sortedsets.py | def get_location(self, place):
"""
Return a dict with the coordinates *place*. The dict's keys are
``'latitude'`` and ``'longitude'``.
If it's not present in the collection, ``None`` will be returned
instead.
"""
pickled_place = self._pickle(place)
try:
... | def get_location(self, place):
"""
Return a dict with the coordinates *place*. The dict's keys are
``'latitude'`` and ``'longitude'``.
If it's not present in the collection, ``None`` will be returned
instead.
"""
pickled_place = self._pickle(place)
try:
... | [
"Return",
"a",
"dict",
"with",
"the",
"coordinates",
"*",
"place",
"*",
".",
"The",
"dict",
"s",
"keys",
"are",
"latitude",
"and",
"longitude",
".",
"If",
"it",
"s",
"not",
"present",
"in",
"the",
"collection",
"None",
"will",
"be",
"returned",
"instead"... | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sortedsets.py#L457-L470 | [
"def",
"get_location",
"(",
"self",
",",
"place",
")",
":",
"pickled_place",
"=",
"self",
".",
"_pickle",
"(",
"place",
")",
"try",
":",
"longitude",
",",
"latitude",
"=",
"self",
".",
"redis",
".",
"geopos",
"(",
"self",
".",
"key",
",",
"pickled_plac... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | GeoDB.places_within_radius | Return descriptions of the places stored in the collection that are
within the circle specified by the given location and radius.
A list of dicts will be returned.
The center of the circle can be specified by the identifier of another
place in the collection with the *place* keyword arg... | redis_collections/sortedsets.py | def places_within_radius(
self, place=None, latitude=None, longitude=None, radius=0, **kwargs
):
"""
Return descriptions of the places stored in the collection that are
within the circle specified by the given location and radius.
A list of dicts will be returned.
Th... | def places_within_radius(
self, place=None, latitude=None, longitude=None, radius=0, **kwargs
):
"""
Return descriptions of the places stored in the collection that are
within the circle specified by the given location and radius.
A list of dicts will be returned.
Th... | [
"Return",
"descriptions",
"of",
"the",
"places",
"stored",
"in",
"the",
"collection",
"that",
"are",
"within",
"the",
"circle",
"specified",
"by",
"the",
"given",
"location",
"and",
"radius",
".",
"A",
"list",
"of",
"dicts",
"will",
"be",
"returned",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sortedsets.py#L472-L526 | [
"def",
"places_within_radius",
"(",
"self",
",",
"place",
"=",
"None",
",",
"latitude",
"=",
"None",
",",
"longitude",
"=",
"None",
",",
"radius",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'withdist'",
"]",
"=",
"True",
"kwargs",
"... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | GeoDB.set_location | Set the location of *place* to the location specified by
*latitude* and *longitude*.
*place* can be any pickle-able Python object. | redis_collections/sortedsets.py | def set_location(self, place, latitude, longitude, pipe=None):
"""
Set the location of *place* to the location specified by
*latitude* and *longitude*.
*place* can be any pickle-able Python object.
"""
pipe = self.redis if pipe is None else pipe
pipe.geoadd(self.... | def set_location(self, place, latitude, longitude, pipe=None):
"""
Set the location of *place* to the location specified by
*latitude* and *longitude*.
*place* can be any pickle-able Python object.
"""
pipe = self.redis if pipe is None else pipe
pipe.geoadd(self.... | [
"Set",
"the",
"location",
"of",
"*",
"place",
"*",
"to",
"the",
"location",
"specified",
"by",
"*",
"latitude",
"*",
"and",
"*",
"longitude",
"*",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sortedsets.py#L528-L536 | [
"def",
"set_location",
"(",
"self",
",",
"place",
",",
"latitude",
",",
"longitude",
",",
"pipe",
"=",
"None",
")",
":",
"pipe",
"=",
"self",
".",
"redis",
"if",
"pipe",
"is",
"None",
"else",
"pipe",
"pipe",
".",
"geoadd",
"(",
"self",
".",
"key",
... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | GeoDB.update | Update the collection with items from *other*. Accepts other
:class:`GeoDB` instances, dictionaries mapping places to
``{'latitude': latitude, 'longitude': longitude}`` dicts,
or sequences of ``(place, latitude, longitude)`` tuples. | redis_collections/sortedsets.py | def update(self, other):
"""
Update the collection with items from *other*. Accepts other
:class:`GeoDB` instances, dictionaries mapping places to
``{'latitude': latitude, 'longitude': longitude}`` dicts,
or sequences of ``(place, latitude, longitude)`` tuples.
"""
... | def update(self, other):
"""
Update the collection with items from *other*. Accepts other
:class:`GeoDB` instances, dictionaries mapping places to
``{'latitude': latitude, 'longitude': longitude}`` dicts,
or sequences of ``(place, latitude, longitude)`` tuples.
"""
... | [
"Update",
"the",
"collection",
"with",
"items",
"from",
"*",
"other",
"*",
".",
"Accepts",
"other",
":",
"class",
":",
"GeoDB",
"instances",
"dictionaries",
"mapping",
"places",
"to",
"{",
"latitude",
":",
"latitude",
"longitude",
":",
"longitude",
"}",
"dic... | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sortedsets.py#L538-L587 | [
"def",
"update",
"(",
"self",
",",
"other",
")",
":",
"# other is another Sorted Set",
"def",
"update_sortedset_trans",
"(",
"pipe",
")",
":",
"items",
"=",
"other",
".",
"_data",
"(",
"pipe",
"=",
"pipe",
")",
"if",
"use_redis",
"else",
"other",
".",
"_da... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | LRUDict.copy | Creates another collection with the same items and maxsize with
the given *key*. | redis_collections/syncable.py | def copy(self, key=None):
"""
Creates another collection with the same items and maxsize with
the given *key*.
"""
other = self.__class__(
maxsize=self.maxsize, redis=self.persistence.redis, key=key
)
other.update(self)
return other | def copy(self, key=None):
"""
Creates another collection with the same items and maxsize with
the given *key*.
"""
other = self.__class__(
maxsize=self.maxsize, redis=self.persistence.redis, key=key
)
other.update(self)
return other | [
"Creates",
"another",
"collection",
"with",
"the",
"same",
"items",
"and",
"maxsize",
"with",
"the",
"given",
"*",
"key",
"*",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/syncable.py#L267-L277 | [
"def",
"copy",
"(",
"self",
",",
"key",
"=",
"None",
")",
":",
"other",
"=",
"self",
".",
"__class__",
"(",
"maxsize",
"=",
"self",
".",
"maxsize",
",",
"redis",
"=",
"self",
".",
"persistence",
".",
"redis",
",",
"key",
"=",
"key",
")",
"other",
... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | LRUDict.fromkeys | Create a new collection with keys from *seq* and values set to
*value*. The keyword arguments are passed to the persistent ``Dict``. | redis_collections/syncable.py | def fromkeys(cls, seq, value=None, **kwargs):
"""
Create a new collection with keys from *seq* and values set to
*value*. The keyword arguments are passed to the persistent ``Dict``.
"""
other = cls(**kwargs)
other.update(((key, value) for key in seq))
return oth... | def fromkeys(cls, seq, value=None, **kwargs):
"""
Create a new collection with keys from *seq* and values set to
*value*. The keyword arguments are passed to the persistent ``Dict``.
"""
other = cls(**kwargs)
other.update(((key, value) for key in seq))
return oth... | [
"Create",
"a",
"new",
"collection",
"with",
"keys",
"from",
"*",
"seq",
"*",
"and",
"values",
"set",
"to",
"*",
"value",
"*",
".",
"The",
"keyword",
"arguments",
"are",
"passed",
"to",
"the",
"persistent",
"Dict",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/syncable.py#L280-L288 | [
"def",
"fromkeys",
"(",
"cls",
",",
"seq",
",",
"value",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"other",
"=",
"cls",
"(",
"*",
"*",
"kwargs",
")",
"other",
".",
"update",
"(",
"(",
"(",
"key",
",",
"value",
")",
"for",
"key",
"in",
"... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | LRUDict.sync | Copy items from the local cache to the persistent Dict.
If *clear_cache* is ``True``, clear out the local cache after
pushing its items to Redis. | redis_collections/syncable.py | def sync(self, clear_cache=False):
"""
Copy items from the local cache to the persistent Dict.
If *clear_cache* is ``True``, clear out the local cache after
pushing its items to Redis.
"""
self.persistence.update(self)
if clear_cache:
self.cache.clear... | def sync(self, clear_cache=False):
"""
Copy items from the local cache to the persistent Dict.
If *clear_cache* is ``True``, clear out the local cache after
pushing its items to Redis.
"""
self.persistence.update(self)
if clear_cache:
self.cache.clear... | [
"Copy",
"items",
"from",
"the",
"local",
"cache",
"to",
"the",
"persistent",
"Dict",
".",
"If",
"*",
"clear_cache",
"*",
"is",
"True",
"clear",
"out",
"the",
"local",
"cache",
"after",
"pushing",
"its",
"items",
"to",
"Redis",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/syncable.py#L290-L299 | [
"def",
"sync",
"(",
"self",
",",
"clear_cache",
"=",
"False",
")",
":",
"self",
".",
"persistence",
".",
"update",
"(",
"self",
")",
"if",
"clear_cache",
":",
"self",
".",
"cache",
".",
"clear",
"(",
")"
] | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | List._data | Return a :obj:`list` of all values from Redis
(without checking the local cache). | redis_collections/lists.py | def _data(self, pipe=None):
"""
Return a :obj:`list` of all values from Redis
(without checking the local cache).
"""
pipe = self.redis if pipe is None else pipe
return [self._unpickle(v) for v in pipe.lrange(self.key, 0, -1)] | def _data(self, pipe=None):
"""
Return a :obj:`list` of all values from Redis
(without checking the local cache).
"""
pipe = self.redis if pipe is None else pipe
return [self._unpickle(v) for v in pipe.lrange(self.key, 0, -1)] | [
"Return",
"a",
":",
"obj",
":",
"list",
"of",
"all",
"values",
"from",
"Redis",
"(",
"without",
"checking",
"the",
"local",
"cache",
")",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/lists.py#L245-L251 | [
"def",
"_data",
"(",
"self",
",",
"pipe",
"=",
"None",
")",
":",
"pipe",
"=",
"self",
".",
"redis",
"if",
"pipe",
"is",
"None",
"else",
"pipe",
"return",
"[",
"self",
".",
"_unpickle",
"(",
"v",
")",
"for",
"v",
"in",
"pipe",
".",
"lrange",
"(",
... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | List.append | Insert *value* at the end of this collection. | redis_collections/lists.py | def append(self, value):
"""Insert *value* at the end of this collection."""
len_self = self.redis.rpush(self.key, self._pickle(value))
if self.writeback:
self.cache[len_self - 1] = value | def append(self, value):
"""Insert *value* at the end of this collection."""
len_self = self.redis.rpush(self.key, self._pickle(value))
if self.writeback:
self.cache[len_self - 1] = value | [
"Insert",
"*",
"value",
"*",
"at",
"the",
"end",
"of",
"this",
"collection",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/lists.py#L338-L343 | [
"def",
"append",
"(",
"self",
",",
"value",
")",
":",
"len_self",
"=",
"self",
".",
"redis",
".",
"rpush",
"(",
"self",
".",
"key",
",",
"self",
".",
"_pickle",
"(",
"value",
")",
")",
"if",
"self",
".",
"writeback",
":",
"self",
".",
"cache",
"[... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | List.copy | Return a new collection with the same items as this one.
If *key* is specified, create the new collection with the given
Redis key. | redis_collections/lists.py | def copy(self, key=None):
"""
Return a new collection with the same items as this one.
If *key* is specified, create the new collection with the given
Redis key.
"""
other = self.__class__(
redis=self.redis, key=key, writeback=self.writeback
)
... | def copy(self, key=None):
"""
Return a new collection with the same items as this one.
If *key* is specified, create the new collection with the given
Redis key.
"""
other = self.__class__(
redis=self.redis, key=key, writeback=self.writeback
)
... | [
"Return",
"a",
"new",
"collection",
"with",
"the",
"same",
"items",
"as",
"this",
"one",
".",
"If",
"*",
"key",
"*",
"is",
"specified",
"create",
"the",
"new",
"collection",
"with",
"the",
"given",
"Redis",
"key",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/lists.py#L352-L363 | [
"def",
"copy",
"(",
"self",
",",
"key",
"=",
"None",
")",
":",
"other",
"=",
"self",
".",
"__class__",
"(",
"redis",
"=",
"self",
".",
"redis",
",",
"key",
"=",
"key",
",",
"writeback",
"=",
"self",
".",
"writeback",
")",
"other",
".",
"extend",
... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | List.extend | Adds the values from the iterable *other* to the end of this
collection. | redis_collections/lists.py | def extend(self, other):
"""
Adds the values from the iterable *other* to the end of this
collection.
"""
def extend_trans(pipe):
values = list(other.__iter__(pipe)) if use_redis else other
len_self = pipe.rpush(self.key, *(self._pickle(v) for v in values)... | def extend(self, other):
"""
Adds the values from the iterable *other* to the end of this
collection.
"""
def extend_trans(pipe):
values = list(other.__iter__(pipe)) if use_redis else other
len_self = pipe.rpush(self.key, *(self._pickle(v) for v in values)... | [
"Adds",
"the",
"values",
"from",
"the",
"iterable",
"*",
"other",
"*",
"to",
"the",
"end",
"of",
"this",
"collection",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/lists.py#L374-L391 | [
"def",
"extend",
"(",
"self",
",",
"other",
")",
":",
"def",
"extend_trans",
"(",
"pipe",
")",
":",
"values",
"=",
"list",
"(",
"other",
".",
"__iter__",
"(",
"pipe",
")",
")",
"if",
"use_redis",
"else",
"other",
"len_self",
"=",
"pipe",
".",
"rpush"... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | List.index | Return the index of the first occurence of *value*.
If *start* or *stop* are provided, return the smallest
index such that ``s[index] == value`` and ``start <= index < stop``. | redis_collections/lists.py | def index(self, value, start=None, stop=None):
"""
Return the index of the first occurence of *value*.
If *start* or *stop* are provided, return the smallest
index such that ``s[index] == value`` and ``start <= index < stop``.
"""
def index_trans(pipe):
len_se... | def index(self, value, start=None, stop=None):
"""
Return the index of the first occurence of *value*.
If *start* or *stop* are provided, return the smallest
index such that ``s[index] == value`` and ``start <= index < stop``.
"""
def index_trans(pipe):
len_se... | [
"Return",
"the",
"index",
"of",
"the",
"first",
"occurence",
"of",
"*",
"value",
"*",
".",
"If",
"*",
"start",
"*",
"or",
"*",
"stop",
"*",
"are",
"provided",
"return",
"the",
"smallest",
"index",
"such",
"that",
"s",
"[",
"index",
"]",
"==",
"value"... | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/lists.py#L393-L411 | [
"def",
"index",
"(",
"self",
",",
"value",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
")",
":",
"def",
"index_trans",
"(",
"pipe",
")",
":",
"len_self",
",",
"normal_start",
"=",
"self",
".",
"_normalize_index",
"(",
"start",
"or",
"0",
","... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | List.insert | Insert *value* into the collection at *index*. | redis_collections/lists.py | def insert(self, index, value):
"""
Insert *value* into the collection at *index*.
"""
if index == 0:
return self._insert_left(value)
def insert_middle_trans(pipe):
self._insert_middle(index, value, pipe=pipe)
return self._transaction(insert_midd... | def insert(self, index, value):
"""
Insert *value* into the collection at *index*.
"""
if index == 0:
return self._insert_left(value)
def insert_middle_trans(pipe):
self._insert_middle(index, value, pipe=pipe)
return self._transaction(insert_midd... | [
"Insert",
"*",
"value",
"*",
"into",
"the",
"collection",
"at",
"*",
"index",
"*",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/lists.py#L445-L455 | [
"def",
"insert",
"(",
"self",
",",
"index",
",",
"value",
")",
":",
"if",
"index",
"==",
"0",
":",
"return",
"self",
".",
"_insert_left",
"(",
"value",
")",
"def",
"insert_middle_trans",
"(",
"pipe",
")",
":",
"self",
".",
"_insert_middle",
"(",
"index... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | List.pop | Retrieve the value at *index*, remove it from the collection, and
return it. | redis_collections/lists.py | def pop(self, index=-1):
"""
Retrieve the value at *index*, remove it from the collection, and
return it.
"""
if index == 0:
return self._pop_left()
elif index == -1:
return self._pop_right()
else:
return self._pop_middle(index) | def pop(self, index=-1):
"""
Retrieve the value at *index*, remove it from the collection, and
return it.
"""
if index == 0:
return self._pop_left()
elif index == -1:
return self._pop_right()
else:
return self._pop_middle(index) | [
"Retrieve",
"the",
"value",
"at",
"*",
"index",
"*",
"remove",
"it",
"from",
"the",
"collection",
"and",
"return",
"it",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/lists.py#L457-L467 | [
"def",
"pop",
"(",
"self",
",",
"index",
"=",
"-",
"1",
")",
":",
"if",
"index",
"==",
"0",
":",
"return",
"self",
".",
"_pop_left",
"(",
")",
"elif",
"index",
"==",
"-",
"1",
":",
"return",
"self",
".",
"_pop_right",
"(",
")",
"else",
":",
"re... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | List.remove | Remove the first occurence of *value*. | redis_collections/lists.py | def remove(self, value):
"""Remove the first occurence of *value*."""
def remove_trans(pipe):
# If we're caching, we'll need to synchronize before removing.
if self.writeback:
self._sync_helper(pipe)
delete_count = pipe.lrem(self.key, 1, self._pickle(... | def remove(self, value):
"""Remove the first occurence of *value*."""
def remove_trans(pipe):
# If we're caching, we'll need to synchronize before removing.
if self.writeback:
self._sync_helper(pipe)
delete_count = pipe.lrem(self.key, 1, self._pickle(... | [
"Remove",
"the",
"first",
"occurence",
"of",
"*",
"value",
"*",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/lists.py#L469-L480 | [
"def",
"remove",
"(",
"self",
",",
"value",
")",
":",
"def",
"remove_trans",
"(",
"pipe",
")",
":",
"# If we're caching, we'll need to synchronize before removing.",
"if",
"self",
".",
"writeback",
":",
"self",
".",
"_sync_helper",
"(",
"pipe",
")",
"delete_count"... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
train | List.reverse | Reverses the items of this collection "in place" (only two values are
retrieved from Redis at a time). | redis_collections/lists.py | def reverse(self):
"""
Reverses the items of this collection "in place" (only two values are
retrieved from Redis at a time).
"""
def reverse_trans(pipe):
if self.writeback:
self._sync_helper(pipe)
n = self.__len__(pipe)
for i ... | def reverse(self):
"""
Reverses the items of this collection "in place" (only two values are
retrieved from Redis at a time).
"""
def reverse_trans(pipe):
if self.writeback:
self._sync_helper(pipe)
n = self.__len__(pipe)
for i ... | [
"Reverses",
"the",
"items",
"of",
"this",
"collection",
"in",
"place",
"(",
"only",
"two",
"values",
"are",
"retrieved",
"from",
"Redis",
"at",
"a",
"time",
")",
"."
] | honzajavorek/redis-collections | python | https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/lists.py#L482-L498 | [
"def",
"reverse",
"(",
"self",
")",
":",
"def",
"reverse_trans",
"(",
"pipe",
")",
":",
"if",
"self",
".",
"writeback",
":",
"self",
".",
"_sync_helper",
"(",
"pipe",
")",
"n",
"=",
"self",
".",
"__len__",
"(",
"pipe",
")",
"for",
"i",
"in",
"range... | 07ca8efe88fb128f7dc7319dfa6a26cd39b3776b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.