partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | JsonCodec.decode | Convert a generic JSON message
* The entire message is converted to JSON and treated as the message data
* The timestamp of the message is the time that the message is RECEIVED | src/wiotp/sdk/messages.py | def decode(message):
"""
Convert a generic JSON message
* The entire message is converted to JSON and treated as the message data
* The timestamp of the message is the time that the message is RECEIVED
"""
try:
data = json.loads(message.payload.decode... | def decode(message):
"""
Convert a generic JSON message
* The entire message is converted to JSON and treated as the message data
* The timestamp of the message is the time that the message is RECEIVED
"""
try:
data = json.loads(message.payload.decode... | [
"Convert",
"a",
"generic",
"JSON",
"message",
"*",
"The",
"entire",
"message",
"is",
"converted",
"to",
"JSON",
"and",
"treated",
"as",
"the",
"message",
"data",
"*",
"The",
"timestamp",
"of",
"the",
"message",
"is",
"the",
"time",
"that",
"the",
"message"... | ibm-watson-iot/iot-python | python | https://github.com/ibm-watson-iot/iot-python/blob/195f05adce3fba4ec997017e41e02ebd85c0c4cc/src/wiotp/sdk/messages.py#L43-L58 | [
"def",
"decode",
"(",
"message",
")",
":",
"try",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"message",
".",
"payload",
".",
"decode",
"(",
"\"utf-8\"",
")",
")",
"except",
"ValueError",
"as",
"e",
":",
"raise",
"InvalidEventException",
"(",
"'Unable t... | 195f05adce3fba4ec997017e41e02ebd85c0c4cc |
test | MyCodec.decode | The decoder understands the comma-seperated format produced by the encoder and
allocates the two values to the correct keys:
data['hello'] = 'world'
data['x'] = 10 | samples/customMessageFormat/myCustomCodec.py | def decode(message):
'''
The decoder understands the comma-seperated format produced by the encoder and
allocates the two values to the correct keys:
data['hello'] = 'world'
data['x'] = 10
'''
(hello, x) = message.payload.split(",")
data = {}
... | def decode(message):
'''
The decoder understands the comma-seperated format produced by the encoder and
allocates the two values to the correct keys:
data['hello'] = 'world'
data['x'] = 10
'''
(hello, x) = message.payload.split(",")
data = {}
... | [
"The",
"decoder",
"understands",
"the",
"comma",
"-",
"seperated",
"format",
"produced",
"by",
"the",
"encoder",
"and",
"allocates",
"the",
"two",
"values",
"to",
"the",
"correct",
"keys",
":",
"data",
"[",
"hello",
"]",
"=",
"world",
"data",
"[",
"x",
"... | ibm-watson-iot/iot-python | python | https://github.com/ibm-watson-iot/iot-python/blob/195f05adce3fba4ec997017e41e02ebd85c0c4cc/samples/customMessageFormat/myCustomCodec.py#L45-L61 | [
"def",
"decode",
"(",
"message",
")",
":",
"(",
"hello",
",",
"x",
")",
"=",
"message",
".",
"payload",
".",
"split",
"(",
"\",\"",
")",
"data",
"=",
"{",
"}",
"data",
"[",
"'hello'",
"]",
"=",
"hello",
"data",
"[",
"'x'",
"]",
"=",
"x",
"times... | 195f05adce3fba4ec997017e41e02ebd85c0c4cc |
test | Usage.dataTransfer | Retrieve the organization-specific status of each of the services offered by the IBM Watson IoT Platform.
In case of failure it throws APIException | src/wiotp/sdk/api/usage/__init__.py | def dataTransfer(self, start, end, detail=False):
"""
Retrieve the organization-specific status of each of the services offered by the IBM Watson IoT Platform.
In case of failure it throws APIException
"""
r = self._apiClient.get(
"api/v0002/usage/data-traffic?start=... | def dataTransfer(self, start, end, detail=False):
"""
Retrieve the organization-specific status of each of the services offered by the IBM Watson IoT Platform.
In case of failure it throws APIException
"""
r = self._apiClient.get(
"api/v0002/usage/data-traffic?start=... | [
"Retrieve",
"the",
"organization",
"-",
"specific",
"status",
"of",
"each",
"of",
"the",
"services",
"offered",
"by",
"the",
"IBM",
"Watson",
"IoT",
"Platform",
".",
"In",
"case",
"of",
"failure",
"it",
"throws",
"APIException"
] | ibm-watson-iot/iot-python | python | https://github.com/ibm-watson-iot/iot-python/blob/195f05adce3fba4ec997017e41e02ebd85c0c4cc/src/wiotp/sdk/api/usage/__init__.py#L62-L76 | [
"def",
"dataTransfer",
"(",
"self",
",",
"start",
",",
"end",
",",
"detail",
"=",
"False",
")",
":",
"r",
"=",
"self",
".",
"_apiClient",
".",
"get",
"(",
"\"api/v0002/usage/data-traffic?start=%s&end=%s&detail=%s\"",
"%",
"(",
"start",
".",
"strftime",
"(",
... | 195f05adce3fba4ec997017e41e02ebd85c0c4cc |
test | MgmtRequests.initiate | Initiates a device management request, such as reboot.
In case of failure it throws APIException | src/wiotp/sdk/api/mgmt/requests.py | def initiate(self, request):
"""
Initiates a device management request, such as reboot.
In case of failure it throws APIException
"""
url = MgmtRequests.mgmtRequests
r = self._apiClient.post(url, request)
if r.status_code == 202:
return r.json()
... | def initiate(self, request):
"""
Initiates a device management request, such as reboot.
In case of failure it throws APIException
"""
url = MgmtRequests.mgmtRequests
r = self._apiClient.post(url, request)
if r.status_code == 202:
return r.json()
... | [
"Initiates",
"a",
"device",
"management",
"request",
"such",
"as",
"reboot",
".",
"In",
"case",
"of",
"failure",
"it",
"throws",
"APIException"
] | ibm-watson-iot/iot-python | python | https://github.com/ibm-watson-iot/iot-python/blob/195f05adce3fba4ec997017e41e02ebd85c0c4cc/src/wiotp/sdk/api/mgmt/requests.py#L45-L56 | [
"def",
"initiate",
"(",
"self",
",",
"request",
")",
":",
"url",
"=",
"MgmtRequests",
".",
"mgmtRequests",
"r",
"=",
"self",
".",
"_apiClient",
".",
"post",
"(",
"url",
",",
"request",
")",
"if",
"r",
".",
"status_code",
"==",
"202",
":",
"return",
"... | 195f05adce3fba4ec997017e41e02ebd85c0c4cc |
test | MgmtRequests.delete | Clears the status of a device management request.
You can use this operation to clear the status for a completed request, or for an in-progress request which may never complete due to a problem.
It accepts requestId (string) as parameters
In case of failure it throws APIException | src/wiotp/sdk/api/mgmt/requests.py | def delete(self, requestId):
"""
Clears the status of a device management request.
You can use this operation to clear the status for a completed request, or for an in-progress request which may never complete due to a problem.
It accepts requestId (string) as parameters
In case ... | def delete(self, requestId):
"""
Clears the status of a device management request.
You can use this operation to clear the status for a completed request, or for an in-progress request which may never complete due to a problem.
It accepts requestId (string) as parameters
In case ... | [
"Clears",
"the",
"status",
"of",
"a",
"device",
"management",
"request",
".",
"You",
"can",
"use",
"this",
"operation",
"to",
"clear",
"the",
"status",
"for",
"a",
"completed",
"request",
"or",
"for",
"an",
"in",
"-",
"progress",
"request",
"which",
"may",... | ibm-watson-iot/iot-python | python | https://github.com/ibm-watson-iot/iot-python/blob/195f05adce3fba4ec997017e41e02ebd85c0c4cc/src/wiotp/sdk/api/mgmt/requests.py#L58-L71 | [
"def",
"delete",
"(",
"self",
",",
"requestId",
")",
":",
"url",
"=",
"MgmtRequests",
".",
"mgmtSingleRequest",
"%",
"(",
"requestId",
")",
"r",
"=",
"self",
".",
"_apiClient",
".",
"delete",
"(",
"url",
")",
"if",
"r",
".",
"status_code",
"==",
"204",... | 195f05adce3fba4ec997017e41e02ebd85c0c4cc |
test | MgmtRequests.get | Gets details of a device management request.
It accepts requestId (string) as parameters
In case of failure it throws APIException | src/wiotp/sdk/api/mgmt/requests.py | def get(self, requestId):
"""
Gets details of a device management request.
It accepts requestId (string) as parameters
In case of failure it throws APIException
"""
url = MgmtRequests.mgmtSingleRequest % (requestId)
r = self._apiClient.get(url)
if r.statu... | def get(self, requestId):
"""
Gets details of a device management request.
It accepts requestId (string) as parameters
In case of failure it throws APIException
"""
url = MgmtRequests.mgmtSingleRequest % (requestId)
r = self._apiClient.get(url)
if r.statu... | [
"Gets",
"details",
"of",
"a",
"device",
"management",
"request",
".",
"It",
"accepts",
"requestId",
"(",
"string",
")",
"as",
"parameters",
"In",
"case",
"of",
"failure",
"it",
"throws",
"APIException"
] | ibm-watson-iot/iot-python | python | https://github.com/ibm-watson-iot/iot-python/blob/195f05adce3fba4ec997017e41e02ebd85c0c4cc/src/wiotp/sdk/api/mgmt/requests.py#L73-L85 | [
"def",
"get",
"(",
"self",
",",
"requestId",
")",
":",
"url",
"=",
"MgmtRequests",
".",
"mgmtSingleRequest",
"%",
"(",
"requestId",
")",
"r",
"=",
"self",
".",
"_apiClient",
".",
"get",
"(",
"url",
")",
"if",
"r",
".",
"status_code",
"==",
"200",
":"... | 195f05adce3fba4ec997017e41e02ebd85c0c4cc |
test | MgmtRequests.getStatus | Get a list of device management request device statuses.
Get an individual device mangaement request device status. | src/wiotp/sdk/api/mgmt/requests.py | def getStatus(self, requestId, typeId=None, deviceId=None):
"""
Get a list of device management request device statuses.
Get an individual device mangaement request device status.
"""
if typeId is None or deviceId is None:
url = MgmtRequests.mgmtRequestStatus % (reque... | def getStatus(self, requestId, typeId=None, deviceId=None):
"""
Get a list of device management request device statuses.
Get an individual device mangaement request device status.
"""
if typeId is None or deviceId is None:
url = MgmtRequests.mgmtRequestStatus % (reque... | [
"Get",
"a",
"list",
"of",
"device",
"management",
"request",
"device",
"statuses",
".",
"Get",
"an",
"individual",
"device",
"mangaement",
"request",
"device",
"status",
"."
] | ibm-watson-iot/iot-python | python | https://github.com/ibm-watson-iot/iot-python/blob/195f05adce3fba4ec997017e41e02ebd85c0c4cc/src/wiotp/sdk/api/mgmt/requests.py#L87-L107 | [
"def",
"getStatus",
"(",
"self",
",",
"requestId",
",",
"typeId",
"=",
"None",
",",
"deviceId",
"=",
"None",
")",
":",
"if",
"typeId",
"is",
"None",
"or",
"deviceId",
"is",
"None",
":",
"url",
"=",
"MgmtRequests",
".",
"mgmtRequestStatus",
"%",
"(",
"r... | 195f05adce3fba4ec997017e41e02ebd85c0c4cc |
test | Index.close | Force a flush of the index to storage. Renders index
inaccessible. | rtree/index.py | def close(self):
"""Force a flush of the index to storage. Renders index
inaccessible."""
if self.handle:
self.handle.destroy()
self.handle = None
else:
raise IOError("Unclosable index") | def close(self):
"""Force a flush of the index to storage. Renders index
inaccessible."""
if self.handle:
self.handle.destroy()
self.handle = None
else:
raise IOError("Unclosable index") | [
"Force",
"a",
"flush",
"of",
"the",
"index",
"to",
"storage",
".",
"Renders",
"index",
"inaccessible",
"."
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/index.py#L298-L305 | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"handle",
":",
"self",
".",
"handle",
".",
"destroy",
"(",
")",
"self",
".",
"handle",
"=",
"None",
"else",
":",
"raise",
"IOError",
"(",
"\"Unclosable index\"",
")"
] | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | Index.insert | Inserts an item into the index with the given coordinates.
:param id: long integer
A long integer that is the identifier for this index entry. IDs
need not be unique to be inserted into the index, and it is up
to the user to ensure they are unique if this is a requirement.
... | rtree/index.py | def insert(self, id, coordinates, obj=None):
"""Inserts an item into the index with the given coordinates.
:param id: long integer
A long integer that is the identifier for this index entry. IDs
need not be unique to be inserted into the index, and it is up
to the u... | def insert(self, id, coordinates, obj=None):
"""Inserts an item into the index with the given coordinates.
:param id: long integer
A long integer that is the identifier for this index entry. IDs
need not be unique to be inserted into the index, and it is up
to the u... | [
"Inserts",
"an",
"item",
"into",
"the",
"index",
"with",
"the",
"given",
"coordinates",
"."
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/index.py#L356-L393 | [
"def",
"insert",
"(",
"self",
",",
"id",
",",
"coordinates",
",",
"obj",
"=",
"None",
")",
":",
"p_mins",
",",
"p_maxs",
"=",
"self",
".",
"get_coordinate_pointers",
"(",
"coordinates",
")",
"data",
"=",
"ctypes",
".",
"c_ubyte",
"(",
"0",
")",
"size",... | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | Index.count | Return number of objects that intersect the given coordinates.
:param coordinates: sequence or array
This may be an object that satisfies the numpy array
protocol, providing the index's dimension * 2 coordinate
pairs representing the `mink` and `maxk` coordinates in
... | rtree/index.py | def count(self, coordinates):
"""Return number of objects that intersect the given coordinates.
:param coordinates: sequence or array
This may be an object that satisfies the numpy array
protocol, providing the index's dimension * 2 coordinate
pairs representing the ... | def count(self, coordinates):
"""Return number of objects that intersect the given coordinates.
:param coordinates: sequence or array
This may be an object that satisfies the numpy array
protocol, providing the index's dimension * 2 coordinate
pairs representing the ... | [
"Return",
"number",
"of",
"objects",
"that",
"intersect",
"the",
"given",
"coordinates",
"."
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/index.py#L396-L430 | [
"def",
"count",
"(",
"self",
",",
"coordinates",
")",
":",
"p_mins",
",",
"p_maxs",
"=",
"self",
".",
"get_coordinate_pointers",
"(",
"coordinates",
")",
"p_num_results",
"=",
"ctypes",
".",
"c_uint64",
"(",
"0",
")",
"core",
".",
"rt",
".",
"Index_Interse... | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | Index.intersection | Return ids or objects in the index that intersect the given
coordinates.
:param coordinates: sequence or array
This may be an object that satisfies the numpy array
protocol, providing the index's dimension * 2 coordinate
pairs representing the `mink` and `maxk` coord... | rtree/index.py | def intersection(self, coordinates, objects=False):
"""Return ids or objects in the index that intersect the given
coordinates.
:param coordinates: sequence or array
This may be an object that satisfies the numpy array
protocol, providing the index's dimension * 2 coordi... | def intersection(self, coordinates, objects=False):
"""Return ids or objects in the index that intersect the given
coordinates.
:param coordinates: sequence or array
This may be an object that satisfies the numpy array
protocol, providing the index's dimension * 2 coordi... | [
"Return",
"ids",
"or",
"objects",
"in",
"the",
"index",
"that",
"intersect",
"the",
"given",
"coordinates",
"."
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/index.py#L432-L488 | [
"def",
"intersection",
"(",
"self",
",",
"coordinates",
",",
"objects",
"=",
"False",
")",
":",
"if",
"objects",
":",
"return",
"self",
".",
"_intersection_obj",
"(",
"coordinates",
",",
"objects",
")",
"p_mins",
",",
"p_maxs",
"=",
"self",
".",
"get_coord... | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | Index.nearest | Returns the ``k``-nearest objects to the given coordinates.
:param coordinates: sequence or array
This may be an object that satisfies the numpy array
protocol, providing the index's dimension * 2 coordinate
pairs representing the `mink` and `maxk` coordinates in
... | rtree/index.py | def nearest(self, coordinates, num_results=1, objects=False):
"""Returns the ``k``-nearest objects to the given coordinates.
:param coordinates: sequence or array
This may be an object that satisfies the numpy array
protocol, providing the index's dimension * 2 coordinate
... | def nearest(self, coordinates, num_results=1, objects=False):
"""Returns the ``k``-nearest objects to the given coordinates.
:param coordinates: sequence or array
This may be an object that satisfies the numpy array
protocol, providing the index's dimension * 2 coordinate
... | [
"Returns",
"the",
"k",
"-",
"nearest",
"objects",
"to",
"the",
"given",
"coordinates",
"."
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/index.py#L560-L604 | [
"def",
"nearest",
"(",
"self",
",",
"coordinates",
",",
"num_results",
"=",
"1",
",",
"objects",
"=",
"False",
")",
":",
"if",
"objects",
":",
"return",
"self",
".",
"_nearest_obj",
"(",
"coordinates",
",",
"num_results",
",",
"objects",
")",
"p_mins",
"... | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | Index.get_bounds | Returns the bounds of the index
:param coordinate_interleaved: If True, the coordinates are turned
in the form [xmin, ymin, ..., kmin, xmax, ymax, ..., kmax],
otherwise they are returned as
[xmin, xmax, ymin, ymax, ..., ..., kmin, kmax]. If not specified,
the :a... | rtree/index.py | def get_bounds(self, coordinate_interleaved=None):
"""Returns the bounds of the index
:param coordinate_interleaved: If True, the coordinates are turned
in the form [xmin, ymin, ..., kmin, xmax, ymax, ..., kmax],
otherwise they are returned as
[xmin, xmax, ymin, ymax... | def get_bounds(self, coordinate_interleaved=None):
"""Returns the bounds of the index
:param coordinate_interleaved: If True, the coordinates are turned
in the form [xmin, ymin, ..., kmin, xmax, ymax, ..., kmax],
otherwise they are returned as
[xmin, xmax, ymin, ymax... | [
"Returns",
"the",
"bounds",
"of",
"the",
"index"
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/index.py#L606-L619 | [
"def",
"get_bounds",
"(",
"self",
",",
"coordinate_interleaved",
"=",
"None",
")",
":",
"if",
"coordinate_interleaved",
"is",
"None",
":",
"coordinate_interleaved",
"=",
"self",
".",
"interleaved",
"return",
"_get_bounds",
"(",
"self",
".",
"handle",
",",
"core"... | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | Index.delete | Deletes items from the index with the given ``'id'`` within the
specified coordinates.
:param id: long integer
A long integer that is the identifier for this index entry. IDs
need not be unique to be inserted into the index, and it is up
to the user to ensure they a... | rtree/index.py | def delete(self, id, coordinates):
"""Deletes items from the index with the given ``'id'`` within the
specified coordinates.
:param id: long integer
A long integer that is the identifier for this index entry. IDs
need not be unique to be inserted into the index, and it ... | def delete(self, id, coordinates):
"""Deletes items from the index with the given ``'id'`` within the
specified coordinates.
:param id: long integer
A long integer that is the identifier for this index entry. IDs
need not be unique to be inserted into the index, and it ... | [
"Deletes",
"items",
"from",
"the",
"index",
"with",
"the",
"given",
"id",
"within",
"the",
"specified",
"coordinates",
"."
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/index.py#L622-L652 | [
"def",
"delete",
"(",
"self",
",",
"id",
",",
"coordinates",
")",
":",
"p_mins",
",",
"p_maxs",
"=",
"self",
".",
"get_coordinate_pointers",
"(",
"coordinates",
")",
"core",
".",
"rt",
".",
"Index_DeleteData",
"(",
"self",
".",
"handle",
",",
"id",
",",
... | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | Index.deinterleave | [xmin, ymin, xmax, ymax] => [xmin, xmax, ymin, ymax]
>>> Index.deinterleave([0, 10, 1, 11])
[0, 1, 10, 11]
>>> Index.deinterleave([0, 1, 2, 10, 11, 12])
[0, 10, 1, 11, 2, 12] | rtree/index.py | def deinterleave(self, interleaved):
"""
[xmin, ymin, xmax, ymax] => [xmin, xmax, ymin, ymax]
>>> Index.deinterleave([0, 10, 1, 11])
[0, 1, 10, 11]
>>> Index.deinterleave([0, 1, 2, 10, 11, 12])
[0, 10, 1, 11, 2, 12]
"""
assert len(interleaved) % 2 == 0,... | def deinterleave(self, interleaved):
"""
[xmin, ymin, xmax, ymax] => [xmin, xmax, ymin, ymax]
>>> Index.deinterleave([0, 10, 1, 11])
[0, 1, 10, 11]
>>> Index.deinterleave([0, 1, 2, 10, 11, 12])
[0, 10, 1, 11, 2, 12]
"""
assert len(interleaved) % 2 == 0,... | [
"[",
"xmin",
"ymin",
"xmax",
"ymax",
"]",
"=",
">",
"[",
"xmin",
"xmax",
"ymin",
"ymax",
"]"
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/index.py#L661-L677 | [
"def",
"deinterleave",
"(",
"self",
",",
"interleaved",
")",
":",
"assert",
"len",
"(",
"interleaved",
")",
"%",
"2",
"==",
"0",
",",
"(",
"\"must be a pairwise list\"",
")",
"dimension",
"=",
"len",
"(",
"interleaved",
")",
"//",
"2",
"di",
"=",
"[",
... | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | Index.interleave | [xmin, xmax, ymin, ymax, zmin, zmax]
=> [xmin, ymin, zmin, xmax, ymax, zmax]
>>> Index.interleave([0, 1, 10, 11])
[0, 10, 1, 11]
>>> Index.interleave([0, 10, 1, 11, 2, 12])
[0, 1, 2, 10, 11, 12]
>>> Index.interleave((-1, 1, 58, 62, 22, 24))
[-1, 58, 22, 1, ... | rtree/index.py | def interleave(self, deinterleaved):
"""
[xmin, xmax, ymin, ymax, zmin, zmax]
=> [xmin, ymin, zmin, xmax, ymax, zmax]
>>> Index.interleave([0, 1, 10, 11])
[0, 10, 1, 11]
>>> Index.interleave([0, 10, 1, 11, 2, 12])
[0, 1, 2, 10, 11, 12]
>>> Index.int... | def interleave(self, deinterleaved):
"""
[xmin, xmax, ymin, ymax, zmin, zmax]
=> [xmin, ymin, zmin, xmax, ymax, zmax]
>>> Index.interleave([0, 1, 10, 11])
[0, 10, 1, 11]
>>> Index.interleave([0, 10, 1, 11, 2, 12])
[0, 1, 2, 10, 11, 12]
>>> Index.int... | [
"[",
"xmin",
"xmax",
"ymin",
"ymax",
"zmin",
"zmax",
"]",
"=",
">",
"[",
"xmin",
"ymin",
"zmin",
"xmax",
"ymax",
"zmax",
"]"
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/index.py#L680-L701 | [
"def",
"interleave",
"(",
"self",
",",
"deinterleaved",
")",
":",
"assert",
"len",
"(",
"deinterleaved",
")",
"%",
"2",
"==",
"0",
",",
"(",
"\"must be a pairwise list\"",
")",
"# dimension = len(deinterleaved) / 2",
"interleaved",
"=",
"[",
"]",
"for",
"i",
... | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | Index._create_idx_from_stream | This function is used to instantiate the index given an
iterable stream of data. | rtree/index.py | def _create_idx_from_stream(self, stream):
"""This function is used to instantiate the index given an
iterable stream of data."""
stream_iter = iter(stream)
dimension = self.properties.dimension
darray = ctypes.c_double * dimension
mins = darray()
maxs = darray()... | def _create_idx_from_stream(self, stream):
"""This function is used to instantiate the index given an
iterable stream of data."""
stream_iter = iter(stream)
dimension = self.properties.dimension
darray = ctypes.c_double * dimension
mins = darray()
maxs = darray()... | [
"This",
"function",
"is",
"used",
"to",
"instantiate",
"the",
"index",
"given",
"an",
"iterable",
"stream",
"of",
"data",
"."
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/index.py#L703-L754 | [
"def",
"_create_idx_from_stream",
"(",
"self",
",",
"stream",
")",
":",
"stream_iter",
"=",
"iter",
"(",
"stream",
")",
"dimension",
"=",
"self",
".",
"properties",
".",
"dimension",
"darray",
"=",
"ctypes",
".",
"c_double",
"*",
"dimension",
"mins",
"=",
... | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | CustomStorageBase.destroy | please override | rtree/index.py | def destroy(self, context, returnError):
"""please override"""
returnError.contents.value = self.IllegalStateError
raise NotImplementedError("You must override this method.") | def destroy(self, context, returnError):
"""please override"""
returnError.contents.value = self.IllegalStateError
raise NotImplementedError("You must override this method.") | [
"please",
"override"
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/index.py#L1348-L1351 | [
"def",
"destroy",
"(",
"self",
",",
"context",
",",
"returnError",
")",
":",
"returnError",
".",
"contents",
".",
"value",
"=",
"self",
".",
"IllegalStateError",
"raise",
"NotImplementedError",
"(",
"\"You must override this method.\"",
")"
] | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | CustomStorageBase.loadByteArray | please override | rtree/index.py | def loadByteArray(self, context, page, resultLen, resultData, returnError):
"""please override"""
returnError.contents.value = self.IllegalStateError
raise NotImplementedError("You must override this method.") | def loadByteArray(self, context, page, resultLen, resultData, returnError):
"""please override"""
returnError.contents.value = self.IllegalStateError
raise NotImplementedError("You must override this method.") | [
"please",
"override"
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/index.py#L1353-L1356 | [
"def",
"loadByteArray",
"(",
"self",
",",
"context",
",",
"page",
",",
"resultLen",
",",
"resultData",
",",
"returnError",
")",
":",
"returnError",
".",
"contents",
".",
"value",
"=",
"self",
".",
"IllegalStateError",
"raise",
"NotImplementedError",
"(",
"\"Yo... | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | CustomStorageBase.storeByteArray | please override | rtree/index.py | def storeByteArray(self, context, page, len, data, returnError):
"""please override"""
returnError.contents.value = self.IllegalStateError
raise NotImplementedError("You must override this method.") | def storeByteArray(self, context, page, len, data, returnError):
"""please override"""
returnError.contents.value = self.IllegalStateError
raise NotImplementedError("You must override this method.") | [
"please",
"override"
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/index.py#L1358-L1361 | [
"def",
"storeByteArray",
"(",
"self",
",",
"context",
",",
"page",
",",
"len",
",",
"data",
",",
"returnError",
")",
":",
"returnError",
".",
"contents",
".",
"value",
"=",
"self",
".",
"IllegalStateError",
"raise",
"NotImplementedError",
"(",
"\"You must over... | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | CustomStorageBase.deleteByteArray | please override | rtree/index.py | def deleteByteArray(self, context, page, returnError):
"""please override"""
returnError.contents.value = self.IllegalStateError
raise NotImplementedError("You must override this method.") | def deleteByteArray(self, context, page, returnError):
"""please override"""
returnError.contents.value = self.IllegalStateError
raise NotImplementedError("You must override this method.") | [
"please",
"override"
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/index.py#L1363-L1366 | [
"def",
"deleteByteArray",
"(",
"self",
",",
"context",
",",
"page",
",",
"returnError",
")",
":",
"returnError",
".",
"contents",
".",
"value",
"=",
"self",
".",
"IllegalStateError",
"raise",
"NotImplementedError",
"(",
"\"You must override this method.\"",
")"
] | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | CustomStorageBase.flush | please override | rtree/index.py | def flush(self, context, returnError):
"""please override"""
returnError.contents.value = self.IllegalStateError
raise NotImplementedError("You must override this method.") | def flush(self, context, returnError):
"""please override"""
returnError.contents.value = self.IllegalStateError
raise NotImplementedError("You must override this method.") | [
"please",
"override"
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/index.py#L1368-L1371 | [
"def",
"flush",
"(",
"self",
",",
"context",
",",
"returnError",
")",
":",
"returnError",
".",
"contents",
".",
"value",
"=",
"self",
".",
"IllegalStateError",
"raise",
"NotImplementedError",
"(",
"\"You must override this method.\"",
")"
] | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | CustomStorage.loadByteArray | Must be overridden. Must return a string with the loaded data. | rtree/index.py | def loadByteArray(self, page, returnError):
"""Must be overridden. Must return a string with the loaded data."""
returnError.contents.value = self.IllegalStateError
raise NotImplementedError("You must override this method.")
return '' | def loadByteArray(self, page, returnError):
"""Must be overridden. Must return a string with the loaded data."""
returnError.contents.value = self.IllegalStateError
raise NotImplementedError("You must override this method.")
return '' | [
"Must",
"be",
"overridden",
".",
"Must",
"return",
"a",
"string",
"with",
"the",
"loaded",
"data",
"."
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/index.py#L1441-L1445 | [
"def",
"loadByteArray",
"(",
"self",
",",
"page",
",",
"returnError",
")",
":",
"returnError",
".",
"contents",
".",
"value",
"=",
"self",
".",
"IllegalStateError",
"raise",
"NotImplementedError",
"(",
"\"You must override this method.\"",
")",
"return",
"''"
] | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | RtreeContainer.insert | Inserts an item into the index with the given coordinates.
:param obj: object
Any object.
:param coordinates: sequence or array
This may be an object that satisfies the numpy array
protocol, providing the index's dimension * 2 coordinate
pairs representi... | rtree/index.py | def insert(self, obj, coordinates):
"""Inserts an item into the index with the given coordinates.
:param obj: object
Any object.
:param coordinates: sequence or array
This may be an object that satisfies the numpy array
protocol, providing the index's dimens... | def insert(self, obj, coordinates):
"""Inserts an item into the index with the given coordinates.
:param obj: object
Any object.
:param coordinates: sequence or array
This may be an object that satisfies the numpy array
protocol, providing the index's dimens... | [
"Inserts",
"an",
"item",
"into",
"the",
"index",
"with",
"the",
"given",
"coordinates",
"."
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/index.py#L1529-L1557 | [
"def",
"insert",
"(",
"self",
",",
"obj",
",",
"coordinates",
")",
":",
"try",
":",
"count",
"=",
"self",
".",
"_objects",
"[",
"id",
"(",
"obj",
")",
"]",
"+",
"1",
"except",
"KeyError",
":",
"count",
"=",
"1",
"self",
".",
"_objects",
"[",
"id"... | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | RtreeContainer.intersection | Return ids or objects in the index that intersect the given
coordinates.
:param coordinates: sequence or array
This may be an object that satisfies the numpy array
protocol, providing the index's dimension * 2 coordinate
pairs representing the `mink` and `maxk` coord... | rtree/index.py | def intersection(self, coordinates, bbox=False):
"""Return ids or objects in the index that intersect the given
coordinates.
:param coordinates: sequence or array
This may be an object that satisfies the numpy array
protocol, providing the index's dimension * 2 coordinat... | def intersection(self, coordinates, bbox=False):
"""Return ids or objects in the index that intersect the given
coordinates.
:param coordinates: sequence or array
This may be an object that satisfies the numpy array
protocol, providing the index's dimension * 2 coordinat... | [
"Return",
"ids",
"or",
"objects",
"in",
"the",
"index",
"that",
"intersect",
"the",
"given",
"coordinates",
"."
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/index.py#L1561-L1609 | [
"def",
"intersection",
"(",
"self",
",",
"coordinates",
",",
"bbox",
"=",
"False",
")",
":",
"if",
"bbox",
"==",
"False",
":",
"for",
"id",
"in",
"super",
"(",
"RtreeContainer",
",",
"self",
")",
".",
"intersection",
"(",
"coordinates",
",",
"bbox",
")... | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | RtreeContainer.delete | Deletes the item from the container within the specified
coordinates.
:param obj: object
Any object.
:param coordinates: sequence or array
Dimension * 2 coordinate pairs, representing the min
and max coordinates in each dimension of the item to be
... | rtree/index.py | def delete(self, obj, coordinates):
"""Deletes the item from the container within the specified
coordinates.
:param obj: object
Any object.
:param coordinates: sequence or array
Dimension * 2 coordinate pairs, representing the min
and max coordinates... | def delete(self, obj, coordinates):
"""Deletes the item from the container within the specified
coordinates.
:param obj: object
Any object.
:param coordinates: sequence or array
Dimension * 2 coordinate pairs, representing the min
and max coordinates... | [
"Deletes",
"the",
"item",
"from",
"the",
"container",
"within",
"the",
"specified",
"coordinates",
"."
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/index.py#L1651-L1688 | [
"def",
"delete",
"(",
"self",
",",
"obj",
",",
"coordinates",
")",
":",
"try",
":",
"count",
"=",
"self",
".",
"_objects",
"[",
"id",
"(",
"obj",
")",
"]",
"-",
"1",
"except",
"KeyError",
":",
"raise",
"IndexError",
"(",
"'object is not in the index'",
... | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | check_return | Error checking for Error calls | rtree/core.py | def check_return(result, func, cargs):
"Error checking for Error calls"
if result != 0:
s = rt.Error_GetLastErrorMsg().decode()
msg = 'LASError in "%s": %s' % \
(func.__name__, s)
rt.Error_Reset()
raise RTreeError(msg)
return True | def check_return(result, func, cargs):
"Error checking for Error calls"
if result != 0:
s = rt.Error_GetLastErrorMsg().decode()
msg = 'LASError in "%s": %s' % \
(func.__name__, s)
rt.Error_Reset()
raise RTreeError(msg)
return True | [
"Error",
"checking",
"for",
"Error",
"calls"
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/core.py#L11-L19 | [
"def",
"check_return",
"(",
"result",
",",
"func",
",",
"cargs",
")",
":",
"if",
"result",
"!=",
"0",
":",
"s",
"=",
"rt",
".",
"Error_GetLastErrorMsg",
"(",
")",
".",
"decode",
"(",
")",
"msg",
"=",
"'LASError in \"%s\": %s'",
"%",
"(",
"func",
".",
... | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | check_void | Error checking for void* returns | rtree/core.py | def check_void(result, func, cargs):
"Error checking for void* returns"
if not bool(result):
s = rt.Error_GetLastErrorMsg().decode()
msg = 'Error in "%s": %s' % (func.__name__, s)
rt.Error_Reset()
raise RTreeError(msg)
return result | def check_void(result, func, cargs):
"Error checking for void* returns"
if not bool(result):
s = rt.Error_GetLastErrorMsg().decode()
msg = 'Error in "%s": %s' % (func.__name__, s)
rt.Error_Reset()
raise RTreeError(msg)
return result | [
"Error",
"checking",
"for",
"void",
"*",
"returns"
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/core.py#L22-L29 | [
"def",
"check_void",
"(",
"result",
",",
"func",
",",
"cargs",
")",
":",
"if",
"not",
"bool",
"(",
"result",
")",
":",
"s",
"=",
"rt",
".",
"Error_GetLastErrorMsg",
"(",
")",
".",
"decode",
"(",
")",
"msg",
"=",
"'Error in \"%s\": %s'",
"%",
"(",
"fu... | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | check_void_done | Error checking for void* returns that might be empty with no error | rtree/core.py | def check_void_done(result, func, cargs):
"Error checking for void* returns that might be empty with no error"
if rt.Error_GetErrorCount():
s = rt.Error_GetLastErrorMsg().decode()
msg = 'Error in "%s": %s' % (func.__name__, s)
rt.Error_Reset()
raise RTreeError(msg)
return res... | def check_void_done(result, func, cargs):
"Error checking for void* returns that might be empty with no error"
if rt.Error_GetErrorCount():
s = rt.Error_GetLastErrorMsg().decode()
msg = 'Error in "%s": %s' % (func.__name__, s)
rt.Error_Reset()
raise RTreeError(msg)
return res... | [
"Error",
"checking",
"for",
"void",
"*",
"returns",
"that",
"might",
"be",
"empty",
"with",
"no",
"error"
] | Toblerity/rtree | python | https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/core.py#L32-L39 | [
"def",
"check_void_done",
"(",
"result",
",",
"func",
",",
"cargs",
")",
":",
"if",
"rt",
".",
"Error_GetErrorCount",
"(",
")",
":",
"s",
"=",
"rt",
".",
"Error_GetLastErrorMsg",
"(",
")",
".",
"decode",
"(",
")",
"msg",
"=",
"'Error in \"%s\": %s'",
"%"... | 5d33357c8e88f1a8344415dc15a7d2440211b281 |
test | WSGIApp.load | Attempt an import of the specified application | flask_common.py | def load(self):
""" Attempt an import of the specified application """
if isinstance(self.application, str):
return util.import_app(self.application)
else:
return self.application | def load(self):
""" Attempt an import of the specified application """
if isinstance(self.application, str):
return util.import_app(self.application)
else:
return self.application | [
"Attempt",
"an",
"import",
"of",
"the",
"specified",
"application"
] | kennethreitz/flask-common | python | https://github.com/kennethreitz/flask-common/blob/7345514942f863396056e0fd252f29082623cec6/flask_common.py#L69-L75 | [
"def",
"load",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"application",
",",
"str",
")",
":",
"return",
"util",
".",
"import_app",
"(",
"self",
".",
"application",
")",
"else",
":",
"return",
"self",
".",
"application"
] | 7345514942f863396056e0fd252f29082623cec6 |
test | Common.init_app | Initializes the Flask application with Common. | flask_common.py | def init_app(self, app):
"""Initializes the Flask application with Common."""
if not hasattr(app, 'extensions'):
app.extensions = {}
if 'common' in app.extensions:
raise RuntimeError("Flask-Common extension already initialized")
app.extensions['common'] = self
... | def init_app(self, app):
"""Initializes the Flask application with Common."""
if not hasattr(app, 'extensions'):
app.extensions = {}
if 'common' in app.extensions:
raise RuntimeError("Flask-Common extension already initialized")
app.extensions['common'] = self
... | [
"Initializes",
"the",
"Flask",
"application",
"with",
"Common",
"."
] | kennethreitz/flask-common | python | https://github.com/kennethreitz/flask-common/blob/7345514942f863396056e0fd252f29082623cec6/flask_common.py#L101-L134 | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"if",
"not",
"hasattr",
"(",
"app",
",",
"'extensions'",
")",
":",
"app",
".",
"extensions",
"=",
"{",
"}",
"if",
"'common'",
"in",
"app",
".",
"extensions",
":",
"raise",
"RuntimeError",
"(",
"\"... | 7345514942f863396056e0fd252f29082623cec6 |
test | Common.serve | Serves the Flask application. | flask_common.py | def serve(self, workers=None, **kwargs):
"""Serves the Flask application."""
if self.app.debug:
print(crayons.yellow('Booting Flask development server...'))
self.app.run()
else:
print(crayons.yellow('Booting Gunicorn...'))
# Start the web server.... | def serve(self, workers=None, **kwargs):
"""Serves the Flask application."""
if self.app.debug:
print(crayons.yellow('Booting Flask development server...'))
self.app.run()
else:
print(crayons.yellow('Booting Gunicorn...'))
# Start the web server.... | [
"Serves",
"the",
"Flask",
"application",
"."
] | kennethreitz/flask-common | python | https://github.com/kennethreitz/flask-common/blob/7345514942f863396056e0fd252f29082623cec6/flask_common.py#L136-L149 | [
"def",
"serve",
"(",
"self",
",",
"workers",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"app",
".",
"debug",
":",
"print",
"(",
"crayons",
".",
"yellow",
"(",
"'Booting Flask development server...'",
")",
")",
"self",
".",
"app"... | 7345514942f863396056e0fd252f29082623cec6 |
test | VersatileImageFieldSerializer.to_native | For djangorestframework <=2.3.14 | versatileimagefield/serializers.py | def to_native(self, value):
"""For djangorestframework <=2.3.14"""
context_request = None
if self.context:
context_request = self.context.get('request', None)
return build_versatileimagefield_url_set(
value,
self.sizes,
request=context_requ... | def to_native(self, value):
"""For djangorestframework <=2.3.14"""
context_request = None
if self.context:
context_request = self.context.get('request', None)
return build_versatileimagefield_url_set(
value,
self.sizes,
request=context_requ... | [
"For",
"djangorestframework",
"<",
"=",
"2",
".",
"3",
".",
"14"
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/serializers.py#L42-L51 | [
"def",
"to_native",
"(",
"self",
",",
"value",
")",
":",
"context_request",
"=",
"None",
"if",
"self",
".",
"context",
":",
"context_request",
"=",
"self",
".",
"context",
".",
"get",
"(",
"'request'",
",",
"None",
")",
"return",
"build_versatileimagefield_u... | d41e279c39cccffafbe876c67596184704ae8877 |
test | CroppedImage.crop_on_centerpoint | Return a PIL Image instance cropped from `image`.
Image has an aspect ratio provided by dividing `width` / `height`),
sized down to `width`x`height`. Any 'excess pixels' are trimmed away
in respect to the pixel of `image` that corresponds to `ppoi` (Primary
Point of Interest).
... | versatileimagefield/versatileimagefield.py | def crop_on_centerpoint(self, image, width, height, ppoi=(0.5, 0.5)):
"""
Return a PIL Image instance cropped from `image`.
Image has an aspect ratio provided by dividing `width` / `height`),
sized down to `width`x`height`. Any 'excess pixels' are trimmed away
in respect to the ... | def crop_on_centerpoint(self, image, width, height, ppoi=(0.5, 0.5)):
"""
Return a PIL Image instance cropped from `image`.
Image has an aspect ratio provided by dividing `width` / `height`),
sized down to `width`x`height`. Any 'excess pixels' are trimmed away
in respect to the ... | [
"Return",
"a",
"PIL",
"Image",
"instance",
"cropped",
"from",
"image",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/versatileimagefield.py#L30-L122 | [
"def",
"crop_on_centerpoint",
"(",
"self",
",",
"image",
",",
"width",
",",
"height",
",",
"ppoi",
"=",
"(",
"0.5",
",",
"0.5",
")",
")",
":",
"ppoi_x_axis",
"=",
"int",
"(",
"image",
".",
"size",
"[",
"0",
"]",
"*",
"ppoi",
"[",
"0",
"]",
")",
... | d41e279c39cccffafbe876c67596184704ae8877 |
test | CroppedImage.process_image | Return a BytesIO instance of `image` cropped to `width` and `height`.
Cropping will first reduce an image down to its longest side
and then crop inwards centered on the Primary Point of Interest
(as specified by `self.ppoi`) | versatileimagefield/versatileimagefield.py | def process_image(self, image, image_format, save_kwargs,
width, height):
"""
Return a BytesIO instance of `image` cropped to `width` and `height`.
Cropping will first reduce an image down to its longest side
and then crop inwards centered on the Primary Point of I... | def process_image(self, image, image_format, save_kwargs,
width, height):
"""
Return a BytesIO instance of `image` cropped to `width` and `height`.
Cropping will first reduce an image down to its longest side
and then crop inwards centered on the Primary Point of I... | [
"Return",
"a",
"BytesIO",
"instance",
"of",
"image",
"cropped",
"to",
"width",
"and",
"height",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/versatileimagefield.py#L124-L152 | [
"def",
"process_image",
"(",
"self",
",",
"image",
",",
"image_format",
",",
"save_kwargs",
",",
"width",
",",
"height",
")",
":",
"imagefile",
"=",
"BytesIO",
"(",
")",
"palette",
"=",
"image",
".",
"getpalette",
"(",
")",
"cropped_image",
"=",
"self",
... | d41e279c39cccffafbe876c67596184704ae8877 |
test | ThumbnailImage.process_image | Return a BytesIO instance of `image` that fits in a bounding box.
Bounding box dimensions are `width`x`height`. | versatileimagefield/versatileimagefield.py | def process_image(self, image, image_format, save_kwargs,
width, height):
"""
Return a BytesIO instance of `image` that fits in a bounding box.
Bounding box dimensions are `width`x`height`.
"""
imagefile = BytesIO()
image.thumbnail(
(wid... | def process_image(self, image, image_format, save_kwargs,
width, height):
"""
Return a BytesIO instance of `image` that fits in a bounding box.
Bounding box dimensions are `width`x`height`.
"""
imagefile = BytesIO()
image.thumbnail(
(wid... | [
"Return",
"a",
"BytesIO",
"instance",
"of",
"image",
"that",
"fits",
"in",
"a",
"bounding",
"box",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/versatileimagefield.py#L164-L180 | [
"def",
"process_image",
"(",
"self",
",",
"image",
",",
"image_format",
",",
"save_kwargs",
",",
"width",
",",
"height",
")",
":",
"imagefile",
"=",
"BytesIO",
"(",
")",
"image",
".",
"thumbnail",
"(",
"(",
"width",
",",
"height",
")",
",",
"Image",
".... | d41e279c39cccffafbe876c67596184704ae8877 |
test | InvertImage.process_image | Return a BytesIO instance of `image` with inverted colors. | versatileimagefield/versatileimagefield.py | def process_image(self, image, image_format, save_kwargs={}):
"""Return a BytesIO instance of `image` with inverted colors."""
imagefile = BytesIO()
inv_image = ImageOps.invert(image)
inv_image.save(
imagefile,
**save_kwargs
)
return imagefile | def process_image(self, image, image_format, save_kwargs={}):
"""Return a BytesIO instance of `image` with inverted colors."""
imagefile = BytesIO()
inv_image = ImageOps.invert(image)
inv_image.save(
imagefile,
**save_kwargs
)
return imagefile | [
"Return",
"a",
"BytesIO",
"instance",
"of",
"image",
"with",
"inverted",
"colors",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/versatileimagefield.py#L190-L198 | [
"def",
"process_image",
"(",
"self",
",",
"image",
",",
"image_format",
",",
"save_kwargs",
"=",
"{",
"}",
")",
":",
"imagefile",
"=",
"BytesIO",
"(",
")",
"inv_image",
"=",
"ImageOps",
".",
"invert",
"(",
"image",
")",
"inv_image",
".",
"save",
"(",
"... | d41e279c39cccffafbe876c67596184704ae8877 |
test | VersatileImageFormField.to_python | Ensure data is prepped properly before handing off to ImageField. | versatileimagefield/forms.py | def to_python(self, data):
"""Ensure data is prepped properly before handing off to ImageField."""
if data is not None:
if hasattr(data, 'open'):
data.open()
return super(VersatileImageFormField, self).to_python(data) | def to_python(self, data):
"""Ensure data is prepped properly before handing off to ImageField."""
if data is not None:
if hasattr(data, 'open'):
data.open()
return super(VersatileImageFormField, self).to_python(data) | [
"Ensure",
"data",
"is",
"prepped",
"properly",
"before",
"handing",
"off",
"to",
"ImageField",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/forms.py#L19-L24 | [
"def",
"to_python",
"(",
"self",
",",
"data",
")",
":",
"if",
"data",
"is",
"not",
"None",
":",
"if",
"hasattr",
"(",
"data",
",",
"'open'",
")",
":",
"data",
".",
"open",
"(",
")",
"return",
"super",
"(",
"VersatileImageFormField",
",",
"self",
")",... | d41e279c39cccffafbe876c67596184704ae8877 |
test | VersatileImageField.process_placeholder_image | Process the field's placeholder image.
Ensures the placeholder image has been saved to the same storage class
as the field in a top level folder with a name specified by
settings.VERSATILEIMAGEFIELD_SETTINGS['placeholder_directory_name']
This should be called by the VersatileImageFileD... | versatileimagefield/fields.py | def process_placeholder_image(self):
"""
Process the field's placeholder image.
Ensures the placeholder image has been saved to the same storage class
as the field in a top level folder with a name specified by
settings.VERSATILEIMAGEFIELD_SETTINGS['placeholder_directory_name']
... | def process_placeholder_image(self):
"""
Process the field's placeholder image.
Ensures the placeholder image has been saved to the same storage class
as the field in a top level folder with a name specified by
settings.VERSATILEIMAGEFIELD_SETTINGS['placeholder_directory_name']
... | [
"Process",
"the",
"field",
"s",
"placeholder",
"image",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/fields.py#L50-L79 | [
"def",
"process_placeholder_image",
"(",
"self",
")",
":",
"if",
"self",
".",
"placeholder_image_name",
":",
"return",
"placeholder_image_name",
"=",
"None",
"placeholder_image",
"=",
"self",
".",
"placeholder_image",
"if",
"placeholder_image",
":",
"if",
"isinstance"... | d41e279c39cccffafbe876c67596184704ae8877 |
test | VersatileImageField.pre_save | Return field's value just before saving. | versatileimagefield/fields.py | def pre_save(self, model_instance, add):
"""Return field's value just before saving."""
file = super(VersatileImageField, self).pre_save(model_instance, add)
self.update_ppoi_field(model_instance)
return file | def pre_save(self, model_instance, add):
"""Return field's value just before saving."""
file = super(VersatileImageField, self).pre_save(model_instance, add)
self.update_ppoi_field(model_instance)
return file | [
"Return",
"field",
"s",
"value",
"just",
"before",
"saving",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/fields.py#L81-L85 | [
"def",
"pre_save",
"(",
"self",
",",
"model_instance",
",",
"add",
")",
":",
"file",
"=",
"super",
"(",
"VersatileImageField",
",",
"self",
")",
".",
"pre_save",
"(",
"model_instance",
",",
"add",
")",
"self",
".",
"update_ppoi_field",
"(",
"model_instance",... | d41e279c39cccffafbe876c67596184704ae8877 |
test | VersatileImageField.update_ppoi_field | Update field's ppoi field, if defined.
This method is hooked up this field's pre_save method to update
the ppoi immediately before the model instance (`instance`)
it is associated with is saved.
This field's ppoi can be forced to update with force=True,
which is how VersatileIm... | versatileimagefield/fields.py | def update_ppoi_field(self, instance, *args, **kwargs):
"""
Update field's ppoi field, if defined.
This method is hooked up this field's pre_save method to update
the ppoi immediately before the model instance (`instance`)
it is associated with is saved.
This field's pp... | def update_ppoi_field(self, instance, *args, **kwargs):
"""
Update field's ppoi field, if defined.
This method is hooked up this field's pre_save method to update
the ppoi immediately before the model instance (`instance`)
it is associated with is saved.
This field's pp... | [
"Update",
"field",
"s",
"ppoi",
"field",
"if",
"defined",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/fields.py#L87-L117 | [
"def",
"update_ppoi_field",
"(",
"self",
",",
"instance",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Nothing to update if the field doesn't have have a ppoi",
"# dimension field.",
"if",
"not",
"self",
".",
"ppoi_field",
":",
"return",
"# getattr will cal... | d41e279c39cccffafbe876c67596184704ae8877 |
test | VersatileImageField.save_form_data | Handle data sent from MultiValueField forms that set ppoi values.
`instance`: The model instance that is being altered via a form
`data`: The data sent from the form to this field which can be either:
* `None`: This is unset data from an optional field
* A two-position tuple: (image_for... | versatileimagefield/fields.py | def save_form_data(self, instance, data):
"""
Handle data sent from MultiValueField forms that set ppoi values.
`instance`: The model instance that is being altered via a form
`data`: The data sent from the form to this field which can be either:
* `None`: This is unset data fro... | def save_form_data(self, instance, data):
"""
Handle data sent from MultiValueField forms that set ppoi values.
`instance`: The model instance that is being altered via a form
`data`: The data sent from the form to this field which can be either:
* `None`: This is unset data fro... | [
"Handle",
"data",
"sent",
"from",
"MultiValueField",
"forms",
"that",
"set",
"ppoi",
"values",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/fields.py#L119-L154 | [
"def",
"save_form_data",
"(",
"self",
",",
"instance",
",",
"data",
")",
":",
"to_assign",
"=",
"data",
"if",
"data",
"and",
"isinstance",
"(",
"data",
",",
"tuple",
")",
":",
"# This value is coming from a MultiValueField",
"if",
"data",
"[",
"0",
"]",
"is"... | d41e279c39cccffafbe876c67596184704ae8877 |
test | VersatileImageField.formfield | Return a formfield. | versatileimagefield/fields.py | def formfield(self, **kwargs):
"""Return a formfield."""
# This is a fairly standard way to set up some defaults
# while letting the caller override them.
defaults = {}
if self.ppoi_field:
defaults['form_class'] = SizedImageCenterpointClickDjangoAdminField
if ... | def formfield(self, **kwargs):
"""Return a formfield."""
# This is a fairly standard way to set up some defaults
# while letting the caller override them.
defaults = {}
if self.ppoi_field:
defaults['form_class'] = SizedImageCenterpointClickDjangoAdminField
if ... | [
"Return",
"a",
"formfield",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/fields.py#L156-L181 | [
"def",
"formfield",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# This is a fairly standard way to set up some defaults",
"# while letting the caller override them.",
"defaults",
"=",
"{",
"}",
"if",
"self",
".",
"ppoi_field",
":",
"defaults",
"[",
"'form_class'",
... | d41e279c39cccffafbe876c67596184704ae8877 |
test | PPOIField.value_to_string | Prepare field for serialization. | versatileimagefield/fields.py | def value_to_string(self, obj):
"""Prepare field for serialization."""
if DJANGO_VERSION > (1, 9):
value = self.value_from_object(obj)
else:
value = self._get_val_from_obj(obj)
return self.get_prep_value(value) | def value_to_string(self, obj):
"""Prepare field for serialization."""
if DJANGO_VERSION > (1, 9):
value = self.value_from_object(obj)
else:
value = self._get_val_from_obj(obj)
return self.get_prep_value(value) | [
"Prepare",
"field",
"for",
"serialization",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/fields.py#L223-L229 | [
"def",
"value_to_string",
"(",
"self",
",",
"obj",
")",
":",
"if",
"DJANGO_VERSION",
">",
"(",
"1",
",",
"9",
")",
":",
"value",
"=",
"self",
".",
"value_from_object",
"(",
"obj",
")",
"else",
":",
"value",
"=",
"self",
".",
"_get_val_from_obj",
"(",
... | d41e279c39cccffafbe876c67596184704ae8877 |
test | cli_progress_bar | Prints out a Yum-style progress bar (via sys.stdout.write).
`start`: The 'current' value of the progress bar.
`end`: The '100%' value of the progress bar.
`bar_length`: The size of the overall progress bar.
Example output with start=20, end=100, bar_length=50:
[###########--------------------------... | versatileimagefield/image_warmer.py | def cli_progress_bar(start, end, bar_length=50):
"""
Prints out a Yum-style progress bar (via sys.stdout.write).
`start`: The 'current' value of the progress bar.
`end`: The '100%' value of the progress bar.
`bar_length`: The size of the overall progress bar.
Example output with start=20, end=1... | def cli_progress_bar(start, end, bar_length=50):
"""
Prints out a Yum-style progress bar (via sys.stdout.write).
`start`: The 'current' value of the progress bar.
`end`: The '100%' value of the progress bar.
`bar_length`: The size of the overall progress bar.
Example output with start=20, end=1... | [
"Prints",
"out",
"a",
"Yum",
"-",
"style",
"progress",
"bar",
"(",
"via",
"sys",
".",
"stdout",
".",
"write",
")",
".",
"start",
":",
"The",
"current",
"value",
"of",
"the",
"progress",
"bar",
".",
"end",
":",
"The",
"100%",
"value",
"of",
"the",
"... | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/image_warmer.py#L20-L49 | [
"def",
"cli_progress_bar",
"(",
"start",
",",
"end",
",",
"bar_length",
"=",
"50",
")",
":",
"percent",
"=",
"float",
"(",
"start",
")",
"/",
"end",
"hashes",
"=",
"'#'",
"*",
"int",
"(",
"round",
"(",
"percent",
"*",
"bar_length",
")",
")",
"spaces"... | d41e279c39cccffafbe876c67596184704ae8877 |
test | VersatileImageFieldWarmer._prewarm_versatileimagefield | Returns a 2-tuple:
0: bool signifying whether the image was successfully pre-warmed
1: The url of the successfully created image OR the path on storage of
the image that was not able to be successfully created.
Arguments:
`size_key_list`: A list of VersatileImageField size ke... | versatileimagefield/image_warmer.py | def _prewarm_versatileimagefield(size_key, versatileimagefieldfile):
"""
Returns a 2-tuple:
0: bool signifying whether the image was successfully pre-warmed
1: The url of the successfully created image OR the path on storage of
the image that was not able to be successfully cr... | def _prewarm_versatileimagefield(size_key, versatileimagefieldfile):
"""
Returns a 2-tuple:
0: bool signifying whether the image was successfully pre-warmed
1: The url of the successfully created image OR the path on storage of
the image that was not able to be successfully cr... | [
"Returns",
"a",
"2",
"-",
"tuple",
":",
"0",
":",
"bool",
"signifying",
"whether",
"the",
"image",
"was",
"successfully",
"pre",
"-",
"warmed",
"1",
":",
"The",
"url",
"of",
"the",
"successfully",
"created",
"image",
"OR",
"the",
"path",
"on",
"storage",... | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/image_warmer.py#L102-L126 | [
"def",
"_prewarm_versatileimagefield",
"(",
"size_key",
",",
"versatileimagefieldfile",
")",
":",
"versatileimagefieldfile",
".",
"create_on_demand",
"=",
"True",
"try",
":",
"url",
"=",
"get_url_from_image_key",
"(",
"versatileimagefieldfile",
",",
"size_key",
")",
"ex... | d41e279c39cccffafbe876c67596184704ae8877 |
test | VersatileImageFieldWarmer.warm | Returns a 2-tuple:
[0]: Number of images successfully pre-warmed
[1]: A list of paths on the storage class associated with the
VersatileImageField field being processed by `self` of
files that could not be successfully seeded. | versatileimagefield/image_warmer.py | def warm(self):
"""
Returns a 2-tuple:
[0]: Number of images successfully pre-warmed
[1]: A list of paths on the storage class associated with the
VersatileImageField field being processed by `self` of
files that could not be successfully seeded.
"""
... | def warm(self):
"""
Returns a 2-tuple:
[0]: Number of images successfully pre-warmed
[1]: A list of paths on the storage class associated with the
VersatileImageField field being processed by `self` of
files that could not be successfully seeded.
"""
... | [
"Returns",
"a",
"2",
"-",
"tuple",
":",
"[",
"0",
"]",
":",
"Number",
"of",
"images",
"successfully",
"pre",
"-",
"warmed",
"[",
"1",
"]",
":",
"A",
"list",
"of",
"paths",
"on",
"the",
"storage",
"class",
"associated",
"with",
"the",
"VersatileImageFie... | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/image_warmer.py#L128-L156 | [
"def",
"warm",
"(",
"self",
")",
":",
"num_images_pre_warmed",
"=",
"0",
"failed_to_create_image_path_list",
"=",
"[",
"]",
"total",
"=",
"self",
".",
"queryset",
".",
"count",
"(",
")",
"*",
"len",
"(",
"self",
".",
"size_key_list",
")",
"for",
"a",
","... | d41e279c39cccffafbe876c67596184704ae8877 |
test | autodiscover | Discover versatileimagefield.py modules.
Iterate over django.apps.get_app_configs() and discover
versatileimagefield.py modules. | versatileimagefield/registry.py | def autodiscover():
"""
Discover versatileimagefield.py modules.
Iterate over django.apps.get_app_configs() and discover
versatileimagefield.py modules.
"""
from importlib import import_module
from django.apps import apps
from django.utils.module_loading import module_has_submodule
... | def autodiscover():
"""
Discover versatileimagefield.py modules.
Iterate over django.apps.get_app_configs() and discover
versatileimagefield.py modules.
"""
from importlib import import_module
from django.apps import apps
from django.utils.module_loading import module_has_submodule
... | [
"Discover",
"versatileimagefield",
".",
"py",
"modules",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/registry.py#L203-L239 | [
"def",
"autodiscover",
"(",
")",
":",
"from",
"importlib",
"import",
"import_module",
"from",
"django",
".",
"apps",
"import",
"apps",
"from",
"django",
".",
"utils",
".",
"module_loading",
"import",
"module_has_submodule",
"for",
"app_config",
"in",
"apps",
"."... | d41e279c39cccffafbe876c67596184704ae8877 |
test | VersatileImageFieldRegistry.register_sizer | Register a new SizedImage subclass (`sizedimage_cls`).
To be used via the attribute (`attr_name`). | versatileimagefield/registry.py | def register_sizer(self, attr_name, sizedimage_cls):
"""
Register a new SizedImage subclass (`sizedimage_cls`).
To be used via the attribute (`attr_name`).
"""
if attr_name.startswith(
'_'
) or attr_name in self.unallowed_sizer_names:
raise Unallo... | def register_sizer(self, attr_name, sizedimage_cls):
"""
Register a new SizedImage subclass (`sizedimage_cls`).
To be used via the attribute (`attr_name`).
"""
if attr_name.startswith(
'_'
) or attr_name in self.unallowed_sizer_names:
raise Unallo... | [
"Register",
"a",
"new",
"SizedImage",
"subclass",
"(",
"sizedimage_cls",
")",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/registry.py#L110-L143 | [
"def",
"register_sizer",
"(",
"self",
",",
"attr_name",
",",
"sizedimage_cls",
")",
":",
"if",
"attr_name",
".",
"startswith",
"(",
"'_'",
")",
"or",
"attr_name",
"in",
"self",
".",
"unallowed_sizer_names",
":",
"raise",
"UnallowedSizerName",
"(",
"\"`%s` is an ... | d41e279c39cccffafbe876c67596184704ae8877 |
test | VersatileImageFieldRegistry.unregister_sizer | Unregister the SizedImage subclass currently assigned to `attr_name`.
If a SizedImage subclass isn't already registered to `attr_name`
NotRegistered will raise. | versatileimagefield/registry.py | def unregister_sizer(self, attr_name):
"""
Unregister the SizedImage subclass currently assigned to `attr_name`.
If a SizedImage subclass isn't already registered to `attr_name`
NotRegistered will raise.
"""
if attr_name not in self._sizedimage_registry:
rais... | def unregister_sizer(self, attr_name):
"""
Unregister the SizedImage subclass currently assigned to `attr_name`.
If a SizedImage subclass isn't already registered to `attr_name`
NotRegistered will raise.
"""
if attr_name not in self._sizedimage_registry:
rais... | [
"Unregister",
"the",
"SizedImage",
"subclass",
"currently",
"assigned",
"to",
"attr_name",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/registry.py#L145-L157 | [
"def",
"unregister_sizer",
"(",
"self",
",",
"attr_name",
")",
":",
"if",
"attr_name",
"not",
"in",
"self",
".",
"_sizedimage_registry",
":",
"raise",
"NotRegistered",
"(",
"'No SizedImage subclass is registered to %s'",
"%",
"attr_name",
")",
"else",
":",
"del",
... | d41e279c39cccffafbe876c67596184704ae8877 |
test | VersatileImageFieldRegistry.register_filter | Register a new FilteredImage subclass (`filterimage_cls`).
To be used via the attribute (filters.`attr_name`) | versatileimagefield/registry.py | def register_filter(self, attr_name, filterimage_cls):
"""
Register a new FilteredImage subclass (`filterimage_cls`).
To be used via the attribute (filters.`attr_name`)
"""
if attr_name.startswith('_'):
raise UnallowedFilterName(
'`%s` is an unallowed... | def register_filter(self, attr_name, filterimage_cls):
"""
Register a new FilteredImage subclass (`filterimage_cls`).
To be used via the attribute (filters.`attr_name`)
"""
if attr_name.startswith('_'):
raise UnallowedFilterName(
'`%s` is an unallowed... | [
"Register",
"a",
"new",
"FilteredImage",
"subclass",
"(",
"filterimage_cls",
")",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/registry.py#L159-L183 | [
"def",
"register_filter",
"(",
"self",
",",
"attr_name",
",",
"filterimage_cls",
")",
":",
"if",
"attr_name",
".",
"startswith",
"(",
"'_'",
")",
":",
"raise",
"UnallowedFilterName",
"(",
"'`%s` is an unallowed Filter name. Filter names cannot begin '",
"'with an undersco... | d41e279c39cccffafbe876c67596184704ae8877 |
test | VersatileImageFieldRegistry.unregister_filter | Unregister the FilteredImage subclass currently assigned to attr_name.
If a FilteredImage subclass isn't already registered to filters.
`attr_name` NotRegistered will raise. | versatileimagefield/registry.py | def unregister_filter(self, attr_name):
"""
Unregister the FilteredImage subclass currently assigned to attr_name.
If a FilteredImage subclass isn't already registered to filters.
`attr_name` NotRegistered will raise.
"""
if attr_name not in self._filter_registry:
... | def unregister_filter(self, attr_name):
"""
Unregister the FilteredImage subclass currently assigned to attr_name.
If a FilteredImage subclass isn't already registered to filters.
`attr_name` NotRegistered will raise.
"""
if attr_name not in self._filter_registry:
... | [
"Unregister",
"the",
"FilteredImage",
"subclass",
"currently",
"assigned",
"to",
"attr_name",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/registry.py#L185-L197 | [
"def",
"unregister_filter",
"(",
"self",
",",
"attr_name",
")",
":",
"if",
"attr_name",
"not",
"in",
"self",
".",
"_filter_registry",
":",
"raise",
"NotRegistered",
"(",
"'No FilteredImage subclass is registered to %s'",
"%",
"attr_name",
")",
"else",
":",
"del",
... | d41e279c39cccffafbe876c67596184704ae8877 |
test | VersatileImageMixIn.url | Return the appropriate URL.
URL is constructed based on these field conditions:
* If empty (not `self.name`) and a placeholder is defined, the
URL to the placeholder is returned.
* Otherwise, defaults to vanilla ImageFieldFile behavior. | versatileimagefield/mixins.py | def url(self):
"""
Return the appropriate URL.
URL is constructed based on these field conditions:
* If empty (not `self.name`) and a placeholder is defined, the
URL to the placeholder is returned.
* Otherwise, defaults to vanilla ImageFieldFile behavior.
... | def url(self):
"""
Return the appropriate URL.
URL is constructed based on these field conditions:
* If empty (not `self.name`) and a placeholder is defined, the
URL to the placeholder is returned.
* Otherwise, defaults to vanilla ImageFieldFile behavior.
... | [
"Return",
"the",
"appropriate",
"URL",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/mixins.py#L63-L75 | [
"def",
"url",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"name",
"and",
"self",
".",
"field",
".",
"placeholder_image_name",
":",
"return",
"self",
".",
"storage",
".",
"url",
"(",
"self",
".",
"field",
".",
"placeholder_image_name",
")",
"return",... | d41e279c39cccffafbe876c67596184704ae8877 |
test | VersatileImageMixIn.ppoi | Primary Point of Interest (ppoi) setter. | versatileimagefield/mixins.py | def ppoi(self, value):
"""Primary Point of Interest (ppoi) setter."""
ppoi = validate_ppoi(
value,
return_converted_tuple=True
)
if ppoi is not False:
self._ppoi_value = ppoi
self.build_filters_and_sizers(ppoi, self.create_on_demand) | def ppoi(self, value):
"""Primary Point of Interest (ppoi) setter."""
ppoi = validate_ppoi(
value,
return_converted_tuple=True
)
if ppoi is not False:
self._ppoi_value = ppoi
self.build_filters_and_sizers(ppoi, self.create_on_demand) | [
"Primary",
"Point",
"of",
"Interest",
"(",
"ppoi",
")",
"setter",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/mixins.py#L98-L106 | [
"def",
"ppoi",
"(",
"self",
",",
"value",
")",
":",
"ppoi",
"=",
"validate_ppoi",
"(",
"value",
",",
"return_converted_tuple",
"=",
"True",
")",
"if",
"ppoi",
"is",
"not",
"False",
":",
"self",
".",
"_ppoi_value",
"=",
"ppoi",
"self",
".",
"build_filters... | d41e279c39cccffafbe876c67596184704ae8877 |
test | VersatileImageMixIn.build_filters_and_sizers | Build the filters and sizers for a field. | versatileimagefield/mixins.py | def build_filters_and_sizers(self, ppoi_value, create_on_demand):
"""Build the filters and sizers for a field."""
name = self.name
if not name and self.field.placeholder_image_name:
name = self.field.placeholder_image_name
self.filters = FilterLibrary(
name,
... | def build_filters_and_sizers(self, ppoi_value, create_on_demand):
"""Build the filters and sizers for a field."""
name = self.name
if not name and self.field.placeholder_image_name:
name = self.field.placeholder_image_name
self.filters = FilterLibrary(
name,
... | [
"Build",
"the",
"filters",
"and",
"sizers",
"for",
"a",
"field",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/mixins.py#L108-L133 | [
"def",
"build_filters_and_sizers",
"(",
"self",
",",
"ppoi_value",
",",
"create_on_demand",
")",
":",
"name",
"=",
"self",
".",
"name",
"if",
"not",
"name",
"and",
"self",
".",
"field",
".",
"placeholder_image_name",
":",
"name",
"=",
"self",
".",
"field",
... | d41e279c39cccffafbe876c67596184704ae8877 |
test | VersatileImageMixIn.get_filtered_root_folder | Return the location where filtered images are stored. | versatileimagefield/mixins.py | def get_filtered_root_folder(self):
"""Return the location where filtered images are stored."""
folder, filename = os.path.split(self.name)
return os.path.join(folder, VERSATILEIMAGEFIELD_FILTERED_DIRNAME, '') | def get_filtered_root_folder(self):
"""Return the location where filtered images are stored."""
folder, filename = os.path.split(self.name)
return os.path.join(folder, VERSATILEIMAGEFIELD_FILTERED_DIRNAME, '') | [
"Return",
"the",
"location",
"where",
"filtered",
"images",
"are",
"stored",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/mixins.py#L135-L138 | [
"def",
"get_filtered_root_folder",
"(",
"self",
")",
":",
"folder",
",",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"self",
".",
"name",
")",
"return",
"os",
".",
"path",
".",
"join",
"(",
"folder",
",",
"VERSATILEIMAGEFIELD_FILTERED_DIRNAME",
... | d41e279c39cccffafbe876c67596184704ae8877 |
test | VersatileImageMixIn.get_sized_root_folder | Return the location where sized images are stored. | versatileimagefield/mixins.py | def get_sized_root_folder(self):
"""Return the location where sized images are stored."""
folder, filename = os.path.split(self.name)
return os.path.join(VERSATILEIMAGEFIELD_SIZED_DIRNAME, folder, '') | def get_sized_root_folder(self):
"""Return the location where sized images are stored."""
folder, filename = os.path.split(self.name)
return os.path.join(VERSATILEIMAGEFIELD_SIZED_DIRNAME, folder, '') | [
"Return",
"the",
"location",
"where",
"sized",
"images",
"are",
"stored",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/mixins.py#L140-L143 | [
"def",
"get_sized_root_folder",
"(",
"self",
")",
":",
"folder",
",",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"self",
".",
"name",
")",
"return",
"os",
".",
"path",
".",
"join",
"(",
"VERSATILEIMAGEFIELD_SIZED_DIRNAME",
",",
"folder",
",",
... | d41e279c39cccffafbe876c67596184704ae8877 |
test | VersatileImageMixIn.get_filtered_sized_root_folder | Return the location where filtered + sized images are stored. | versatileimagefield/mixins.py | def get_filtered_sized_root_folder(self):
"""Return the location where filtered + sized images are stored."""
sized_root_folder = self.get_sized_root_folder()
return os.path.join(
sized_root_folder,
VERSATILEIMAGEFIELD_FILTERED_DIRNAME
) | def get_filtered_sized_root_folder(self):
"""Return the location where filtered + sized images are stored."""
sized_root_folder = self.get_sized_root_folder()
return os.path.join(
sized_root_folder,
VERSATILEIMAGEFIELD_FILTERED_DIRNAME
) | [
"Return",
"the",
"location",
"where",
"filtered",
"+",
"sized",
"images",
"are",
"stored",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/mixins.py#L145-L151 | [
"def",
"get_filtered_sized_root_folder",
"(",
"self",
")",
":",
"sized_root_folder",
"=",
"self",
".",
"get_sized_root_folder",
"(",
")",
"return",
"os",
".",
"path",
".",
"join",
"(",
"sized_root_folder",
",",
"VERSATILEIMAGEFIELD_FILTERED_DIRNAME",
")"
] | d41e279c39cccffafbe876c67596184704ae8877 |
test | VersatileImageMixIn.delete_matching_files_from_storage | Delete files in `root_folder` which match `regex` before file ext.
Example values:
* root_folder = 'foo/'
* self.name = 'bar.jpg'
* regex = re.compile('-baz')
Result:
* foo/bar-baz.jpg <- Deleted
* foo/bar-biz.jpg <- Not deleted | versatileimagefield/mixins.py | def delete_matching_files_from_storage(self, root_folder, regex):
"""
Delete files in `root_folder` which match `regex` before file ext.
Example values:
* root_folder = 'foo/'
* self.name = 'bar.jpg'
* regex = re.compile('-baz')
Result:
... | def delete_matching_files_from_storage(self, root_folder, regex):
"""
Delete files in `root_folder` which match `regex` before file ext.
Example values:
* root_folder = 'foo/'
* self.name = 'bar.jpg'
* regex = re.compile('-baz')
Result:
... | [
"Delete",
"files",
"in",
"root_folder",
"which",
"match",
"regex",
"before",
"file",
"ext",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/mixins.py#L153-L191 | [
"def",
"delete_matching_files_from_storage",
"(",
"self",
",",
"root_folder",
",",
"regex",
")",
":",
"if",
"not",
"self",
".",
"name",
":",
"# pragma: no cover",
"return",
"try",
":",
"directory_list",
",",
"file_list",
"=",
"self",
".",
"storage",
".",
"list... | d41e279c39cccffafbe876c67596184704ae8877 |
test | validate_ppoi_tuple | Validates that a tuple (`value`)...
...has a len of exactly 2
...both values are floats/ints that are greater-than-or-equal-to 0
AND less-than-or-equal-to 1 | versatileimagefield/validators.py | def validate_ppoi_tuple(value):
"""
Validates that a tuple (`value`)...
...has a len of exactly 2
...both values are floats/ints that are greater-than-or-equal-to 0
AND less-than-or-equal-to 1
"""
valid = True
while valid is True:
if len(value) == 2 and isinstance(value, tuple... | def validate_ppoi_tuple(value):
"""
Validates that a tuple (`value`)...
...has a len of exactly 2
...both values are floats/ints that are greater-than-or-equal-to 0
AND less-than-or-equal-to 1
"""
valid = True
while valid is True:
if len(value) == 2 and isinstance(value, tuple... | [
"Validates",
"that",
"a",
"tuple",
"(",
"value",
")",
"...",
"...",
"has",
"a",
"len",
"of",
"exactly",
"2",
"...",
"both",
"values",
"are",
"floats",
"/",
"ints",
"that",
"are",
"greater",
"-",
"than",
"-",
"or",
"-",
"equal",
"-",
"to",
"0",
"AND... | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/validators.py#L14-L32 | [
"def",
"validate_ppoi_tuple",
"(",
"value",
")",
":",
"valid",
"=",
"True",
"while",
"valid",
"is",
"True",
":",
"if",
"len",
"(",
"value",
")",
"==",
"2",
"and",
"isinstance",
"(",
"value",
",",
"tuple",
")",
":",
"for",
"x",
"in",
"value",
":",
"... | d41e279c39cccffafbe876c67596184704ae8877 |
test | validate_ppoi | Converts, validates and optionally returns a string with formatting:
'%(x_axis)dx%(y_axis)d' into a two position tuple.
If a tuple is passed to `value` it is also validated.
Both x_axis and y_axis must be floats or ints greater
than 0 and less than 1. | versatileimagefield/validators.py | def validate_ppoi(value, return_converted_tuple=False):
"""
Converts, validates and optionally returns a string with formatting:
'%(x_axis)dx%(y_axis)d' into a two position tuple.
If a tuple is passed to `value` it is also validated.
Both x_axis and y_axis must be floats or ints greater
than 0... | def validate_ppoi(value, return_converted_tuple=False):
"""
Converts, validates and optionally returns a string with formatting:
'%(x_axis)dx%(y_axis)d' into a two position tuple.
If a tuple is passed to `value` it is also validated.
Both x_axis and y_axis must be floats or ints greater
than 0... | [
"Converts",
"validates",
"and",
"optionally",
"returns",
"a",
"string",
"with",
"formatting",
":",
"%",
"(",
"x_axis",
")",
"dx%",
"(",
"y_axis",
")",
"d",
"into",
"a",
"two",
"position",
"tuple",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/validators.py#L35-L76 | [
"def",
"validate_ppoi",
"(",
"value",
",",
"return_converted_tuple",
"=",
"False",
")",
":",
"valid_ppoi",
"=",
"True",
"to_return",
"=",
"None",
"if",
"isinstance",
"(",
"value",
",",
"tuple",
")",
":",
"valid_ppoi",
"=",
"validate_ppoi_tuple",
"(",
"value",
... | d41e279c39cccffafbe876c67596184704ae8877 |
test | ProcessedImage.preprocess | Preprocess an image.
An API hook for image pre-processing. Calls any image format specific
pre-processors (if defined). I.E. If `image_format` is 'JPEG', this
method will look for a method named `preprocess_JPEG`, if found
`image` will be passed to it.
Arguments:
* ... | versatileimagefield/datastructures/base.py | def preprocess(self, image, image_format):
"""
Preprocess an image.
An API hook for image pre-processing. Calls any image format specific
pre-processors (if defined). I.E. If `image_format` is 'JPEG', this
method will look for a method named `preprocess_JPEG`, if found
`... | def preprocess(self, image, image_format):
"""
Preprocess an image.
An API hook for image pre-processing. Calls any image format specific
pre-processors (if defined). I.E. If `image_format` is 'JPEG', this
method will look for a method named `preprocess_JPEG`, if found
`... | [
"Preprocess",
"an",
"image",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/datastructures/base.py#L60-L104 | [
"def",
"preprocess",
"(",
"self",
",",
"image",
",",
"image_format",
")",
":",
"save_kwargs",
"=",
"{",
"'format'",
":",
"image_format",
"}",
"# Ensuring image is properly rotated",
"if",
"hasattr",
"(",
"image",
",",
"'_getexif'",
")",
":",
"exif_datadict",
"="... | d41e279c39cccffafbe876c67596184704ae8877 |
test | ProcessedImage.preprocess_GIF | Receive a PIL Image instance of a GIF and return 2-tuple.
Args:
* [0]: Original Image instance (passed to `image`)
* [1]: Dict with a transparency key (to GIF transparency layer) | versatileimagefield/datastructures/base.py | def preprocess_GIF(self, image, **kwargs):
"""
Receive a PIL Image instance of a GIF and return 2-tuple.
Args:
* [0]: Original Image instance (passed to `image`)
* [1]: Dict with a transparency key (to GIF transparency layer)
"""
if 'transparency' in imag... | def preprocess_GIF(self, image, **kwargs):
"""
Receive a PIL Image instance of a GIF and return 2-tuple.
Args:
* [0]: Original Image instance (passed to `image`)
* [1]: Dict with a transparency key (to GIF transparency layer)
"""
if 'transparency' in imag... | [
"Receive",
"a",
"PIL",
"Image",
"instance",
"of",
"a",
"GIF",
"and",
"return",
"2",
"-",
"tuple",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/datastructures/base.py#L106-L118 | [
"def",
"preprocess_GIF",
"(",
"self",
",",
"image",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'transparency'",
"in",
"image",
".",
"info",
":",
"save_kwargs",
"=",
"{",
"'transparency'",
":",
"image",
".",
"info",
"[",
"'transparency'",
"]",
"}",
"else",... | d41e279c39cccffafbe876c67596184704ae8877 |
test | ProcessedImage.preprocess_JPEG | Receive a PIL Image instance of a JPEG and returns 2-tuple.
Args:
* [0]: Image instance, converted to RGB
* [1]: Dict with a quality key (mapped to the value of `QUAL` as
defined by the `VERSATILEIMAGEFIELD_JPEG_RESIZE_QUALITY`
setting) | versatileimagefield/datastructures/base.py | def preprocess_JPEG(self, image, **kwargs):
"""
Receive a PIL Image instance of a JPEG and returns 2-tuple.
Args:
* [0]: Image instance, converted to RGB
* [1]: Dict with a quality key (mapped to the value of `QUAL` as
defined by the `VERSATILEIMAGEFIE... | def preprocess_JPEG(self, image, **kwargs):
"""
Receive a PIL Image instance of a JPEG and returns 2-tuple.
Args:
* [0]: Image instance, converted to RGB
* [1]: Dict with a quality key (mapped to the value of `QUAL` as
defined by the `VERSATILEIMAGEFIE... | [
"Receive",
"a",
"PIL",
"Image",
"instance",
"of",
"a",
"JPEG",
"and",
"returns",
"2",
"-",
"tuple",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/datastructures/base.py#L120-L136 | [
"def",
"preprocess_JPEG",
"(",
"self",
",",
"image",
",",
"*",
"*",
"kwargs",
")",
":",
"save_kwargs",
"=",
"{",
"'progressive'",
":",
"VERSATILEIMAGEFIELD_PROGRESSIVE_JPEG",
",",
"'quality'",
":",
"QUAL",
"}",
"if",
"image",
".",
"mode",
"!=",
"'RGB'",
":",... | d41e279c39cccffafbe876c67596184704ae8877 |
test | ProcessedImage.retrieve_image | Return a PIL Image instance stored at `path_to_image`. | versatileimagefield/datastructures/base.py | def retrieve_image(self, path_to_image):
"""Return a PIL Image instance stored at `path_to_image`."""
image = self.storage.open(path_to_image, 'rb')
file_ext = path_to_image.rsplit('.')[-1]
image_format, mime_type = get_image_metadata_from_file_ext(file_ext)
return (
... | def retrieve_image(self, path_to_image):
"""Return a PIL Image instance stored at `path_to_image`."""
image = self.storage.open(path_to_image, 'rb')
file_ext = path_to_image.rsplit('.')[-1]
image_format, mime_type = get_image_metadata_from_file_ext(file_ext)
return (
... | [
"Return",
"a",
"PIL",
"Image",
"instance",
"stored",
"at",
"path_to_image",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/datastructures/base.py#L138-L149 | [
"def",
"retrieve_image",
"(",
"self",
",",
"path_to_image",
")",
":",
"image",
"=",
"self",
".",
"storage",
".",
"open",
"(",
"path_to_image",
",",
"'rb'",
")",
"file_ext",
"=",
"path_to_image",
".",
"rsplit",
"(",
"'.'",
")",
"[",
"-",
"1",
"]",
"imag... | d41e279c39cccffafbe876c67596184704ae8877 |
test | ProcessedImage.save_image | Save an image to self.storage at `save_path`.
Arguments:
`imagefile`: Raw image data, typically a BytesIO instance.
`save_path`: The path within self.storage where the image should
be saved.
`file_ext`: The file extension of the image-to-be-saved.
... | versatileimagefield/datastructures/base.py | def save_image(self, imagefile, save_path, file_ext, mime_type):
"""
Save an image to self.storage at `save_path`.
Arguments:
`imagefile`: Raw image data, typically a BytesIO instance.
`save_path`: The path within self.storage where the image should
... | def save_image(self, imagefile, save_path, file_ext, mime_type):
"""
Save an image to self.storage at `save_path`.
Arguments:
`imagefile`: Raw image data, typically a BytesIO instance.
`save_path`: The path within self.storage where the image should
... | [
"Save",
"an",
"image",
"to",
"self",
".",
"storage",
"at",
"save_path",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/datastructures/base.py#L151-L172 | [
"def",
"save_image",
"(",
"self",
",",
"imagefile",
",",
"save_path",
",",
"file_ext",
",",
"mime_type",
")",
":",
"file_to_save",
"=",
"InMemoryUploadedFile",
"(",
"imagefile",
",",
"None",
",",
"'foo.%s'",
"%",
"file_ext",
",",
"mime_type",
",",
"imagefile",... | d41e279c39cccffafbe876c67596184704ae8877 |
test | SizedImage.ppoi_as_str | Return PPOI value as a string. | versatileimagefield/datastructures/sizedimage.py | def ppoi_as_str(self):
"""Return PPOI value as a string."""
return "%s__%s" % (
str(self.ppoi[0]).replace('.', '-'),
str(self.ppoi[1]).replace('.', '-')
) | def ppoi_as_str(self):
"""Return PPOI value as a string."""
return "%s__%s" % (
str(self.ppoi[0]).replace('.', '-'),
str(self.ppoi[1]).replace('.', '-')
) | [
"Return",
"PPOI",
"value",
"as",
"a",
"string",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/datastructures/sizedimage.py#L64-L69 | [
"def",
"ppoi_as_str",
"(",
"self",
")",
":",
"return",
"\"%s__%s\"",
"%",
"(",
"str",
"(",
"self",
".",
"ppoi",
"[",
"0",
"]",
")",
".",
"replace",
"(",
"'.'",
",",
"'-'",
")",
",",
"str",
"(",
"self",
".",
"ppoi",
"[",
"1",
"]",
")",
".",
"r... | d41e279c39cccffafbe876c67596184704ae8877 |
test | SizedImage.create_resized_image | Create a resized image.
`path_to_image`: The path to the image with the media directory to
resize. If `None`, the
VERSATILEIMAGEFIELD_PLACEHOLDER_IMAGE will be used.
`save_path_on_storage`: Where on self.storage to save the resized image
`width`... | versatileimagefield/datastructures/sizedimage.py | def create_resized_image(self, path_to_image, save_path_on_storage,
width, height):
"""
Create a resized image.
`path_to_image`: The path to the image with the media directory to
resize. If `None`, the
VERSATILEIMAGE... | def create_resized_image(self, path_to_image, save_path_on_storage,
width, height):
"""
Create a resized image.
`path_to_image`: The path to the image with the media directory to
resize. If `None`, the
VERSATILEIMAGE... | [
"Create",
"a",
"resized",
"image",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/datastructures/sizedimage.py#L185-L213 | [
"def",
"create_resized_image",
"(",
"self",
",",
"path_to_image",
",",
"save_path_on_storage",
",",
"width",
",",
"height",
")",
":",
"image",
",",
"file_ext",
",",
"image_format",
",",
"mime_type",
"=",
"self",
".",
"retrieve_image",
"(",
"path_to_image",
")",
... | d41e279c39cccffafbe876c67596184704ae8877 |
test | ClearableFileInputWithImagePreview.render | Render the widget as an HTML string.
Overridden here to support Django < 1.11. | versatileimagefield/widgets.py | def render(self, name, value, attrs=None, renderer=None):
"""
Render the widget as an HTML string.
Overridden here to support Django < 1.11.
"""
if self.has_template_widget_rendering:
return super(ClearableFileInputWithImagePreview, self).render(
name... | def render(self, name, value, attrs=None, renderer=None):
"""
Render the widget as an HTML string.
Overridden here to support Django < 1.11.
"""
if self.has_template_widget_rendering:
return super(ClearableFileInputWithImagePreview, self).render(
name... | [
"Render",
"the",
"widget",
"as",
"an",
"HTML",
"string",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/widgets.py#L41-L53 | [
"def",
"render",
"(",
"self",
",",
"name",
",",
"value",
",",
"attrs",
"=",
"None",
",",
"renderer",
"=",
"None",
")",
":",
"if",
"self",
".",
"has_template_widget_rendering",
":",
"return",
"super",
"(",
"ClearableFileInputWithImagePreview",
",",
"self",
")... | d41e279c39cccffafbe876c67596184704ae8877 |
test | ClearableFileInputWithImagePreview.get_context | Get the context to render this widget with. | versatileimagefield/widgets.py | def get_context(self, name, value, attrs):
"""Get the context to render this widget with."""
if self.has_template_widget_rendering:
context = super(ClearableFileInputWithImagePreview, self).get_context(name, value, attrs)
else:
# Build the context manually.
co... | def get_context(self, name, value, attrs):
"""Get the context to render this widget with."""
if self.has_template_widget_rendering:
context = super(ClearableFileInputWithImagePreview, self).get_context(name, value, attrs)
else:
# Build the context manually.
co... | [
"Get",
"the",
"context",
"to",
"render",
"this",
"widget",
"with",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/widgets.py#L66-L106 | [
"def",
"get_context",
"(",
"self",
",",
"name",
",",
"value",
",",
"attrs",
")",
":",
"if",
"self",
".",
"has_template_widget_rendering",
":",
"context",
"=",
"super",
"(",
"ClearableFileInputWithImagePreview",
",",
"self",
")",
".",
"get_context",
"(",
"name"... | d41e279c39cccffafbe876c67596184704ae8877 |
test | ClearableFileInputWithImagePreview.build_attrs | Build an attribute dictionary. | versatileimagefield/widgets.py | def build_attrs(self, base_attrs, extra_attrs=None):
"""Build an attribute dictionary."""
attrs = base_attrs.copy()
if extra_attrs is not None:
attrs.update(extra_attrs)
return attrs | def build_attrs(self, base_attrs, extra_attrs=None):
"""Build an attribute dictionary."""
attrs = base_attrs.copy()
if extra_attrs is not None:
attrs.update(extra_attrs)
return attrs | [
"Build",
"an",
"attribute",
"dictionary",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/widgets.py#L108-L113 | [
"def",
"build_attrs",
"(",
"self",
",",
"base_attrs",
",",
"extra_attrs",
"=",
"None",
")",
":",
"attrs",
"=",
"base_attrs",
".",
"copy",
"(",
")",
"if",
"extra_attrs",
"is",
"not",
"None",
":",
"attrs",
".",
"update",
"(",
"extra_attrs",
")",
"return",
... | d41e279c39cccffafbe876c67596184704ae8877 |
test | get_resized_filename | Return the 'resized filename' (according to `width`, `height` and
`filename_key`) in the following format:
`filename`-`filename_key`-`width`x`height`.ext | versatileimagefield/utils.py | def get_resized_filename(filename, width, height, filename_key):
"""
Return the 'resized filename' (according to `width`, `height` and
`filename_key`) in the following format:
`filename`-`filename_key`-`width`x`height`.ext
"""
try:
image_name, ext = filename.rsplit('.', 1)
except Val... | def get_resized_filename(filename, width, height, filename_key):
"""
Return the 'resized filename' (according to `width`, `height` and
`filename_key`) in the following format:
`filename`-`filename_key`-`width`x`height`.ext
"""
try:
image_name, ext = filename.rsplit('.', 1)
except Val... | [
"Return",
"the",
"resized",
"filename",
"(",
"according",
"to",
"width",
"height",
"and",
"filename_key",
")",
"in",
"the",
"following",
"format",
":",
"filename",
"-",
"filename_key",
"-",
"width",
"x",
"height",
".",
"ext"
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/utils.py#L77-L104 | [
"def",
"get_resized_filename",
"(",
"filename",
",",
"width",
",",
"height",
",",
"filename_key",
")",
":",
"try",
":",
"image_name",
",",
"ext",
"=",
"filename",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"except",
"ValueError",
":",
"image_name",
"=",
"... | d41e279c39cccffafbe876c67596184704ae8877 |
test | get_resized_path | Return a `path_to_image` location on `storage` as dictated by `width`, `height`
and `filename_key` | versatileimagefield/utils.py | def get_resized_path(path_to_image, width, height,
filename_key, storage):
"""
Return a `path_to_image` location on `storage` as dictated by `width`, `height`
and `filename_key`
"""
containing_folder, filename = os.path.split(path_to_image)
resized_filename = get_resized_fi... | def get_resized_path(path_to_image, width, height,
filename_key, storage):
"""
Return a `path_to_image` location on `storage` as dictated by `width`, `height`
and `filename_key`
"""
containing_folder, filename = os.path.split(path_to_image)
resized_filename = get_resized_fi... | [
"Return",
"a",
"path_to_image",
"location",
"on",
"storage",
"as",
"dictated",
"by",
"width",
"height",
"and",
"filename_key"
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/utils.py#L107-L128 | [
"def",
"get_resized_path",
"(",
"path_to_image",
",",
"width",
",",
"height",
",",
"filename_key",
",",
"storage",
")",
":",
"containing_folder",
",",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path_to_image",
")",
"resized_filename",
"=",
"get_re... | d41e279c39cccffafbe876c67596184704ae8877 |
test | get_filtered_filename | Return the 'filtered filename' (according to `filename_key`)
in the following format:
`filename`__`filename_key`__.ext | versatileimagefield/utils.py | def get_filtered_filename(filename, filename_key):
"""
Return the 'filtered filename' (according to `filename_key`)
in the following format:
`filename`__`filename_key`__.ext
"""
try:
image_name, ext = filename.rsplit('.', 1)
except ValueError:
image_name = filename
ex... | def get_filtered_filename(filename, filename_key):
"""
Return the 'filtered filename' (according to `filename_key`)
in the following format:
`filename`__`filename_key`__.ext
"""
try:
image_name, ext = filename.rsplit('.', 1)
except ValueError:
image_name = filename
ex... | [
"Return",
"the",
"filtered",
"filename",
"(",
"according",
"to",
"filename_key",
")",
"in",
"the",
"following",
"format",
":",
"filename",
"__",
"filename_key",
"__",
".",
"ext"
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/utils.py#L131-L146 | [
"def",
"get_filtered_filename",
"(",
"filename",
",",
"filename_key",
")",
":",
"try",
":",
"image_name",
",",
"ext",
"=",
"filename",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"except",
"ValueError",
":",
"image_name",
"=",
"filename",
"ext",
"=",
"'jpg'"... | d41e279c39cccffafbe876c67596184704ae8877 |
test | get_filtered_path | Return the 'filtered path' | versatileimagefield/utils.py | def get_filtered_path(path_to_image, filename_key, storage):
"""
Return the 'filtered path'
"""
containing_folder, filename = os.path.split(path_to_image)
filtered_filename = get_filtered_filename(filename, filename_key)
path_to_return = os.path.join(*[
containing_folder,
VERSAT... | def get_filtered_path(path_to_image, filename_key, storage):
"""
Return the 'filtered path'
"""
containing_folder, filename = os.path.split(path_to_image)
filtered_filename = get_filtered_filename(filename, filename_key)
path_to_return = os.path.join(*[
containing_folder,
VERSAT... | [
"Return",
"the",
"filtered",
"path"
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/utils.py#L149-L163 | [
"def",
"get_filtered_path",
"(",
"path_to_image",
",",
"filename_key",
",",
"storage",
")",
":",
"containing_folder",
",",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path_to_image",
")",
"filtered_filename",
"=",
"get_filtered_filename",
"(",
"filenam... | d41e279c39cccffafbe876c67596184704ae8877 |
test | validate_versatileimagefield_sizekey_list | Validate a list of size keys.
`sizes`: An iterable of 2-tuples, both strings. Example:
[
('large', 'url'),
('medium', 'crop__400x400'),
('small', 'thumbnail__100x100')
] | versatileimagefield/utils.py | def validate_versatileimagefield_sizekey_list(sizes):
"""
Validate a list of size keys.
`sizes`: An iterable of 2-tuples, both strings. Example:
[
('large', 'url'),
('medium', 'crop__400x400'),
('small', 'thumbnail__100x100')
]
"""
try:
for key, size_key in s... | def validate_versatileimagefield_sizekey_list(sizes):
"""
Validate a list of size keys.
`sizes`: An iterable of 2-tuples, both strings. Example:
[
('large', 'url'),
('medium', 'crop__400x400'),
('small', 'thumbnail__100x100')
]
"""
try:
for key, size_key in s... | [
"Validate",
"a",
"list",
"of",
"size",
"keys",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/utils.py#L176-L204 | [
"def",
"validate_versatileimagefield_sizekey_list",
"(",
"sizes",
")",
":",
"try",
":",
"for",
"key",
",",
"size_key",
"in",
"sizes",
":",
"size_key_split",
"=",
"size_key",
".",
"split",
"(",
"'__'",
")",
"if",
"size_key_split",
"[",
"-",
"1",
"]",
"!=",
... | d41e279c39cccffafbe876c67596184704ae8877 |
test | get_url_from_image_key | Build a URL from `image_key`. | versatileimagefield/utils.py | def get_url_from_image_key(image_instance, image_key):
"""Build a URL from `image_key`."""
img_key_split = image_key.split('__')
if 'x' in img_key_split[-1]:
size_key = img_key_split.pop(-1)
else:
size_key = None
img_url = reduce(getattr, img_key_split, image_instance)
if size_ke... | def get_url_from_image_key(image_instance, image_key):
"""Build a URL from `image_key`."""
img_key_split = image_key.split('__')
if 'x' in img_key_split[-1]:
size_key = img_key_split.pop(-1)
else:
size_key = None
img_url = reduce(getattr, img_key_split, image_instance)
if size_ke... | [
"Build",
"a",
"URL",
"from",
"image_key",
"."
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/utils.py#L207-L217 | [
"def",
"get_url_from_image_key",
"(",
"image_instance",
",",
"image_key",
")",
":",
"img_key_split",
"=",
"image_key",
".",
"split",
"(",
"'__'",
")",
"if",
"'x'",
"in",
"img_key_split",
"[",
"-",
"1",
"]",
":",
"size_key",
"=",
"img_key_split",
".",
"pop",
... | d41e279c39cccffafbe876c67596184704ae8877 |
test | build_versatileimagefield_url_set | Return a dictionary of urls corresponding to size_set
- `image_instance`: A VersatileImageFieldFile
- `size_set`: An iterable of 2-tuples, both strings. Example:
[
('large', 'url'),
('medium', 'crop__400x400'),
('small', 'thumbnail__100x100')
]
The ab... | versatileimagefield/utils.py | def build_versatileimagefield_url_set(image_instance, size_set, request=None):
"""
Return a dictionary of urls corresponding to size_set
- `image_instance`: A VersatileImageFieldFile
- `size_set`: An iterable of 2-tuples, both strings. Example:
[
('large', 'url'),
('mediu... | def build_versatileimagefield_url_set(image_instance, size_set, request=None):
"""
Return a dictionary of urls corresponding to size_set
- `image_instance`: A VersatileImageFieldFile
- `size_set`: An iterable of 2-tuples, both strings. Example:
[
('large', 'url'),
('mediu... | [
"Return",
"a",
"dictionary",
"of",
"urls",
"corresponding",
"to",
"size_set",
"-",
"image_instance",
":",
"A",
"VersatileImageFieldFile",
"-",
"size_set",
":",
"An",
"iterable",
"of",
"2",
"-",
"tuples",
"both",
"strings",
".",
"Example",
":",
"[",
"(",
"lar... | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/utils.py#L220-L247 | [
"def",
"build_versatileimagefield_url_set",
"(",
"image_instance",
",",
"size_set",
",",
"request",
"=",
"None",
")",
":",
"size_set",
"=",
"validate_versatileimagefield_sizekey_list",
"(",
"size_set",
")",
"to_return",
"=",
"{",
"}",
"if",
"image_instance",
"or",
"... | d41e279c39cccffafbe876c67596184704ae8877 |
test | get_rendition_key_set | Retrieve a validated and prepped Rendition Key Set from
settings.VERSATILEIMAGEFIELD_RENDITION_KEY_SETS | versatileimagefield/utils.py | def get_rendition_key_set(key):
"""
Retrieve a validated and prepped Rendition Key Set from
settings.VERSATILEIMAGEFIELD_RENDITION_KEY_SETS
"""
try:
rendition_key_set = IMAGE_SETS[key]
except KeyError:
raise ImproperlyConfigured(
"No Rendition Key Set exists at "
... | def get_rendition_key_set(key):
"""
Retrieve a validated and prepped Rendition Key Set from
settings.VERSATILEIMAGEFIELD_RENDITION_KEY_SETS
"""
try:
rendition_key_set = IMAGE_SETS[key]
except KeyError:
raise ImproperlyConfigured(
"No Rendition Key Set exists at "
... | [
"Retrieve",
"a",
"validated",
"and",
"prepped",
"Rendition",
"Key",
"Set",
"from",
"settings",
".",
"VERSATILEIMAGEFIELD_RENDITION_KEY_SETS"
] | respondcreate/django-versatileimagefield | python | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/utils.py#L250-L263 | [
"def",
"get_rendition_key_set",
"(",
"key",
")",
":",
"try",
":",
"rendition_key_set",
"=",
"IMAGE_SETS",
"[",
"key",
"]",
"except",
"KeyError",
":",
"raise",
"ImproperlyConfigured",
"(",
"\"No Rendition Key Set exists at \"",
"\"settings.VERSATILEIMAGEFIELD_RENDITION_KEY_S... | d41e279c39cccffafbe876c67596184704ae8877 |
test | format_instruction | Takes a raw `Instruction` and translates it into a human readable text
representation. As of writing, the text representation for WASM is not yet
standardized, so we just emit some generic format. | wasm/formatter.py | def format_instruction(insn):
"""
Takes a raw `Instruction` and translates it into a human readable text
representation. As of writing, the text representation for WASM is not yet
standardized, so we just emit some generic format.
"""
text = insn.op.mnemonic
if not insn.imm:
return ... | def format_instruction(insn):
"""
Takes a raw `Instruction` and translates it into a human readable text
representation. As of writing, the text representation for WASM is not yet
standardized, so we just emit some generic format.
"""
text = insn.op.mnemonic
if not insn.imm:
return ... | [
"Takes",
"a",
"raw",
"Instruction",
"and",
"translates",
"it",
"into",
"a",
"human",
"readable",
"text",
"representation",
".",
"As",
"of",
"writing",
"the",
"text",
"representation",
"for",
"WASM",
"is",
"not",
"yet",
"standardized",
"so",
"we",
"just",
"em... | athre0z/wasm | python | https://github.com/athre0z/wasm/blob/bc9c7e3f40242a2a8fc9650c4b994f0cddf8d755/wasm/formatter.py#L11-L27 | [
"def",
"format_instruction",
"(",
"insn",
")",
":",
"text",
"=",
"insn",
".",
"op",
".",
"mnemonic",
"if",
"not",
"insn",
".",
"imm",
":",
"return",
"text",
"return",
"text",
"+",
"' '",
"+",
"', '",
".",
"join",
"(",
"[",
"getattr",
"(",
"insn",
"... | bc9c7e3f40242a2a8fc9650c4b994f0cddf8d755 |
test | format_function | Takes a `FunctionBody` and optionally a `FunctionType`, yielding the string
representation of the function line by line. The function type is required
for formatting function parameter and return value information. | wasm/formatter.py | def format_function(
func_body,
func_type=None,
indent=2,
format_locals=True,
):
"""
Takes a `FunctionBody` and optionally a `FunctionType`, yielding the string
representation of the function line by line. The function type is required
for formatting function parameter and return value ... | def format_function(
func_body,
func_type=None,
indent=2,
format_locals=True,
):
"""
Takes a `FunctionBody` and optionally a `FunctionType`, yielding the string
representation of the function line by line. The function type is required
for formatting function parameter and return value ... | [
"Takes",
"a",
"FunctionBody",
"and",
"optionally",
"a",
"FunctionType",
"yielding",
"the",
"string",
"representation",
"of",
"the",
"function",
"line",
"by",
"line",
".",
"The",
"function",
"type",
"is",
"required",
"for",
"formatting",
"function",
"parameter",
... | athre0z/wasm | python | https://github.com/athre0z/wasm/blob/bc9c7e3f40242a2a8fc9650c4b994f0cddf8d755/wasm/formatter.py#L46-L80 | [
"def",
"format_function",
"(",
"func_body",
",",
"func_type",
"=",
"None",
",",
"indent",
"=",
"2",
",",
"format_locals",
"=",
"True",
",",
")",
":",
"if",
"func_type",
"is",
"None",
":",
"yield",
"'func'",
"else",
":",
"param_section",
"=",
"' (param {})'... | bc9c7e3f40242a2a8fc9650c4b994f0cddf8d755 |
test | decode_bytecode | Decodes raw bytecode, yielding `Instruction`s. | wasm/decode.py | def decode_bytecode(bytecode):
"""Decodes raw bytecode, yielding `Instruction`s."""
bytecode_wnd = memoryview(bytecode)
while bytecode_wnd:
opcode_id = byte2int(bytecode_wnd[0])
opcode = OPCODE_MAP[opcode_id]
if opcode.imm_struct is not None:
offs, imm, _ = opcode.imm_st... | def decode_bytecode(bytecode):
"""Decodes raw bytecode, yielding `Instruction`s."""
bytecode_wnd = memoryview(bytecode)
while bytecode_wnd:
opcode_id = byte2int(bytecode_wnd[0])
opcode = OPCODE_MAP[opcode_id]
if opcode.imm_struct is not None:
offs, imm, _ = opcode.imm_st... | [
"Decodes",
"raw",
"bytecode",
"yielding",
"Instruction",
"s",
"."
] | athre0z/wasm | python | https://github.com/athre0z/wasm/blob/bc9c7e3f40242a2a8fc9650c4b994f0cddf8d755/wasm/decode.py#L14-L29 | [
"def",
"decode_bytecode",
"(",
"bytecode",
")",
":",
"bytecode_wnd",
"=",
"memoryview",
"(",
"bytecode",
")",
"while",
"bytecode_wnd",
":",
"opcode_id",
"=",
"byte2int",
"(",
"bytecode_wnd",
"[",
"0",
"]",
")",
"opcode",
"=",
"OPCODE_MAP",
"[",
"opcode_id",
... | bc9c7e3f40242a2a8fc9650c4b994f0cddf8d755 |
test | decode_module | Decodes raw WASM modules, yielding `ModuleFragment`s. | wasm/decode.py | def decode_module(module, decode_name_subsections=False):
"""Decodes raw WASM modules, yielding `ModuleFragment`s."""
module_wnd = memoryview(module)
# Read & yield module header.
hdr = ModuleHeader()
hdr_len, hdr_data, _ = hdr.from_raw(None, module_wnd)
yield ModuleFragment(hdr, hdr_data)
... | def decode_module(module, decode_name_subsections=False):
"""Decodes raw WASM modules, yielding `ModuleFragment`s."""
module_wnd = memoryview(module)
# Read & yield module header.
hdr = ModuleHeader()
hdr_len, hdr_data, _ = hdr.from_raw(None, module_wnd)
yield ModuleFragment(hdr, hdr_data)
... | [
"Decodes",
"raw",
"WASM",
"modules",
"yielding",
"ModuleFragment",
"s",
"."
] | athre0z/wasm | python | https://github.com/athre0z/wasm/blob/bc9c7e3f40242a2a8fc9650c4b994f0cddf8d755/wasm/decode.py#L32-L62 | [
"def",
"decode_module",
"(",
"module",
",",
"decode_name_subsections",
"=",
"False",
")",
":",
"module_wnd",
"=",
"memoryview",
"(",
"module",
")",
"# Read & yield module header.",
"hdr",
"=",
"ModuleHeader",
"(",
")",
"hdr_len",
",",
"hdr_data",
",",
"_",
"=",
... | bc9c7e3f40242a2a8fc9650c4b994f0cddf8d755 |
test | deprecated_func | Deprecates a function, printing a warning on the first usage. | wasm/compat.py | def deprecated_func(func):
"""Deprecates a function, printing a warning on the first usage."""
# We use a mutable container here to work around Py2's lack of
# the `nonlocal` keyword.
first_usage = [True]
@functools.wraps(func)
def wrapper(*args, **kwargs):
if first_usage[0]:
... | def deprecated_func(func):
"""Deprecates a function, printing a warning on the first usage."""
# We use a mutable container here to work around Py2's lack of
# the `nonlocal` keyword.
first_usage = [True]
@functools.wraps(func)
def wrapper(*args, **kwargs):
if first_usage[0]:
... | [
"Deprecates",
"a",
"function",
"printing",
"a",
"warning",
"on",
"the",
"first",
"usage",
"."
] | athre0z/wasm | python | https://github.com/athre0z/wasm/blob/bc9c7e3f40242a2a8fc9650c4b994f0cddf8d755/wasm/compat.py#L50-L67 | [
"def",
"deprecated_func",
"(",
"func",
")",
":",
"# We use a mutable container here to work around Py2's lack of",
"# the `nonlocal` keyword.",
"first_usage",
"=",
"[",
"True",
"]",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
... | bc9c7e3f40242a2a8fc9650c4b994f0cddf8d755 |
test | Manager.send_action | Send an :class:`~panoramisk.actions.Action` to the server:
:param action: an Action or dict with action name and parameters to
send
:type action: Action or dict or Command
:param as_list: If True, the action Future will retrieve all responses
:type as_list: boolea... | panoramisk/manager.py | def send_action(self, action, as_list=None, **kwargs):
"""Send an :class:`~panoramisk.actions.Action` to the server:
:param action: an Action or dict with action name and parameters to
send
:type action: Action or dict or Command
:param as_list: If True, the actio... | def send_action(self, action, as_list=None, **kwargs):
"""Send an :class:`~panoramisk.actions.Action` to the server:
:param action: an Action or dict with action name and parameters to
send
:type action: Action or dict or Command
:param as_list: If True, the actio... | [
"Send",
"an",
":",
"class",
":",
"~panoramisk",
".",
"actions",
".",
"Action",
"to",
"the",
"server",
":"
] | gawel/panoramisk | python | https://github.com/gawel/panoramisk/blob/2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e/panoramisk/manager.py#L110-L138 | [
"def",
"send_action",
"(",
"self",
",",
"action",
",",
"as_list",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"action",
".",
"update",
"(",
"kwargs",
")",
"return",
"self",
".",
"protocol",
".",
"send",
"(",
"action",
",",
"as_list",
"=",
"as_lis... | 2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e |
test | Manager.send_command | Send a :class:`~panoramisk.actions.Command` to the server::
manager = Manager()
resp = manager.send_command('http show status')
Return a response :class:`~panoramisk.message.Message`.
See https://wiki.asterisk.org/wiki/display/AST/ManagerAction_Command | panoramisk/manager.py | def send_command(self, command, as_list=False):
"""Send a :class:`~panoramisk.actions.Command` to the server::
manager = Manager()
resp = manager.send_command('http show status')
Return a response :class:`~panoramisk.message.Message`.
See https://wiki.asterisk.org/wiki/... | def send_command(self, command, as_list=False):
"""Send a :class:`~panoramisk.actions.Command` to the server::
manager = Manager()
resp = manager.send_command('http show status')
Return a response :class:`~panoramisk.message.Message`.
See https://wiki.asterisk.org/wiki/... | [
"Send",
"a",
":",
"class",
":",
"~panoramisk",
".",
"actions",
".",
"Command",
"to",
"the",
"server",
"::"
] | gawel/panoramisk | python | https://github.com/gawel/panoramisk/blob/2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e/panoramisk/manager.py#L140-L151 | [
"def",
"send_command",
"(",
"self",
",",
"command",
",",
"as_list",
"=",
"False",
")",
":",
"action",
"=",
"actions",
".",
"Action",
"(",
"{",
"'Command'",
":",
"command",
",",
"'Action'",
":",
"'Command'",
"}",
",",
"as_list",
"=",
"as_list",
")",
"re... | 2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e |
test | Manager.send_agi_command | Send a :class:`~panoramisk.actions.Command` to the server:
:param channel: Channel name where to launch command.
Ex: 'SIP/000000-00000a53'
:type channel: String
:param command: command to launch. Ex: 'GET VARIABLE async_agi_server'
:type command: String
:param as_... | panoramisk/manager.py | def send_agi_command(self, channel, command, as_list=False):
"""Send a :class:`~panoramisk.actions.Command` to the server:
:param channel: Channel name where to launch command.
Ex: 'SIP/000000-00000a53'
:type channel: String
:param command: command to launch. Ex: 'GET VAR... | def send_agi_command(self, channel, command, as_list=False):
"""Send a :class:`~panoramisk.actions.Command` to the server:
:param channel: Channel name where to launch command.
Ex: 'SIP/000000-00000a53'
:type channel: String
:param command: command to launch. Ex: 'GET VAR... | [
"Send",
"a",
":",
"class",
":",
"~panoramisk",
".",
"actions",
".",
"Command",
"to",
"the",
"server",
":"
] | gawel/panoramisk | python | https://github.com/gawel/panoramisk/blob/2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e/panoramisk/manager.py#L153-L182 | [
"def",
"send_agi_command",
"(",
"self",
",",
"channel",
",",
"command",
",",
"as_list",
"=",
"False",
")",
":",
"action",
"=",
"actions",
".",
"Command",
"(",
"{",
"'Action'",
":",
"'AGI'",
",",
"'Channel'",
":",
"channel",
",",
"'Command'",
":",
"comman... | 2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e |
test | Manager.connect | connect to the server | panoramisk/manager.py | def connect(self):
"""connect to the server"""
if self.loop is None: # pragma: no cover
self.loop = asyncio.get_event_loop()
t = asyncio.Task(
self.loop.create_connection(
self.config['protocol_factory'],
self.config['host'], self.config['... | def connect(self):
"""connect to the server"""
if self.loop is None: # pragma: no cover
self.loop = asyncio.get_event_loop()
t = asyncio.Task(
self.loop.create_connection(
self.config['protocol_factory'],
self.config['host'], self.config['... | [
"connect",
"to",
"the",
"server"
] | gawel/panoramisk | python | https://github.com/gawel/panoramisk/blob/2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e/panoramisk/manager.py#L184-L195 | [
"def",
"connect",
"(",
"self",
")",
":",
"if",
"self",
".",
"loop",
"is",
"None",
":",
"# pragma: no cover",
"self",
".",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"t",
"=",
"asyncio",
".",
"Task",
"(",
"self",
".",
"loop",
".",
"creat... | 2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e |
test | Manager.register_event | register an event. See :class:`~panoramisk.message.Message`:
.. code-block:: python
>>> def callback(manager, event):
... print(manager, event)
>>> manager = Manager()
>>> manager.register_event('Meetme*', callback)
<function callback at 0x...>
... | panoramisk/manager.py | def register_event(self, pattern, callback=None):
"""register an event. See :class:`~panoramisk.message.Message`:
.. code-block:: python
>>> def callback(manager, event):
... print(manager, event)
>>> manager = Manager()
>>> manager.register_event('M... | def register_event(self, pattern, callback=None):
"""register an event. See :class:`~panoramisk.message.Message`:
.. code-block:: python
>>> def callback(manager, event):
... print(manager, event)
>>> manager = Manager()
>>> manager.register_event('M... | [
"register",
"an",
"event",
".",
"See",
":",
"class",
":",
"~panoramisk",
".",
"message",
".",
"Message",
":"
] | gawel/panoramisk | python | https://github.com/gawel/panoramisk/blob/2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e/panoramisk/manager.py#L197-L226 | [
"def",
"register_event",
"(",
"self",
",",
"pattern",
",",
"callback",
"=",
"None",
")",
":",
"def",
"_register_event",
"(",
"callback",
")",
":",
"if",
"not",
"self",
".",
"callbacks",
"[",
"pattern",
"]",
":",
"self",
".",
"patterns",
".",
"append",
... | 2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e |
test | Manager.close | Close the connection | panoramisk/manager.py | def close(self):
"""Close the connection"""
if self.pinger:
self.pinger.cancel()
self.pinger = None
if getattr(self, 'protocol', None):
self.protocol.close() | def close(self):
"""Close the connection"""
if self.pinger:
self.pinger.cancel()
self.pinger = None
if getattr(self, 'protocol', None):
self.protocol.close() | [
"Close",
"the",
"connection"
] | gawel/panoramisk | python | https://github.com/gawel/panoramisk/blob/2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e/panoramisk/manager.py#L242-L248 | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"pinger",
":",
"self",
".",
"pinger",
".",
"cancel",
"(",
")",
"self",
".",
"pinger",
"=",
"None",
"if",
"getattr",
"(",
"self",
",",
"'protocol'",
",",
"None",
")",
":",
"self",
".",
"pro... | 2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e |
test | Request.send_command | Send a command for FastAGI request:
:param command: Command to launch on FastAGI request. Ex: 'EXEC StartMusicOnHolds'
:type command: String
:Example:
::
@asyncio.coroutine
def call_waiting(request):
print(['AGI variables:', request.headers])
... | panoramisk/fast_agi.py | def send_command(self, command):
"""Send a command for FastAGI request:
:param command: Command to launch on FastAGI request. Ex: 'EXEC StartMusicOnHolds'
:type command: String
:Example:
::
@asyncio.coroutine
def call_waiting(request):
... | def send_command(self, command):
"""Send a command for FastAGI request:
:param command: Command to launch on FastAGI request. Ex: 'EXEC StartMusicOnHolds'
:type command: String
:Example:
::
@asyncio.coroutine
def call_waiting(request):
... | [
"Send",
"a",
"command",
"for",
"FastAGI",
"request",
":"
] | gawel/panoramisk | python | https://github.com/gawel/panoramisk/blob/2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e/panoramisk/fast_agi.py#L18-L50 | [
"def",
"send_command",
"(",
"self",
",",
"command",
")",
":",
"command",
"+=",
"'\\n'",
"self",
".",
"writer",
".",
"write",
"(",
"command",
".",
"encode",
"(",
"self",
".",
"encoding",
")",
")",
"yield",
"from",
"self",
".",
"writer",
".",
"drain",
... | 2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e |
test | Request._read_result | Parse read a response from the AGI and parse it.
:return dict: The AGI response parsed into a dict. | panoramisk/fast_agi.py | def _read_result(self):
"""Parse read a response from the AGI and parse it.
:return dict: The AGI response parsed into a dict.
"""
response = yield from self.reader.readline()
return parse_agi_result(response.decode(self.encoding)[:-1]) | def _read_result(self):
"""Parse read a response from the AGI and parse it.
:return dict: The AGI response parsed into a dict.
"""
response = yield from self.reader.readline()
return parse_agi_result(response.decode(self.encoding)[:-1]) | [
"Parse",
"read",
"a",
"response",
"from",
"the",
"AGI",
"and",
"parse",
"it",
"."
] | gawel/panoramisk | python | https://github.com/gawel/panoramisk/blob/2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e/panoramisk/fast_agi.py#L53-L59 | [
"def",
"_read_result",
"(",
"self",
")",
":",
"response",
"=",
"yield",
"from",
"self",
".",
"reader",
".",
"readline",
"(",
")",
"return",
"parse_agi_result",
"(",
"response",
".",
"decode",
"(",
"self",
".",
"encoding",
")",
"[",
":",
"-",
"1",
"]",
... | 2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e |
test | Application.add_route | Add a route for FastAGI requests:
:param path: URI to answer. Ex: 'calls/start'
:type path: String
:param endpoint: command to launch. Ex: start
:type endpoint: callable
:Example:
::
@asyncio.coroutine
def start(request):
print(... | panoramisk/fast_agi.py | def add_route(self, path, endpoint):
"""Add a route for FastAGI requests:
:param path: URI to answer. Ex: 'calls/start'
:type path: String
:param endpoint: command to launch. Ex: start
:type endpoint: callable
:Example:
::
@asyncio.coroutine
... | def add_route(self, path, endpoint):
"""Add a route for FastAGI requests:
:param path: URI to answer. Ex: 'calls/start'
:type path: String
:param endpoint: command to launch. Ex: start
:type endpoint: callable
:Example:
::
@asyncio.coroutine
... | [
"Add",
"a",
"route",
"for",
"FastAGI",
"requests",
":"
] | gawel/panoramisk | python | https://github.com/gawel/panoramisk/blob/2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e/panoramisk/fast_agi.py#L80-L106 | [
"def",
"add_route",
"(",
"self",
",",
"path",
",",
"endpoint",
")",
":",
"assert",
"callable",
"(",
"endpoint",
")",
",",
"endpoint",
"if",
"path",
"in",
"self",
".",
"_route",
":",
"raise",
"ValueError",
"(",
"'A route already exists.'",
")",
"if",
"not",... | 2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e |
test | Application.del_route | Delete a route for FastAGI requests:
:param path: URI to answer. Ex: 'calls/start'
:type path: String
:Example:
::
@asyncio.coroutine
def start(request):
print('Receive a FastAGI request')
print(['AGI variables:', request.header... | panoramisk/fast_agi.py | def del_route(self, path):
"""Delete a route for FastAGI requests:
:param path: URI to answer. Ex: 'calls/start'
:type path: String
:Example:
::
@asyncio.coroutine
def start(request):
print('Receive a FastAGI request')
p... | def del_route(self, path):
"""Delete a route for FastAGI requests:
:param path: URI to answer. Ex: 'calls/start'
:type path: String
:Example:
::
@asyncio.coroutine
def start(request):
print('Receive a FastAGI request')
p... | [
"Delete",
"a",
"route",
"for",
"FastAGI",
"requests",
":"
] | gawel/panoramisk | python | https://github.com/gawel/panoramisk/blob/2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e/panoramisk/fast_agi.py#L108-L130 | [
"def",
"del_route",
"(",
"self",
",",
"path",
")",
":",
"if",
"path",
"not",
"in",
"self",
".",
"_route",
":",
"raise",
"ValueError",
"(",
"'This route doesn\\'t exist.'",
")",
"del",
"(",
"self",
".",
"_route",
"[",
"path",
"]",
")"
] | 2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e |
test | Application.handler | AsyncIO coroutine handler to launch socket listening.
:Example:
::
@asyncio.coroutine
def start(request):
print('Receive a FastAGI request')
print(['AGI variables:', request.headers])
fa_app = Application()
fa_app.add_ro... | panoramisk/fast_agi.py | def handler(self, reader, writer):
"""AsyncIO coroutine handler to launch socket listening.
:Example:
::
@asyncio.coroutine
def start(request):
print('Receive a FastAGI request')
print(['AGI variables:', request.headers])
fa... | def handler(self, reader, writer):
"""AsyncIO coroutine handler to launch socket listening.
:Example:
::
@asyncio.coroutine
def start(request):
print('Receive a FastAGI request')
print(['AGI variables:', request.headers])
fa... | [
"AsyncIO",
"coroutine",
"handler",
"to",
"launch",
"socket",
"listening",
"."
] | gawel/panoramisk | python | https://github.com/gawel/panoramisk/blob/2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e/panoramisk/fast_agi.py#L133-L184 | [
"def",
"handler",
"(",
"self",
",",
"reader",
",",
"writer",
")",
":",
"buffer",
"=",
"b''",
"while",
"b'\\n\\n'",
"not",
"in",
"buffer",
":",
"buffer",
"+=",
"yield",
"from",
"reader",
".",
"read",
"(",
"self",
".",
"buf_size",
")",
"lines",
"=",
"b... | 2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e |
test | parse_agi_result | Parse AGI results using Regular expression.
AGI Result examples::
100 result=0 Trying...
200 result=0
200 result=-1
200 result=132456
200 result= (timeout)
510 Invalid or unknown command
520-Invalid command syntax. Proper usage follows:
int() a... | panoramisk/utils.py | def parse_agi_result(line):
"""Parse AGI results using Regular expression.
AGI Result examples::
100 result=0 Trying...
200 result=0
200 result=-1
200 result=132456
200 result= (timeout)
510 Invalid or unknown command
520-Invalid command syntax. Pr... | def parse_agi_result(line):
"""Parse AGI results using Regular expression.
AGI Result examples::
100 result=0 Trying...
200 result=0
200 result=-1
200 result=132456
200 result= (timeout)
510 Invalid or unknown command
520-Invalid command syntax. Pr... | [
"Parse",
"AGI",
"results",
"using",
"Regular",
"expression",
"."
] | gawel/panoramisk | python | https://github.com/gawel/panoramisk/blob/2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e/panoramisk/utils.py#L18-L54 | [
"def",
"parse_agi_result",
"(",
"line",
")",
":",
"# print(\"--------------\\n\", line)",
"if",
"line",
"==",
"'HANGUP'",
":",
"return",
"{",
"'error'",
":",
"'AGIResultHangup'",
",",
"'msg'",
":",
"'User hungup during execution'",
"}",
"kwargs",
"=",
"dict",
"(",
... | 2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e |
test | agi_code_check | Check the AGI code and return a dict to help on error handling. | panoramisk/utils.py | def agi_code_check(code=None, response=None, line=None):
"""
Check the AGI code and return a dict to help on error handling.
"""
code = int(code)
response = response or ""
result = {'status_code': code, 'result': ('', ''), 'msg': ''}
if code == 100:
result['msg'] = line
elif code... | def agi_code_check(code=None, response=None, line=None):
"""
Check the AGI code and return a dict to help on error handling.
"""
code = int(code)
response = response or ""
result = {'status_code': code, 'result': ('', ''), 'msg': ''}
if code == 100:
result['msg'] = line
elif code... | [
"Check",
"the",
"AGI",
"code",
"and",
"return",
"a",
"dict",
"to",
"help",
"on",
"error",
"handling",
"."
] | gawel/panoramisk | python | https://github.com/gawel/panoramisk/blob/2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e/panoramisk/utils.py#L57-L88 | [
"def",
"agi_code_check",
"(",
"code",
"=",
"None",
",",
"response",
"=",
"None",
",",
"line",
"=",
"None",
")",
":",
"code",
"=",
"int",
"(",
"code",
")",
"response",
"=",
"response",
"or",
"\"\"",
"result",
"=",
"{",
"'status_code'",
":",
"code",
",... | 2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e |
test | IdGenerator.reset | Mostly used for unit testing. Allow to use a static uuid and reset
all counter | panoramisk/utils.py | def reset(cls, uid=None):
"""Mostly used for unit testing. Allow to use a static uuid and reset
all counter"""
for instance in cls.instances:
if uid:
instance.uid = uid
instance.generator = instance.get_generator() | def reset(cls, uid=None):
"""Mostly used for unit testing. Allow to use a static uuid and reset
all counter"""
for instance in cls.instances:
if uid:
instance.uid = uid
instance.generator = instance.get_generator() | [
"Mostly",
"used",
"for",
"unit",
"testing",
".",
"Allow",
"to",
"use",
"a",
"static",
"uuid",
"and",
"reset",
"all",
"counter"
] | gawel/panoramisk | python | https://github.com/gawel/panoramisk/blob/2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e/panoramisk/utils.py#L129-L135 | [
"def",
"reset",
"(",
"cls",
",",
"uid",
"=",
"None",
")",
":",
"for",
"instance",
"in",
"cls",
".",
"instances",
":",
"if",
"uid",
":",
"instance",
".",
"uid",
"=",
"uid",
"instance",
".",
"generator",
"=",
"instance",
".",
"get_generator",
"(",
")"
... | 2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e |
test | IdGenerator.get_instances | Mostly used for debugging | panoramisk/utils.py | def get_instances(self):
"""Mostly used for debugging"""
return ["<%s prefix:%s (uid:%s)>" % (self.__class__.__name__,
i.prefix, self.uid)
for i in self.instances] | def get_instances(self):
"""Mostly used for debugging"""
return ["<%s prefix:%s (uid:%s)>" % (self.__class__.__name__,
i.prefix, self.uid)
for i in self.instances] | [
"Mostly",
"used",
"for",
"debugging"
] | gawel/panoramisk | python | https://github.com/gawel/panoramisk/blob/2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e/panoramisk/utils.py#L137-L141 | [
"def",
"get_instances",
"(",
"self",
")",
":",
"return",
"[",
"\"<%s prefix:%s (uid:%s)>\"",
"%",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"i",
".",
"prefix",
",",
"self",
".",
"uid",
")",
"for",
"i",
"in",
"self",
".",
"instances",
"]"
] | 2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e |
test | Message.success | return True if a response status is Success or Follows:
.. code-block:: python
>>> resp = Message({'Response': 'Success'})
>>> print(resp.success)
True
>>> resp['Response'] = 'Failed'
>>> resp.success
False | panoramisk/message.py | def success(self):
"""return True if a response status is Success or Follows:
.. code-block:: python
>>> resp = Message({'Response': 'Success'})
>>> print(resp.success)
True
>>> resp['Response'] = 'Failed'
>>> resp.success
False
... | def success(self):
"""return True if a response status is Success or Follows:
.. code-block:: python
>>> resp = Message({'Response': 'Success'})
>>> print(resp.success)
True
>>> resp['Response'] = 'Failed'
>>> resp.success
False
... | [
"return",
"True",
"if",
"a",
"response",
"status",
"is",
"Success",
"or",
"Follows",
":"
] | gawel/panoramisk | python | https://github.com/gawel/panoramisk/blob/2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e/panoramisk/message.py#L61-L77 | [
"def",
"success",
"(",
"self",
")",
":",
"if",
"'event'",
"in",
"self",
":",
"return",
"True",
"if",
"self",
".",
"response",
"in",
"self",
".",
"success_responses",
":",
"return",
"True",
"return",
"False"
] | 2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.