Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
SVD.predict | (self) |
This method computes a final rating for unknown pairs (user, item)
|
This method computes a final rating for unknown pairs (user, item) | def predict(self):
"""
This method computes a final rating for unknown pairs (user, item)
"""
if self.test_file is not None:
for user in self.test_set['users']:
for item in self.test_set['feedback'][user]:
self.predictions.append((user, i... | [
"def",
"predict",
"(",
"self",
")",
":",
"if",
"self",
".",
"test_file",
"is",
"not",
"None",
":",
"for",
"user",
"in",
"self",
".",
"test_set",
"[",
"'users'",
"]",
":",
"for",
"item",
"in",
"self",
".",
"test_set",
"[",
"'feedback'",
"]",
"[",
"u... | [
128,
4
] | [
140,
32
] | python | en | ['en', 'error', 'th'] | False |
SVD.compute | (self, verbose=True, metrics=None, verbose_evaluation=True, as_table=False, table_sep='\t') |
Extends compute method from BaseRatingPrediction. Method to run recommender algorithm
:param verbose: Print recommender and database information
:type verbose: bool, default True
:param metrics: List of evaluation measures
:type metrics: list, default None
:param verb... |
Extends compute method from BaseRatingPrediction. Method to run recommender algorithm | def compute(self, verbose=True, metrics=None, verbose_evaluation=True, as_table=False, table_sep='\t'):
"""
Extends compute method from BaseRatingPrediction. Method to run recommender algorithm
:param verbose: Print recommender and database information
:type verbose: bool, default True
... | [
"def",
"compute",
"(",
"self",
",",
"verbose",
"=",
"True",
",",
"metrics",
"=",
"None",
",",
"verbose_evaluation",
"=",
"True",
",",
"as_table",
"=",
"False",
",",
"table_sep",
"=",
"'\\t'",
")",
":",
"super",
"(",
"SVD",
",",
"self",
")",
".",
"com... | [
142,
4
] | [
184,
94
] | python | en | ['en', 'error', 'th'] | False |
OpenLayersWidget.map_options | (self) | Build the map options hash for the OpenLayers template. | Build the map options hash for the OpenLayers template. | def map_options(self):
"""Build the map options hash for the OpenLayers template."""
# JavaScript construction utilities for the Bounds and Projection.
def ol_bounds(extent):
return 'new OpenLayers.Bounds(%s)' % extent
def ol_projection(srid):
return 'new OpenLay... | [
"def",
"map_options",
"(",
"self",
")",
":",
"# JavaScript construction utilities for the Bounds and Projection.",
"def",
"ol_bounds",
"(",
"extent",
")",
":",
"return",
"'new OpenLayers.Bounds(%s)'",
"%",
"extent",
"def",
"ol_projection",
"(",
"srid",
")",
":",
"return... | [
80,
4
] | [
116,
26
] | python | en | ['en', 'en', 'en'] | True |
validate_options | (options) | Validates options. | Validates options. | def validate_options(options):
"""Validates options."""
kwcase = options.get('keyword_case')
if kwcase not in [None, 'upper', 'lower', 'capitalize']:
raise SQLParseError('Invalid value for keyword_case: '
'{!r}'.format(kwcase))
idcase = options.get('identifier_case')... | [
"def",
"validate_options",
"(",
"options",
")",
":",
"kwcase",
"=",
"options",
".",
"get",
"(",
"'keyword_case'",
")",
"if",
"kwcase",
"not",
"in",
"[",
"None",
",",
"'upper'",
",",
"'lower'",
",",
"'capitalize'",
"]",
":",
"raise",
"SQLParseError",
"(",
... | [
13,
0
] | [
128,
18
] | python | en | ['en', 'et', 'en'] | False |
build_filter_stack | (stack, options) | Setup and return a filter stack.
Args:
stack: :class:`~sqlparse.filters.FilterStack` instance
options: Dictionary with options validated by validate_options.
| Setup and return a filter stack. | def build_filter_stack(stack, options):
"""Setup and return a filter stack.
Args:
stack: :class:`~sqlparse.filters.FilterStack` instance
options: Dictionary with options validated by validate_options.
"""
# Token filter
if options.get('keyword_case'):
stack.preprocess.append(
... | [
"def",
"build_filter_stack",
"(",
"stack",
",",
"options",
")",
":",
"# Token filter",
"if",
"options",
".",
"get",
"(",
"'keyword_case'",
")",
":",
"stack",
".",
"preprocess",
".",
"append",
"(",
"filters",
".",
"KeywordCaseFilter",
"(",
"options",
"[",
"'k... | [
131,
0
] | [
197,
16
] | python | en | ['en', 'da', 'en'] | True |
serve | (request, path, document_root=None, show_indexes=False) |
Serve static files below a given point in the directory structure.
To use, put a URL pattern such as::
from django.views.static import serve
path('<path:path>', serve, {'document_root': '/path/to/my/files/'})
in your URLconf. You must provide the ``document_root`` param. You may
als... |
Serve static files below a given point in the directory structure. | def serve(request, path, document_root=None, show_indexes=False):
"""
Serve static files below a given point in the directory structure.
To use, put a URL pattern such as::
from django.views.static import serve
path('<path:path>', serve, {'document_root': '/path/to/my/files/'})
in yo... | [
"def",
"serve",
"(",
"request",
",",
"path",
",",
"document_root",
"=",
"None",
",",
"show_indexes",
"=",
"False",
")",
":",
"path",
"=",
"posixpath",
".",
"normpath",
"(",
"path",
")",
".",
"lstrip",
"(",
"'/'",
")",
"fullpath",
"=",
"Path",
"(",
"s... | [
18,
0
] | [
53,
19
] | python | en | ['en', 'error', 'th'] | False |
was_modified_since | (header=None, mtime=0, size=0) |
Was something modified since the user last downloaded it?
header
This is the value of the If-Modified-Since header. If this is None,
I'll just return True.
mtime
This is the modification time of the item we're talking about.
size
This is the size of the item we're talking ab... |
Was something modified since the user last downloaded it? | def was_modified_since(header=None, mtime=0, size=0):
"""
Was something modified since the user last downloaded it?
header
This is the value of the If-Modified-Since header. If this is None,
I'll just return True.
mtime
This is the modification time of the item we're talking about.
... | [
"def",
"was_modified_since",
"(",
"header",
"=",
"None",
",",
"mtime",
"=",
"0",
",",
"size",
"=",
"0",
")",
":",
"try",
":",
"if",
"header",
"is",
"None",
":",
"raise",
"ValueError",
"matches",
"=",
"re",
".",
"match",
"(",
"r\"^([^;]+)(; length=([0-9]+... | [
107,
0
] | [
134,
16
] | python | en | ['en', 'error', 'th'] | False |
image2float_array | (image, scale_factor=None) |
source: https://github.com/ahundt/robotics_setup/blob/master/datasets/google_brain_robot_data/depth_image_encoding.py
Recovers the depth values from an image.
Reverses the depth to image conversion performed by FloatArrayToRgbImage or
FloatArrayToGrayImage.
The image is treated as an arr... |
source: https://github.com/ahundt/robotics_setup/blob/master/datasets/google_brain_robot_data/depth_image_encoding.py
Recovers the depth values from an image.
Reverses the depth to image conversion performed by FloatArrayToRgbImage or
FloatArrayToGrayImage.
The image is treated as an arr... | def image2float_array(image, scale_factor=None):
'''
source: https://github.com/ahundt/robotics_setup/blob/master/datasets/google_brain_robot_data/depth_image_encoding.py
Recovers the depth values from an image.
Reverses the depth to image conversion performed by FloatArrayToRgbImage or
Floa... | [
"def",
"image2float_array",
"(",
"image",
",",
"scale_factor",
"=",
"None",
")",
":",
"image_array",
"=",
"np",
".",
"array",
"(",
"image",
")",
"image_dtype",
"=",
"image_array",
".",
"dtype",
"image_shape",
"=",
"image_array",
".",
"shape",
"channels",
"="... | [
105,
0
] | [
149,
23
] | python | en | ['en', 'error', 'th'] | False |
image_resize2square | (image, desired_size=None) |
Transform image to a square image with desired size(resolution)
Padding image with black color which defined as MASK_BACKGROUND
|
Transform image to a square image with desired size(resolution)
Padding image with black color which defined as MASK_BACKGROUND
| def image_resize2square(image, desired_size=None):
'''
Transform image to a square image with desired size(resolution)
Padding image with black color which defined as MASK_BACKGROUND
'''
# initialize dimensions of the image to be resized and
# grab the image size
old_size = image.shape[:2]
... | [
"def",
"image_resize2square",
"(",
"image",
",",
"desired_size",
"=",
"None",
")",
":",
"# initialize dimensions of the image to be resized and",
"# grab the image size",
"old_size",
"=",
"image",
".",
"shape",
"[",
":",
"2",
"]",
"# if both the width and height are None, t... | [
152,
0
] | [
183,
20
] | python | en | ['en', 'error', 'th'] | False |
image_enhance | (image, shift) |
Input image is a numpy array with unit8 grayscale.
This function will enhance the bright by adding num to each pixel.
perform normalization
|
Input image is a numpy array with unit8 grayscale.
This function will enhance the bright by adding num to each pixel.
perform normalization
| def image_enhance(image, shift):
'''
Input image is a numpy array with unit8 grayscale.
This function will enhance the bright by adding num to each pixel.
perform normalization
'''
if shift > 0:
for i in range(shift):
image += 1
# If pixel value == 0 which means ... | [
"def",
"image_enhance",
"(",
"image",
",",
"shift",
")",
":",
"if",
"shift",
">",
"0",
":",
"for",
"i",
"in",
"range",
"(",
"shift",
")",
":",
"image",
"+=",
"1",
"# If pixel value == 0 which means the value = 256 but overflow to 0",
"# shift the overflow pix values... | [
186,
0
] | [
199,
16
] | python | en | ['en', 'error', 'th'] | False |
process_image | (img, shift, resolution) |
Pre-process image before store in numpy file.
shift: shift all pixels a distance with the shift value to avoid black color in image.
resolution: change image resolution to fit model.
|
Pre-process image before store in numpy file.
shift: shift all pixels a distance with the shift value to avoid black color in image.
resolution: change image resolution to fit model.
| def process_image(img, shift, resolution):
'''
Pre-process image before store in numpy file.
shift: shift all pixels a distance with the shift value to avoid black color in image.
resolution: change image resolution to fit model.
'''
# Add 5 for each pixel on the grayscale image.
if ... | [
"def",
"process_image",
"(",
"img",
",",
"shift",
",",
"resolution",
")",
":",
"# Add 5 for each pixel on the grayscale image.",
"if",
"MODE",
"!=",
"\"L\"",
":",
"img",
"=",
"image_enhance",
"(",
"img",
",",
"shift",
"=",
"shift",
")",
"# The source image should ... | [
202,
0
] | [
215,
14
] | python | en | ['en', 'error', 'th'] | False |
change_background_color | (img, original_color, new_color) |
Convert mask color of 4 channels png image to new color
|
Convert mask color of 4 channels png image to new color
| def change_background_color(img, original_color, new_color):
'''
Convert mask color of 4 channels png image to new color
'''
r1, g1, b1, a1 = original_color[0], original_color[1], original_color[2], original_color[3] # Original value
# mask background color (0,0,0,0)
r2, g2, b2, a2 = new_colo... | [
"def",
"change_background_color",
"(",
"img",
",",
"original_color",
",",
"new_color",
")",
":",
"r1",
",",
"g1",
",",
"b1",
",",
"a1",
"=",
"original_color",
"[",
"0",
"]",
",",
"original_color",
"[",
"1",
"]",
",",
"original_color",
"[",
"2",
"]",
",... | [
218,
0
] | [
230,
14
] | python | en | ['en', 'error', 'th'] | False |
convert_mask_data | (mask, resolution=RESOLUTION, from_background_color=COCO_BACKGROUND,
to_background_color=MASK_BACKGROUND) |
1. Resize mask to square with size of resolution.
2. Change back ground color to black
3. Change pixel value to 1 for masking
4. Change pixel value to 0 for non-masking area
5. Reduce data type to uint8 to reduce the file size of mask.
|
1. Resize mask to square with size of resolution.
2. Change back ground color to black
3. Change pixel value to 1 for masking
4. Change pixel value to 0 for non-masking area
5. Reduce data type to uint8 to reduce the file size of mask.
| def convert_mask_data(mask, resolution=RESOLUTION, from_background_color=COCO_BACKGROUND,
to_background_color=MASK_BACKGROUND):
'''
1. Resize mask to square with size of resolution.
2. Change back ground color to black
3. Change pixel value to 1 for masking
4. Change pixel valu... | [
"def",
"convert_mask_data",
"(",
"mask",
",",
"resolution",
"=",
"RESOLUTION",
",",
"from_background_color",
"=",
"COCO_BACKGROUND",
",",
"to_background_color",
"=",
"MASK_BACKGROUND",
")",
":",
"mask",
"=",
"image_resize2square",
"(",
"mask",
",",
"resolution",
")"... | [
233,
0
] | [
254,
15
] | python | en | ['en', 'error', 'th'] | False |
convert_img_data | (img, dims=4, resolution=RESOLUTION) |
Convert image data by
1. Shift RGB channel with value 1 to avoid pure black color.
2. Resize image to square
3. Normalized data
4. reshape to require dimension 3 or 4
|
Convert image data by
1. Shift RGB channel with value 1 to avoid pure black color.
2. Resize image to square
3. Normalized data
4. reshape to require dimension 3 or 4
| def convert_img_data(img, dims=4, resolution=RESOLUTION):
'''
Convert image data by
1. Shift RGB channel with value 1 to avoid pure black color.
2. Resize image to square
3. Normalized data
4. reshape to require dimension 3 or 4
'''
# img = img[:, :, :3]
if GRAYSCALE == True:
... | [
"def",
"convert_img_data",
"(",
"img",
",",
"dims",
"=",
"4",
",",
"resolution",
"=",
"RESOLUTION",
")",
":",
"# img = img[:, :, :3]",
"if",
"GRAYSCALE",
"==",
"True",
":",
"# Add 1 for each pixel and change resolution on the image.",
"img",
"=",
"process_image",
"(",... | [
257,
0
] | [
286,
14
] | python | en | ['en', 'error', 'th'] | False |
BaseSessionManager.encode | (self, session_dict) |
Return the given session dictionary serialized and encoded as a string.
|
Return the given session dictionary serialized and encoded as a string.
| def encode(self, session_dict):
"""
Return the given session dictionary serialized and encoded as a string.
"""
session_store_class = self.model.get_session_store_class()
return session_store_class().encode(session_dict) | [
"def",
"encode",
"(",
"self",
",",
"session_dict",
")",
":",
"session_store_class",
"=",
"self",
".",
"model",
".",
"get_session_store_class",
"(",
")",
"return",
"session_store_class",
"(",
")",
".",
"encode",
"(",
"session_dict",
")"
] | [
9,
4
] | [
14,
57
] | python | en | ['en', 'error', 'th'] | False |
AddDiskResourcesIfNeeded | (context) | Checks context if disk resources need to be added. | Checks context if disk resources need to be added. | def AddDiskResourcesIfNeeded(context):
"""Checks context if disk resources need to be added."""
if default.DISK_RESOURCES in context.properties:
return context.properties[default.DISK_RESOURCES]
else:
return [] | [
"def",
"AddDiskResourcesIfNeeded",
"(",
"context",
")",
":",
"if",
"default",
".",
"DISK_RESOURCES",
"in",
"context",
".",
"properties",
":",
"return",
"context",
".",
"properties",
"[",
"default",
".",
"DISK_RESOURCES",
"]",
"else",
":",
"return",
"[",
"]"
] | [
30,
0
] | [
35,
13
] | python | en | ['en', 'en', 'en'] | True |
AutoName | (base, resource, *args) | Helper method to generate names automatically based on default. | Helper method to generate names automatically based on default. | def AutoName(base, resource, *args):
"""Helper method to generate names automatically based on default."""
auto_name = '%s-%s' % (base, '-'.join(list(args) + [default.AKA[resource]]))
if not RFC1035_RE.match(auto_name):
raise Error('"%s" name for type %s does not match RFC1035 regex (%s)' %
(a... | [
"def",
"AutoName",
"(",
"base",
",",
"resource",
",",
"*",
"args",
")",
":",
"auto_name",
"=",
"'%s-%s'",
"%",
"(",
"base",
",",
"'-'",
".",
"join",
"(",
"list",
"(",
"args",
")",
"+",
"[",
"default",
".",
"AKA",
"[",
"resource",
"]",
"]",
")",
... | [
38,
0
] | [
44,
18
] | python | en | ['en', 'en', 'en'] | True |
AutoRef | (base, resource, *args) | Helper method that builds a reference for an auto-named resource. | Helper method that builds a reference for an auto-named resource. | def AutoRef(base, resource, *args):
"""Helper method that builds a reference for an auto-named resource."""
return Ref(AutoName(base, resource, *args)) | [
"def",
"AutoRef",
"(",
"base",
",",
"resource",
",",
"*",
"args",
")",
":",
"return",
"Ref",
"(",
"AutoName",
"(",
"base",
",",
"resource",
",",
"*",
"args",
")",
")"
] | [
47,
0
] | [
49,
45
] | python | en | ['en', 'en', 'en'] | True |
OrderedItems | (dict_obj) | Convenient method to yield sorted iteritems of a dictionary. | Convenient method to yield sorted iteritems of a dictionary. | def OrderedItems(dict_obj):
"""Convenient method to yield sorted iteritems of a dictionary."""
keys = list(dict_obj.keys())
keys.sort()
for k in keys:
yield (k, dict_obj[k]) | [
"def",
"OrderedItems",
"(",
"dict_obj",
")",
":",
"keys",
"=",
"list",
"(",
"dict_obj",
".",
"keys",
"(",
")",
")",
"keys",
".",
"sort",
"(",
")",
"for",
"k",
"in",
"keys",
":",
"yield",
"(",
"k",
",",
"dict_obj",
"[",
"k",
"]",
")"
] | [
52,
0
] | [
57,
26
] | python | en | ['en', 'en', 'en'] | True |
ShortenZoneName | (zone) | Given a string that looks like a zone name, creates a shorter version. | Given a string that looks like a zone name, creates a shorter version. | def ShortenZoneName(zone):
"""Given a string that looks like a zone name, creates a shorter version."""
geo, coord, number, letter = re.findall(r'(\w+)-(\w+)(\d)-(\w)', zone)[0]
geo = geo.lower() if len(geo) == 2 else default.LOC[geo.lower()]
coord = default.LOC[coord.lower()]
number = str(number)
letter = ... | [
"def",
"ShortenZoneName",
"(",
"zone",
")",
":",
"geo",
",",
"coord",
",",
"number",
",",
"letter",
"=",
"re",
".",
"findall",
"(",
"r'(\\w+)-(\\w+)(\\d)-(\\w)'",
",",
"zone",
")",
"[",
"0",
"]",
"geo",
"=",
"geo",
".",
"lower",
"(",
")",
"if",
"len"... | [
60,
0
] | [
67,
44
] | python | en | ['en', 'en', 'en'] | True |
ZoneToRegion | (zone) | Derives the region from a zone name. | Derives the region from a zone name. | def ZoneToRegion(zone):
"""Derives the region from a zone name."""
parts = zone.split('-')
if len(parts) != 3:
raise Error('Cannot derive region from zone "%s"' % zone)
return '-'.join(parts[:2]) | [
"def",
"ZoneToRegion",
"(",
"zone",
")",
":",
"parts",
"=",
"zone",
".",
"split",
"(",
"'-'",
")",
"if",
"len",
"(",
"parts",
")",
"!=",
"3",
":",
"raise",
"Error",
"(",
"'Cannot derive region from zone \"%s\"'",
"%",
"zone",
")",
"return",
"'-'",
".",
... | [
70,
0
] | [
75,
28
] | python | en | ['en', 'en', 'en'] | True |
FormatException | (message) | Adds more information to the exception. | Adds more information to the exception. | def FormatException(message):
"""Adds more information to the exception."""
message = ('Exception Type: %s\n'
'Details: %s\n'
'Message: %s\n') % (sys.exc_info()[0], traceback.format_exc(), message)
return message | [
"def",
"FormatException",
"(",
"message",
")",
":",
"message",
"=",
"(",
"'Exception Type: %s\\n'",
"'Details: %s\\n'",
"'Message: %s\\n'",
")",
"%",
"(",
"sys",
".",
"exc_info",
"(",
")",
"[",
"0",
"]",
",",
"traceback",
".",
"format_exc",
"(",
")",
",",
... | [
78,
0
] | [
83,
16
] | python | en | ['en', 'en', 'en'] | True |
SummarizeResources | (res_dict) | Summarizes the name of resources per resource type. | Summarizes the name of resources per resource type. | def SummarizeResources(res_dict):
"""Summarizes the name of resources per resource type."""
result = {}
for res in res_dict:
result.setdefault(res['type'], []).append(res['name'])
return result | [
"def",
"SummarizeResources",
"(",
"res_dict",
")",
":",
"result",
"=",
"{",
"}",
"for",
"res",
"in",
"res_dict",
":",
"result",
".",
"setdefault",
"(",
"res",
"[",
"'type'",
"]",
",",
"[",
"]",
")",
".",
"append",
"(",
"res",
"[",
"'name'",
"]",
")... | [
160,
0
] | [
165,
15
] | python | en | ['en', 'en', 'en'] | True |
ListPropertyValuesOfType | (res_dict, prop, res_type) | Lists all the values for a property of a certain type. | Lists all the values for a property of a certain type. | def ListPropertyValuesOfType(res_dict, prop, res_type):
"""Lists all the values for a property of a certain type."""
return [r['properties'][prop] for r in res_dict if r['type'] == res_type] | [
"def",
"ListPropertyValuesOfType",
"(",
"res_dict",
",",
"prop",
",",
"res_type",
")",
":",
"return",
"[",
"r",
"[",
"'properties'",
"]",
"[",
"prop",
"]",
"for",
"r",
"in",
"res_dict",
"if",
"r",
"[",
"'type'",
"]",
"==",
"res_type",
"]"
] | [
168,
0
] | [
170,
75
] | python | en | ['en', 'en', 'en'] | True |
MakeResource | (resource_list, output_list=None) | Wrapper for a DM template basic spec. | Wrapper for a DM template basic spec. | def MakeResource(resource_list, output_list=None):
"""Wrapper for a DM template basic spec."""
content = {'resources': resource_list}
if output_list:
content['outputs'] = output_list
return yaml.dump(content) | [
"def",
"MakeResource",
"(",
"resource_list",
",",
"output_list",
"=",
"None",
")",
":",
"content",
"=",
"{",
"'resources'",
":",
"resource_list",
"}",
"if",
"output_list",
":",
"content",
"[",
"'outputs'",
"]",
"=",
"output_list",
"return",
"yaml",
".",
"dum... | [
173,
0
] | [
178,
27
] | python | en | ['en', 'en', 'en'] | True |
TakeZoneOut | (properties) | Given a properties dictionary, removes the zone specific information. | Given a properties dictionary, removes the zone specific information. | def TakeZoneOut(properties):
"""Given a properties dictionary, removes the zone specific information."""
def _CleanZoneUrl(value):
value = value.split('/')[-1] if IsComputeLink(value) else value
return value
for name in default.VM_ZONE_PROPERTIES:
if name in properties:
properties[name] = _Cle... | [
"def",
"TakeZoneOut",
"(",
"properties",
")",
":",
"def",
"_CleanZoneUrl",
"(",
"value",
")",
":",
"value",
"=",
"value",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
"if",
"IsComputeLink",
"(",
"value",
")",
"else",
"value",
"return",
"value",
... | [
181,
0
] | [
203,
80
] | python | en | ['en', 'en', 'en'] | True |
FormatErrorsDec | (func) | Decorator to format exceptions if they get raised. | Decorator to format exceptions if they get raised. | def FormatErrorsDec(func):
"""Decorator to format exceptions if they get raised."""
def FormatErrorsWrap(context):
try:
return func(context)
except Exception as e:
raise Error(FormatException(e.message))
return FormatErrorsWrap | [
"def",
"FormatErrorsDec",
"(",
"func",
")",
":",
"def",
"FormatErrorsWrap",
"(",
"context",
")",
":",
"try",
":",
"return",
"func",
"(",
"context",
")",
"except",
"Exception",
"as",
"e",
":",
"raise",
"Error",
"(",
"FormatException",
"(",
"e",
".",
"mess... | [
218,
0
] | [
227,
25
] | python | en | ['en', 'en', 'en'] | True |
get_flatpages | (parser, token) |
Retrieve all flatpage objects available for the current site and
visible to the specific user (or visible to all users if no user is
specified). Populate the template context with them in a variable
whose name is defined by the ``as`` clause.
An optional ``for`` clause controls the user whose perm... |
Retrieve all flatpage objects available for the current site and
visible to the specific user (or visible to all users if no user is
specified). Populate the template context with them in a variable
whose name is defined by the ``as`` clause. | def get_flatpages(parser, token):
"""
Retrieve all flatpage objects available for the current site and
visible to the specific user (or visible to all users if no user is
specified). Populate the template context with them in a variable
whose name is defined by the ``as`` clause.
An optional ``... | [
"def",
"get_flatpages",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"syntax_message",
"=",
"(",
"\"%(tag_name)s expects a syntax of %(tag_name)s \"",
"\"['url_starts_with'] [for user] as context_name\"",
"%",
"{",
"'tag_na... | [
45,
0
] | [
98,
58
] | python | en | ['en', 'error', 'th'] | False |
base64_encode | (string) | Base64 encode a string of bytes or text. The resulting bytes are
safe to use in URLs.
| Base64 encode a string of bytes or text. The resulting bytes are
safe to use in URLs.
| def base64_encode(string):
"""Base64 encode a string of bytes or text. The resulting bytes are
safe to use in URLs.
"""
string = want_bytes(string)
return base64.urlsafe_b64encode(string).rstrip(b"=") | [
"def",
"base64_encode",
"(",
"string",
")",
":",
"string",
"=",
"want_bytes",
"(",
"string",
")",
"return",
"base64",
".",
"urlsafe_b64encode",
"(",
"string",
")",
".",
"rstrip",
"(",
"b\"=\"",
")"
] | [
14,
0
] | [
19,
56
] | python | en | ['en', 'en', 'en'] | True |
base64_decode | (string) | Base64 decode a URL-safe string of bytes or text. The result is
bytes.
| Base64 decode a URL-safe string of bytes or text. The result is
bytes.
| def base64_decode(string):
"""Base64 decode a URL-safe string of bytes or text. The result is
bytes.
"""
string = want_bytes(string, encoding="ascii", errors="ignore")
string += b"=" * (-len(string) % 4)
try:
return base64.urlsafe_b64decode(string)
except (TypeError, ValueError):
... | [
"def",
"base64_decode",
"(",
"string",
")",
":",
"string",
"=",
"want_bytes",
"(",
"string",
",",
"encoding",
"=",
"\"ascii\"",
",",
"errors",
"=",
"\"ignore\"",
")",
"string",
"+=",
"b\"=\"",
"*",
"(",
"-",
"len",
"(",
"string",
")",
"%",
"4",
")",
... | [
22,
0
] | [
32,
52
] | python | en | ['en', 'en', 'en'] | True |
default_key_func | (key, key_prefix, version) |
Default function to generate keys.
Construct the key used by all other methods. By default, prepend
the `key_prefix`. KEY_FUNCTION can be used to specify an alternate
function with custom key making behavior.
|
Default function to generate keys. | def default_key_func(key, key_prefix, version):
"""
Default function to generate keys.
Construct the key used by all other methods. By default, prepend
the `key_prefix`. KEY_FUNCTION can be used to specify an alternate
function with custom key making behavior.
"""
return '%s:%s:%s' % (key_p... | [
"def",
"default_key_func",
"(",
"key",
",",
"key_prefix",
",",
"version",
")",
":",
"return",
"'%s:%s:%s'",
"%",
"(",
"key_prefix",
",",
"version",
",",
"key",
")"
] | [
28,
0
] | [
36,
50
] | python | en | ['en', 'error', 'th'] | False |
get_key_func | (key_func) |
Function to decide which key function to use.
Default to ``default_key_func``.
|
Function to decide which key function to use. | def get_key_func(key_func):
"""
Function to decide which key function to use.
Default to ``default_key_func``.
"""
if key_func is not None:
if callable(key_func):
return key_func
else:
return import_string(key_func)
return default_key_func | [
"def",
"get_key_func",
"(",
"key_func",
")",
":",
"if",
"key_func",
"is",
"not",
"None",
":",
"if",
"callable",
"(",
"key_func",
")",
":",
"return",
"key_func",
"else",
":",
"return",
"import_string",
"(",
"key_func",
")",
"return",
"default_key_func"
] | [
39,
0
] | [
50,
27
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.get_backend_timeout | (self, timeout=DEFAULT_TIMEOUT) |
Return the timeout value usable by this backend based upon the provided
timeout.
|
Return the timeout value usable by this backend based upon the provided
timeout.
| def get_backend_timeout(self, timeout=DEFAULT_TIMEOUT):
"""
Return the timeout value usable by this backend based upon the provided
timeout.
"""
if timeout == DEFAULT_TIMEOUT:
timeout = self.default_timeout
elif timeout == 0:
# ticket 21147 - avoid... | [
"def",
"get_backend_timeout",
"(",
"self",
",",
"timeout",
"=",
"DEFAULT_TIMEOUT",
")",
":",
"if",
"timeout",
"==",
"DEFAULT_TIMEOUT",
":",
"timeout",
"=",
"self",
".",
"default_timeout",
"elif",
"timeout",
"==",
"0",
":",
"# ticket 21147 - avoid time.time() related... | [
82,
4
] | [
92,
65
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.make_key | (self, key, version=None) |
Construct the key used by all other methods. By default, use the
key_func to generate a key (which, by default, prepends the
`key_prefix' and 'version'). A different key function can be provided
at the time of cache construction; alternatively, you can subclass the
cache backend... |
Construct the key used by all other methods. By default, use the
key_func to generate a key (which, by default, prepends the
`key_prefix' and 'version'). A different key function can be provided
at the time of cache construction; alternatively, you can subclass the
cache backend... | def make_key(self, key, version=None):
"""
Construct the key used by all other methods. By default, use the
key_func to generate a key (which, by default, prepends the
`key_prefix' and 'version'). A different key function can be provided
at the time of cache construction; alterna... | [
"def",
"make_key",
"(",
"self",
",",
"key",
",",
"version",
"=",
"None",
")",
":",
"if",
"version",
"is",
"None",
":",
"version",
"=",
"self",
".",
"version",
"return",
"self",
".",
"key_func",
"(",
"key",
",",
"self",
".",
"key_prefix",
",",
"versio... | [
94,
4
] | [
105,
59
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.add | (self, key, value, timeout=DEFAULT_TIMEOUT, version=None) |
Set a value in the cache if the key does not already exist. If
timeout is given, use that timeout for the key; otherwise use the
default cache timeout.
Return True if the value was stored, False otherwise.
|
Set a value in the cache if the key does not already exist. If
timeout is given, use that timeout for the key; otherwise use the
default cache timeout. | def add(self, key, value, timeout=DEFAULT_TIMEOUT, version=None):
"""
Set a value in the cache if the key does not already exist. If
timeout is given, use that timeout for the key; otherwise use the
default cache timeout.
Return True if the value was stored, False otherwise.
... | [
"def",
"add",
"(",
"self",
",",
"key",
",",
"value",
",",
"timeout",
"=",
"DEFAULT_TIMEOUT",
",",
"version",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseCache must provide an add() method'",
")"
] | [
107,
4
] | [
115,
89
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.get | (self, key, default=None, version=None) |
Fetch a given key from the cache. If the key does not exist, return
default, which itself defaults to None.
|
Fetch a given key from the cache. If the key does not exist, return
default, which itself defaults to None.
| def get(self, key, default=None, version=None):
"""
Fetch a given key from the cache. If the key does not exist, return
default, which itself defaults to None.
"""
raise NotImplementedError('subclasses of BaseCache must provide a get() method') | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
",",
"version",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseCache must provide a get() method'",
")"
] | [
117,
4
] | [
122,
88
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.set | (self, key, value, timeout=DEFAULT_TIMEOUT, version=None) |
Set a value in the cache. If timeout is given, use that timeout for the
key; otherwise use the default cache timeout.
|
Set a value in the cache. If timeout is given, use that timeout for the
key; otherwise use the default cache timeout.
| def set(self, key, value, timeout=DEFAULT_TIMEOUT, version=None):
"""
Set a value in the cache. If timeout is given, use that timeout for the
key; otherwise use the default cache timeout.
"""
raise NotImplementedError('subclasses of BaseCache must provide a set() method') | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"value",
",",
"timeout",
"=",
"DEFAULT_TIMEOUT",
",",
"version",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseCache must provide a set() method'",
")"
] | [
124,
4
] | [
129,
88
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.touch | (self, key, timeout=DEFAULT_TIMEOUT, version=None) |
Update the key's expiry time using timeout. Return True if successful
or False if the key does not exist.
|
Update the key's expiry time using timeout. Return True if successful
or False if the key does not exist.
| def touch(self, key, timeout=DEFAULT_TIMEOUT, version=None):
"""
Update the key's expiry time using timeout. Return True if successful
or False if the key does not exist.
"""
raise NotImplementedError('subclasses of BaseCache must provide a touch() method') | [
"def",
"touch",
"(",
"self",
",",
"key",
",",
"timeout",
"=",
"DEFAULT_TIMEOUT",
",",
"version",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseCache must provide a touch() method'",
")"
] | [
131,
4
] | [
136,
90
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.delete | (self, key, version=None) |
Delete a key from the cache and return whether it succeeded, failing
silently.
|
Delete a key from the cache and return whether it succeeded, failing
silently.
| def delete(self, key, version=None):
"""
Delete a key from the cache and return whether it succeeded, failing
silently.
"""
raise NotImplementedError('subclasses of BaseCache must provide a delete() method') | [
"def",
"delete",
"(",
"self",
",",
"key",
",",
"version",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseCache must provide a delete() method'",
")"
] | [
138,
4
] | [
143,
91
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.get_many | (self, keys, version=None) |
Fetch a bunch of keys from the cache. For certain backends (memcached,
pgsql) this can be *much* faster when fetching multiple values.
Return a dict mapping each key in keys to its value. If the given
key is missing, it will be missing from the response dict.
|
Fetch a bunch of keys from the cache. For certain backends (memcached,
pgsql) this can be *much* faster when fetching multiple values. | def get_many(self, keys, version=None):
"""
Fetch a bunch of keys from the cache. For certain backends (memcached,
pgsql) this can be *much* faster when fetching multiple values.
Return a dict mapping each key in keys to its value. If the given
key is missing, it will be missing... | [
"def",
"get_many",
"(",
"self",
",",
"keys",
",",
"version",
"=",
"None",
")",
":",
"d",
"=",
"{",
"}",
"for",
"k",
"in",
"keys",
":",
"val",
"=",
"self",
".",
"get",
"(",
"k",
",",
"self",
".",
"_missing_key",
",",
"version",
"=",
"version",
"... | [
145,
4
] | [
158,
16
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.get_or_set | (self, key, default, timeout=DEFAULT_TIMEOUT, version=None) |
Fetch a given key from the cache. If the key does not exist,
add the key and set it to the default value. The default value can
also be any callable. If timeout is given, use that timeout for the
key; otherwise use the default cache timeout.
Return the value of the key stored o... |
Fetch a given key from the cache. If the key does not exist,
add the key and set it to the default value. The default value can
also be any callable. If timeout is given, use that timeout for the
key; otherwise use the default cache timeout. | def get_or_set(self, key, default, timeout=DEFAULT_TIMEOUT, version=None):
"""
Fetch a given key from the cache. If the key does not exist,
add the key and set it to the default value. The default value can
also be any callable. If timeout is given, use that timeout for the
key; ... | [
"def",
"get_or_set",
"(",
"self",
",",
"key",
",",
"default",
",",
"timeout",
"=",
"DEFAULT_TIMEOUT",
",",
"version",
"=",
"None",
")",
":",
"val",
"=",
"self",
".",
"get",
"(",
"key",
",",
"self",
".",
"_missing_key",
",",
"version",
"=",
"version",
... | [
160,
4
] | [
177,
18
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.has_key | (self, key, version=None) |
Return True if the key is in the cache and has not expired.
|
Return True if the key is in the cache and has not expired.
| def has_key(self, key, version=None):
"""
Return True if the key is in the cache and has not expired.
"""
return self.get(key, self._missing_key, version=version) is not self._missing_key | [
"def",
"has_key",
"(",
"self",
",",
"key",
",",
"version",
"=",
"None",
")",
":",
"return",
"self",
".",
"get",
"(",
"key",
",",
"self",
".",
"_missing_key",
",",
"version",
"=",
"version",
")",
"is",
"not",
"self",
".",
"_missing_key"
] | [
179,
4
] | [
183,
89
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.incr | (self, key, delta=1, version=None) |
Add delta to value in the cache. If the key does not exist, raise a
ValueError exception.
|
Add delta to value in the cache. If the key does not exist, raise a
ValueError exception.
| def incr(self, key, delta=1, version=None):
"""
Add delta to value in the cache. If the key does not exist, raise a
ValueError exception.
"""
value = self.get(key, self._missing_key, version=version)
if value is self._missing_key:
raise ValueError("Key '%s' no... | [
"def",
"incr",
"(",
"self",
",",
"key",
",",
"delta",
"=",
"1",
",",
"version",
"=",
"None",
")",
":",
"value",
"=",
"self",
".",
"get",
"(",
"key",
",",
"self",
".",
"_missing_key",
",",
"version",
"=",
"version",
")",
"if",
"value",
"is",
"self... | [
185,
4
] | [
195,
24
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.decr | (self, key, delta=1, version=None) |
Subtract delta from value in the cache. If the key does not exist, raise
a ValueError exception.
|
Subtract delta from value in the cache. If the key does not exist, raise
a ValueError exception.
| def decr(self, key, delta=1, version=None):
"""
Subtract delta from value in the cache. If the key does not exist, raise
a ValueError exception.
"""
return self.incr(key, -delta, version=version) | [
"def",
"decr",
"(",
"self",
",",
"key",
",",
"delta",
"=",
"1",
",",
"version",
"=",
"None",
")",
":",
"return",
"self",
".",
"incr",
"(",
"key",
",",
"-",
"delta",
",",
"version",
"=",
"version",
")"
] | [
197,
4
] | [
202,
54
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.__contains__ | (self, key) |
Return True if the key is in the cache and has not expired.
|
Return True if the key is in the cache and has not expired.
| def __contains__(self, key):
"""
Return True if the key is in the cache and has not expired.
"""
# This is a separate method, rather than just a copy of has_key(),
# so that it always has the same functionality as has_key(), even
# if a subclass overrides it.
retu... | [
"def",
"__contains__",
"(",
"self",
",",
"key",
")",
":",
"# This is a separate method, rather than just a copy of has_key(),",
"# so that it always has the same functionality as has_key(), even",
"# if a subclass overrides it.",
"return",
"self",
".",
"has_key",
"(",
"key",
")"
] | [
204,
4
] | [
211,
32
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.set_many | (self, data, timeout=DEFAULT_TIMEOUT, version=None) |
Set a bunch of values in the cache at once from a dict of key/value
pairs. For certain backends (memcached), this is much more efficient
than calling set() multiple times.
If timeout is given, use that timeout for the key; otherwise use the
default cache timeout.
On b... |
Set a bunch of values in the cache at once from a dict of key/value
pairs. For certain backends (memcached), this is much more efficient
than calling set() multiple times. | def set_many(self, data, timeout=DEFAULT_TIMEOUT, version=None):
"""
Set a bunch of values in the cache at once from a dict of key/value
pairs. For certain backends (memcached), this is much more efficient
than calling set() multiple times.
If timeout is given, use that timeout... | [
"def",
"set_many",
"(",
"self",
",",
"data",
",",
"timeout",
"=",
"DEFAULT_TIMEOUT",
",",
"version",
"=",
"None",
")",
":",
"for",
"key",
",",
"value",
"in",
"data",
".",
"items",
"(",
")",
":",
"self",
".",
"set",
"(",
"key",
",",
"value",
",",
... | [
213,
4
] | [
227,
17
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.delete_many | (self, keys, version=None) |
Delete a bunch of values in the cache at once. For certain backends
(memcached), this is much more efficient than calling delete() multiple
times.
|
Delete a bunch of values in the cache at once. For certain backends
(memcached), this is much more efficient than calling delete() multiple
times.
| def delete_many(self, keys, version=None):
"""
Delete a bunch of values in the cache at once. For certain backends
(memcached), this is much more efficient than calling delete() multiple
times.
"""
for key in keys:
self.delete(key, version=version) | [
"def",
"delete_many",
"(",
"self",
",",
"keys",
",",
"version",
"=",
"None",
")",
":",
"for",
"key",
"in",
"keys",
":",
"self",
".",
"delete",
"(",
"key",
",",
"version",
"=",
"version",
")"
] | [
229,
4
] | [
236,
45
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.clear | (self) | Remove *all* values from the cache at once. | Remove *all* values from the cache at once. | def clear(self):
"""Remove *all* values from the cache at once."""
raise NotImplementedError('subclasses of BaseCache must provide a clear() method') | [
"def",
"clear",
"(",
"self",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseCache must provide a clear() method'",
")"
] | [
238,
4
] | [
240,
90
] | python | en | ['en', 'en', 'en'] | True |
BaseCache.validate_key | (self, key) |
Warn about keys that would not be portable to the memcached
backend. This encourages (but does not force) writing backend-portable
cache code.
|
Warn about keys that would not be portable to the memcached
backend. This encourages (but does not force) writing backend-portable
cache code.
| def validate_key(self, key):
"""
Warn about keys that would not be portable to the memcached
backend. This encourages (but does not force) writing backend-portable
cache code.
"""
for warning in memcache_key_warnings(key):
warnings.warn(warning, CacheKeyWarnin... | [
"def",
"validate_key",
"(",
"self",
",",
"key",
")",
":",
"for",
"warning",
"in",
"memcache_key_warnings",
"(",
"key",
")",
":",
"warnings",
".",
"warn",
"(",
"warning",
",",
"CacheKeyWarning",
")"
] | [
242,
4
] | [
249,
51
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.incr_version | (self, key, delta=1, version=None) |
Add delta to the cache version for the supplied key. Return the new
version.
|
Add delta to the cache version for the supplied key. Return the new
version.
| def incr_version(self, key, delta=1, version=None):
"""
Add delta to the cache version for the supplied key. Return the new
version.
"""
if version is None:
version = self.version
value = self.get(key, self._missing_key, version=version)
if value is s... | [
"def",
"incr_version",
"(",
"self",
",",
"key",
",",
"delta",
"=",
"1",
",",
"version",
"=",
"None",
")",
":",
"if",
"version",
"is",
"None",
":",
"version",
"=",
"self",
".",
"version",
"value",
"=",
"self",
".",
"get",
"(",
"key",
",",
"self",
... | [
251,
4
] | [
265,
30
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.decr_version | (self, key, delta=1, version=None) |
Subtract delta from the cache version for the supplied key. Return the
new version.
|
Subtract delta from the cache version for the supplied key. Return the
new version.
| def decr_version(self, key, delta=1, version=None):
"""
Subtract delta from the cache version for the supplied key. Return the
new version.
"""
return self.incr_version(key, -delta, version) | [
"def",
"decr_version",
"(",
"self",
",",
"key",
",",
"delta",
"=",
"1",
",",
"version",
"=",
"None",
")",
":",
"return",
"self",
".",
"incr_version",
"(",
"key",
",",
"-",
"delta",
",",
"version",
")"
] | [
267,
4
] | [
272,
54
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.close | (self, **kwargs) | Close the cache connection | Close the cache connection | def close(self, **kwargs):
"""Close the cache connection"""
pass | [
"def",
"close",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"pass"
] | [
274,
4
] | [
276,
12
] | python | en | ['en', 'en', 'en'] | True |
literals | (choices, prefix="", suffix="") |
Create a regex from a space-separated list of literal `choices`.
If provided, `prefix` and `suffix` will be attached to each choice
individually.
|
Create a regex from a space-separated list of literal `choices`. | def literals(choices, prefix="", suffix=""):
"""
Create a regex from a space-separated list of literal `choices`.
If provided, `prefix` and `suffix` will be attached to each choice
individually.
"""
return "|".join(prefix + re.escape(c) + suffix for c in choices.split()) | [
"def",
"literals",
"(",
"choices",
",",
"prefix",
"=",
"\"\"",
",",
"suffix",
"=",
"\"\"",
")",
":",
"return",
"\"|\"",
".",
"join",
"(",
"prefix",
"+",
"re",
".",
"escape",
"(",
"c",
")",
"+",
"suffix",
"for",
"c",
"in",
"choices",
".",
"split",
... | [
19,
0
] | [
26,
76
] | python | en | ['en', 'error', 'th'] | False |
prepare_js_for_gettext | (js) |
Convert the Javascript source `js` into something resembling C for
xgettext.
What actually happens is that all the regex literals are replaced with
"REGEX".
|
Convert the Javascript source `js` into something resembling C for
xgettext. | def prepare_js_for_gettext(js):
"""
Convert the Javascript source `js` into something resembling C for
xgettext.
What actually happens is that all the regex literals are replaced with
"REGEX".
"""
def escape_quotes(m):
"""Used in a regex to properly escape double quotes."""
... | [
"def",
"prepare_js_for_gettext",
"(",
"js",
")",
":",
"def",
"escape_quotes",
"(",
"m",
")",
":",
"\"\"\"Used in a regex to properly escape double quotes.\"\"\"",
"s",
"=",
"m",
"[",
"0",
"]",
"if",
"s",
"==",
"'\"'",
":",
"return",
"r'\\\"'",
"else",
":",
"re... | [
184,
0
] | [
219,
21
] | python | en | ['en', 'error', 'th'] | False |
Lexer.lex | (self, text) |
Lexically analyze `text`.
Yield pairs (`name`, `tokentext`).
|
Lexically analyze `text`. | def lex(self, text):
"""
Lexically analyze `text`.
Yield pairs (`name`, `tokentext`).
"""
end = len(text)
state = self.state
regexes = self.regexes
toks = self.toks
start = 0
while start < end:
for match in regexes[state].find... | [
"def",
"lex",
"(",
"self",
",",
"text",
")",
":",
"end",
"=",
"len",
"(",
"text",
")",
"state",
"=",
"self",
".",
"state",
"regexes",
"=",
"self",
".",
"regexes",
"toks",
"=",
"self",
".",
"toks",
"start",
"=",
"0",
"while",
"start",
"<",
"end",
... | [
48,
4
] | [
72,
26
] | python | en | ['en', 'error', 'th'] | False |
sql_flush | (style, connection, reset_sequences=True, allow_cascade=False) |
Return a list of the SQL statements used to flush the database.
|
Return a list of the SQL statements used to flush the database.
| def sql_flush(style, connection, reset_sequences=True, allow_cascade=False):
"""
Return a list of the SQL statements used to flush the database.
"""
tables = connection.introspection.django_table_names(only_existing=True, include_views=False)
return connection.ops.sql_flush(
style,
t... | [
"def",
"sql_flush",
"(",
"style",
",",
"connection",
",",
"reset_sequences",
"=",
"True",
",",
"allow_cascade",
"=",
"False",
")",
":",
"tables",
"=",
"connection",
".",
"introspection",
".",
"django_table_names",
"(",
"only_existing",
"=",
"True",
",",
"inclu... | [
4,
0
] | [
14,
5
] | python | en | ['en', 'error', 'th'] | False |
_get_project_id | () | Get project ID from default GCP connection. | Get project ID from default GCP connection. | def _get_project_id():
"""Get project ID from default GCP connection."""
extras = BaseHook.get_connection("google_cloud_default").extra_dejson
key = "extra__google_cloud_platform__project"
if key in extras:
project_id = extras[key]
else:
raise ("Must configure project_id in google_cloud_default "
... | [
"def",
"_get_project_id",
"(",
")",
":",
"extras",
"=",
"BaseHook",
".",
"get_connection",
"(",
"\"google_cloud_default\"",
")",
".",
"extra_dejson",
"key",
"=",
"\"extra__google_cloud_platform__project\"",
"if",
"key",
"in",
"extras",
":",
"project_id",
"=",
"extra... | [
33,
0
] | [
43,
19
] | python | en | ['en', 'en', 'en'] | True |
filter_detections | (detections, score_threshold=0.3, nms_iou_threshold=0.5, max_size=None) |
Remove detections with a low probability, run Non-maximum Suppression. If set, apply max size to all boxes.
:param detections: Tensor with detections in form [ymin, xmin, ymax, xmax, label, probability].
:param score_threshold: Minimal probability of a detection to be included in the result.
:param nm... |
Remove detections with a low probability, run Non-maximum Suppression. If set, apply max size to all boxes. | def filter_detections(detections, score_threshold=0.3, nms_iou_threshold=0.5, max_size=None):
"""
Remove detections with a low probability, run Non-maximum Suppression. If set, apply max size to all boxes.
:param detections: Tensor with detections in form [ymin, xmin, ymax, xmax, label, probability].
:... | [
"def",
"filter_detections",
"(",
"detections",
",",
"score_threshold",
"=",
"0.3",
",",
"nms_iou_threshold",
"=",
"0.5",
",",
"max_size",
"=",
"None",
")",
":",
"mask",
"=",
"detections",
"[",
":",
",",
"4",
"]",
">=",
"score_threshold",
"result",
"=",
"tf... | [
67,
0
] | [
96,
21
] | python | en | ['en', 'error', 'th'] | False |
Draw.settransform | (self, offset) | Sets a transformation offset. | Sets a transformation offset. | def settransform(self, offset):
"""Sets a transformation offset."""
(xoffset, yoffset) = offset
self.transform = (1, 0, xoffset, 0, 1, yoffset) | [
"def",
"settransform",
"(",
"self",
",",
"offset",
")",
":",
"(",
"xoffset",
",",
"yoffset",
")",
"=",
"offset",
"self",
".",
"transform",
"=",
"(",
"1",
",",
"0",
",",
"xoffset",
",",
"0",
",",
"1",
",",
"yoffset",
")"
] | [
92,
4
] | [
95,
55
] | python | en | ['en', 'en', 'en'] | True |
Draw.arc | (self, xy, start, end, *options) |
Draws an arc (a portion of a circle outline) between the start and end
angles, inside the given bounding box.
.. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.arc`
|
Draws an arc (a portion of a circle outline) between the start and end
angles, inside the given bounding box. | def arc(self, xy, start, end, *options):
"""
Draws an arc (a portion of a circle outline) between the start and end
angles, inside the given bounding box.
.. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.arc`
"""
self.render("arc", xy, start, end, *options) | [
"def",
"arc",
"(",
"self",
",",
"xy",
",",
"start",
",",
"end",
",",
"*",
"options",
")",
":",
"self",
".",
"render",
"(",
"\"arc\"",
",",
"xy",
",",
"start",
",",
"end",
",",
"*",
"options",
")"
] | [
97,
4
] | [
104,
52
] | python | en | ['en', 'error', 'th'] | False |
Draw.chord | (self, xy, start, end, *options) |
Same as :py:meth:`~PIL.ImageDraw2.Draw.arc`, but connects the end points
with a straight line.
.. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.chord`
|
Same as :py:meth:`~PIL.ImageDraw2.Draw.arc`, but connects the end points
with a straight line. | def chord(self, xy, start, end, *options):
"""
Same as :py:meth:`~PIL.ImageDraw2.Draw.arc`, but connects the end points
with a straight line.
.. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.chord`
"""
self.render("chord", xy, start, end, *options) | [
"def",
"chord",
"(",
"self",
",",
"xy",
",",
"start",
",",
"end",
",",
"*",
"options",
")",
":",
"self",
".",
"render",
"(",
"\"chord\"",
",",
"xy",
",",
"start",
",",
"end",
",",
"*",
"options",
")"
] | [
106,
4
] | [
113,
54
] | python | en | ['en', 'error', 'th'] | False |
Draw.ellipse | (self, xy, *options) |
Draws an ellipse inside the given bounding box.
.. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.ellipse`
|
Draws an ellipse inside the given bounding box. | def ellipse(self, xy, *options):
"""
Draws an ellipse inside the given bounding box.
.. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.ellipse`
"""
self.render("ellipse", xy, *options) | [
"def",
"ellipse",
"(",
"self",
",",
"xy",
",",
"*",
"options",
")",
":",
"self",
".",
"render",
"(",
"\"ellipse\"",
",",
"xy",
",",
"*",
"options",
")"
] | [
115,
4
] | [
121,
44
] | python | en | ['en', 'error', 'th'] | False |
Draw.line | (self, xy, *options) |
Draws a line between the coordinates in the ``xy`` list.
.. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.line`
|
Draws a line between the coordinates in the ``xy`` list. | def line(self, xy, *options):
"""
Draws a line between the coordinates in the ``xy`` list.
.. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.line`
"""
self.render("line", xy, *options) | [
"def",
"line",
"(",
"self",
",",
"xy",
",",
"*",
"options",
")",
":",
"self",
".",
"render",
"(",
"\"line\"",
",",
"xy",
",",
"*",
"options",
")"
] | [
123,
4
] | [
129,
41
] | python | en | ['en', 'error', 'th'] | False |
Draw.pieslice | (self, xy, start, end, *options) |
Same as arc, but also draws straight lines between the end points and the
center of the bounding box.
.. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.pieslice`
|
Same as arc, but also draws straight lines between the end points and the
center of the bounding box. | def pieslice(self, xy, start, end, *options):
"""
Same as arc, but also draws straight lines between the end points and the
center of the bounding box.
.. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.pieslice`
"""
self.render("pieslice", xy, start, end, *options) | [
"def",
"pieslice",
"(",
"self",
",",
"xy",
",",
"start",
",",
"end",
",",
"*",
"options",
")",
":",
"self",
".",
"render",
"(",
"\"pieslice\"",
",",
"xy",
",",
"start",
",",
"end",
",",
"*",
"options",
")"
] | [
131,
4
] | [
138,
57
] | python | en | ['en', 'error', 'th'] | False |
Draw.polygon | (self, xy, *options) |
Draws a polygon.
The polygon outline consists of straight lines between the given
coordinates, plus a straight line between the last and the first
coordinate.
.. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.polygon`
|
Draws a polygon. | def polygon(self, xy, *options):
"""
Draws a polygon.
The polygon outline consists of straight lines between the given
coordinates, plus a straight line between the last and the first
coordinate.
.. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.polygon`
"""
... | [
"def",
"polygon",
"(",
"self",
",",
"xy",
",",
"*",
"options",
")",
":",
"self",
".",
"render",
"(",
"\"polygon\"",
",",
"xy",
",",
"*",
"options",
")"
] | [
140,
4
] | [
151,
44
] | python | en | ['en', 'error', 'th'] | False |
Draw.rectangle | (self, xy, *options) |
Draws a rectangle.
.. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.rectangle`
|
Draws a rectangle. | def rectangle(self, xy, *options):
"""
Draws a rectangle.
.. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.rectangle`
"""
self.render("rectangle", xy, *options) | [
"def",
"rectangle",
"(",
"self",
",",
"xy",
",",
"*",
"options",
")",
":",
"self",
".",
"render",
"(",
"\"rectangle\"",
",",
"xy",
",",
"*",
"options",
")"
] | [
153,
4
] | [
159,
46
] | python | en | ['en', 'error', 'th'] | False |
Draw.text | (self, xy, text, font) |
Draws the string at the given position.
.. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.text`
|
Draws the string at the given position. | def text(self, xy, text, font):
"""
Draws the string at the given position.
.. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.text`
"""
if self.transform:
xy = ImagePath.Path(xy)
xy.transform(self.transform)
self.draw.text(xy, text, font=font.font, f... | [
"def",
"text",
"(",
"self",
",",
"xy",
",",
"text",
",",
"font",
")",
":",
"if",
"self",
".",
"transform",
":",
"xy",
"=",
"ImagePath",
".",
"Path",
"(",
"xy",
")",
"xy",
".",
"transform",
"(",
"self",
".",
"transform",
")",
"self",
".",
"draw",
... | [
161,
4
] | [
170,
65
] | python | en | ['en', 'error', 'th'] | False |
Draw.textsize | (self, text, font) |
Return the size of the given string, in pixels.
.. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.textsize`
|
Return the size of the given string, in pixels. | def textsize(self, text, font):
"""
Return the size of the given string, in pixels.
.. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.textsize`
"""
return self.draw.textsize(text, font=font.font) | [
"def",
"textsize",
"(",
"self",
",",
"text",
",",
"font",
")",
":",
"return",
"self",
".",
"draw",
".",
"textsize",
"(",
"text",
",",
"font",
"=",
"font",
".",
"font",
")"
] | [
172,
4
] | [
178,
55
] | python | en | ['en', 'error', 'th'] | False |
MostPopular.__init__ | (self, train_file=None, test_file=None, output_file=None, as_binary=False, rank_length=10, sep='\t',
output_sep='\t') |
Most Popular for Item Recommendation
This algorithm predicts a rank for each user using the count of number of feedback of users and items
Usage::
>> MostPopular(train, test).compute()
>> MostPopular(train, test, as_binary=True).compute()
:param train_file: F... |
Most Popular for Item Recommendation | def __init__(self, train_file=None, test_file=None, output_file=None, as_binary=False, rank_length=10, sep='\t',
output_sep='\t'):
"""
Most Popular for Item Recommendation
This algorithm predicts a rank for each user using the count of number of feedback of users and items
... | [
"def",
"__init__",
"(",
"self",
",",
"train_file",
"=",
"None",
",",
"test_file",
"=",
"None",
",",
"output_file",
"=",
"None",
",",
"as_binary",
"=",
"False",
",",
"rank_length",
"=",
"10",
",",
"sep",
"=",
"'\\t'",
",",
"output_sep",
"=",
"'\\t'",
")... | [
18,
4
] | [
58,
46
] | python | en | ['en', 'error', 'th'] | False |
MostPopular.predict | (self) |
This method predict final result, building an rank of each user of the train set.
|
This method predict final result, building an rank of each user of the train set. | def predict(self):
"""
This method predict final result, building an rank of each user of the train set.
"""
for user in set(self.users):
predictions = list()
for item in self.train_set['items_unobserved'].get(user, []):
if self.as_binary:
... | [
"def",
"predict",
"(",
"self",
")",
":",
"for",
"user",
"in",
"set",
"(",
"self",
".",
"users",
")",
":",
"predictions",
"=",
"list",
"(",
")",
"for",
"item",
"in",
"self",
".",
"train_set",
"[",
"'items_unobserved'",
"]",
".",
"get",
"(",
"user",
... | [
60,
4
] | [
80,
58
] | python | en | ['en', 'error', 'th'] | False |
MostPopular.compute | (self, verbose=True, metrics=None, verbose_evaluation=True, as_table=False, table_sep='\t') |
Extends compute method from BaseItemRecommendation. Method to run recommender algorithm
:param verbose: Print recommender and database information
:type verbose: bool, default True
:param metrics: List of evaluation measures
:type metrics: list, default None
:param ve... |
Extends compute method from BaseItemRecommendation. Method to run recommender algorithm | def compute(self, verbose=True, metrics=None, verbose_evaluation=True, as_table=False, table_sep='\t'):
"""
Extends compute method from BaseItemRecommendation. Method to run recommender algorithm
:param verbose: Print recommender and database information
:type verbose: bool, default Tru... | [
"def",
"compute",
"(",
"self",
",",
"verbose",
"=",
"True",
",",
"metrics",
"=",
"None",
",",
"verbose_evaluation",
"=",
"True",
",",
"as_table",
"=",
"False",
",",
"table_sep",
"=",
"'\\t'",
")",
":",
"super",
"(",
"MostPopular",
",",
"self",
")",
"."... | [
82,
4
] | [
115,
94
] | python | en | ['en', 'error', 'th'] | False |
convert_type | (ty, default=None) | Converts a callable or python ty into the most appropriate param
ty.
| Converts a callable or python ty into the most appropriate param
ty.
| def convert_type(ty, default=None):
"""Converts a callable or python ty into the most appropriate param
ty.
"""
guessed_type = False
if ty is None and default is not None:
if isinstance(default, tuple):
ty = tuple(map(type, default))
else:
ty = type(default)
... | [
"def",
"convert_type",
"(",
"ty",
",",
"default",
"=",
"None",
")",
":",
"guessed_type",
"=",
"False",
"if",
"ty",
"is",
"None",
"and",
"default",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"default",
",",
"tuple",
")",
":",
"ty",
"=",
"tuple... | [
594,
0
] | [
633,
28
] | python | en | ['en', 'en', 'en'] | True |
ParamType.get_metavar | (self, param) | Returns the metavar default for this param if it provides one. | Returns the metavar default for this param if it provides one. | def get_metavar(self, param):
"""Returns the metavar default for this param if it provides one.""" | [
"def",
"get_metavar",
"(",
"self",
",",
"param",
")",
":"
] | [
40,
4
] | [
41,
76
] | python | en | ['en', 'en', 'en'] | True |
ParamType.get_missing_message | (self, param) | Optionally might return extra information about a missing
parameter.
.. versionadded:: 2.0
| Optionally might return extra information about a missing
parameter. | def get_missing_message(self, param):
"""Optionally might return extra information about a missing
parameter.
.. versionadded:: 2.0
""" | [
"def",
"get_missing_message",
"(",
"self",
",",
"param",
")",
":"
] | [
43,
4
] | [
48,
11
] | python | en | ['en', 'en', 'en'] | True |
ParamType.convert | (self, value, param, ctx) | Converts the value. This is not invoked for values that are
`None` (the missing value).
| Converts the value. This is not invoked for values that are
`None` (the missing value).
| def convert(self, value, param, ctx):
"""Converts the value. This is not invoked for values that are
`None` (the missing value).
"""
return value | [
"def",
"convert",
"(",
"self",
",",
"value",
",",
"param",
",",
"ctx",
")",
":",
"return",
"value"
] | [
50,
4
] | [
54,
20
] | python | en | ['en', 'en', 'en'] | True |
ParamType.split_envvar_value | (self, rv) | Given a value from an environment variable this splits it up
into small chunks depending on the defined envvar list splitter.
If the splitter is set to `None`, which means that whitespace splits,
then leading and trailing whitespace is ignored. Otherwise, leading
and trailing splitters... | Given a value from an environment variable this splits it up
into small chunks depending on the defined envvar list splitter. | def split_envvar_value(self, rv):
"""Given a value from an environment variable this splits it up
into small chunks depending on the defined envvar list splitter.
If the splitter is set to `None`, which means that whitespace splits,
then leading and trailing whitespace is ignored. Othe... | [
"def",
"split_envvar_value",
"(",
"self",
",",
"rv",
")",
":",
"return",
"(",
"rv",
"or",
"''",
")",
".",
"split",
"(",
"self",
".",
"envvar_list_splitter",
")"
] | [
56,
4
] | [
64,
58
] | python | en | ['en', 'en', 'en'] | True |
ParamType.fail | (self, message, param=None, ctx=None) | Helper method to fail with an invalid value message. | Helper method to fail with an invalid value message. | def fail(self, message, param=None, ctx=None):
"""Helper method to fail with an invalid value message."""
raise BadParameter(message, ctx=ctx, param=param) | [
"def",
"fail",
"(",
"self",
",",
"message",
",",
"param",
"=",
"None",
",",
"ctx",
"=",
"None",
")",
":",
"raise",
"BadParameter",
"(",
"message",
",",
"ctx",
"=",
"ctx",
",",
"param",
"=",
"param",
")"
] | [
66,
4
] | [
68,
57
] | python | en | ['en', 'en', 'en'] | True |
from_datastore | (entity) | Translates Datastore results into the format expected by the
application.
Datastore typically returns:
[Entity{key: (kind, id), prop: val, ...}]
This returns:
{id: id, prop: val, ...}
| Translates Datastore results into the format expected by the
application. | def from_datastore(entity):
"""Translates Datastore results into the format expected by the
application.
Datastore typically returns:
[Entity{key: (kind, id), prop: val, ...}]
This returns:
{id: id, prop: val, ...}
"""
if not entity:
return None
if isinstance(entity... | [
"def",
"from_datastore",
"(",
"entity",
")",
":",
"if",
"not",
"entity",
":",
"return",
"None",
"if",
"isinstance",
"(",
"entity",
",",
"builtin_list",
")",
":",
"entity",
"=",
"entity",
".",
"pop",
"(",
")",
"entity",
"[",
"'id'",
"]",
"=",
"entity",
... | [
29,
0
] | [
45,
17
] | python | en | ['en', 'en', 'en'] | True |
SpatiaLiteOperations.spatial_version | (self) | Determine the version of the SpatiaLite library. | Determine the version of the SpatiaLite library. | def spatial_version(self):
"""Determine the version of the SpatiaLite library."""
try:
version = self.spatialite_version_tuple()[1:]
except Exception as exc:
raise ImproperlyConfigured(
'Cannot determine the SpatiaLite version for the "%s" database. '
... | [
"def",
"spatial_version",
"(",
"self",
")",
":",
"try",
":",
"version",
"=",
"self",
".",
"spatialite_version_tuple",
"(",
")",
"[",
"1",
":",
"]",
"except",
"Exception",
"as",
"exc",
":",
"raise",
"ImproperlyConfigured",
"(",
"'Cannot determine the SpatiaLite v... | [
88,
4
] | [
101,
22
] | python | en | ['en', 'en', 'en'] | True |
SpatiaLiteOperations.convert_extent | (self, box) |
Convert the polygon data received from SpatiaLite to min/max values.
|
Convert the polygon data received from SpatiaLite to min/max values.
| def convert_extent(self, box):
"""
Convert the polygon data received from SpatiaLite to min/max values.
"""
if box is None:
return None
shell = GEOSGeometry(box).shell
xmin, ymin = shell[0][:2]
xmax, ymax = shell[2][:2]
return (xmin, ymin, xmax... | [
"def",
"convert_extent",
"(",
"self",
",",
"box",
")",
":",
"if",
"box",
"is",
"None",
":",
"return",
"None",
"shell",
"=",
"GEOSGeometry",
"(",
"box",
")",
".",
"shell",
"xmin",
",",
"ymin",
"=",
"shell",
"[",
"0",
"]",
"[",
":",
"2",
"]",
"xmax... | [
103,
4
] | [
112,
39
] | python | en | ['en', 'error', 'th'] | False |
SpatiaLiteOperations.geo_db_type | (self, f) |
Return None because geometry columns are added via the
`AddGeometryColumn` stored procedure on SpatiaLite.
|
Return None because geometry columns are added via the
`AddGeometryColumn` stored procedure on SpatiaLite.
| def geo_db_type(self, f):
"""
Return None because geometry columns are added via the
`AddGeometryColumn` stored procedure on SpatiaLite.
"""
return None | [
"def",
"geo_db_type",
"(",
"self",
",",
"f",
")",
":",
"return",
"None"
] | [
114,
4
] | [
119,
19
] | python | en | ['en', 'error', 'th'] | False |
SpatiaLiteOperations.get_distance | (self, f, value, lookup_type) |
Return the distance parameters for the given geometry field,
lookup value, and lookup type.
|
Return the distance parameters for the given geometry field,
lookup value, and lookup type.
| def get_distance(self, f, value, lookup_type):
"""
Return the distance parameters for the given geometry field,
lookup value, and lookup type.
"""
if not value:
return []
value = value[0]
if isinstance(value, Distance):
if f.geodetic(self.c... | [
"def",
"get_distance",
"(",
"self",
",",
"f",
",",
"value",
",",
"lookup_type",
")",
":",
"if",
"not",
"value",
":",
"return",
"[",
"]",
"value",
"=",
"value",
"[",
"0",
"]",
"if",
"isinstance",
"(",
"value",
",",
"Distance",
")",
":",
"if",
"f",
... | [
121,
4
] | [
141,
27
] | python | en | ['en', 'error', 'th'] | False |
SpatiaLiteOperations._get_spatialite_func | (self, func) |
Helper routine for calling SpatiaLite functions and returning
their result.
Any error occurring in this method should be handled by the caller.
|
Helper routine for calling SpatiaLite functions and returning
their result.
Any error occurring in this method should be handled by the caller.
| def _get_spatialite_func(self, func):
"""
Helper routine for calling SpatiaLite functions and returning
their result.
Any error occurring in this method should be handled by the caller.
"""
cursor = self.connection._cursor()
try:
cursor.execute('SELECT... | [
"def",
"_get_spatialite_func",
"(",
"self",
",",
"func",
")",
":",
"cursor",
"=",
"self",
".",
"connection",
".",
"_cursor",
"(",
")",
"try",
":",
"cursor",
".",
"execute",
"(",
"'SELECT %s'",
"%",
"func",
")",
"row",
"=",
"cursor",
".",
"fetchone",
"(... | [
143,
4
] | [
155,
21
] | python | en | ['en', 'error', 'th'] | False |
SpatiaLiteOperations.geos_version | (self) | Return the version of GEOS used by SpatiaLite as a string. | Return the version of GEOS used by SpatiaLite as a string. | def geos_version(self):
"Return the version of GEOS used by SpatiaLite as a string."
return self._get_spatialite_func('geos_version()') | [
"def",
"geos_version",
"(",
"self",
")",
":",
"return",
"self",
".",
"_get_spatialite_func",
"(",
"'geos_version()'",
")"
] | [
157,
4
] | [
159,
58
] | python | en | ['en', 'en', 'en'] | True |
SpatiaLiteOperations.proj_version | (self) | Return the version of the PROJ library used by SpatiaLite. | Return the version of the PROJ library used by SpatiaLite. | def proj_version(self):
"""Return the version of the PROJ library used by SpatiaLite."""
return self._get_spatialite_func('proj4_version()') | [
"def",
"proj_version",
"(",
"self",
")",
":",
"return",
"self",
".",
"_get_spatialite_func",
"(",
"'proj4_version()'",
")"
] | [
161,
4
] | [
163,
59
] | python | en | ['en', 'en', 'en'] | True |
SpatiaLiteOperations.lwgeom_version | (self) | Return the version of LWGEOM library used by SpatiaLite. | Return the version of LWGEOM library used by SpatiaLite. | def lwgeom_version(self):
"""Return the version of LWGEOM library used by SpatiaLite."""
return self._get_spatialite_func('lwgeom_version()') | [
"def",
"lwgeom_version",
"(",
"self",
")",
":",
"return",
"self",
".",
"_get_spatialite_func",
"(",
"'lwgeom_version()'",
")"
] | [
165,
4
] | [
167,
60
] | python | en | ['en', 'en', 'en'] | True |
SpatiaLiteOperations.spatialite_version | (self) | Return the SpatiaLite library version as a string. | Return the SpatiaLite library version as a string. | def spatialite_version(self):
"Return the SpatiaLite library version as a string."
return self._get_spatialite_func('spatialite_version()') | [
"def",
"spatialite_version",
"(",
"self",
")",
":",
"return",
"self",
".",
"_get_spatialite_func",
"(",
"'spatialite_version()'",
")"
] | [
169,
4
] | [
171,
64
] | python | en | ['en', 'en', 'en'] | True |
SpatiaLiteOperations.spatialite_version_tuple | (self) |
Return the SpatiaLite version as a tuple (version string, major,
minor, subminor).
|
Return the SpatiaLite version as a tuple (version string, major,
minor, subminor).
| def spatialite_version_tuple(self):
"""
Return the SpatiaLite version as a tuple (version string, major,
minor, subminor).
"""
version = self.spatialite_version()
return (version,) + get_version_tuple(version) | [
"def",
"spatialite_version_tuple",
"(",
"self",
")",
":",
"version",
"=",
"self",
".",
"spatialite_version",
"(",
")",
"return",
"(",
"version",
",",
")",
"+",
"get_version_tuple",
"(",
"version",
")"
] | [
173,
4
] | [
179,
54
] | python | en | ['en', 'error', 'th'] | False |
SpatiaLiteOperations.spatial_aggregate_name | (self, agg_name) |
Return the spatial aggregate SQL template and function for the
given Aggregate instance.
|
Return the spatial aggregate SQL template and function for the
given Aggregate instance.
| def spatial_aggregate_name(self, agg_name):
"""
Return the spatial aggregate SQL template and function for the
given Aggregate instance.
"""
agg_name = 'unionagg' if agg_name.lower() == 'union' else agg_name.lower()
return getattr(self, agg_name) | [
"def",
"spatial_aggregate_name",
"(",
"self",
",",
"agg_name",
")",
":",
"agg_name",
"=",
"'unionagg'",
"if",
"agg_name",
".",
"lower",
"(",
")",
"==",
"'union'",
"else",
"agg_name",
".",
"lower",
"(",
")",
"return",
"getattr",
"(",
"self",
",",
"agg_name"... | [
181,
4
] | [
187,
38
] | python | en | ['en', 'error', 'th'] | False |
handle_photo_save | (sender: ModelBase, instance: Photo, **kwargs) | log photo changes in audit | log photo changes in audit | def handle_photo_save(sender: ModelBase, instance: Photo, **kwargs):
""" log photo changes in audit """
label = instance._meta.app_label
model = instance._meta.model_name
verb = AuditVerbEnum.CREATED.value if kwargs.get('created') else AuditVerbEnum.UPDATED.value
# since images and album are creat... | [
"def",
"handle_photo_save",
"(",
"sender",
":",
"ModelBase",
",",
"instance",
":",
"Photo",
",",
"*",
"*",
"kwargs",
")",
":",
"label",
"=",
"instance",
".",
"_meta",
".",
"app_label",
"model",
"=",
"instance",
".",
"_meta",
".",
"model_name",
"verb",
"=... | [
11,
0
] | [
22,
79
] | python | en | ['en', 'en', 'en'] | True |
handle_album_save | (sender, instance: Album, **kwargs) | log album changes in audit | log album changes in audit | def handle_album_save(sender, instance: Album, **kwargs):
""" log album changes in audit """
label = instance._meta.app_label
model = instance._meta.model_name
verb = AuditVerbEnum.CREATED.value if kwargs.get('created') else AuditVerbEnum.UPDATED.value
# since images and album are created by users... | [
"def",
"handle_album_save",
"(",
"sender",
",",
"instance",
":",
"Album",
",",
"*",
"*",
"kwargs",
")",
":",
"label",
"=",
"instance",
".",
"_meta",
".",
"app_label",
"model",
"=",
"instance",
".",
"_meta",
".",
"model_name",
"verb",
"=",
"AuditVerbEnum",
... | [
26,
0
] | [
37,
79
] | python | en | ['en', 'da', 'en'] | True |
_create_structure | (C, ball_x, ball_y, left=True) | Creates entire Goldberg machine structure. | Creates entire Goldberg machine structure. | def _create_structure(C, ball_x, ball_y, left=True):
"""Creates entire Goldberg machine structure."""
# Add ball.
ball = C.add('dynamic ball', scale=0.1) \
.set_center_x(ball_x * C.scene.width) \
.set_center_y(ball_y * C.scene.height)
# Add alley in which ball is located.
b... | [
"def",
"_create_structure",
"(",
"C",
",",
"ball_x",
",",
"ball_y",
",",
"left",
"=",
"True",
")",
":",
"# Add ball.",
"ball",
"=",
"C",
".",
"add",
"(",
"'dynamic ball'",
",",
"scale",
"=",
"0.1",
")",
".",
"set_center_x",
"(",
"ball_x",
"*",
"C",
"... | [
61,
0
] | [
109,
29
] | python | en | ['fr', 'it', 'en'] | False |
_unicode_ci_compare | (s1, s2) |
Perform case-insensitive comparison of two identifiers, using the
recommended algorithm from Unicode Technical Report 36, section
2.11.2(B)(2).
|
Perform case-insensitive comparison of two identifiers, using the
recommended algorithm from Unicode Technical Report 36, section
2.11.2(B)(2).
| def _unicode_ci_compare(s1, s2):
"""
Perform case-insensitive comparison of two identifiers, using the
recommended algorithm from Unicode Technical Report 36, section
2.11.2(B)(2).
"""
return unicodedata.normalize('NFKC', s1).casefold() == unicodedata.normalize('NFKC', s2).casefold() | [
"def",
"_unicode_ci_compare",
"(",
"s1",
",",
"s2",
")",
":",
"return",
"unicodedata",
".",
"normalize",
"(",
"'NFKC'",
",",
"s1",
")",
".",
"casefold",
"(",
")",
"==",
"unicodedata",
".",
"normalize",
"(",
"'NFKC'",
",",
"s2",
")",
".",
"casefold",
"(... | [
23,
0
] | [
29,
103
] | python | en | ['en', 'error', 'th'] | False |
AuthenticationForm.__init__ | (self, request=None, *args, **kwargs) |
The 'request' parameter is set for custom auth use by subclasses.
The form data comes in via the standard 'data' kwarg.
|
The 'request' parameter is set for custom auth use by subclasses.
The form data comes in via the standard 'data' kwarg.
| def __init__(self, request=None, *args, **kwargs):
"""
The 'request' parameter is set for custom auth use by subclasses.
The form data comes in via the standard 'data' kwarg.
"""
self.request = request
self.user_cache = None
super().__init__(*args, **kwargs)
... | [
"def",
"__init__",
"(",
"self",
",",
"request",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"request",
"=",
"request",
"self",
".",
"user_cache",
"=",
"None",
"super",
"(",
")",
".",
"__init__",
"(",
"*",
"args",
... | [
179,
4
] | [
194,
86
] | python | en | ['en', 'error', 'th'] | False |
AuthenticationForm.confirm_login_allowed | (self, user) |
Controls whether the given User may log in. This is a policy setting,
independent of end-user authentication. This default behavior is to
allow login by active users, and reject login by inactive users.
If the given user cannot log in, this method should raise a
``ValidationErr... |
Controls whether the given User may log in. This is a policy setting,
independent of end-user authentication. This default behavior is to
allow login by active users, and reject login by inactive users. | def confirm_login_allowed(self, user):
"""
Controls whether the given User may log in. This is a policy setting,
independent of end-user authentication. This default behavior is to
allow login by active users, and reject login by inactive users.
If the given user cannot log in, ... | [
"def",
"confirm_login_allowed",
"(",
"self",
",",
"user",
")",
":",
"if",
"not",
"user",
".",
"is_active",
":",
"raise",
"ValidationError",
"(",
"self",
".",
"error_messages",
"[",
"'inactive'",
"]",
",",
"code",
"=",
"'inactive'",
",",
")"
] | [
209,
4
] | [
224,
13
] | python | en | ['en', 'error', 'th'] | False |
PasswordResetForm.send_mail | (self, subject_template_name, email_template_name,
context, from_email, to_email, html_email_template_name=None) |
Send a django.core.mail.EmailMultiAlternatives to `to_email`.
|
Send a django.core.mail.EmailMultiAlternatives to `to_email`.
| def send_mail(self, subject_template_name, email_template_name,
context, from_email, to_email, html_email_template_name=None):
"""
Send a django.core.mail.EmailMultiAlternatives to `to_email`.
"""
subject = loader.render_to_string(subject_template_name, context)
... | [
"def",
"send_mail",
"(",
"self",
",",
"subject_template_name",
",",
"email_template_name",
",",
"context",
",",
"from_email",
",",
"to_email",
",",
"html_email_template_name",
"=",
"None",
")",
":",
"subject",
"=",
"loader",
".",
"render_to_string",
"(",
"subject_... | [
244,
4
] | [
259,
28
] | python | en | ['en', 'error', 'th'] | False |
PasswordResetForm.get_users | (self, email) | Given an email, return matching user(s) who should receive a reset.
This allows subclasses to more easily customize the default policies
that prevent inactive users and users with unusable passwords from
resetting their password.
| Given an email, return matching user(s) who should receive a reset. | def get_users(self, email):
"""Given an email, return matching user(s) who should receive a reset.
This allows subclasses to more easily customize the default policies
that prevent inactive users and users with unusable passwords from
resetting their password.
"""
email_... | [
"def",
"get_users",
"(",
"self",
",",
"email",
")",
":",
"email_field_name",
"=",
"UserModel",
".",
"get_email_field_name",
"(",
")",
"active_users",
"=",
"UserModel",
".",
"_default_manager",
".",
"filter",
"(",
"*",
"*",
"{",
"'%s__iexact'",
"%",
"email_fiel... | [
261,
4
] | [
277,
9
] | python | en | ['en', 'en', 'en'] | True |
PasswordResetForm.save | (self, domain_override=None,
subject_template_name='registration/password_reset_subject.txt',
email_template_name='registration/password_reset_email.html',
use_https=False, token_generator=default_token_generator,
from_email=None, request=None, html_email_template_nam... |
Generate a one-use only link for resetting password and send it to the
user.
|
Generate a one-use only link for resetting password and send it to the
user.
| def save(self, domain_override=None,
subject_template_name='registration/password_reset_subject.txt',
email_template_name='registration/password_reset_email.html',
use_https=False, token_generator=default_token_generator,
from_email=None, request=None, html_email_temp... | [
"def",
"save",
"(",
"self",
",",
"domain_override",
"=",
"None",
",",
"subject_template_name",
"=",
"'registration/password_reset_subject.txt'",
",",
"email_template_name",
"=",
"'registration/password_reset_email.html'",
",",
"use_https",
"=",
"False",
",",
"token_generato... | [
279,
4
] | [
312,
13
] | python | en | ['en', 'error', 'th'] | False |
PasswordChangeForm.clean_old_password | (self) |
Validate that the old_password field is correct.
|
Validate that the old_password field is correct.
| def clean_old_password(self):
"""
Validate that the old_password field is correct.
"""
old_password = self.cleaned_data["old_password"]
if not self.user.check_password(old_password):
raise ValidationError(
self.error_messages['password_incorrect'],
... | [
"def",
"clean_old_password",
"(",
"self",
")",
":",
"old_password",
"=",
"self",
".",
"cleaned_data",
"[",
"\"old_password\"",
"]",
"if",
"not",
"self",
".",
"user",
".",
"check_password",
"(",
"old_password",
")",
":",
"raise",
"ValidationError",
"(",
"self",... | [
376,
4
] | [
386,
27
] | python | en | ['en', 'error', 'th'] | False |
AdminPasswordChangeForm.save | (self, commit=True) | Save the new password. | Save the new password. | def save(self, commit=True):
"""Save the new password."""
password = self.cleaned_data["password1"]
self.user.set_password(password)
if commit:
self.user.save()
return self.user | [
"def",
"save",
"(",
"self",
",",
"commit",
"=",
"True",
")",
":",
"password",
"=",
"self",
".",
"cleaned_data",
"[",
"\"password1\"",
"]",
"self",
".",
"user",
".",
"set_password",
"(",
"password",
")",
"if",
"commit",
":",
"self",
".",
"user",
".",
... | [
425,
4
] | [
431,
24
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.