id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
54,100 | haikuginger/beekeeper | beekeeper/hive.py | Hive.from_domain | def from_domain(cls, domain, version=None, require_https=True):
"""
Try to find a hive for the given domain; raise an error if we have to
failover to HTTP and haven't explicitly suppressed it in the call.
"""
url = 'https://' + domain + '/api/hive.json'
try:
r... | python | def from_domain(cls, domain, version=None, require_https=True):
"""
Try to find a hive for the given domain; raise an error if we have to
failover to HTTP and haven't explicitly suppressed it in the call.
"""
url = 'https://' + domain + '/api/hive.json'
try:
r... | [
"def",
"from_domain",
"(",
"cls",
",",
"domain",
",",
"version",
"=",
"None",
",",
"require_https",
"=",
"True",
")",
":",
"url",
"=",
"'https://'",
"+",
"domain",
"+",
"'/api/hive.json'",
"try",
":",
"return",
"cls",
".",
"from_url",
"(",
"url",
",",
... | Try to find a hive for the given domain; raise an error if we have to
failover to HTTP and haven't explicitly suppressed it in the call. | [
"Try",
"to",
"find",
"a",
"hive",
"for",
"the",
"given",
"domain",
";",
"raise",
"an",
"error",
"if",
"we",
"have",
"to",
"failover",
"to",
"HTTP",
"and",
"haven",
"t",
"explicitly",
"suppressed",
"it",
"in",
"the",
"call",
"."
] | b647d3add0b407ec5dc3a2a39c4f6dac31243b18 | https://github.com/haikuginger/beekeeper/blob/b647d3add0b407ec5dc3a2a39c4f6dac31243b18/beekeeper/hive.py#L62-L72 |
54,101 | haikuginger/beekeeper | beekeeper/hive.py | Hive.from_version | def from_version(self, version, require_https=False):
"""
Create a Hive object based on the information in the object
and the version passed into the method.
"""
if version is None or self.version() == version:
return self
else:
return Hive.from_ur... | python | def from_version(self, version, require_https=False):
"""
Create a Hive object based on the information in the object
and the version passed into the method.
"""
if version is None or self.version() == version:
return self
else:
return Hive.from_ur... | [
"def",
"from_version",
"(",
"self",
",",
"version",
",",
"require_https",
"=",
"False",
")",
":",
"if",
"version",
"is",
"None",
"or",
"self",
".",
"version",
"(",
")",
"==",
"version",
":",
"return",
"self",
"else",
":",
"return",
"Hive",
".",
"from_u... | Create a Hive object based on the information in the object
and the version passed into the method. | [
"Create",
"a",
"Hive",
"object",
"based",
"on",
"the",
"information",
"in",
"the",
"object",
"and",
"the",
"version",
"passed",
"into",
"the",
"method",
"."
] | b647d3add0b407ec5dc3a2a39c4f6dac31243b18 | https://github.com/haikuginger/beekeeper/blob/b647d3add0b407ec5dc3a2a39c4f6dac31243b18/beekeeper/hive.py#L74-L82 |
54,102 | haikuginger/beekeeper | beekeeper/hive.py | Hive.get_version_url | def get_version_url(self, version):
"""
Retrieve the URL for the designated version of the hive.
"""
for each_version in self.other_versions():
if version == each_version['version'] and 'location' in each_version:
return each_version.get('location')
ra... | python | def get_version_url(self, version):
"""
Retrieve the URL for the designated version of the hive.
"""
for each_version in self.other_versions():
if version == each_version['version'] and 'location' in each_version:
return each_version.get('location')
ra... | [
"def",
"get_version_url",
"(",
"self",
",",
"version",
")",
":",
"for",
"each_version",
"in",
"self",
".",
"other_versions",
"(",
")",
":",
"if",
"version",
"==",
"each_version",
"[",
"'version'",
"]",
"and",
"'location'",
"in",
"each_version",
":",
"return"... | Retrieve the URL for the designated version of the hive. | [
"Retrieve",
"the",
"URL",
"for",
"the",
"designated",
"version",
"of",
"the",
"hive",
"."
] | b647d3add0b407ec5dc3a2a39c4f6dac31243b18 | https://github.com/haikuginger/beekeeper/blob/b647d3add0b407ec5dc3a2a39c4f6dac31243b18/beekeeper/hive.py#L84-L91 |
54,103 | synw/dataswim | dataswim/maps/__init__.py | Map.marker_ | def marker_(self, lat, long, text, pmap, color=None, icon=None):
"""
Returns the map with a marker to the default map
"""
try:
xmap = self._marker(lat, long, text, pmap, color, icon)
return xmap
except Exception as e:
self.err(e, self.marker_, ... | python | def marker_(self, lat, long, text, pmap, color=None, icon=None):
"""
Returns the map with a marker to the default map
"""
try:
xmap = self._marker(lat, long, text, pmap, color, icon)
return xmap
except Exception as e:
self.err(e, self.marker_, ... | [
"def",
"marker_",
"(",
"self",
",",
"lat",
",",
"long",
",",
"text",
",",
"pmap",
",",
"color",
"=",
"None",
",",
"icon",
"=",
"None",
")",
":",
"try",
":",
"xmap",
"=",
"self",
".",
"_marker",
"(",
"lat",
",",
"long",
",",
"text",
",",
"pmap",... | Returns the map with a marker to the default map | [
"Returns",
"the",
"map",
"with",
"a",
"marker",
"to",
"the",
"default",
"map"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/maps/__init__.py#L36-L44 |
54,104 | synw/dataswim | dataswim/maps/__init__.py | Map.marker | def marker(self, lat, long, text, color=None, icon=None):
"""
Set the main map with a marker to the default map
"""
try:
self.dsmap = self._marker(lat, long, text, self.dsmap, color, icon)
return self.dsmap
except Exception as e:
self.err(e, se... | python | def marker(self, lat, long, text, color=None, icon=None):
"""
Set the main map with a marker to the default map
"""
try:
self.dsmap = self._marker(lat, long, text, self.dsmap, color, icon)
return self.dsmap
except Exception as e:
self.err(e, se... | [
"def",
"marker",
"(",
"self",
",",
"lat",
",",
"long",
",",
"text",
",",
"color",
"=",
"None",
",",
"icon",
"=",
"None",
")",
":",
"try",
":",
"self",
".",
"dsmap",
"=",
"self",
".",
"_marker",
"(",
"lat",
",",
"long",
",",
"text",
",",
"self",... | Set the main map with a marker to the default map | [
"Set",
"the",
"main",
"map",
"with",
"a",
"marker",
"to",
"the",
"default",
"map"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/maps/__init__.py#L46-L54 |
54,105 | synw/dataswim | dataswim/maps/__init__.py | Map._marker | def _marker(self, lat, long, text, xmap, color=None, icon=None,
text_mark=False, style=None):
"""
Adds a marker to the default map
"""
kwargs = {}
if icon is not None:
kwargs["icon"] = icon
if color is not None:
kwargs["color"] = co... | python | def _marker(self, lat, long, text, xmap, color=None, icon=None,
text_mark=False, style=None):
"""
Adds a marker to the default map
"""
kwargs = {}
if icon is not None:
kwargs["icon"] = icon
if color is not None:
kwargs["color"] = co... | [
"def",
"_marker",
"(",
"self",
",",
"lat",
",",
"long",
",",
"text",
",",
"xmap",
",",
"color",
"=",
"None",
",",
"icon",
"=",
"None",
",",
"text_mark",
"=",
"False",
",",
"style",
"=",
"None",
")",
":",
"kwargs",
"=",
"{",
"}",
"if",
"icon",
"... | Adds a marker to the default map | [
"Adds",
"a",
"marker",
"to",
"the",
"default",
"map"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/maps/__init__.py#L56-L83 |
54,106 | synw/dataswim | dataswim/maps/__init__.py | Map.map | def map(self, lat, long, zoom=13, tiles="map"):
"""
Sets a map
"""
try:
self.dsmap = self._map(lat, long, zoom, tiles)
except Exception as e:
self.err(e, self.map, "Can not get map") | python | def map(self, lat, long, zoom=13, tiles="map"):
"""
Sets a map
"""
try:
self.dsmap = self._map(lat, long, zoom, tiles)
except Exception as e:
self.err(e, self.map, "Can not get map") | [
"def",
"map",
"(",
"self",
",",
"lat",
",",
"long",
",",
"zoom",
"=",
"13",
",",
"tiles",
"=",
"\"map\"",
")",
":",
"try",
":",
"self",
".",
"dsmap",
"=",
"self",
".",
"_map",
"(",
"lat",
",",
"long",
",",
"zoom",
",",
"tiles",
")",
"except",
... | Sets a map | [
"Sets",
"a",
"map"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/maps/__init__.py#L94-L101 |
54,107 | AntagonistHQ/openprovider.py | openprovider/modules/__init__.py | OE | def OE(element, value, transform=lambda x: x):
"""
Create an Optional Element.
Returns an Element as ElementMaker would, unless value is None. Optionally the value can be
transformed through a function.
>>> OE('elem', None)
None
>>> lxml.etree.tostring(OE('elem', 'value'))
<elem>value... | python | def OE(element, value, transform=lambda x: x):
"""
Create an Optional Element.
Returns an Element as ElementMaker would, unless value is None. Optionally the value can be
transformed through a function.
>>> OE('elem', None)
None
>>> lxml.etree.tostring(OE('elem', 'value'))
<elem>value... | [
"def",
"OE",
"(",
"element",
",",
"value",
",",
"transform",
"=",
"lambda",
"x",
":",
"x",
")",
":",
"return",
"E",
"(",
"element",
",",
"transform",
"(",
"value",
")",
")",
"if",
"value",
"is",
"not",
"None",
"else",
"None"
] | Create an Optional Element.
Returns an Element as ElementMaker would, unless value is None. Optionally the value can be
transformed through a function.
>>> OE('elem', None)
None
>>> lxml.etree.tostring(OE('elem', 'value'))
<elem>value</elem>
>>> lxml.etree.tostring(OE('elem', True, int))... | [
"Create",
"an",
"Optional",
"Element",
"."
] | 5871c3d5b3661e23667f147f49f20389c817a0a4 | https://github.com/AntagonistHQ/openprovider.py/blob/5871c3d5b3661e23667f147f49f20389c817a0a4/openprovider/modules/__init__.py#L8-L24 |
54,108 | limpyd/redis-limpyd | limpyd/fields.py | RedisProxyCommand._make_command_method | def _make_command_method(cls, command_name):
"""
Return a function which call _call_command for the given name.
Used to bind redis commands to our own calls
"""
def func(self, *args, **kwargs):
return self._call_command(command_name, *args, **kwargs)
return fu... | python | def _make_command_method(cls, command_name):
"""
Return a function which call _call_command for the given name.
Used to bind redis commands to our own calls
"""
def func(self, *args, **kwargs):
return self._call_command(command_name, *args, **kwargs)
return fu... | [
"def",
"_make_command_method",
"(",
"cls",
",",
"command_name",
")",
":",
"def",
"func",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_call_command",
"(",
"command_name",
",",
"*",
"args",
",",
"*",
"*",
"... | Return a function which call _call_command for the given name.
Used to bind redis commands to our own calls | [
"Return",
"a",
"function",
"which",
"call",
"_call_command",
"for",
"the",
"given",
"name",
".",
"Used",
"to",
"bind",
"redis",
"commands",
"to",
"our",
"own",
"calls"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L91-L98 |
54,109 | limpyd/redis-limpyd | limpyd/fields.py | RedisProxyCommand._call_command | def _call_command(self, name, *args, **kwargs):
"""
Check if the command to be executed is a modifier, to connect the object.
Then call _traverse_command.
"""
obj = getattr(self, '_instance', self) # _instance if a field, self if an instance
# The object may not be alre... | python | def _call_command(self, name, *args, **kwargs):
"""
Check if the command to be executed is a modifier, to connect the object.
Then call _traverse_command.
"""
obj = getattr(self, '_instance', self) # _instance if a field, self if an instance
# The object may not be alre... | [
"def",
"_call_command",
"(",
"self",
",",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"obj",
"=",
"getattr",
"(",
"self",
",",
"'_instance'",
",",
"self",
")",
"# _instance if a field, self if an instance",
"# The object may not be already connect... | Check if the command to be executed is a modifier, to connect the object.
Then call _traverse_command. | [
"Check",
"if",
"the",
"command",
"to",
"be",
"executed",
"is",
"a",
"modifier",
"to",
"connect",
"the",
"object",
".",
"Then",
"call",
"_traverse_command",
"."
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L100-L115 |
54,110 | limpyd/redis-limpyd | limpyd/fields.py | RedisProxyCommand._traverse_command | def _traverse_command(self, name, *args, **kwargs):
"""
Add the key to the args and call the Redis command.
"""
if not name in self.available_commands:
raise AttributeError("%s is not an available command for %s" %
(name, self.__class__.__name... | python | def _traverse_command(self, name, *args, **kwargs):
"""
Add the key to the args and call the Redis command.
"""
if not name in self.available_commands:
raise AttributeError("%s is not an available command for %s" %
(name, self.__class__.__name... | [
"def",
"_traverse_command",
"(",
"self",
",",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"name",
"in",
"self",
".",
"available_commands",
":",
"raise",
"AttributeError",
"(",
"\"%s is not an available command for %s\"",
"%",
"(",... | Add the key to the args and call the Redis command. | [
"Add",
"the",
"key",
"to",
"the",
"args",
"and",
"call",
"the",
"Redis",
"command",
"."
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L117-L135 |
54,111 | limpyd/redis-limpyd | limpyd/fields.py | RedisField.proxy_set | def proxy_set(self, value):
"""
A helper to easily call the proxy_setter of the field
"""
setter = getattr(self, self.proxy_setter)
if isinstance(value, (list, tuple, set)):
result = setter(*value)
elif isinstance(value, dict):
result = setter(**va... | python | def proxy_set(self, value):
"""
A helper to easily call the proxy_setter of the field
"""
setter = getattr(self, self.proxy_setter)
if isinstance(value, (list, tuple, set)):
result = setter(*value)
elif isinstance(value, dict):
result = setter(**va... | [
"def",
"proxy_set",
"(",
"self",
",",
"value",
")",
":",
"setter",
"=",
"getattr",
"(",
"self",
",",
"self",
".",
"proxy_setter",
")",
"if",
"isinstance",
"(",
"value",
",",
"(",
"list",
",",
"tuple",
",",
"set",
")",
")",
":",
"result",
"=",
"sett... | A helper to easily call the proxy_setter of the field | [
"A",
"helper",
"to",
"easily",
"call",
"the",
"proxy_setter",
"of",
"the",
"field"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L223-L234 |
54,112 | limpyd/redis-limpyd | limpyd/fields.py | RedisField.key | def key(self):
"""
A property to return the key used in redis for the current field.
"""
return self.make_key(
self._instance._name,
self._instance.pk.get(),
self.name,
) | python | def key(self):
"""
A property to return the key used in redis for the current field.
"""
return self.make_key(
self._instance._name,
self._instance.pk.get(),
self.name,
) | [
"def",
"key",
"(",
"self",
")",
":",
"return",
"self",
".",
"make_key",
"(",
"self",
".",
"_instance",
".",
"_name",
",",
"self",
".",
"_instance",
".",
"pk",
".",
"get",
"(",
")",
",",
"self",
".",
"name",
",",
")"
] | A property to return the key used in redis for the current field. | [
"A",
"property",
"to",
"return",
"the",
"key",
"used",
"in",
"redis",
"for",
"the",
"current",
"field",
"."
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L237-L245 |
54,113 | limpyd/redis-limpyd | limpyd/fields.py | RedisField.post_command | def post_command(self, sender, name, result, args, kwargs):
"""
Call after we got the result of a redis command.
By default, let the instance manage the post_modify signal
"""
return self._instance.post_command(
sender=self,
name=name,
... | python | def post_command(self, sender, name, result, args, kwargs):
"""
Call after we got the result of a redis command.
By default, let the instance manage the post_modify signal
"""
return self._instance.post_command(
sender=self,
name=name,
... | [
"def",
"post_command",
"(",
"self",
",",
"sender",
",",
"name",
",",
"result",
",",
"args",
",",
"kwargs",
")",
":",
"return",
"self",
".",
"_instance",
".",
"post_command",
"(",
"sender",
"=",
"self",
",",
"name",
"=",
"name",
",",
"result",
"=",
"r... | Call after we got the result of a redis command.
By default, let the instance manage the post_modify signal | [
"Call",
"after",
"we",
"got",
"the",
"result",
"of",
"a",
"redis",
"command",
".",
"By",
"default",
"let",
"the",
"instance",
"manage",
"the",
"post_modify",
"signal"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L330-L341 |
54,114 | limpyd/redis-limpyd | limpyd/fields.py | RedisField.exists | def exists(self):
"""
Call the exists command to check if the redis key exists for the current
field
"""
try:
key = self.key
except DoesNotExist:
"""
If the object doesn't exists anymore, its PK is deleted, so the
"self.key"... | python | def exists(self):
"""
Call the exists command to check if the redis key exists for the current
field
"""
try:
key = self.key
except DoesNotExist:
"""
If the object doesn't exists anymore, its PK is deleted, so the
"self.key"... | [
"def",
"exists",
"(",
"self",
")",
":",
"try",
":",
"key",
"=",
"self",
".",
"key",
"except",
"DoesNotExist",
":",
"\"\"\"\n If the object doesn't exists anymore, its PK is deleted, so the\n \"self.key\" call will raise a DoesNotExist exception. We catch it\n ... | Call the exists command to check if the redis key exists for the current
field | [
"Call",
"the",
"exists",
"command",
"to",
"check",
"if",
"the",
"redis",
"key",
"exists",
"for",
"the",
"current",
"field"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L343-L358 |
54,115 | limpyd/redis-limpyd | limpyd/fields.py | RedisField._indexes | def _indexes(self):
"""Instantiate the indexes only when asked
Returns
-------
list
An empty list if the field is not indexable, else a list of all indexes
tied to the field.
If no indexes where passed when creating the field, the default indexes
... | python | def _indexes(self):
"""Instantiate the indexes only when asked
Returns
-------
list
An empty list if the field is not indexable, else a list of all indexes
tied to the field.
If no indexes where passed when creating the field, the default indexes
... | [
"def",
"_indexes",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"indexable",
":",
"return",
"[",
"]",
"if",
"not",
"self",
".",
"index_classes",
":",
"self",
".",
"index_classes",
"=",
"self",
".",
"get_default_indexes",
"(",
")",
"[",
":",
":",
... | Instantiate the indexes only when asked
Returns
-------
list
An empty list if the field is not indexable, else a list of all indexes
tied to the field.
If no indexes where passed when creating the field, the default indexes
from the field/model/da... | [
"Instantiate",
"the",
"indexes",
"only",
"when",
"asked"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L361-L387 |
54,116 | limpyd/redis-limpyd | limpyd/fields.py | RedisField.has_index | def has_index(self, index):
"""Tells if the field have an index matching the current one
Parameters
-----------
index: type or BaseIndex
It could be an index instance, or an index class
Returns
-------
bool
Will be ``True`` if the current... | python | def has_index(self, index):
"""Tells if the field have an index matching the current one
Parameters
-----------
index: type or BaseIndex
It could be an index instance, or an index class
Returns
-------
bool
Will be ``True`` if the current... | [
"def",
"has_index",
"(",
"self",
",",
"index",
")",
":",
"klass",
"=",
"index",
"if",
"isclass",
"(",
"index",
")",
"else",
"index",
".",
"__class__",
"for",
"one_index",
"in",
"self",
".",
"_indexes",
":",
"if",
"isinstance",
"(",
"one_index",
",",
"k... | Tells if the field have an index matching the current one
Parameters
-----------
index: type or BaseIndex
It could be an index instance, or an index class
Returns
-------
bool
Will be ``True`` if the current field has an index that is an instance... | [
"Tells",
"if",
"the",
"field",
"have",
"an",
"index",
"matching",
"the",
"current",
"one"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L389-L408 |
54,117 | limpyd/redis-limpyd | limpyd/fields.py | RedisField._attach_to_instance | def _attach_to_instance(self, instance):
"""
Attach the current field to an instance of a model. Can be overriden to
do something when an instance is set
"""
self._instance = instance
self.lockable = self.lockable and instance.lockable | python | def _attach_to_instance(self, instance):
"""
Attach the current field to an instance of a model. Can be overriden to
do something when an instance is set
"""
self._instance = instance
self.lockable = self.lockable and instance.lockable | [
"def",
"_attach_to_instance",
"(",
"self",
",",
"instance",
")",
":",
"self",
".",
"_instance",
"=",
"instance",
"self",
".",
"lockable",
"=",
"self",
".",
"lockable",
"and",
"instance",
".",
"lockable"
] | Attach the current field to an instance of a model. Can be overriden to
do something when an instance is set | [
"Attach",
"the",
"current",
"field",
"to",
"an",
"instance",
"of",
"a",
"model",
".",
"Can",
"be",
"overriden",
"to",
"do",
"something",
"when",
"an",
"instance",
"is",
"set"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L417-L423 |
54,118 | limpyd/redis-limpyd | limpyd/fields.py | RedisField.attached_to_model | def attached_to_model(self):
"""Tells if the current field is the one attached to the model, not instance"""
try:
if not bool(self._model):
return False
except AttributeError:
return False
else:
try:
return not bool(self... | python | def attached_to_model(self):
"""Tells if the current field is the one attached to the model, not instance"""
try:
if not bool(self._model):
return False
except AttributeError:
return False
else:
try:
return not bool(self... | [
"def",
"attached_to_model",
"(",
"self",
")",
":",
"try",
":",
"if",
"not",
"bool",
"(",
"self",
".",
"_model",
")",
":",
"return",
"False",
"except",
"AttributeError",
":",
"return",
"False",
"else",
":",
"try",
":",
"return",
"not",
"bool",
"(",
"sel... | Tells if the current field is the one attached to the model, not instance | [
"Tells",
"if",
"the",
"current",
"field",
"is",
"the",
"one",
"attached",
"to",
"the",
"model",
"not",
"instance"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L426-L437 |
54,119 | limpyd/redis-limpyd | limpyd/fields.py | RedisField._call_command | def _call_command(self, name, *args, **kwargs):
"""
Add lock management and call parent.
"""
meth = super(RedisField, self)._call_command
if self.indexable and name in self.available_modifiers:
with FieldLock(self):
try:
result = me... | python | def _call_command(self, name, *args, **kwargs):
"""
Add lock management and call parent.
"""
meth = super(RedisField, self)._call_command
if self.indexable and name in self.available_modifiers:
with FieldLock(self):
try:
result = me... | [
"def",
"_call_command",
"(",
"self",
",",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"meth",
"=",
"super",
"(",
"RedisField",
",",
"self",
")",
".",
"_call_command",
"if",
"self",
".",
"indexable",
"and",
"name",
"in",
"self",
".",
... | Add lock management and call parent. | [
"Add",
"lock",
"management",
"and",
"call",
"parent",
"."
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L439-L456 |
54,120 | limpyd/redis-limpyd | limpyd/fields.py | RedisField.clear_indexes | def clear_indexes(self, chunk_size=1000, aggressive=False, index_class=None):
"""Clear all indexes tied to this field
Parameters
----------
chunk_size: int
Default to 1000, it's the number of instances to load at once if not in aggressive mode.
aggressive: bool
... | python | def clear_indexes(self, chunk_size=1000, aggressive=False, index_class=None):
"""Clear all indexes tied to this field
Parameters
----------
chunk_size: int
Default to 1000, it's the number of instances to load at once if not in aggressive mode.
aggressive: bool
... | [
"def",
"clear_indexes",
"(",
"self",
",",
"chunk_size",
"=",
"1000",
",",
"aggressive",
"=",
"False",
",",
"index_class",
"=",
"None",
")",
":",
"assert",
"self",
".",
"indexable",
",",
"\"Field not indexable\"",
"assert",
"self",
".",
"attached_to_model",
","... | Clear all indexes tied to this field
Parameters
----------
chunk_size: int
Default to 1000, it's the number of instances to load at once if not in aggressive mode.
aggressive: bool
Default to ``False``. When ``False``, the actual collection of instances will
... | [
"Clear",
"all",
"indexes",
"tied",
"to",
"this",
"field"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L517-L554 |
54,121 | limpyd/redis-limpyd | limpyd/fields.py | RedisField.rebuild_indexes | def rebuild_indexes(self, chunk_size=1000, aggressive_clear=False, index_class=None):
"""Rebuild all indexes tied to this field
Parameters
----------
chunk_size: int
Default to 1000, it's the number of instances to load at once.
aggressive_clear: bool
Wil... | python | def rebuild_indexes(self, chunk_size=1000, aggressive_clear=False, index_class=None):
"""Rebuild all indexes tied to this field
Parameters
----------
chunk_size: int
Default to 1000, it's the number of instances to load at once.
aggressive_clear: bool
Wil... | [
"def",
"rebuild_indexes",
"(",
"self",
",",
"chunk_size",
"=",
"1000",
",",
"aggressive_clear",
"=",
"False",
",",
"index_class",
"=",
"None",
")",
":",
"assert",
"self",
".",
"indexable",
",",
"\"Field not indexable\"",
"assert",
"self",
".",
"attached_to_model... | Rebuild all indexes tied to this field
Parameters
----------
chunk_size: int
Default to 1000, it's the number of instances to load at once.
aggressive_clear: bool
Will be passed to the `aggressive` argument of the `clear_indexes` method.
If `False`, a... | [
"Rebuild",
"all",
"indexes",
"tied",
"to",
"this",
"field"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L556-L591 |
54,122 | limpyd/redis-limpyd | limpyd/fields.py | RedisField._reset | def _reset(self, command, *args, **kwargs):
"""
Shortcut for commands that reset values of the field.
All will be deindexed and reindexed.
"""
if self.indexable:
self.deindex()
result = self._traverse_command(command, *args, **kwargs)
if self.indexable... | python | def _reset(self, command, *args, **kwargs):
"""
Shortcut for commands that reset values of the field.
All will be deindexed and reindexed.
"""
if self.indexable:
self.deindex()
result = self._traverse_command(command, *args, **kwargs)
if self.indexable... | [
"def",
"_reset",
"(",
"self",
",",
"command",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"indexable",
":",
"self",
".",
"deindex",
"(",
")",
"result",
"=",
"self",
".",
"_traverse_command",
"(",
"command",
",",
"*",
"ar... | Shortcut for commands that reset values of the field.
All will be deindexed and reindexed. | [
"Shortcut",
"for",
"commands",
"that",
"reset",
"values",
"of",
"the",
"field",
".",
"All",
"will",
"be",
"deindexed",
"and",
"reindexed",
"."
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L616-L626 |
54,123 | limpyd/redis-limpyd | limpyd/fields.py | RedisField._del | def _del(self, command, *args, **kwargs):
"""
Shortcut for commands that remove all values of the field.
All will be deindexed.
"""
if self.indexable:
self.deindex()
return self._traverse_command(command, *args, **kwargs) | python | def _del(self, command, *args, **kwargs):
"""
Shortcut for commands that remove all values of the field.
All will be deindexed.
"""
if self.indexable:
self.deindex()
return self._traverse_command(command, *args, **kwargs) | [
"def",
"_del",
"(",
"self",
",",
"command",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"indexable",
":",
"self",
".",
"deindex",
"(",
")",
"return",
"self",
".",
"_traverse_command",
"(",
"command",
",",
"*",
"args",
",... | Shortcut for commands that remove all values of the field.
All will be deindexed. | [
"Shortcut",
"for",
"commands",
"that",
"remove",
"all",
"values",
"of",
"the",
"field",
".",
"All",
"will",
"be",
"deindexed",
"."
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L640-L647 |
54,124 | limpyd/redis-limpyd | limpyd/fields.py | SingleValueField._call_set | def _call_set(self, command, value, *args, **kwargs):
"""
Helper for commands that only set a value to the field.
"""
if self.indexable:
current = self.proxy_get()
if normalize(current) != normalize(value):
if current is not None:
... | python | def _call_set(self, command, value, *args, **kwargs):
"""
Helper for commands that only set a value to the field.
"""
if self.indexable:
current = self.proxy_get()
if normalize(current) != normalize(value):
if current is not None:
... | [
"def",
"_call_set",
"(",
"self",
",",
"command",
",",
"value",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"indexable",
":",
"current",
"=",
"self",
".",
"proxy_get",
"(",
")",
"if",
"normalize",
"(",
"current",
")",
"!=... | Helper for commands that only set a value to the field. | [
"Helper",
"for",
"commands",
"that",
"only",
"set",
"a",
"value",
"to",
"the",
"field",
"."
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L657-L668 |
54,125 | limpyd/redis-limpyd | limpyd/fields.py | StringField._call_setnx | def _call_setnx(self, command, value):
"""
Index only if value has been set.
"""
result = self._traverse_command(command, value)
if self.indexable and value is not None and result:
self.index(value)
return result | python | def _call_setnx(self, command, value):
"""
Index only if value has been set.
"""
result = self._traverse_command(command, value)
if self.indexable and value is not None and result:
self.index(value)
return result | [
"def",
"_call_setnx",
"(",
"self",
",",
"command",
",",
"value",
")",
":",
"result",
"=",
"self",
".",
"_traverse_command",
"(",
"command",
",",
"value",
")",
"if",
"self",
".",
"indexable",
"and",
"value",
"is",
"not",
"None",
"and",
"result",
":",
"s... | Index only if value has been set. | [
"Index",
"only",
"if",
"value",
"has",
"been",
"set",
"."
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L687-L694 |
54,126 | limpyd/redis-limpyd | limpyd/fields.py | MultiValuesField._add | def _add(self, command, *args, **kwargs):
"""
Shortcut for commands that only add values to the field.
Added values will be indexed.
"""
if self.indexable:
self.index(args)
return self._traverse_command(command, *args, **kwargs) | python | def _add(self, command, *args, **kwargs):
"""
Shortcut for commands that only add values to the field.
Added values will be indexed.
"""
if self.indexable:
self.index(args)
return self._traverse_command(command, *args, **kwargs) | [
"def",
"_add",
"(",
"self",
",",
"command",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"indexable",
":",
"self",
".",
"index",
"(",
"args",
")",
"return",
"self",
".",
"_traverse_command",
"(",
"command",
",",
"*",
"arg... | Shortcut for commands that only add values to the field.
Added values will be indexed. | [
"Shortcut",
"for",
"commands",
"that",
"only",
"add",
"values",
"to",
"the",
"field",
".",
"Added",
"values",
"will",
"be",
"indexed",
"."
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L717-L724 |
54,127 | limpyd/redis-limpyd | limpyd/fields.py | MultiValuesField._rem | def _rem(self, command, *args, **kwargs):
"""
Shortcut for commands that only remove values from the field.
Removed values will be deindexed.
"""
if self.indexable:
self.deindex(args)
return self._traverse_command(command, *args, **kwargs) | python | def _rem(self, command, *args, **kwargs):
"""
Shortcut for commands that only remove values from the field.
Removed values will be deindexed.
"""
if self.indexable:
self.deindex(args)
return self._traverse_command(command, *args, **kwargs) | [
"def",
"_rem",
"(",
"self",
",",
"command",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"indexable",
":",
"self",
".",
"deindex",
"(",
"args",
")",
"return",
"self",
".",
"_traverse_command",
"(",
"command",
",",
"*",
"a... | Shortcut for commands that only remove values from the field.
Removed values will be deindexed. | [
"Shortcut",
"for",
"commands",
"that",
"only",
"remove",
"values",
"from",
"the",
"field",
".",
"Removed",
"values",
"will",
"be",
"deindexed",
"."
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L726-L733 |
54,128 | limpyd/redis-limpyd | limpyd/fields.py | MultiValuesField._pop | def _pop(self, command, *args, **kwargs):
"""
Shortcut for commands that pop a value from the field, returning it while
removing it.
The returned value will be deindexed
"""
result = self._traverse_command(command, *args, **kwargs)
if self.indexable:
s... | python | def _pop(self, command, *args, **kwargs):
"""
Shortcut for commands that pop a value from the field, returning it while
removing it.
The returned value will be deindexed
"""
result = self._traverse_command(command, *args, **kwargs)
if self.indexable:
s... | [
"def",
"_pop",
"(",
"self",
",",
"command",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"self",
".",
"_traverse_command",
"(",
"command",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"self",
".",
"indexable",
":",
... | Shortcut for commands that pop a value from the field, returning it while
removing it.
The returned value will be deindexed | [
"Shortcut",
"for",
"commands",
"that",
"pop",
"a",
"value",
"from",
"the",
"field",
"returning",
"it",
"while",
"removing",
"it",
".",
"The",
"returned",
"value",
"will",
"be",
"deindexed"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L735-L744 |
54,129 | limpyd/redis-limpyd | limpyd/fields.py | MultiValuesField.index | def index(self, values=None, only_index=None):
"""
Index all values stored in the field, or only given ones if any.
"""
assert self.indexable, "Field not indexable"
assert not only_index or self.has_index(only_index), "Invalid index"
if only_index:
only_index ... | python | def index(self, values=None, only_index=None):
"""
Index all values stored in the field, or only given ones if any.
"""
assert self.indexable, "Field not indexable"
assert not only_index or self.has_index(only_index), "Invalid index"
if only_index:
only_index ... | [
"def",
"index",
"(",
"self",
",",
"values",
"=",
"None",
",",
"only_index",
"=",
"None",
")",
":",
"assert",
"self",
".",
"indexable",
",",
"\"Field not indexable\"",
"assert",
"not",
"only_index",
"or",
"self",
".",
"has_index",
"(",
"only_index",
")",
",... | Index all values stored in the field, or only given ones if any. | [
"Index",
"all",
"values",
"stored",
"in",
"the",
"field",
"or",
"only",
"given",
"ones",
"if",
"any",
"."
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L746-L770 |
54,130 | limpyd/redis-limpyd | limpyd/fields.py | SortedSetField._call_zincrby | def _call_zincrby(self, command, value, *args, **kwargs):
"""
This command update a score of a given value. But it can be a new value
of the sorted set, so we index it.
"""
if self.indexable:
self.index([value])
return self._traverse_command(command, value, *a... | python | def _call_zincrby(self, command, value, *args, **kwargs):
"""
This command update a score of a given value. But it can be a new value
of the sorted set, so we index it.
"""
if self.indexable:
self.index([value])
return self._traverse_command(command, value, *a... | [
"def",
"_call_zincrby",
"(",
"self",
",",
"command",
",",
"value",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"indexable",
":",
"self",
".",
"index",
"(",
"[",
"value",
"]",
")",
"return",
"self",
".",
"_traverse_command"... | This command update a score of a given value. But it can be a new value
of the sorted set, so we index it. | [
"This",
"command",
"update",
"a",
"score",
"of",
"a",
"given",
"value",
".",
"But",
"it",
"can",
"be",
"a",
"new",
"value",
"of",
"the",
"sorted",
"set",
"so",
"we",
"index",
"it",
"."
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L876-L883 |
54,131 | limpyd/redis-limpyd | limpyd/fields.py | ListField._pushx | def _pushx(self, command, *args, **kwargs):
"""
Helper for lpushx and rpushx, that only index the new values if the list
existed when the command was called
"""
result = self._traverse_command(command, *args, **kwargs)
if self.indexable and result:
self.index(... | python | def _pushx(self, command, *args, **kwargs):
"""
Helper for lpushx and rpushx, that only index the new values if the list
existed when the command was called
"""
result = self._traverse_command(command, *args, **kwargs)
if self.indexable and result:
self.index(... | [
"def",
"_pushx",
"(",
"self",
",",
"command",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"self",
".",
"_traverse_command",
"(",
"command",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"self",
".",
"indexable",
"and... | Helper for lpushx and rpushx, that only index the new values if the list
existed when the command was called | [
"Helper",
"for",
"lpushx",
"and",
"rpushx",
"that",
"only",
"index",
"the",
"new",
"values",
"if",
"the",
"list",
"existed",
"when",
"the",
"command",
"was",
"called"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L975-L983 |
54,132 | limpyd/redis-limpyd | limpyd/fields.py | ListField._call_lset | def _call_lset(self, command, index, value, *args, **kwargs):
"""
Before setting the new value, get the previous one to deindex it. Then
call the command and index the new value, if exists
"""
if self.indexable:
old_value = self.lindex(index)
self.deindex(... | python | def _call_lset(self, command, index, value, *args, **kwargs):
"""
Before setting the new value, get the previous one to deindex it. Then
call the command and index the new value, if exists
"""
if self.indexable:
old_value = self.lindex(index)
self.deindex(... | [
"def",
"_call_lset",
"(",
"self",
",",
"command",
",",
"index",
",",
"value",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"indexable",
":",
"old_value",
"=",
"self",
".",
"lindex",
"(",
"index",
")",
"self",
".",
"deinde... | Before setting the new value, get the previous one to deindex it. Then
call the command and index the new value, if exists | [
"Before",
"setting",
"the",
"new",
"value",
"get",
"the",
"previous",
"one",
"to",
"deindex",
"it",
".",
"Then",
"call",
"the",
"command",
"and",
"index",
"the",
"new",
"value",
"if",
"exists"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L1001-L1012 |
54,133 | limpyd/redis-limpyd | limpyd/fields.py | HashField.deindex | def deindex(self, values=None, only_index=None):
"""
Deal with dicts and field names.
"""
assert self.indexable, "Field not indexable"
assert not only_index or self.has_index(only_index), "Invalid index"
if only_index:
only_index = only_index if isclass(only_i... | python | def deindex(self, values=None, only_index=None):
"""
Deal with dicts and field names.
"""
assert self.indexable, "Field not indexable"
assert not only_index or self.has_index(only_index), "Invalid index"
if only_index:
only_index = only_index if isclass(only_i... | [
"def",
"deindex",
"(",
"self",
",",
"values",
"=",
"None",
",",
"only_index",
"=",
"None",
")",
":",
"assert",
"self",
".",
"indexable",
",",
"\"Field not indexable\"",
"assert",
"not",
"only_index",
"or",
"self",
".",
"has_index",
"(",
"only_index",
")",
... | Deal with dicts and field names. | [
"Deal",
"with",
"dicts",
"and",
"field",
"names",
"."
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L1112-L1128 |
54,134 | limpyd/redis-limpyd | limpyd/fields.py | InstanceHashField._traverse_command | def _traverse_command(self, name, *args, **kwargs):
"""Add key AND the hash field to the args, and call the Redis command."""
args = list(args)
args.insert(0, self.name)
return super(InstanceHashField, self)._traverse_command(name, *args, **kwargs) | python | def _traverse_command(self, name, *args, **kwargs):
"""Add key AND the hash field to the args, and call the Redis command."""
args = list(args)
args.insert(0, self.name)
return super(InstanceHashField, self)._traverse_command(name, *args, **kwargs) | [
"def",
"_traverse_command",
"(",
"self",
",",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"list",
"(",
"args",
")",
"args",
".",
"insert",
"(",
"0",
",",
"self",
".",
"name",
")",
"return",
"super",
"(",
"InstanceHashF... | Add key AND the hash field to the args, and call the Redis command. | [
"Add",
"key",
"AND",
"the",
"hash",
"field",
"to",
"the",
"args",
"and",
"call",
"the",
"Redis",
"command",
"."
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L1170-L1174 |
54,135 | limpyd/redis-limpyd | limpyd/fields.py | PKField._validate | def _validate(self, value):
"""
Validate that a given new pk to set is always set, and return it.
The returned value should be normalized, and will be used without check.
"""
if value is None:
raise ValueError('The pk for %s is not "auto-increment", you must fill it' ... | python | def _validate(self, value):
"""
Validate that a given new pk to set is always set, and return it.
The returned value should be normalized, and will be used without check.
"""
if value is None:
raise ValueError('The pk for %s is not "auto-increment", you must fill it' ... | [
"def",
"_validate",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'The pk for %s is not \"auto-increment\", you must fill it'",
"%",
"self",
".",
"_model",
".",
"__name__",
")",
"value",
"=",
"self",
".",
"... | Validate that a given new pk to set is always set, and return it.
The returned value should be normalized, and will be used without check. | [
"Validate",
"that",
"a",
"given",
"new",
"pk",
"to",
"set",
"is",
"always",
"set",
"and",
"return",
"it",
".",
"The",
"returned",
"value",
"should",
"be",
"normalized",
"and",
"will",
"be",
"used",
"without",
"check",
"."
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L1234-L1249 |
54,136 | limpyd/redis-limpyd | limpyd/fields.py | PKField.exists | def exists(self, value=None):
"""
Return True if the given pk value exists for the given class.
If no value is given, we use the value of the current field, which
is the value of the "_pk" attribute of its instance.
"""
try:
if not value:
value... | python | def exists(self, value=None):
"""
Return True if the given pk value exists for the given class.
If no value is given, we use the value of the current field, which
is the value of the "_pk" attribute of its instance.
"""
try:
if not value:
value... | [
"def",
"exists",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"try",
":",
"if",
"not",
"value",
":",
"value",
"=",
"self",
".",
"get",
"(",
")",
"except",
"(",
"AttributeError",
",",
"DoesNotExist",
")",
":",
"# If the instance is deleted, the _pk att... | Return True if the given pk value exists for the given class.
If no value is given, we use the value of the current field, which
is the value of the "_pk" attribute of its instance. | [
"Return",
"True",
"if",
"the",
"given",
"pk",
"value",
"exists",
"for",
"the",
"given",
"class",
".",
"If",
"no",
"value",
"is",
"given",
"we",
"use",
"the",
"value",
"of",
"the",
"current",
"field",
"which",
"is",
"the",
"value",
"of",
"the",
"_pk",
... | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L1259-L1274 |
54,137 | limpyd/redis-limpyd | limpyd/fields.py | PKField.get | def get(self):
"""
We do not call the default getter as we have the value cached in the
instance in its _pk attribute
"""
if not hasattr(self, '_instance'):
raise ImplementationError("Impossible to get the PK of an unbound field")
if not hasattr(self._instance... | python | def get(self):
"""
We do not call the default getter as we have the value cached in the
instance in its _pk attribute
"""
if not hasattr(self, '_instance'):
raise ImplementationError("Impossible to get the PK of an unbound field")
if not hasattr(self._instance... | [
"def",
"get",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_instance'",
")",
":",
"raise",
"ImplementationError",
"(",
"\"Impossible to get the PK of an unbound field\"",
")",
"if",
"not",
"hasattr",
"(",
"self",
".",
"_instance",
",",
"'... | We do not call the default getter as we have the value cached in the
instance in its _pk attribute | [
"We",
"do",
"not",
"call",
"the",
"default",
"getter",
"as",
"we",
"have",
"the",
"value",
"cached",
"in",
"the",
"instance",
"in",
"its",
"_pk",
"attribute"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L1309-L1322 |
54,138 | limpyd/redis-limpyd | limpyd/fields.py | AutoPKField._validate | def _validate(self, value):
"""
Validate that a given new pk to set is always set to None, then return
a new pk
"""
if value is not None:
raise ValueError('The pk for %s is "auto-increment", you must not fill it' %
self._model.__name__)
... | python | def _validate(self, value):
"""
Validate that a given new pk to set is always set to None, then return
a new pk
"""
if value is not None:
raise ValueError('The pk for %s is "auto-increment", you must not fill it' %
self._model.__name__)
... | [
"def",
"_validate",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"raise",
"ValueError",
"(",
"'The pk for %s is \"auto-increment\", you must not fill it'",
"%",
"self",
".",
"_model",
".",
"__name__",
")",
"key",
"=",
"self",
"... | Validate that a given new pk to set is always set to None, then return
a new pk | [
"Validate",
"that",
"a",
"given",
"new",
"pk",
"to",
"set",
"is",
"always",
"set",
"to",
"None",
"then",
"return",
"a",
"new",
"pk"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L1336-L1345 |
54,139 | limpyd/redis-limpyd | limpyd/fields.py | FieldLock.acquire | def acquire(self, *args, **kwargs):
"""
Really acquire the lock only if it's not a sub-lock. Then save the
sub-lock status.
"""
if not self.field.lockable:
return
if self.already_locked_by_model:
self.sub_lock_mode = True
return
... | python | def acquire(self, *args, **kwargs):
"""
Really acquire the lock only if it's not a sub-lock. Then save the
sub-lock status.
"""
if not self.field.lockable:
return
if self.already_locked_by_model:
self.sub_lock_mode = True
return
... | [
"def",
"acquire",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"field",
".",
"lockable",
":",
"return",
"if",
"self",
".",
"already_locked_by_model",
":",
"self",
".",
"sub_lock_mode",
"=",
"True",
"return... | Really acquire the lock only if it's not a sub-lock. Then save the
sub-lock status. | [
"Really",
"acquire",
"the",
"lock",
"only",
"if",
"it",
"s",
"not",
"a",
"sub",
"-",
"lock",
".",
"Then",
"save",
"the",
"sub",
"-",
"lock",
"status",
"."
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L1388-L1399 |
54,140 | limpyd/redis-limpyd | limpyd/fields.py | FieldLock.release | def release(self, *args, **kwargs):
"""
Really release the lock only if it's not a sub-lock. Then save the
sub-lock status and mark the model as unlocked.
"""
if not self.field.lockable:
return
if self.sub_lock_mode:
return
super(FieldLock,... | python | def release(self, *args, **kwargs):
"""
Really release the lock only if it's not a sub-lock. Then save the
sub-lock status and mark the model as unlocked.
"""
if not self.field.lockable:
return
if self.sub_lock_mode:
return
super(FieldLock,... | [
"def",
"release",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"field",
".",
"lockable",
":",
"return",
"if",
"self",
".",
"sub_lock_mode",
":",
"return",
"super",
"(",
"FieldLock",
",",
"self",
")",
"... | Really release the lock only if it's not a sub-lock. Then save the
sub-lock status and mark the model as unlocked. | [
"Really",
"release",
"the",
"lock",
"only",
"if",
"it",
"s",
"not",
"a",
"sub",
"-",
"lock",
".",
"Then",
"save",
"the",
"sub",
"-",
"lock",
"status",
"and",
"mark",
"the",
"model",
"as",
"unlocked",
"."
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L1401-L1411 |
54,141 | limpyd/redis-limpyd | limpyd/contrib/indexes.py | MultiIndexes.compose | def compose(cls, index_classes, key=None, transform=None, name=None):
"""Create a new class with the given index classes
Parameters
-----------
index_classes: list
The list of index classes to be used in the multi-index class to create
name: str
The name ... | python | def compose(cls, index_classes, key=None, transform=None, name=None):
"""Create a new class with the given index classes
Parameters
-----------
index_classes: list
The list of index classes to be used in the multi-index class to create
name: str
The name ... | [
"def",
"compose",
"(",
"cls",
",",
"index_classes",
",",
"key",
"=",
"None",
",",
"transform",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"attrs",
"=",
"{",
"}",
"if",
"index_classes",
":",
"attrs",
"[",
"'index_classes'",
"]",
"=",
"index_classe... | Create a new class with the given index classes
Parameters
-----------
index_classes: list
The list of index classes to be used in the multi-index class to create
name: str
The name of the new multi-index class. If not set, it will be the same
as the ... | [
"Create",
"a",
"new",
"class",
"with",
"the",
"given",
"index",
"classes"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/indexes.py#L33-L67 |
54,142 | limpyd/redis-limpyd | limpyd/contrib/indexes.py | MultiIndexes.can_handle_suffix | def can_handle_suffix(self, suffix):
"""Tell if one of the managed indexes can be used for the given filter prefix
For parameters, see BaseIndex.can_handle_suffix
"""
for index in self._indexes:
if index.can_handle_suffix(suffix):
return True
retur... | python | def can_handle_suffix(self, suffix):
"""Tell if one of the managed indexes can be used for the given filter prefix
For parameters, see BaseIndex.can_handle_suffix
"""
for index in self._indexes:
if index.can_handle_suffix(suffix):
return True
retur... | [
"def",
"can_handle_suffix",
"(",
"self",
",",
"suffix",
")",
":",
"for",
"index",
"in",
"self",
".",
"_indexes",
":",
"if",
"index",
".",
"can_handle_suffix",
"(",
"suffix",
")",
":",
"return",
"True",
"return",
"False"
] | Tell if one of the managed indexes can be used for the given filter prefix
For parameters, see BaseIndex.can_handle_suffix | [
"Tell",
"if",
"one",
"of",
"the",
"managed",
"indexes",
"can",
"be",
"used",
"for",
"the",
"given",
"filter",
"prefix"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/indexes.py#L81-L91 |
54,143 | limpyd/redis-limpyd | limpyd/contrib/indexes.py | MultiIndexes.prepare_args | def prepare_args(self, args, transform=True):
"""Prepare args to be used by a sub-index
Parameters
----------
args: list
The while list of arguments passed to add, check_uniqueness, get_filtered_keys...
transform: bool
If ``True``, the last entry in `args... | python | def prepare_args(self, args, transform=True):
"""Prepare args to be used by a sub-index
Parameters
----------
args: list
The while list of arguments passed to add, check_uniqueness, get_filtered_keys...
transform: bool
If ``True``, the last entry in `args... | [
"def",
"prepare_args",
"(",
"self",
",",
"args",
",",
"transform",
"=",
"True",
")",
":",
"updated_args",
"=",
"list",
"(",
"args",
")",
"if",
"transform",
":",
"updated_args",
"[",
"-",
"1",
"]",
"=",
"self",
".",
"transform_value",
"(",
"updated_args",... | Prepare args to be used by a sub-index
Parameters
----------
args: list
The while list of arguments passed to add, check_uniqueness, get_filtered_keys...
transform: bool
If ``True``, the last entry in `args`, ie the value, will be transformed.
Else it... | [
"Prepare",
"args",
"to",
"be",
"used",
"by",
"a",
"sub",
"-",
"index"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/indexes.py#L144-L162 |
54,144 | limpyd/redis-limpyd | limpyd/contrib/indexes.py | MultiIndexes.check_uniqueness | def check_uniqueness(self, *args):
"""For a unique index, check if the given args are not used twice
For the parameters, seen BaseIndex.check_uniqueness
"""
self.get_unique_index().check_uniqueness(*self.prepare_args(args, transform=False)) | python | def check_uniqueness(self, *args):
"""For a unique index, check if the given args are not used twice
For the parameters, seen BaseIndex.check_uniqueness
"""
self.get_unique_index().check_uniqueness(*self.prepare_args(args, transform=False)) | [
"def",
"check_uniqueness",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"get_unique_index",
"(",
")",
".",
"check_uniqueness",
"(",
"*",
"self",
".",
"prepare_args",
"(",
"args",
",",
"transform",
"=",
"False",
")",
")"
] | For a unique index, check if the given args are not used twice
For the parameters, seen BaseIndex.check_uniqueness | [
"For",
"a",
"unique",
"index",
"check",
"if",
"the",
"given",
"args",
"are",
"not",
"used",
"twice"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/indexes.py#L164-L170 |
54,145 | limpyd/redis-limpyd | limpyd/contrib/indexes.py | MultiIndexes.add | def add(self, *args, **kwargs):
"""Add the instance tied to the field to all the indexes
For the parameters, seen BaseIndex.add
"""
check_uniqueness = kwargs.pop('check_uniqueness', False)
args = self.prepare_args(args)
for index in self._indexes:
index.ad... | python | def add(self, *args, **kwargs):
"""Add the instance tied to the field to all the indexes
For the parameters, seen BaseIndex.add
"""
check_uniqueness = kwargs.pop('check_uniqueness', False)
args = self.prepare_args(args)
for index in self._indexes:
index.ad... | [
"def",
"add",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"check_uniqueness",
"=",
"kwargs",
".",
"pop",
"(",
"'check_uniqueness'",
",",
"False",
")",
"args",
"=",
"self",
".",
"prepare_args",
"(",
"args",
")",
"for",
"index",
"... | Add the instance tied to the field to all the indexes
For the parameters, seen BaseIndex.add | [
"Add",
"the",
"instance",
"tied",
"to",
"the",
"field",
"to",
"all",
"the",
"indexes"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/indexes.py#L172-L185 |
54,146 | limpyd/redis-limpyd | limpyd/contrib/indexes.py | MultiIndexes.remove | def remove(self, *args):
"""Remove the instance tied to the field from all the indexes
For the parameters, seen BaseIndex.remove
"""
args = self.prepare_args(args)
for index in self._indexes:
index.remove(*args) | python | def remove(self, *args):
"""Remove the instance tied to the field from all the indexes
For the parameters, seen BaseIndex.remove
"""
args = self.prepare_args(args)
for index in self._indexes:
index.remove(*args) | [
"def",
"remove",
"(",
"self",
",",
"*",
"args",
")",
":",
"args",
"=",
"self",
".",
"prepare_args",
"(",
"args",
")",
"for",
"index",
"in",
"self",
".",
"_indexes",
":",
"index",
".",
"remove",
"(",
"*",
"args",
")"
] | Remove the instance tied to the field from all the indexes
For the parameters, seen BaseIndex.remove | [
"Remove",
"the",
"instance",
"tied",
"to",
"the",
"field",
"from",
"all",
"the",
"indexes"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/indexes.py#L187-L197 |
54,147 | limpyd/redis-limpyd | limpyd/contrib/indexes.py | MultiIndexes.get_filtered_keys | def get_filtered_keys(self, suffix, *args, **kwargs):
"""Returns the index keys to be used by the collection for the given args
For the parameters, see BaseIndex.get_filtered_keys
"""
args = self.prepare_args(args, transform=False)
for index in self._indexes:
if i... | python | def get_filtered_keys(self, suffix, *args, **kwargs):
"""Returns the index keys to be used by the collection for the given args
For the parameters, see BaseIndex.get_filtered_keys
"""
args = self.prepare_args(args, transform=False)
for index in self._indexes:
if i... | [
"def",
"get_filtered_keys",
"(",
"self",
",",
"suffix",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"self",
".",
"prepare_args",
"(",
"args",
",",
"transform",
"=",
"False",
")",
"for",
"index",
"in",
"self",
".",
"_indexes",
":... | Returns the index keys to be used by the collection for the given args
For the parameters, see BaseIndex.get_filtered_keys | [
"Returns",
"the",
"index",
"keys",
"to",
"be",
"used",
"by",
"the",
"collection",
"for",
"the",
"given",
"args"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/indexes.py#L199-L210 |
54,148 | limpyd/redis-limpyd | limpyd/indexes.py | BaseIndex.configure | def configure(cls, **kwargs):
"""Create a new index class with the given info
This allow to avoid creating a new class when only few changes are
to be made
Parameters
----------
kwargs: dict
prefix: str
The string part to use in the collectio... | python | def configure(cls, **kwargs):
"""Create a new index class with the given info
This allow to avoid creating a new class when only few changes are
to be made
Parameters
----------
kwargs: dict
prefix: str
The string part to use in the collectio... | [
"def",
"configure",
"(",
"cls",
",",
"*",
"*",
"kwargs",
")",
":",
"attrs",
"=",
"{",
"}",
"for",
"key",
"in",
"(",
"'prefix'",
",",
"'handle_uniqueness'",
",",
"'key'",
")",
":",
"if",
"key",
"in",
"kwargs",
":",
"attrs",
"[",
"key",
"]",
"=",
"... | Create a new index class with the given info
This allow to avoid creating a new class when only few changes are
to be made
Parameters
----------
kwargs: dict
prefix: str
The string part to use in the collection, before the normal suffix.
... | [
"Create",
"a",
"new",
"index",
"class",
"with",
"the",
"given",
"info"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/indexes.py#L56-L111 |
54,149 | limpyd/redis-limpyd | limpyd/indexes.py | BaseIndex.can_handle_suffix | def can_handle_suffix(self, suffix):
"""Tell if the current index can be used for the given filter suffix
Parameters
----------
suffix: str
The filter suffix we want to check. Must not includes the "__" part.
Returns
-------
bool
``True``... | python | def can_handle_suffix(self, suffix):
"""Tell if the current index can be used for the given filter suffix
Parameters
----------
suffix: str
The filter suffix we want to check. Must not includes the "__" part.
Returns
-------
bool
``True``... | [
"def",
"can_handle_suffix",
"(",
"self",
",",
"suffix",
")",
":",
"try",
":",
"return",
"self",
".",
"remove_prefix",
"(",
"suffix",
")",
"in",
"self",
".",
"handled_suffixes",
"except",
"IndexError",
":",
"return",
"False"
] | Tell if the current index can be used for the given filter suffix
Parameters
----------
suffix: str
The filter suffix we want to check. Must not includes the "__" part.
Returns
-------
bool
``True`` if the index can handle this suffix, ``False`` ... | [
"Tell",
"if",
"the",
"current",
"index",
"can",
"be",
"used",
"for",
"the",
"given",
"filter",
"suffix"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/indexes.py#L113-L130 |
54,150 | limpyd/redis-limpyd | limpyd/indexes.py | BaseIndex.transform_value | def transform_value(self, value):
"""Convert the value to be stored.
This does nothing by default but subclasses can change this.
Then the index will be able to filter on the transformed value.
For example if the transform capitalizes some text, the filter
would be ``myfield__ca... | python | def transform_value(self, value):
"""Convert the value to be stored.
This does nothing by default but subclasses can change this.
Then the index will be able to filter on the transformed value.
For example if the transform capitalizes some text, the filter
would be ``myfield__ca... | [
"def",
"transform_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"self",
".",
"transform",
":",
"return",
"value",
"try",
":",
"# we store a staticmethod but we accept a method taking `self` and `value`",
"return",
"self",
".",
"transform",
"(",
"self",
"... | Convert the value to be stored.
This does nothing by default but subclasses can change this.
Then the index will be able to filter on the transformed value.
For example if the transform capitalizes some text, the filter
would be ``myfield__capitalized__eq='FOO'`` | [
"Convert",
"the",
"value",
"to",
"be",
"stored",
"."
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/indexes.py#L157-L174 |
54,151 | limpyd/redis-limpyd | limpyd/indexes.py | BaseIndex.remove_prefix | def remove_prefix(cls, suffix):
""""Remove the class prefix from the suffix
The collection pass the full suffix used in the filters to the index.
But to know if it is valid, we have to remove the prefix to get the
real suffix, for example to check if the suffix is handled by the index.
... | python | def remove_prefix(cls, suffix):
""""Remove the class prefix from the suffix
The collection pass the full suffix used in the filters to the index.
But to know if it is valid, we have to remove the prefix to get the
real suffix, for example to check if the suffix is handled by the index.
... | [
"def",
"remove_prefix",
"(",
"cls",
",",
"suffix",
")",
":",
"if",
"not",
"cls",
".",
"prefix",
":",
"return",
"suffix",
"if",
"cls",
".",
"prefix",
"==",
"suffix",
":",
"return",
"None",
"return",
"(",
"suffix",
"or",
"''",
")",
".",
"split",
"(",
... | Remove the class prefix from the suffix
The collection pass the full suffix used in the filters to the index.
But to know if it is valid, we have to remove the prefix to get the
real suffix, for example to check if the suffix is handled by the index.
Parameters
-----------
... | [
"Remove",
"the",
"class",
"prefix",
"from",
"the",
"suffix"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/indexes.py#L177-L205 |
54,152 | limpyd/redis-limpyd | limpyd/indexes.py | BaseIndex.attached_to_model | def attached_to_model(self):
"""Tells if the current index is the one attached to the model field, not instance field"""
try:
if not bool(self.model):
return False
except AttributeError:
return False
else:
try:
return no... | python | def attached_to_model(self):
"""Tells if the current index is the one attached to the model field, not instance field"""
try:
if not bool(self.model):
return False
except AttributeError:
return False
else:
try:
return no... | [
"def",
"attached_to_model",
"(",
"self",
")",
":",
"try",
":",
"if",
"not",
"bool",
"(",
"self",
".",
"model",
")",
":",
"return",
"False",
"except",
"AttributeError",
":",
"return",
"False",
"else",
":",
"try",
":",
"return",
"not",
"bool",
"(",
"self... | Tells if the current index is the one attached to the model field, not instance field | [
"Tells",
"if",
"the",
"current",
"index",
"is",
"the",
"one",
"attached",
"to",
"the",
"model",
"field",
"not",
"instance",
"field"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/indexes.py#L218-L229 |
54,153 | limpyd/redis-limpyd | limpyd/indexes.py | BaseIndex._rollback | def _rollback(self):
"""Restore the index in its previous state
This uses values that were indexed/deindexed since the last call
to `_reset_cache`.
This is used when an error is encountered while updating a value,
to return to the previous state
"""
# to avoid u... | python | def _rollback(self):
"""Restore the index in its previous state
This uses values that were indexed/deindexed since the last call
to `_reset_cache`.
This is used when an error is encountered while updating a value,
to return to the previous state
"""
# to avoid u... | [
"def",
"_rollback",
"(",
"self",
")",
":",
"# to avoid using self set that may be updated during the process",
"indexed_values",
"=",
"set",
"(",
"self",
".",
"_indexed_values",
")",
"deindexed_values",
"=",
"set",
"(",
"self",
".",
"_deindexed_values",
")",
"for",
"a... | Restore the index in its previous state
This uses values that were indexed/deindexed since the last call
to `_reset_cache`.
This is used when an error is encountered while updating a value,
to return to the previous state | [
"Restore",
"the",
"index",
"in",
"its",
"previous",
"state"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/indexes.py#L241-L257 |
54,154 | limpyd/redis-limpyd | limpyd/indexes.py | BaseIndex.assert_pks_uniqueness | def assert_pks_uniqueness(self, pks, exclude, value):
"""Check uniqueness of pks
Parameters
-----------
pks: iterable
The pks to check for uniqueness. If more than one different,
it will raise. If only one and different than `exclude`, it will
raise t... | python | def assert_pks_uniqueness(self, pks, exclude, value):
"""Check uniqueness of pks
Parameters
-----------
pks: iterable
The pks to check for uniqueness. If more than one different,
it will raise. If only one and different than `exclude`, it will
raise t... | [
"def",
"assert_pks_uniqueness",
"(",
"self",
",",
"pks",
",",
"exclude",
",",
"value",
")",
":",
"pks",
"=",
"list",
"(",
"set",
"(",
"pks",
")",
")",
"if",
"len",
"(",
"pks",
")",
">",
"1",
":",
"# this may not happen !",
"raise",
"UniquenessError",
"... | Check uniqueness of pks
Parameters
-----------
pks: iterable
The pks to check for uniqueness. If more than one different,
it will raise. If only one and different than `exclude`, it will
raise too.
exclude: str
The pk that we accept to be ... | [
"Check",
"uniqueness",
"of",
"pks"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/indexes.py#L321-L358 |
54,155 | limpyd/redis-limpyd | limpyd/indexes.py | BaseIndex.clear | def clear(self, chunk_size=1000, aggressive=False):
"""Will deindex all the value for the current field
Parameters
----------
chunk_size: int
Default to 1000, it's the number of instances to load at once if not in aggressive mode.
aggressive: bool
Default... | python | def clear(self, chunk_size=1000, aggressive=False):
"""Will deindex all the value for the current field
Parameters
----------
chunk_size: int
Default to 1000, it's the number of instances to load at once if not in aggressive mode.
aggressive: bool
Default... | [
"def",
"clear",
"(",
"self",
",",
"chunk_size",
"=",
"1000",
",",
"aggressive",
"=",
"False",
")",
":",
"assert",
"self",
".",
"attached_to_model",
",",
"'`clear` can only be called on an index attached to the model field'",
"if",
"aggressive",
":",
"keys",
"=",
"se... | Will deindex all the value for the current field
Parameters
----------
chunk_size: int
Default to 1000, it's the number of instances to load at once if not in aggressive mode.
aggressive: bool
Default to ``False``. When ``False``, the actual collection of instanc... | [
"Will",
"deindex",
"all",
"the",
"value",
"for",
"the",
"current",
"field"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/indexes.py#L403-L452 |
54,156 | limpyd/redis-limpyd | limpyd/indexes.py | BaseIndex.rebuild | def rebuild(self, chunk_size=1000, aggressive_clear=False):
"""Rebuild the whole index for this field.
Parameters
----------
chunk_size: int
Default to 1000, it's the number of instances to load at once.
aggressive_clear: bool
Will be passed to the `aggre... | python | def rebuild(self, chunk_size=1000, aggressive_clear=False):
"""Rebuild the whole index for this field.
Parameters
----------
chunk_size: int
Default to 1000, it's the number of instances to load at once.
aggressive_clear: bool
Will be passed to the `aggre... | [
"def",
"rebuild",
"(",
"self",
",",
"chunk_size",
"=",
"1000",
",",
"aggressive_clear",
"=",
"False",
")",
":",
"assert",
"self",
".",
"attached_to_model",
",",
"'`rebuild` can only be called on an index attached to the model field'",
"self",
".",
"clear",
"(",
"chunk... | Rebuild the whole index for this field.
Parameters
----------
chunk_size: int
Default to 1000, it's the number of instances to load at once.
aggressive_clear: bool
Will be passed to the `aggressive` argument of the `clear` method.
If `False`, all valu... | [
"Rebuild",
"the",
"whole",
"index",
"for",
"this",
"field",
"."
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/indexes.py#L454-L489 |
54,157 | limpyd/redis-limpyd | limpyd/indexes.py | TextRangeIndex.prepare_value_for_storage | def prepare_value_for_storage(self, value, pk):
"""Prepare the value to be stored in the zset
We'll store the value and pk concatenated.
For the parameters, see BaseRangeIndex.prepare_value_for_storage
"""
value = super(TextRangeIndex, self).prepare_value_for_storage(value, pk)... | python | def prepare_value_for_storage(self, value, pk):
"""Prepare the value to be stored in the zset
We'll store the value and pk concatenated.
For the parameters, see BaseRangeIndex.prepare_value_for_storage
"""
value = super(TextRangeIndex, self).prepare_value_for_storage(value, pk)... | [
"def",
"prepare_value_for_storage",
"(",
"self",
",",
"value",
",",
"pk",
")",
":",
"value",
"=",
"super",
"(",
"TextRangeIndex",
",",
"self",
")",
".",
"prepare_value_for_storage",
"(",
"value",
",",
"pk",
")",
"return",
"self",
".",
"separator",
".",
"jo... | Prepare the value to be stored in the zset
We'll store the value and pk concatenated.
For the parameters, see BaseRangeIndex.prepare_value_for_storage | [
"Prepare",
"the",
"value",
"to",
"be",
"stored",
"in",
"the",
"zset"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/indexes.py#L1102-L1110 |
54,158 | limpyd/redis-limpyd | limpyd/indexes.py | TextRangeIndex._extract_value_from_storage | def _extract_value_from_storage(self, string):
"""Taking a string that was a member of the zset, extract the value and pk
Parameters
----------
string: str
The member extracted from the sorted set
Returns
-------
tuple
Tuple with the valu... | python | def _extract_value_from_storage(self, string):
"""Taking a string that was a member of the zset, extract the value and pk
Parameters
----------
string: str
The member extracted from the sorted set
Returns
-------
tuple
Tuple with the valu... | [
"def",
"_extract_value_from_storage",
"(",
"self",
",",
"string",
")",
":",
"parts",
"=",
"string",
".",
"split",
"(",
"self",
".",
"separator",
")",
"pk",
"=",
"parts",
".",
"pop",
"(",
")",
"return",
"self",
".",
"separator",
".",
"join",
"(",
"parts... | Taking a string that was a member of the zset, extract the value and pk
Parameters
----------
string: str
The member extracted from the sorted set
Returns
-------
tuple
Tuple with the value and the pk, extracted from the string | [
"Taking",
"a",
"string",
"that",
"was",
"a",
"member",
"of",
"the",
"zset",
"extract",
"the",
"value",
"and",
"pk"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/indexes.py#L1112-L1128 |
54,159 | limpyd/redis-limpyd | limpyd/indexes.py | TextRangeIndex.get_boundaries | def get_boundaries(self, filter_type, value):
"""Compute the boundaries to pass to zrangebylex depending of the filter type
The third return value, ``exclude`` is ``None`` except for the filters
`lt` and `gt` because we cannot explicitly exclude it when
querying the sorted-set
... | python | def get_boundaries(self, filter_type, value):
"""Compute the boundaries to pass to zrangebylex depending of the filter type
The third return value, ``exclude`` is ``None`` except for the filters
`lt` and `gt` because we cannot explicitly exclude it when
querying the sorted-set
... | [
"def",
"get_boundaries",
"(",
"self",
",",
"filter_type",
",",
"value",
")",
":",
"assert",
"filter_type",
"in",
"self",
".",
"handled_suffixes",
"start",
"=",
"'-'",
"end",
"=",
"'+'",
"exclude",
"=",
"None",
"if",
"filter_type",
"in",
"(",
"None",
",",
... | Compute the boundaries to pass to zrangebylex depending of the filter type
The third return value, ``exclude`` is ``None`` except for the filters
`lt` and `gt` because we cannot explicitly exclude it when
querying the sorted-set
For the parameters, see BaseRangeIndex.store
No... | [
"Compute",
"the",
"boundaries",
"to",
"pass",
"to",
"zrangebylex",
"depending",
"of",
"the",
"filter",
"type"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/indexes.py#L1151-L1206 |
54,160 | limpyd/redis-limpyd | limpyd/indexes.py | NumberRangeIndex.get_boundaries | def get_boundaries(self, filter_type, value):
"""Compute the boundaries to pass to the sorted-set command depending of the filter type
The third return value, ``exclude`` is always ``None`` because we can easily restrict the
score to filter on in the sorted-set.
For the parameters, see... | python | def get_boundaries(self, filter_type, value):
"""Compute the boundaries to pass to the sorted-set command depending of the filter type
The third return value, ``exclude`` is always ``None`` because we can easily restrict the
score to filter on in the sorted-set.
For the parameters, see... | [
"def",
"get_boundaries",
"(",
"self",
",",
"filter_type",
",",
"value",
")",
":",
"assert",
"filter_type",
"in",
"self",
".",
"handled_suffixes",
"start",
"=",
"'-inf'",
"end",
"=",
"'+inf'",
"exclude",
"=",
"None",
"if",
"filter_type",
"in",
"(",
"None",
... | Compute the boundaries to pass to the sorted-set command depending of the filter type
The third return value, ``exclude`` is always ``None`` because we can easily restrict the
score to filter on in the sorted-set.
For the parameters, see BaseRangeIndex.store
Notes
-----
... | [
"Compute",
"the",
"boundaries",
"to",
"pass",
"to",
"the",
"sorted",
"-",
"set",
"command",
"depending",
"of",
"the",
"filter",
"type"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/indexes.py#L1334-L1372 |
54,161 | olt/scriptine | doc/example_hello.py | hello_command | def hello_command(name, print_counter=False, repeat=10):
"""Print nice greetings."""
for i in range(repeat):
if print_counter:
print i+1,
print 'Hello, %s!' % name | python | def hello_command(name, print_counter=False, repeat=10):
"""Print nice greetings."""
for i in range(repeat):
if print_counter:
print i+1,
print 'Hello, %s!' % name | [
"def",
"hello_command",
"(",
"name",
",",
"print_counter",
"=",
"False",
",",
"repeat",
"=",
"10",
")",
":",
"for",
"i",
"in",
"range",
"(",
"repeat",
")",
":",
"if",
"print_counter",
":",
"print",
"i",
"+",
"1",
",",
"print",
"'Hello, %s!'",
"%",
"n... | Print nice greetings. | [
"Print",
"nice",
"greetings",
"."
] | f4cfea939f2f3ad352b24c5f6410f79e78723d0e | https://github.com/olt/scriptine/blob/f4cfea939f2f3ad352b24c5f6410f79e78723d0e/doc/example_hello.py#L3-L8 |
54,162 | phareous/insteonlocal | insteonlocal/Group.py | Group.scene_command | def scene_command(self, command):
"""Wrapper to send posted scene command and get response"""
self.logger.info("scene_command: Group %s Command %s", self.group_id, command)
command_url = self.hub.hub_url + '/0?' + command + self.group_id + "=I=0"
return self.hub.post_direct_command(comma... | python | def scene_command(self, command):
"""Wrapper to send posted scene command and get response"""
self.logger.info("scene_command: Group %s Command %s", self.group_id, command)
command_url = self.hub.hub_url + '/0?' + command + self.group_id + "=I=0"
return self.hub.post_direct_command(comma... | [
"def",
"scene_command",
"(",
"self",
",",
"command",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"scene_command: Group %s Command %s\"",
",",
"self",
".",
"group_id",
",",
"command",
")",
"command_url",
"=",
"self",
".",
"hub",
".",
"hub_url",
"+",
... | Wrapper to send posted scene command and get response | [
"Wrapper",
"to",
"send",
"posted",
"scene",
"command",
"and",
"get",
"response"
] | a4544a17d143fb285852cb873e862c270d55dd00 | https://github.com/phareous/insteonlocal/blob/a4544a17d143fb285852cb873e862c270d55dd00/insteonlocal/Group.py#L58-L62 |
54,163 | phareous/insteonlocal | insteonlocal/Group.py | Group.enter_unlink_mode | def enter_unlink_mode(self):
"""Enter unlinking mode for a group"""
self.logger.info("enter_unlink_mode Group %s", self.group_id)
self.scene_command('0A')
# should send http://0.0.0.0/0?0A01=I=0
## TODO check return status
status = self.hub.get_buffer_status()
re... | python | def enter_unlink_mode(self):
"""Enter unlinking mode for a group"""
self.logger.info("enter_unlink_mode Group %s", self.group_id)
self.scene_command('0A')
# should send http://0.0.0.0/0?0A01=I=0
## TODO check return status
status = self.hub.get_buffer_status()
re... | [
"def",
"enter_unlink_mode",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"enter_unlink_mode Group %s\"",
",",
"self",
".",
"group_id",
")",
"self",
".",
"scene_command",
"(",
"'0A'",
")",
"# should send http://0.0.0.0/0?0A01=I=0",
"## TODO check... | Enter unlinking mode for a group | [
"Enter",
"unlinking",
"mode",
"for",
"a",
"group"
] | a4544a17d143fb285852cb873e862c270d55dd00 | https://github.com/phareous/insteonlocal/blob/a4544a17d143fb285852cb873e862c270d55dd00/insteonlocal/Group.py#L77-L85 |
54,164 | phareous/insteonlocal | insteonlocal/Group.py | Group.cancel_link_unlink_mode | def cancel_link_unlink_mode(self):
"""Cancel linking or unlinking mode"""
self.logger.info("cancel_link_unlink_mode")
self.scene_command('08')
# should send http://0.0.0.0/0?08=I=0
## TODO check return status
status = self.hub.get_buffer_status()
return status | python | def cancel_link_unlink_mode(self):
"""Cancel linking or unlinking mode"""
self.logger.info("cancel_link_unlink_mode")
self.scene_command('08')
# should send http://0.0.0.0/0?08=I=0
## TODO check return status
status = self.hub.get_buffer_status()
return status | [
"def",
"cancel_link_unlink_mode",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"cancel_link_unlink_mode\"",
")",
"self",
".",
"scene_command",
"(",
"'08'",
")",
"# should send http://0.0.0.0/0?08=I=0",
"## TODO check return status",
"status",
"=",
... | Cancel linking or unlinking mode | [
"Cancel",
"linking",
"or",
"unlinking",
"mode"
] | a4544a17d143fb285852cb873e862c270d55dd00 | https://github.com/phareous/insteonlocal/blob/a4544a17d143fb285852cb873e862c270d55dd00/insteonlocal/Group.py#L88-L96 |
54,165 | limpyd/redis-limpyd | limpyd/contrib/collection.py | ExtendedCollectionManager._list_to_set | def _list_to_set(self, list_key, set_key):
"""
Store all content of the given ListField in a redis set.
Use scripting if available to avoid retrieving all values locally from
the list before sending them back to the set
"""
if self.cls.database.support_scripting():
... | python | def _list_to_set(self, list_key, set_key):
"""
Store all content of the given ListField in a redis set.
Use scripting if available to avoid retrieving all values locally from
the list before sending them back to the set
"""
if self.cls.database.support_scripting():
... | [
"def",
"_list_to_set",
"(",
"self",
",",
"list_key",
",",
"set_key",
")",
":",
"if",
"self",
".",
"cls",
".",
"database",
".",
"support_scripting",
"(",
")",
":",
"self",
".",
"cls",
".",
"database",
".",
"call_script",
"(",
"# be sure to use the script dict... | Store all content of the given ListField in a redis set.
Use scripting if available to avoid retrieving all values locally from
the list before sending them back to the set | [
"Store",
"all",
"content",
"of",
"the",
"given",
"ListField",
"in",
"a",
"redis",
"set",
".",
"Use",
"scripting",
"if",
"available",
"to",
"avoid",
"retrieving",
"all",
"values",
"locally",
"from",
"the",
"list",
"before",
"sending",
"them",
"back",
"to",
... | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/collection.py#L56-L71 |
54,166 | limpyd/redis-limpyd | limpyd/contrib/collection.py | ExtendedCollectionManager._collection | def _collection(self):
"""
Effectively retrieve data according to lazy_collection.
If we have a stored collection, without any result, return an empty list
"""
old_sort_limits_and_len_mode = None if self._sort_limits is None else self._sort_limits.copy(), self._len_mode
o... | python | def _collection(self):
"""
Effectively retrieve data according to lazy_collection.
If we have a stored collection, without any result, return an empty list
"""
old_sort_limits_and_len_mode = None if self._sort_limits is None else self._sort_limits.copy(), self._len_mode
o... | [
"def",
"_collection",
"(",
"self",
")",
":",
"old_sort_limits_and_len_mode",
"=",
"None",
"if",
"self",
".",
"_sort_limits",
"is",
"None",
"else",
"self",
".",
"_sort_limits",
".",
"copy",
"(",
")",
",",
"self",
".",
"_len_mode",
"old_sorts",
"=",
"None",
... | Effectively retrieve data according to lazy_collection.
If we have a stored collection, without any result, return an empty list | [
"Effectively",
"retrieve",
"data",
"according",
"to",
"lazy_collection",
".",
"If",
"we",
"have",
"a",
"stored",
"collection",
"without",
"any",
"result",
"return",
"an",
"empty",
"list"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/collection.py#L74-L98 |
54,167 | limpyd/redis-limpyd | limpyd/contrib/collection.py | ExtendedCollectionManager._prepare_sets | def _prepare_sets(self, sets):
"""
The original "_prepare_sets" method simple return the list of sets in
_lazy_collection, know to be all keys of redis sets.
As the new "intersect" method can accept different types of "set", we
have to handle them because we must return only keys... | python | def _prepare_sets(self, sets):
"""
The original "_prepare_sets" method simple return the list of sets in
_lazy_collection, know to be all keys of redis sets.
As the new "intersect" method can accept different types of "set", we
have to handle them because we must return only keys... | [
"def",
"_prepare_sets",
"(",
"self",
",",
"sets",
")",
":",
"if",
"self",
".",
"stored_key",
"and",
"not",
"self",
".",
"stored_key_exists",
"(",
")",
":",
"raise",
"DoesNotExist",
"(",
"'This collection is based on a previous one, '",
"'stored at a key that does not ... | The original "_prepare_sets" method simple return the list of sets in
_lazy_collection, know to be all keys of redis sets.
As the new "intersect" method can accept different types of "set", we
have to handle them because we must return only keys of redis sets. | [
"The",
"original",
"_prepare_sets",
"method",
"simple",
"return",
"the",
"list",
"of",
"sets",
"in",
"_lazy_collection",
"know",
"to",
"be",
"all",
"keys",
"of",
"redis",
"sets",
".",
"As",
"the",
"new",
"intersect",
"method",
"can",
"accept",
"different",
"... | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/collection.py#L100-L196 |
54,168 | limpyd/redis-limpyd | limpyd/contrib/collection.py | ExtendedCollectionManager._combine_sets | def _combine_sets(self, sets, final_set):
"""
Given a list of set, combine them to create the final set that will be
used to make the final redis call.
If we have a least a sorted set, use zinterstore insted of sunionstore
"""
if self._has_sortedsets:
self.cls... | python | def _combine_sets(self, sets, final_set):
"""
Given a list of set, combine them to create the final set that will be
used to make the final redis call.
If we have a least a sorted set, use zinterstore insted of sunionstore
"""
if self._has_sortedsets:
self.cls... | [
"def",
"_combine_sets",
"(",
"self",
",",
"sets",
",",
"final_set",
")",
":",
"if",
"self",
".",
"_has_sortedsets",
":",
"self",
".",
"cls",
".",
"get_connection",
"(",
")",
".",
"zinterstore",
"(",
"final_set",
",",
"list",
"(",
"sets",
")",
")",
"els... | Given a list of set, combine them to create the final set that will be
used to make the final redis call.
If we have a least a sorted set, use zinterstore insted of sunionstore | [
"Given",
"a",
"list",
"of",
"set",
"combine",
"them",
"to",
"create",
"the",
"final",
"set",
"that",
"will",
"be",
"used",
"to",
"make",
"the",
"final",
"redis",
"call",
".",
"If",
"we",
"have",
"a",
"least",
"a",
"sorted",
"set",
"use",
"zinterstore",... | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/collection.py#L240-L250 |
54,169 | limpyd/redis-limpyd | limpyd/contrib/collection.py | ExtendedCollectionManager._final_redis_call | def _final_redis_call(self, final_set, sort_options):
"""
The final redis call to obtain the values to return from the "final_set"
with some sort options.
IIf we have at leaset a sorted set and if we don't have any sort
options, call zrange on the final set wich is the result of ... | python | def _final_redis_call(self, final_set, sort_options):
"""
The final redis call to obtain the values to return from the "final_set"
with some sort options.
IIf we have at leaset a sorted set and if we don't have any sort
options, call zrange on the final set wich is the result of ... | [
"def",
"_final_redis_call",
"(",
"self",
",",
"final_set",
",",
"sort_options",
")",
":",
"conn",
"=",
"self",
".",
"cls",
".",
"get_connection",
"(",
")",
"# we have a sorted set without need to sort, use zrange",
"if",
"self",
".",
"_has_sortedsets",
"and",
"sort_... | The final redis call to obtain the values to return from the "final_set"
with some sort options.
IIf we have at leaset a sorted set and if we don't have any sort
options, call zrange on the final set wich is the result of a call to
zinterstore. | [
"The",
"final",
"redis",
"call",
"to",
"obtain",
"the",
"values",
"to",
"return",
"from",
"the",
"final_set",
"with",
"some",
"sort",
"options",
".",
"IIf",
"we",
"have",
"at",
"leaset",
"a",
"sorted",
"set",
"and",
"if",
"we",
"don",
"t",
"have",
"any... | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/collection.py#L252-L277 |
54,170 | limpyd/redis-limpyd | limpyd/contrib/collection.py | ExtendedCollectionManager._collection_length | def _collection_length(self, final_set):
"""
Return the length of the final collection, directly asking redis for the
count without calling sort
"""
conn = self.cls.get_connection()
# we have a sorted set without need to sort, use zcard
if self._has_sortedsets:
... | python | def _collection_length(self, final_set):
"""
Return the length of the final collection, directly asking redis for the
count without calling sort
"""
conn = self.cls.get_connection()
# we have a sorted set without need to sort, use zcard
if self._has_sortedsets:
... | [
"def",
"_collection_length",
"(",
"self",
",",
"final_set",
")",
":",
"conn",
"=",
"self",
".",
"cls",
".",
"get_connection",
"(",
")",
"# we have a sorted set without need to sort, use zcard",
"if",
"self",
".",
"_has_sortedsets",
":",
"return",
"conn",
".",
"zca... | Return the length of the final collection, directly asking redis for the
count without calling sort | [
"Return",
"the",
"length",
"of",
"the",
"final",
"collection",
"directly",
"asking",
"redis",
"for",
"the",
"count",
"without",
"calling",
"sort"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/collection.py#L279-L297 |
54,171 | limpyd/redis-limpyd | limpyd/contrib/collection.py | ExtendedCollectionManager._prepare_sort_by_score | def _prepare_sort_by_score(self, values, sort_options):
"""
Create the key to sort on the sorted set references in
self._sort_by_sortedset and adapte sort options
"""
# create the keys
base_tmp_key, tmp_keys = self._zset_to_keys(
key=se... | python | def _prepare_sort_by_score(self, values, sort_options):
"""
Create the key to sort on the sorted set references in
self._sort_by_sortedset and adapte sort options
"""
# create the keys
base_tmp_key, tmp_keys = self._zset_to_keys(
key=se... | [
"def",
"_prepare_sort_by_score",
"(",
"self",
",",
"values",
",",
"sort_options",
")",
":",
"# create the keys",
"base_tmp_key",
",",
"tmp_keys",
"=",
"self",
".",
"_zset_to_keys",
"(",
"key",
"=",
"self",
".",
"_sort_by_sortedset",
"[",
"'by'",
"]",
",",
"val... | Create the key to sort on the sorted set references in
self._sort_by_sortedset and adapte sort options | [
"Create",
"the",
"key",
"to",
"sort",
"on",
"the",
"sorted",
"set",
"references",
"in",
"self",
".",
"_sort_by_sortedset",
"and",
"adapte",
"sort",
"options"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/collection.py#L397-L424 |
54,172 | limpyd/redis-limpyd | limpyd/contrib/collection.py | ExtendedCollectionManager._prepare_sort_options | def _prepare_sort_options(self, has_pk):
"""
Prepare sort options for _values attributes.
If we manager sort by score after getting the result, we do not want to
get values from the first sort call, but only from the last one, after
converting results in zset into keys
""... | python | def _prepare_sort_options(self, has_pk):
"""
Prepare sort options for _values attributes.
If we manager sort by score after getting the result, we do not want to
get values from the first sort call, but only from the last one, after
converting results in zset into keys
""... | [
"def",
"_prepare_sort_options",
"(",
"self",
",",
"has_pk",
")",
":",
"sort_options",
"=",
"super",
"(",
"ExtendedCollectionManager",
",",
"self",
")",
".",
"_prepare_sort_options",
"(",
"has_pk",
")",
"if",
"self",
".",
"_values",
":",
"# if we asked for values, ... | Prepare sort options for _values attributes.
If we manager sort by score after getting the result, we do not want to
get values from the first sort call, but only from the last one, after
converting results in zset into keys | [
"Prepare",
"sort",
"options",
"for",
"_values",
"attributes",
".",
"If",
"we",
"manager",
"sort",
"by",
"score",
"after",
"getting",
"the",
"result",
"we",
"do",
"not",
"want",
"to",
"get",
"values",
"from",
"the",
"first",
"sort",
"call",
"but",
"only",
... | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/collection.py#L497-L523 |
54,173 | limpyd/redis-limpyd | limpyd/contrib/collection.py | ExtendedCollectionManager._get_final_set | def _get_final_set(self, sets, pk, sort_options):
"""
Add intersects fo sets and call parent's _get_final_set.
If we have to sort by sorted score, and we have a slice, we have to
convert the whole sorted set to keys now.
"""
if self._lazy_collection['intersects']:
... | python | def _get_final_set(self, sets, pk, sort_options):
"""
Add intersects fo sets and call parent's _get_final_set.
If we have to sort by sorted score, and we have a slice, we have to
convert the whole sorted set to keys now.
"""
if self._lazy_collection['intersects']:
... | [
"def",
"_get_final_set",
"(",
"self",
",",
"sets",
",",
"pk",
",",
"sort_options",
")",
":",
"if",
"self",
".",
"_lazy_collection",
"[",
"'intersects'",
"]",
":",
"# if the intersect method was called, we had new sets to intersect",
"# to the global set of sets.",
"# And ... | Add intersects fo sets and call parent's _get_final_set.
If we have to sort by sorted score, and we have a slice, we have to
convert the whole sorted set to keys now. | [
"Add",
"intersects",
"fo",
"sets",
"and",
"call",
"parent",
"s",
"_get_final_set",
".",
"If",
"we",
"have",
"to",
"sort",
"by",
"sorted",
"score",
"and",
"we",
"have",
"a",
"slice",
"we",
"have",
"to",
"convert",
"the",
"whole",
"sorted",
"set",
"to",
... | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/collection.py#L525-L559 |
54,174 | limpyd/redis-limpyd | limpyd/contrib/collection.py | ExtendedCollectionManager._add_filters | def _add_filters(self, **filters):
"""
In addition to the normal _add_filters, this one accept RedisField objects
on the right part of a filter. The value will be fetched from redis when
calling the collection.
The filter value can also be a model instance, in which case its PK w... | python | def _add_filters(self, **filters):
"""
In addition to the normal _add_filters, this one accept RedisField objects
on the right part of a filter. The value will be fetched from redis when
calling the collection.
The filter value can also be a model instance, in which case its PK w... | [
"def",
"_add_filters",
"(",
"self",
",",
"*",
"*",
"filters",
")",
":",
"string_filters",
"=",
"filters",
".",
"copy",
"(",
")",
"for",
"key",
",",
"value",
"in",
"filters",
".",
"items",
"(",
")",
":",
"is_extended",
"=",
"False",
"if",
"isinstance",
... | In addition to the normal _add_filters, this one accept RedisField objects
on the right part of a filter. The value will be fetched from redis when
calling the collection.
The filter value can also be a model instance, in which case its PK will
be fetched when calling the collection, too... | [
"In",
"addition",
"to",
"the",
"normal",
"_add_filters",
"this",
"one",
"accept",
"RedisField",
"objects",
"on",
"the",
"right",
"part",
"of",
"a",
"filter",
".",
"The",
"value",
"will",
"be",
"fetched",
"from",
"redis",
"when",
"calling",
"the",
"collection... | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/collection.py#L561-L603 |
54,175 | limpyd/redis-limpyd | limpyd/contrib/collection.py | ExtendedCollectionManager._get_pk | def _get_pk(self):
"""
Override the default _get_pk method to retrieve the real pk value if we
have a SingleValueField or a RedisModel instead of a real PK value
"""
pk = super(ExtendedCollectionManager, self)._get_pk()
if pk is not None and isinstance(pk, RawFilter):
... | python | def _get_pk(self):
"""
Override the default _get_pk method to retrieve the real pk value if we
have a SingleValueField or a RedisModel instead of a real PK value
"""
pk = super(ExtendedCollectionManager, self)._get_pk()
if pk is not None and isinstance(pk, RawFilter):
... | [
"def",
"_get_pk",
"(",
"self",
")",
":",
"pk",
"=",
"super",
"(",
"ExtendedCollectionManager",
",",
"self",
")",
".",
"_get_pk",
"(",
")",
"if",
"pk",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"pk",
",",
"RawFilter",
")",
":",
"# We have a RedisMode... | Override the default _get_pk method to retrieve the real pk value if we
have a SingleValueField or a RedisModel instead of a real PK value | [
"Override",
"the",
"default",
"_get_pk",
"method",
"to",
"retrieve",
"the",
"real",
"pk",
"value",
"if",
"we",
"have",
"a",
"SingleValueField",
"or",
"a",
"RedisModel",
"instead",
"of",
"a",
"real",
"PK",
"value"
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/collection.py#L605-L622 |
54,176 | limpyd/redis-limpyd | limpyd/contrib/collection.py | ExtendedCollectionManager.from_stored | def from_stored(self, key):
"""
Set the current collection as based on a stored one. The key argument
is the key off the stored collection.
"""
# only one stored key allowed
if self.stored_key:
raise ValueError('This collection is already based on a stored one... | python | def from_stored(self, key):
"""
Set the current collection as based on a stored one. The key argument
is the key off the stored collection.
"""
# only one stored key allowed
if self.stored_key:
raise ValueError('This collection is already based on a stored one... | [
"def",
"from_stored",
"(",
"self",
",",
"key",
")",
":",
"# only one stored key allowed",
"if",
"self",
".",
"stored_key",
":",
"raise",
"ValueError",
"(",
"'This collection is already based on a stored one'",
")",
"# prepare the collection",
"self",
".",
"stored_key",
... | Set the current collection as based on a stored one. The key argument
is the key off the stored collection. | [
"Set",
"the",
"current",
"collection",
"as",
"based",
"on",
"a",
"stored",
"one",
".",
"The",
"key",
"argument",
"is",
"the",
"key",
"off",
"the",
"stored",
"collection",
"."
] | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/collection.py#L730-L748 |
54,177 | limpyd/redis-limpyd | limpyd/contrib/collection.py | ExtendedCollectionManager.values | def values(self, *fields):
"""
Ask the collection to return a list of dict of given fields for each
instance found in the collection.
If no fields are given, all "simple value" fields are used.
"""
if not fields:
fields = self._get_simple_fields()
fie... | python | def values(self, *fields):
"""
Ask the collection to return a list of dict of given fields for each
instance found in the collection.
If no fields are given, all "simple value" fields are used.
"""
if not fields:
fields = self._get_simple_fields()
fie... | [
"def",
"values",
"(",
"self",
",",
"*",
"fields",
")",
":",
"if",
"not",
"fields",
":",
"fields",
"=",
"self",
".",
"_get_simple_fields",
"(",
")",
"fields",
"=",
"self",
".",
"_coerce_fields_parameters",
"(",
"fields",
")",
"self",
".",
"_instances",
"=... | Ask the collection to return a list of dict of given fields for each
instance found in the collection.
If no fields are given, all "simple value" fields are used. | [
"Ask",
"the",
"collection",
"to",
"return",
"a",
"list",
"of",
"dict",
"of",
"given",
"fields",
"for",
"each",
"instance",
"found",
"in",
"the",
"collection",
".",
"If",
"no",
"fields",
"are",
"given",
"all",
"simple",
"value",
"fields",
"are",
"used",
"... | 3c745dde1390a0bd09690b77a089dcc08c6c7e43 | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/collection.py#L765-L778 |
54,178 | caseyjlaw/rtpipe | rtpipe/parsems.py | readiter | def readiter(d):
""" Read iteration of size iterint
"""
da = ms.getdata([d['datacol'],'axis_info','u','v','w','flag','data_desc_id'], ifraxis=True)
good = n.where((da['data_desc_id']) == d['spwlist'][0])[0] # take first spw
time0 = da['axis_info']['... | python | def readiter(d):
""" Read iteration of size iterint
"""
da = ms.getdata([d['datacol'],'axis_info','u','v','w','flag','data_desc_id'], ifraxis=True)
good = n.where((da['data_desc_id']) == d['spwlist'][0])[0] # take first spw
time0 = da['axis_info']['... | [
"def",
"readiter",
"(",
"d",
")",
":",
"da",
"=",
"ms",
".",
"getdata",
"(",
"[",
"d",
"[",
"'datacol'",
"]",
",",
"'axis_info'",
",",
"'u'",
",",
"'v'",
",",
"'w'",
",",
"'flag'",
",",
"'data_desc_id'",
"]",
",",
"ifraxis",
"=",
"True",
")",
"go... | Read iteration of size iterint | [
"Read",
"iteration",
"of",
"size",
"iterint"
] | ac33e4332cf215091a63afbb3137850876d73ec0 | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsems.py#L242-L266 |
54,179 | fcurella/django-fakery | django_fakery/utils.py | language_to_locale | def language_to_locale(language):
"""
Converts django's `LANGUAGE_CODE` settings to a proper locale code.
"""
tokens = language.split('-')
if len(tokens) == 1:
return tokens[0]
return "%s_%s" % (tokens[0], tokens[1].upper()) | python | def language_to_locale(language):
"""
Converts django's `LANGUAGE_CODE` settings to a proper locale code.
"""
tokens = language.split('-')
if len(tokens) == 1:
return tokens[0]
return "%s_%s" % (tokens[0], tokens[1].upper()) | [
"def",
"language_to_locale",
"(",
"language",
")",
":",
"tokens",
"=",
"language",
".",
"split",
"(",
"'-'",
")",
"if",
"len",
"(",
"tokens",
")",
"==",
"1",
":",
"return",
"tokens",
"[",
"0",
"]",
"return",
"\"%s_%s\"",
"%",
"(",
"tokens",
"[",
"0",... | Converts django's `LANGUAGE_CODE` settings to a proper locale code. | [
"Converts",
"django",
"s",
"LANGUAGE_CODE",
"settings",
"to",
"a",
"proper",
"locale",
"code",
"."
] | 05b6d6a9bf4b8fab98bf91fe1dce5a812d951987 | https://github.com/fcurella/django-fakery/blob/05b6d6a9bf4b8fab98bf91fe1dce5a812d951987/django_fakery/utils.py#L1-L8 |
54,180 | caseyjlaw/rtpipe | rtpipe/interactive.py | initializenb | def initializenb():
""" Find input files and log initialization info """
logger.info('Working directory: {0}'.format(os.getcwd()))
logger.info('Run on {0}'.format(asctime()))
try:
fileroot = os.environ['fileroot']
logger.info('Setting fileroot to {0} from environment variable.\n'.format... | python | def initializenb():
""" Find input files and log initialization info """
logger.info('Working directory: {0}'.format(os.getcwd()))
logger.info('Run on {0}'.format(asctime()))
try:
fileroot = os.environ['fileroot']
logger.info('Setting fileroot to {0} from environment variable.\n'.format... | [
"def",
"initializenb",
"(",
")",
":",
"logger",
".",
"info",
"(",
"'Working directory: {0}'",
".",
"format",
"(",
"os",
".",
"getcwd",
"(",
")",
")",
")",
"logger",
".",
"info",
"(",
"'Run on {0}'",
".",
"format",
"(",
"asctime",
"(",
")",
")",
")",
... | Find input files and log initialization info | [
"Find",
"input",
"files",
"and",
"log",
"initialization",
"info"
] | ac33e4332cf215091a63afbb3137850876d73ec0 | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/interactive.py#L18-L42 |
54,181 | caseyjlaw/rtpipe | rtpipe/interactive.py | plot_interactive | def plot_interactive(mergepkl, noisepkl=None, thresh=6.0, thresh_link=7.0, ignoret=None, savehtml=True, url_path='plots'):
""" Backwards compatible function for making interactive candidate summary plot """
data = readdata(mergepkl)
circleinds = calcinds(data, thresh, ignoret)
crossinds = calcinds(data... | python | def plot_interactive(mergepkl, noisepkl=None, thresh=6.0, thresh_link=7.0, ignoret=None, savehtml=True, url_path='plots'):
""" Backwards compatible function for making interactive candidate summary plot """
data = readdata(mergepkl)
circleinds = calcinds(data, thresh, ignoret)
crossinds = calcinds(data... | [
"def",
"plot_interactive",
"(",
"mergepkl",
",",
"noisepkl",
"=",
"None",
",",
"thresh",
"=",
"6.0",
",",
"thresh_link",
"=",
"7.0",
",",
"ignoret",
"=",
"None",
",",
"savehtml",
"=",
"True",
",",
"url_path",
"=",
"'plots'",
")",
":",
"data",
"=",
"rea... | Backwards compatible function for making interactive candidate summary plot | [
"Backwards",
"compatible",
"function",
"for",
"making",
"interactive",
"candidate",
"summary",
"plot"
] | ac33e4332cf215091a63afbb3137850876d73ec0 | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/interactive.py#L45-L70 |
54,182 | caseyjlaw/rtpipe | rtpipe/interactive.py | plotloc | def plotloc(data, circleinds=[], crossinds=[], edgeinds=[], url_path=None, fileroot=None,
tools="hover,tap,pan,box_select,wheel_zoom,reset", plot_width=450, plot_height=400):
""" Make a light-weight loc figure """
fields = ['l1', 'm1', 'sizes', 'colors', 'snrs', 'key']
if not circleinds: circl... | python | def plotloc(data, circleinds=[], crossinds=[], edgeinds=[], url_path=None, fileroot=None,
tools="hover,tap,pan,box_select,wheel_zoom,reset", plot_width=450, plot_height=400):
""" Make a light-weight loc figure """
fields = ['l1', 'm1', 'sizes', 'colors', 'snrs', 'key']
if not circleinds: circl... | [
"def",
"plotloc",
"(",
"data",
",",
"circleinds",
"=",
"[",
"]",
",",
"crossinds",
"=",
"[",
"]",
",",
"edgeinds",
"=",
"[",
"]",
",",
"url_path",
"=",
"None",
",",
"fileroot",
"=",
"None",
",",
"tools",
"=",
"\"hover,tap,pan,box_select,wheel_zoom,reset\""... | Make a light-weight loc figure | [
"Make",
"a",
"light",
"-",
"weight",
"loc",
"figure"
] | ac33e4332cf215091a63afbb3137850876d73ec0 | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/interactive.py#L237-L279 |
54,183 | caseyjlaw/rtpipe | rtpipe/interactive.py | plotstat | def plotstat(data, circleinds=None, crossinds=None, edgeinds=None, url_path=None, fileroot=None,
tools="hover,tap,pan,box_select,wheel_zoom,reset", plot_width=450, plot_height=400):
""" Make a light-weight stat figure """
fields = ['imkur', 'specstd', 'sizes', 'colors', 'snrs', 'key']
if not... | python | def plotstat(data, circleinds=None, crossinds=None, edgeinds=None, url_path=None, fileroot=None,
tools="hover,tap,pan,box_select,wheel_zoom,reset", plot_width=450, plot_height=400):
""" Make a light-weight stat figure """
fields = ['imkur', 'specstd', 'sizes', 'colors', 'snrs', 'key']
if not... | [
"def",
"plotstat",
"(",
"data",
",",
"circleinds",
"=",
"None",
",",
"crossinds",
"=",
"None",
",",
"edgeinds",
"=",
"None",
",",
"url_path",
"=",
"None",
",",
"fileroot",
"=",
"None",
",",
"tools",
"=",
"\"hover,tap,pan,box_select,wheel_zoom,reset\"",
",",
... | Make a light-weight stat figure | [
"Make",
"a",
"light",
"-",
"weight",
"stat",
"figure"
] | ac33e4332cf215091a63afbb3137850876d73ec0 | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/interactive.py#L282-L325 |
54,184 | caseyjlaw/rtpipe | rtpipe/interactive.py | plotnorm | def plotnorm(data, circleinds=[], crossinds=[], edgeinds=[], url_path=None, fileroot=None,
tools="hover,tap,pan,box_select,wheel_zoom,reset", plot_width=450, plot_height=400):
""" Make a light-weight norm figure """
fields = ['zs', 'sizes', 'colors', 'abssnr', 'key', 'snrs']
if not circleinds... | python | def plotnorm(data, circleinds=[], crossinds=[], edgeinds=[], url_path=None, fileroot=None,
tools="hover,tap,pan,box_select,wheel_zoom,reset", plot_width=450, plot_height=400):
""" Make a light-weight norm figure """
fields = ['zs', 'sizes', 'colors', 'abssnr', 'key', 'snrs']
if not circleinds... | [
"def",
"plotnorm",
"(",
"data",
",",
"circleinds",
"=",
"[",
"]",
",",
"crossinds",
"=",
"[",
"]",
",",
"edgeinds",
"=",
"[",
"]",
",",
"url_path",
"=",
"None",
",",
"fileroot",
"=",
"None",
",",
"tools",
"=",
"\"hover,tap,pan,box_select,wheel_zoom,reset\"... | Make a light-weight norm figure | [
"Make",
"a",
"light",
"-",
"weight",
"norm",
"figure"
] | ac33e4332cf215091a63afbb3137850876d73ec0 | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/interactive.py#L328-L360 |
54,185 | caseyjlaw/rtpipe | rtpipe/interactive.py | plotnoise | def plotnoise(noisepkl, mergepkl, plot_width=950, plot_height=400):
""" Make two panel plot to summary noise analysis with estimated flux scale """
d = pickle.load(open(mergepkl))
ndist, imstd, flagfrac = plotnoisedist(noisepkl, plot_width=plot_width/2, plot_height=plot_height)
fluxscale = calcfluxscal... | python | def plotnoise(noisepkl, mergepkl, plot_width=950, plot_height=400):
""" Make two panel plot to summary noise analysis with estimated flux scale """
d = pickle.load(open(mergepkl))
ndist, imstd, flagfrac = plotnoisedist(noisepkl, plot_width=plot_width/2, plot_height=plot_height)
fluxscale = calcfluxscal... | [
"def",
"plotnoise",
"(",
"noisepkl",
",",
"mergepkl",
",",
"plot_width",
"=",
"950",
",",
"plot_height",
"=",
"400",
")",
":",
"d",
"=",
"pickle",
".",
"load",
"(",
"open",
"(",
"mergepkl",
")",
")",
"ndist",
",",
"imstd",
",",
"flagfrac",
"=",
"plot... | Make two panel plot to summary noise analysis with estimated flux scale | [
"Make",
"two",
"panel",
"plot",
"to",
"summary",
"noise",
"analysis",
"with",
"estimated",
"flux",
"scale"
] | ac33e4332cf215091a63afbb3137850876d73ec0 | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/interactive.py#L363-L373 |
54,186 | caseyjlaw/rtpipe | rtpipe/interactive.py | plotnoisecum | def plotnoisecum(noisepkl, fluxscale=1, plot_width=450, plot_height=400):
""" Merged noise pkl converted to interactive cumulative histogram
noisepkl is standard noise pickle file.
fluxscale is scaling applied by gain calibrator. telcal solutions have fluxscale=1.
also returns corrected imnoise values... | python | def plotnoisecum(noisepkl, fluxscale=1, plot_width=450, plot_height=400):
""" Merged noise pkl converted to interactive cumulative histogram
noisepkl is standard noise pickle file.
fluxscale is scaling applied by gain calibrator. telcal solutions have fluxscale=1.
also returns corrected imnoise values... | [
"def",
"plotnoisecum",
"(",
"noisepkl",
",",
"fluxscale",
"=",
"1",
",",
"plot_width",
"=",
"450",
",",
"plot_height",
"=",
"400",
")",
":",
"# noise histogram",
"noises",
"=",
"read_noise",
"(",
"noisepkl",
")",
"imnoise",
"=",
"np",
".",
"sort",
"(",
"... | Merged noise pkl converted to interactive cumulative histogram
noisepkl is standard noise pickle file.
fluxscale is scaling applied by gain calibrator. telcal solutions have fluxscale=1.
also returns corrected imnoise values if non-unity fluxscale provided | [
"Merged",
"noise",
"pkl",
"converted",
"to",
"interactive",
"cumulative",
"histogram"
] | ac33e4332cf215091a63afbb3137850876d73ec0 | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/interactive.py#L376-L396 |
54,187 | caseyjlaw/rtpipe | rtpipe/interactive.py | calcfluxscale | def calcfluxscale(d, imstd_med, flagfrac_med):
""" Given state dict and noise properties, estimate flux scale at the VLA
imstd and flagfrac are expected to be median (typical) values from sample in merged noise pkl.
"""
# useful functions and VLA parameters
sensitivity = lambda sefd, dt, bw, eta,... | python | def calcfluxscale(d, imstd_med, flagfrac_med):
""" Given state dict and noise properties, estimate flux scale at the VLA
imstd and flagfrac are expected to be median (typical) values from sample in merged noise pkl.
"""
# useful functions and VLA parameters
sensitivity = lambda sefd, dt, bw, eta,... | [
"def",
"calcfluxscale",
"(",
"d",
",",
"imstd_med",
",",
"flagfrac_med",
")",
":",
"# useful functions and VLA parameters",
"sensitivity",
"=",
"lambda",
"sefd",
",",
"dt",
",",
"bw",
",",
"eta",
",",
"nbl",
",",
"npol",
":",
"sefd",
"/",
"(",
"eta",
"*",
... | Given state dict and noise properties, estimate flux scale at the VLA
imstd and flagfrac are expected to be median (typical) values from sample in merged noise pkl. | [
"Given",
"state",
"dict",
"and",
"noise",
"properties",
"estimate",
"flux",
"scale",
"at",
"the",
"VLA"
] | ac33e4332cf215091a63afbb3137850876d73ec0 | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/interactive.py#L421-L454 |
54,188 | caseyjlaw/rtpipe | rtpipe/interactive.py | findhight | def findhight(data, ignoret=None, threshold=20):
""" Find bad time ranges from distribution of candidates.
ignoret is list of tuples [(t0, t1), (t2, t3)] defining ranges to ignore.
threshold is made above std of candidate distribution in time.
Returns the time (in seconds) and counts for bins above thr... | python | def findhight(data, ignoret=None, threshold=20):
""" Find bad time ranges from distribution of candidates.
ignoret is list of tuples [(t0, t1), (t2, t3)] defining ranges to ignore.
threshold is made above std of candidate distribution in time.
Returns the time (in seconds) and counts for bins above thr... | [
"def",
"findhight",
"(",
"data",
",",
"ignoret",
"=",
"None",
",",
"threshold",
"=",
"20",
")",
":",
"time",
"=",
"np",
".",
"sort",
"(",
"data",
"[",
"'time'",
"]",
")",
"ww",
"=",
"np",
".",
"ones",
"(",
"len",
"(",
"time",
")",
",",
"dtype",... | Find bad time ranges from distribution of candidates.
ignoret is list of tuples [(t0, t1), (t2, t3)] defining ranges to ignore.
threshold is made above std of candidate distribution in time.
Returns the time (in seconds) and counts for bins above threshold. | [
"Find",
"bad",
"time",
"ranges",
"from",
"distribution",
"of",
"candidates",
"."
] | ac33e4332cf215091a63afbb3137850876d73ec0 | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/interactive.py#L526-L545 |
54,189 | caseyjlaw/rtpipe | rtpipe/interactive.py | calcontime | def calcontime(data, inds=None):
""" Given indices of good times, calculate total time per scan with indices. """
if not inds:
inds = range(len(data['time']))
logger.info('No indices provided. Assuming all are valid.')
scans = set([data['scan'][i] for i in inds])
total = 0.
for sca... | python | def calcontime(data, inds=None):
""" Given indices of good times, calculate total time per scan with indices. """
if not inds:
inds = range(len(data['time']))
logger.info('No indices provided. Assuming all are valid.')
scans = set([data['scan'][i] for i in inds])
total = 0.
for sca... | [
"def",
"calcontime",
"(",
"data",
",",
"inds",
"=",
"None",
")",
":",
"if",
"not",
"inds",
":",
"inds",
"=",
"range",
"(",
"len",
"(",
"data",
"[",
"'time'",
"]",
")",
")",
"logger",
".",
"info",
"(",
"'No indices provided. Assuming all are valid.'",
")"... | Given indices of good times, calculate total time per scan with indices. | [
"Given",
"indices",
"of",
"good",
"times",
"calculate",
"total",
"time",
"per",
"scan",
"with",
"indices",
"."
] | ac33e4332cf215091a63afbb3137850876d73ec0 | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/interactive.py#L575-L588 |
54,190 | caseyjlaw/rtpipe | rtpipe/interactive.py | calcsize | def calcsize(values, sizerange=(2,70), inds=None, plaw=3):
""" Use set of values to calculate symbol size.
values is a list of floats for candidate significance.
inds is an optional list of indexes to use to calculate symbol size.
Scaling of symbol size min max set by sizerange tuple (min, max).
pl... | python | def calcsize(values, sizerange=(2,70), inds=None, plaw=3):
""" Use set of values to calculate symbol size.
values is a list of floats for candidate significance.
inds is an optional list of indexes to use to calculate symbol size.
Scaling of symbol size min max set by sizerange tuple (min, max).
pl... | [
"def",
"calcsize",
"(",
"values",
",",
"sizerange",
"=",
"(",
"2",
",",
"70",
")",
",",
"inds",
"=",
"None",
",",
"plaw",
"=",
"3",
")",
":",
"if",
"inds",
":",
"smax",
"=",
"max",
"(",
"[",
"abs",
"(",
"values",
"[",
"i",
"]",
")",
"for",
... | Use set of values to calculate symbol size.
values is a list of floats for candidate significance.
inds is an optional list of indexes to use to calculate symbol size.
Scaling of symbol size min max set by sizerange tuple (min, max).
plaw is powerlaw scaling of symbol size from values | [
"Use",
"set",
"of",
"values",
"to",
"calculate",
"symbol",
"size",
"."
] | ac33e4332cf215091a63afbb3137850876d73ec0 | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/interactive.py#L674-L689 |
54,191 | caseyjlaw/rtpipe | rtpipe/interactive.py | colorsat | def colorsat(l,m):
""" Returns color for given l,m
Designed to look like a color wheel that is more saturated in middle.
"""
lm = np.zeros(len(l), dtype='complex')
lm.real = l
lm.imag = m
red = 0.5*(1+np.cos(np.angle(lm)))
green = 0.5*(1+np.cos(np.angle(lm) + 2*3.14/3))
blue = 0.5*(... | python | def colorsat(l,m):
""" Returns color for given l,m
Designed to look like a color wheel that is more saturated in middle.
"""
lm = np.zeros(len(l), dtype='complex')
lm.real = l
lm.imag = m
red = 0.5*(1+np.cos(np.angle(lm)))
green = 0.5*(1+np.cos(np.angle(lm) + 2*3.14/3))
blue = 0.5*(... | [
"def",
"colorsat",
"(",
"l",
",",
"m",
")",
":",
"lm",
"=",
"np",
".",
"zeros",
"(",
"len",
"(",
"l",
")",
",",
"dtype",
"=",
"'complex'",
")",
"lm",
".",
"real",
"=",
"l",
"lm",
".",
"imag",
"=",
"m",
"red",
"=",
"0.5",
"*",
"(",
"1",
"+... | Returns color for given l,m
Designed to look like a color wheel that is more saturated in middle. | [
"Returns",
"color",
"for",
"given",
"l",
"m",
"Designed",
"to",
"look",
"like",
"a",
"color",
"wheel",
"that",
"is",
"more",
"saturated",
"in",
"middle",
"."
] | ac33e4332cf215091a63afbb3137850876d73ec0 | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/interactive.py#L692-L704 |
54,192 | caseyjlaw/rtpipe | rtpipe/interactive.py | filterdata | def filterdata(data, plinds, d, threshold, ignorestr):
""" Iteratively filter bad times and set indices for later plotting """
logger.info('Ignoring times from ignorestr {0}'.format(ignorestr))
ignoret = parseignoret(ignorestr)
thresh0 = d['sigma_image1']
thresh1 = d['sigma_plot']
plinds['cir... | python | def filterdata(data, plinds, d, threshold, ignorestr):
""" Iteratively filter bad times and set indices for later plotting """
logger.info('Ignoring times from ignorestr {0}'.format(ignorestr))
ignoret = parseignoret(ignorestr)
thresh0 = d['sigma_image1']
thresh1 = d['sigma_plot']
plinds['cir... | [
"def",
"filterdata",
"(",
"data",
",",
"plinds",
",",
"d",
",",
"threshold",
",",
"ignorestr",
")",
":",
"logger",
".",
"info",
"(",
"'Ignoring times from ignorestr {0}'",
".",
"format",
"(",
"ignorestr",
")",
")",
"ignoret",
"=",
"parseignoret",
"(",
"ignor... | Iteratively filter bad times and set indices for later plotting | [
"Iteratively",
"filter",
"bad",
"times",
"and",
"set",
"indices",
"for",
"later",
"plotting"
] | ac33e4332cf215091a63afbb3137850876d73ec0 | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/interactive.py#L707-L743 |
54,193 | caseyjlaw/rtpipe | rtpipe/interactive.py | displayplot | def displayplot(data, plinds, plottype, scaling, fileroot, url_path='http://www.aoc.nrao.edu/~claw/plots'):
""" Generate interactive plot """
plotdict = {'dmt': plotdmt, 'norm': plotnorm,
'loc': plotloc, 'stat': plotstat,
'all': plotall}
sizedict = {'dmt': [900,500], 'norm': [... | python | def displayplot(data, plinds, plottype, scaling, fileroot, url_path='http://www.aoc.nrao.edu/~claw/plots'):
""" Generate interactive plot """
plotdict = {'dmt': plotdmt, 'norm': plotnorm,
'loc': plotloc, 'stat': plotstat,
'all': plotall}
sizedict = {'dmt': [900,500], 'norm': [... | [
"def",
"displayplot",
"(",
"data",
",",
"plinds",
",",
"plottype",
",",
"scaling",
",",
"fileroot",
",",
"url_path",
"=",
"'http://www.aoc.nrao.edu/~claw/plots'",
")",
":",
"plotdict",
"=",
"{",
"'dmt'",
":",
"plotdmt",
",",
"'norm'",
":",
"plotnorm",
",",
"... | Generate interactive plot | [
"Generate",
"interactive",
"plot"
] | ac33e4332cf215091a63afbb3137850876d73ec0 | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/interactive.py#L756-L778 |
54,194 | caseyjlaw/rtpipe | rtpipe/interactive.py | addclassifications | def addclassifications(agdir, prop, version=None, statfeats = [0,4,5,6,7,8]):
""" Calculates real score probability of prop from an activegit repo.
version is string name of activegit tag.
Default agdir initialization will have latest tag, so version is optional.
statfeats set to work with alnotebook n... | python | def addclassifications(agdir, prop, version=None, statfeats = [0,4,5,6,7,8]):
""" Calculates real score probability of prop from an activegit repo.
version is string name of activegit tag.
Default agdir initialization will have latest tag, so version is optional.
statfeats set to work with alnotebook n... | [
"def",
"addclassifications",
"(",
"agdir",
",",
"prop",
",",
"version",
"=",
"None",
",",
"statfeats",
"=",
"[",
"0",
",",
"4",
",",
"5",
",",
"6",
",",
"7",
",",
"8",
"]",
")",
":",
"try",
":",
"ag",
"=",
"activegit",
".",
"ActiveGit",
"(",
"a... | Calculates real score probability of prop from an activegit repo.
version is string name of activegit tag.
Default agdir initialization will have latest tag, so version is optional.
statfeats set to work with alnotebook naming. | [
"Calculates",
"real",
"score",
"probability",
"of",
"prop",
"from",
"an",
"activegit",
"repo",
"."
] | ac33e4332cf215091a63afbb3137850876d73ec0 | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/interactive.py#L781-L799 |
54,195 | Fantomas42/django-emoticons | emoticons/settings.py | cast_to_list | def cast_to_list(emoticons_list):
"""
Fix list of emoticons with a single name
to a list for easier future iterations,
and cast iterables to list.
"""
emoticons_tuple = []
for emoticons, image in emoticons_list:
if isinstance(emoticons, basestring):
emoticons = [emoticons... | python | def cast_to_list(emoticons_list):
"""
Fix list of emoticons with a single name
to a list for easier future iterations,
and cast iterables to list.
"""
emoticons_tuple = []
for emoticons, image in emoticons_list:
if isinstance(emoticons, basestring):
emoticons = [emoticons... | [
"def",
"cast_to_list",
"(",
"emoticons_list",
")",
":",
"emoticons_tuple",
"=",
"[",
"]",
"for",
"emoticons",
",",
"image",
"in",
"emoticons_list",
":",
"if",
"isinstance",
"(",
"emoticons",
",",
"basestring",
")",
":",
"emoticons",
"=",
"[",
"emoticons",
"]... | Fix list of emoticons with a single name
to a list for easier future iterations,
and cast iterables to list. | [
"Fix",
"list",
"of",
"emoticons",
"with",
"a",
"single",
"name",
"to",
"a",
"list",
"for",
"easier",
"future",
"iterations",
"and",
"cast",
"iterables",
"to",
"list",
"."
] | 14a9895505874dfdd28e74d563a5fc521e3a315f | https://github.com/Fantomas42/django-emoticons/blob/14a9895505874dfdd28e74d563a5fc521e3a315f/emoticons/settings.py#L107-L120 |
54,196 | Fantomas42/django-emoticons | emoticons/settings.py | compile_emoticons | def compile_emoticons(emoticons_list):
"""
Compile a new list of emoticon tuples.
Each tuple contains a compiled regular expression
of the emoticon, and the html version of the emoticon.
"""
emoticons_compiled = []
for emoticons, image in emoticons_list:
for emoticon in emoticons:
... | python | def compile_emoticons(emoticons_list):
"""
Compile a new list of emoticon tuples.
Each tuple contains a compiled regular expression
of the emoticon, and the html version of the emoticon.
"""
emoticons_compiled = []
for emoticons, image in emoticons_list:
for emoticon in emoticons:
... | [
"def",
"compile_emoticons",
"(",
"emoticons_list",
")",
":",
"emoticons_compiled",
"=",
"[",
"]",
"for",
"emoticons",
",",
"image",
"in",
"emoticons_list",
":",
"for",
"emoticon",
"in",
"emoticons",
":",
"context",
"=",
"{",
"'name'",
":",
"emoticon",
",",
"... | Compile a new list of emoticon tuples.
Each tuple contains a compiled regular expression
of the emoticon, and the html version of the emoticon. | [
"Compile",
"a",
"new",
"list",
"of",
"emoticon",
"tuples",
".",
"Each",
"tuple",
"contains",
"a",
"compiled",
"regular",
"expression",
"of",
"the",
"emoticon",
"and",
"the",
"html",
"version",
"of",
"the",
"emoticon",
"."
] | 14a9895505874dfdd28e74d563a5fc521e3a315f | https://github.com/Fantomas42/django-emoticons/blob/14a9895505874dfdd28e74d563a5fc521e3a315f/emoticons/settings.py#L123-L140 |
54,197 | xiongchiamiov/pyfixit | pyfixit/step.py | Step._update | def _update(self, data):
'''Update the step using the blob of json-parsed data directly from the
API.
'''
self.orderby = data['orderby']
self.revision = data['revisionid']
self.title = data['title']
self.lines = [Line(self.guideid, self.stepid, line['lineid'], data=line)
... | python | def _update(self, data):
'''Update the step using the blob of json-parsed data directly from the
API.
'''
self.orderby = data['orderby']
self.revision = data['revisionid']
self.title = data['title']
self.lines = [Line(self.guideid, self.stepid, line['lineid'], data=line)
... | [
"def",
"_update",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"orderby",
"=",
"data",
"[",
"'orderby'",
"]",
"self",
".",
"revision",
"=",
"data",
"[",
"'revisionid'",
"]",
"self",
".",
"title",
"=",
"data",
"[",
"'title'",
"]",
"self",
".",
"... | Update the step using the blob of json-parsed data directly from the
API. | [
"Update",
"the",
"step",
"using",
"the",
"blob",
"of",
"json",
"-",
"parsed",
"data",
"directly",
"from",
"the",
"API",
"."
] | 808a0c852a26e4211b2e3a72da972ab34a586dc4 | https://github.com/xiongchiamiov/pyfixit/blob/808a0c852a26e4211b2e3a72da972ab34a586dc4/pyfixit/step.py#L53-L66 |
54,198 | caseyjlaw/rtpipe | rtpipe/cli.py | read | def read(filename, paramfile, bdfdir, scan):
""" Simple parse and return metadata for pipeline for first scan """
filename = os.path.abspath(filename)
scans = ps.read_scans(filename, bdfdir=bdfdir)
logger.info('Scans, Target names:')
logger.info('%s' % str([(ss, scans[ss]['source']) for ss in scan... | python | def read(filename, paramfile, bdfdir, scan):
""" Simple parse and return metadata for pipeline for first scan """
filename = os.path.abspath(filename)
scans = ps.read_scans(filename, bdfdir=bdfdir)
logger.info('Scans, Target names:')
logger.info('%s' % str([(ss, scans[ss]['source']) for ss in scan... | [
"def",
"read",
"(",
"filename",
",",
"paramfile",
",",
"bdfdir",
",",
"scan",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"filename",
")",
"scans",
"=",
"ps",
".",
"read_scans",
"(",
"filename",
",",
"bdfdir",
"=",
"bdfdir",
")... | Simple parse and return metadata for pipeline for first scan | [
"Simple",
"parse",
"and",
"return",
"metadata",
"for",
"pipeline",
"for",
"first",
"scan"
] | ac33e4332cf215091a63afbb3137850876d73ec0 | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/cli.py#L22-L31 |
54,199 | caseyjlaw/rtpipe | rtpipe/cli.py | searchone | def searchone(filename, scan, paramfile, logfile, bdfdir):
""" Searches one scan of filename
filename is name of local sdm ('filename.GN' expected locally).
scan is scan number to search. if none provided, script prints all.
assumes filename is an sdm.
"""
filename = os.path.abspath(filename)
... | python | def searchone(filename, scan, paramfile, logfile, bdfdir):
""" Searches one scan of filename
filename is name of local sdm ('filename.GN' expected locally).
scan is scan number to search. if none provided, script prints all.
assumes filename is an sdm.
"""
filename = os.path.abspath(filename)
... | [
"def",
"searchone",
"(",
"filename",
",",
"scan",
",",
"paramfile",
",",
"logfile",
",",
"bdfdir",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"filename",
")",
"scans",
"=",
"ps",
".",
"read_scans",
"(",
"filename",
",",
"bdfdir"... | Searches one scan of filename
filename is name of local sdm ('filename.GN' expected locally).
scan is scan number to search. if none provided, script prints all.
assumes filename is an sdm. | [
"Searches",
"one",
"scan",
"of",
"filename"
] | ac33e4332cf215091a63afbb3137850876d73ec0 | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/cli.py#L40-L64 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.