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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
mapping | (data_source, geom_name='geom', layer_key=0, multi_geom=False) |
Given a DataSource, generates a dictionary that may be used
for invoking the LayerMapping utility.
Keyword Arguments:
`geom_name` => The name of the geometry field to use for the model.
`layer_key` => The key for specifying which layer in the DataSource to use;
defaults to 0 (the first l... |
Given a DataSource, generates a dictionary that may be used
for invoking the LayerMapping utility. | def mapping(data_source, geom_name='geom', layer_key=0, multi_geom=False):
"""
Given a DataSource, generates a dictionary that may be used
for invoking the LayerMapping utility.
Keyword Arguments:
`geom_name` => The name of the geometry field to use for the model.
`layer_key` => The key for ... | [
"def",
"mapping",
"(",
"data_source",
",",
"geom_name",
"=",
"'geom'",
",",
"layer_key",
"=",
"0",
",",
"multi_geom",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"data_source",
",",
"six",
".",
"string_types",
")",
":",
"# Instantiating the DataSource fro... | [
12,
0
] | [
49,
19
] | python | en | ['en', 'error', 'th'] | False |
ogrinspect | (*args, **kwargs) |
Given a data source (either a string or a DataSource object) and a string
model name this function will generate a GeoDjango model.
Usage:
>>> from django.contrib.gis.utils import ogrinspect
>>> ogrinspect('/path/to/shapefile.shp','NewModel')
...will print model definition to stout
or p... |
Given a data source (either a string or a DataSource object) and a string
model name this function will generate a GeoDjango model. | def ogrinspect(*args, **kwargs):
"""
Given a data source (either a string or a DataSource object) and a string
model name this function will generate a GeoDjango model.
Usage:
>>> from django.contrib.gis.utils import ogrinspect
>>> ogrinspect('/path/to/shapefile.shp','NewModel')
...will p... | [
"def",
"ogrinspect",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"'\\n'",
".",
"join",
"(",
"s",
"for",
"s",
"in",
"_ogrinspect",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
")"
] | [
52,
0
] | [
120,
61
] | python | en | ['en', 'error', 'th'] | False |
_ogrinspect | (data_source, model_name, geom_name='geom', layer_key=0, srid=None,
multi_geom=False, name_field=None, imports=True,
decimal=False, blank=False, null=False) |
Helper routine for `ogrinspect` that generates GeoDjango models corresponding
to the given data source. See the `ogrinspect` docstring for more details.
|
Helper routine for `ogrinspect` that generates GeoDjango models corresponding
to the given data source. See the `ogrinspect` docstring for more details.
| def _ogrinspect(data_source, model_name, geom_name='geom', layer_key=0, srid=None,
multi_geom=False, name_field=None, imports=True,
decimal=False, blank=False, null=False):
"""
Helper routine for `ogrinspect` that generates GeoDjango models corresponding
to the given data sou... | [
"def",
"_ogrinspect",
"(",
"data_source",
",",
"model_name",
",",
"geom_name",
"=",
"'geom'",
",",
"layer_key",
"=",
"0",
",",
"srid",
"=",
"None",
",",
"multi_geom",
"=",
"False",
",",
"name_field",
"=",
"None",
",",
"imports",
"=",
"True",
",",
"decima... | [
123,
0
] | [
238,
56
] | python | en | ['en', 'error', 'th'] | False |
noop | (value, param=None) | A noop filter that always return its first argument and does nothing with
its second (optional) one.
Useful for testing out whitespace in filter arguments (see #19882). | A noop filter that always return its first argument and does nothing with
its second (optional) one.
Useful for testing out whitespace in filter arguments (see #19882). | def noop(value, param=None):
"""A noop filter that always return its first argument and does nothing with
its second (optional) one.
Useful for testing out whitespace in filter arguments (see #19882)."""
return value | [
"def",
"noop",
"(",
"value",
",",
"param",
"=",
"None",
")",
":",
"return",
"value"
] | [
17,
0
] | [
21,
16
] | python | en | ['en', 'en', 'en'] | True |
no_params | () | Expected no_params __doc__ | Expected no_params __doc__ | def no_params():
"""Expected no_params __doc__"""
return "no_params - Expected result" | [
"def",
"no_params",
"(",
")",
":",
"return",
"\"no_params - Expected result\""
] | [
30,
0
] | [
32,
40
] | python | en | ['en', 'en', 'en'] | True |
one_param | (arg) | Expected one_param __doc__ | Expected one_param __doc__ | def one_param(arg):
"""Expected one_param __doc__"""
return "one_param - Expected result: %s" % arg | [
"def",
"one_param",
"(",
"arg",
")",
":",
"return",
"\"one_param - Expected result: %s\"",
"%",
"arg"
] | [
37,
0
] | [
39,
50
] | python | en | ['en', 'en', 'en'] | True |
explicit_no_context | (arg) | Expected explicit_no_context __doc__ | Expected explicit_no_context __doc__ | def explicit_no_context(arg):
"""Expected explicit_no_context __doc__"""
return "explicit_no_context - Expected result: %s" % arg | [
"def",
"explicit_no_context",
"(",
"arg",
")",
":",
"return",
"\"explicit_no_context - Expected result: %s\"",
"%",
"arg"
] | [
44,
0
] | [
46,
60
] | python | ca | ['es', 'ca', 'en'] | False |
no_params_with_context | (context) | Expected no_params_with_context __doc__ | Expected no_params_with_context __doc__ | def no_params_with_context(context):
"""Expected no_params_with_context __doc__"""
return "no_params_with_context - Expected result (context value: %s)" % context['value'] | [
"def",
"no_params_with_context",
"(",
"context",
")",
":",
"return",
"\"no_params_with_context - Expected result (context value: %s)\"",
"%",
"context",
"[",
"'value'",
"]"
] | [
51,
0
] | [
53,
92
] | python | en | ['en', 'en', 'en'] | True |
params_and_context | (context, arg) | Expected params_and_context __doc__ | Expected params_and_context __doc__ | def params_and_context(context, arg):
"""Expected params_and_context __doc__"""
return "params_and_context - Expected result (context value: %s): %s" % (context['value'], arg) | [
"def",
"params_and_context",
"(",
"context",
",",
"arg",
")",
":",
"return",
"\"params_and_context - Expected result (context value: %s): %s\"",
"%",
"(",
"context",
"[",
"'value'",
"]",
",",
"arg",
")"
] | [
58,
0
] | [
60,
99
] | python | en | ['en', 'en', 'en'] | True |
simple_two_params | (one, two) | Expected simple_two_params __doc__ | Expected simple_two_params __doc__ | def simple_two_params(one, two):
"""Expected simple_two_params __doc__"""
return "simple_two_params - Expected result: %s, %s" % (one, two) | [
"def",
"simple_two_params",
"(",
"one",
",",
"two",
")",
":",
"return",
"\"simple_two_params - Expected result: %s, %s\"",
"%",
"(",
"one",
",",
"two",
")"
] | [
65,
0
] | [
67,
69
] | python | en | ['en', 'en', 'en'] | True |
simple_one_default | (one, two='hi') | Expected simple_one_default __doc__ | Expected simple_one_default __doc__ | def simple_one_default(one, two='hi'):
"""Expected simple_one_default __doc__"""
return "simple_one_default - Expected result: %s, %s" % (one, two) | [
"def",
"simple_one_default",
"(",
"one",
",",
"two",
"=",
"'hi'",
")",
":",
"return",
"\"simple_one_default - Expected result: %s, %s\"",
"%",
"(",
"one",
",",
"two",
")"
] | [
72,
0
] | [
74,
70
] | python | en | ['en', 'en', 'en'] | True |
simple_unlimited_args | (one, two='hi', *args) | Expected simple_unlimited_args __doc__ | Expected simple_unlimited_args __doc__ | def simple_unlimited_args(one, two='hi', *args):
"""Expected simple_unlimited_args __doc__"""
return "simple_unlimited_args - Expected result: %s" % (', '.join(six.text_type(arg) for arg in [one, two] + list(args))) | [
"def",
"simple_unlimited_args",
"(",
"one",
",",
"two",
"=",
"'hi'",
",",
"*",
"args",
")",
":",
"return",
"\"simple_unlimited_args - Expected result: %s\"",
"%",
"(",
"', '",
".",
"join",
"(",
"six",
".",
"text_type",
"(",
"arg",
")",
"for",
"arg",
"in",
... | [
79,
0
] | [
81,
125
] | python | en | ['en', 'en', 'en'] | True |
simple_only_unlimited_args | (*args) | Expected simple_only_unlimited_args __doc__ | Expected simple_only_unlimited_args __doc__ | def simple_only_unlimited_args(*args):
"""Expected simple_only_unlimited_args __doc__"""
return "simple_only_unlimited_args - Expected result: %s" % ', '.join(six.text_type(arg) for arg in args) | [
"def",
"simple_only_unlimited_args",
"(",
"*",
"args",
")",
":",
"return",
"\"simple_only_unlimited_args - Expected result: %s\"",
"%",
"', '",
".",
"join",
"(",
"six",
".",
"text_type",
"(",
"arg",
")",
"for",
"arg",
"in",
"args",
")"
] | [
86,
0
] | [
88,
109
] | python | en | ['en', 'en', 'en'] | True |
simple_unlimited_args_kwargs | (one, two='hi', *args, **kwargs) | Expected simple_unlimited_args_kwargs __doc__ | Expected simple_unlimited_args_kwargs __doc__ | def simple_unlimited_args_kwargs(one, two='hi', *args, **kwargs):
"""Expected simple_unlimited_args_kwargs __doc__"""
# Sort the dictionary by key to guarantee the order for testing.
sorted_kwarg = sorted(six.iteritems(kwargs), key=operator.itemgetter(0))
return "simple_unlimited_args_kwargs - Expected ... | [
"def",
"simple_unlimited_args_kwargs",
"(",
"one",
",",
"two",
"=",
"'hi'",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Sort the dictionary by key to guarantee the order for testing.",
"sorted_kwarg",
"=",
"sorted",
"(",
"six",
".",
"iteritems",
"(",
"... | [
93,
0
] | [
100,
5
] | python | en | ['en', 'en', 'en'] | True |
simple_tag_without_context_parameter | (arg) | Expected simple_tag_without_context_parameter __doc__ | Expected simple_tag_without_context_parameter __doc__ | def simple_tag_without_context_parameter(arg):
"""Expected simple_tag_without_context_parameter __doc__"""
return "Expected result" | [
"def",
"simple_tag_without_context_parameter",
"(",
"arg",
")",
":",
"return",
"\"Expected result\""
] | [
105,
0
] | [
107,
28
] | python | en | ['en', 'en', 'en'] | True |
inclusion_no_params | () | Expected inclusion_no_params __doc__ | Expected inclusion_no_params __doc__ | def inclusion_no_params():
"""Expected inclusion_no_params __doc__"""
return {"result": "inclusion_no_params - Expected result"} | [
"def",
"inclusion_no_params",
"(",
")",
":",
"return",
"{",
"\"result\"",
":",
"\"inclusion_no_params - Expected result\"",
"}"
] | [
129,
0
] | [
131,
62
] | python | en | ['en', 'en', 'en'] | True |
inclusion_no_params_from_template | () | Expected inclusion_no_params_from_template __doc__ | Expected inclusion_no_params_from_template __doc__ | def inclusion_no_params_from_template():
"""Expected inclusion_no_params_from_template __doc__"""
return {"result": "inclusion_no_params_from_template - Expected result"} | [
"def",
"inclusion_no_params_from_template",
"(",
")",
":",
"return",
"{",
"\"result\"",
":",
"\"inclusion_no_params_from_template - Expected result\"",
"}"
] | [
136,
0
] | [
138,
76
] | python | en | ['en', 'en', 'en'] | True |
inclusion_one_param | (arg) | Expected inclusion_one_param __doc__ | Expected inclusion_one_param __doc__ | def inclusion_one_param(arg):
"""Expected inclusion_one_param __doc__"""
return {"result": "inclusion_one_param - Expected result: %s" % arg} | [
"def",
"inclusion_one_param",
"(",
"arg",
")",
":",
"return",
"{",
"\"result\"",
":",
"\"inclusion_one_param - Expected result: %s\"",
"%",
"arg",
"}"
] | [
143,
0
] | [
145,
72
] | python | en | ['en', 'en', 'en'] | True |
inclusion_one_param_from_template | (arg) | Expected inclusion_one_param_from_template __doc__ | Expected inclusion_one_param_from_template __doc__ | def inclusion_one_param_from_template(arg):
"""Expected inclusion_one_param_from_template __doc__"""
return {"result": "inclusion_one_param_from_template - Expected result: %s" % arg} | [
"def",
"inclusion_one_param_from_template",
"(",
"arg",
")",
":",
"return",
"{",
"\"result\"",
":",
"\"inclusion_one_param_from_template - Expected result: %s\"",
"%",
"arg",
"}"
] | [
150,
0
] | [
152,
86
] | python | en | ['en', 'en', 'en'] | True |
inclusion_explicit_no_context | (arg) | Expected inclusion_explicit_no_context __doc__ | Expected inclusion_explicit_no_context __doc__ | def inclusion_explicit_no_context(arg):
"""Expected inclusion_explicit_no_context __doc__"""
return {"result": "inclusion_explicit_no_context - Expected result: %s" % arg} | [
"def",
"inclusion_explicit_no_context",
"(",
"arg",
")",
":",
"return",
"{",
"\"result\"",
":",
"\"inclusion_explicit_no_context - Expected result: %s\"",
"%",
"arg",
"}"
] | [
157,
0
] | [
159,
82
] | python | en | ['en', 'en', 'en'] | True |
inclusion_explicit_no_context_from_template | (arg) | Expected inclusion_explicit_no_context_from_template __doc__ | Expected inclusion_explicit_no_context_from_template __doc__ | def inclusion_explicit_no_context_from_template(arg):
"""Expected inclusion_explicit_no_context_from_template __doc__"""
return {"result": "inclusion_explicit_no_context_from_template - Expected result: %s" % arg} | [
"def",
"inclusion_explicit_no_context_from_template",
"(",
"arg",
")",
":",
"return",
"{",
"\"result\"",
":",
"\"inclusion_explicit_no_context_from_template - Expected result: %s\"",
"%",
"arg",
"}"
] | [
164,
0
] | [
166,
96
] | python | en | ['en', 'en', 'en'] | True |
inclusion_no_params_with_context | (context) | Expected inclusion_no_params_with_context __doc__ | Expected inclusion_no_params_with_context __doc__ | def inclusion_no_params_with_context(context):
"""Expected inclusion_no_params_with_context __doc__"""
return {"result": "inclusion_no_params_with_context - Expected result (context value: %s)" % context['value']} | [
"def",
"inclusion_no_params_with_context",
"(",
"context",
")",
":",
"return",
"{",
"\"result\"",
":",
"\"inclusion_no_params_with_context - Expected result (context value: %s)\"",
"%",
"context",
"[",
"'value'",
"]",
"}"
] | [
171,
0
] | [
173,
114
] | python | en | ['en', 'en', 'en'] | True |
inclusion_no_params_with_context_from_template | (context) | Expected inclusion_no_params_with_context_from_template __doc__ | Expected inclusion_no_params_with_context_from_template __doc__ | def inclusion_no_params_with_context_from_template(context):
"""Expected inclusion_no_params_with_context_from_template __doc__"""
return {"result": "inclusion_no_params_with_context_from_template - Expected result (context value: %s)" % context['value']} | [
"def",
"inclusion_no_params_with_context_from_template",
"(",
"context",
")",
":",
"return",
"{",
"\"result\"",
":",
"\"inclusion_no_params_with_context_from_template - Expected result (context value: %s)\"",
"%",
"context",
"[",
"'value'",
"]",
"}"
] | [
178,
0
] | [
180,
128
] | python | en | ['en', 'en', 'en'] | True |
inclusion_params_and_context | (context, arg) | Expected inclusion_params_and_context __doc__ | Expected inclusion_params_and_context __doc__ | def inclusion_params_and_context(context, arg):
"""Expected inclusion_params_and_context __doc__"""
return {"result": "inclusion_params_and_context - Expected result (context value: %s): %s" % (context['value'], arg)} | [
"def",
"inclusion_params_and_context",
"(",
"context",
",",
"arg",
")",
":",
"return",
"{",
"\"result\"",
":",
"\"inclusion_params_and_context - Expected result (context value: %s): %s\"",
"%",
"(",
"context",
"[",
"'value'",
"]",
",",
"arg",
")",
"}"
] | [
185,
0
] | [
187,
121
] | python | en | ['en', 'en', 'en'] | True |
inclusion_params_and_context_from_template | (context, arg) | Expected inclusion_params_and_context_from_template __doc__ | Expected inclusion_params_and_context_from_template __doc__ | def inclusion_params_and_context_from_template(context, arg):
"""Expected inclusion_params_and_context_from_template __doc__"""
return {"result": "inclusion_params_and_context_from_template - Expected result (context value: %s): %s" % (context['value'], arg)} | [
"def",
"inclusion_params_and_context_from_template",
"(",
"context",
",",
"arg",
")",
":",
"return",
"{",
"\"result\"",
":",
"\"inclusion_params_and_context_from_template - Expected result (context value: %s): %s\"",
"%",
"(",
"context",
"[",
"'value'",
"]",
",",
"arg",
")"... | [
192,
0
] | [
194,
135
] | python | en | ['en', 'en', 'en'] | True |
inclusion_two_params | (one, two) | Expected inclusion_two_params __doc__ | Expected inclusion_two_params __doc__ | def inclusion_two_params(one, two):
"""Expected inclusion_two_params __doc__"""
return {"result": "inclusion_two_params - Expected result: %s, %s" % (one, two)} | [
"def",
"inclusion_two_params",
"(",
"one",
",",
"two",
")",
":",
"return",
"{",
"\"result\"",
":",
"\"inclusion_two_params - Expected result: %s, %s\"",
"%",
"(",
"one",
",",
"two",
")",
"}"
] | [
199,
0
] | [
201,
84
] | python | en | ['en', 'en', 'en'] | True |
inclusion_two_params_from_template | (one, two) | Expected inclusion_two_params_from_template __doc__ | Expected inclusion_two_params_from_template __doc__ | def inclusion_two_params_from_template(one, two):
"""Expected inclusion_two_params_from_template __doc__"""
return {"result": "inclusion_two_params_from_template - Expected result: %s, %s" % (one, two)} | [
"def",
"inclusion_two_params_from_template",
"(",
"one",
",",
"two",
")",
":",
"return",
"{",
"\"result\"",
":",
"\"inclusion_two_params_from_template - Expected result: %s, %s\"",
"%",
"(",
"one",
",",
"two",
")",
"}"
] | [
206,
0
] | [
208,
98
] | python | en | ['en', 'en', 'en'] | True |
inclusion_one_default | (one, two='hi') | Expected inclusion_one_default __doc__ | Expected inclusion_one_default __doc__ | def inclusion_one_default(one, two='hi'):
"""Expected inclusion_one_default __doc__"""
return {"result": "inclusion_one_default - Expected result: %s, %s" % (one, two)} | [
"def",
"inclusion_one_default",
"(",
"one",
",",
"two",
"=",
"'hi'",
")",
":",
"return",
"{",
"\"result\"",
":",
"\"inclusion_one_default - Expected result: %s, %s\"",
"%",
"(",
"one",
",",
"two",
")",
"}"
] | [
213,
0
] | [
215,
85
] | python | en | ['en', 'en', 'en'] | True |
inclusion_one_default_from_template | (one, two='hi') | Expected inclusion_one_default_from_template __doc__ | Expected inclusion_one_default_from_template __doc__ | def inclusion_one_default_from_template(one, two='hi'):
"""Expected inclusion_one_default_from_template __doc__"""
return {"result": "inclusion_one_default_from_template - Expected result: %s, %s" % (one, two)} | [
"def",
"inclusion_one_default_from_template",
"(",
"one",
",",
"two",
"=",
"'hi'",
")",
":",
"return",
"{",
"\"result\"",
":",
"\"inclusion_one_default_from_template - Expected result: %s, %s\"",
"%",
"(",
"one",
",",
"two",
")",
"}"
] | [
220,
0
] | [
222,
99
] | python | en | ['en', 'en', 'en'] | True |
inclusion_unlimited_args | (one, two='hi', *args) | Expected inclusion_unlimited_args __doc__ | Expected inclusion_unlimited_args __doc__ | def inclusion_unlimited_args(one, two='hi', *args):
"""Expected inclusion_unlimited_args __doc__"""
return {"result": "inclusion_unlimited_args - Expected result: %s" % (', '.join(six.text_type(arg) for arg in [one, two] + list(args)))} | [
"def",
"inclusion_unlimited_args",
"(",
"one",
",",
"two",
"=",
"'hi'",
",",
"*",
"args",
")",
":",
"return",
"{",
"\"result\"",
":",
"\"inclusion_unlimited_args - Expected result: %s\"",
"%",
"(",
"', '",
".",
"join",
"(",
"six",
".",
"text_type",
"(",
"arg",... | [
227,
0
] | [
229,
140
] | python | en | ['en', 'en', 'en'] | True |
inclusion_unlimited_args_from_template | (one, two='hi', *args) | Expected inclusion_unlimited_args_from_template __doc__ | Expected inclusion_unlimited_args_from_template __doc__ | def inclusion_unlimited_args_from_template(one, two='hi', *args):
"""Expected inclusion_unlimited_args_from_template __doc__"""
return {"result": "inclusion_unlimited_args_from_template - Expected result: %s" % (', '.join(six.text_type(arg) for arg in [one, two] + list(args)))} | [
"def",
"inclusion_unlimited_args_from_template",
"(",
"one",
",",
"two",
"=",
"'hi'",
",",
"*",
"args",
")",
":",
"return",
"{",
"\"result\"",
":",
"\"inclusion_unlimited_args_from_template - Expected result: %s\"",
"%",
"(",
"', '",
".",
"join",
"(",
"six",
".",
... | [
234,
0
] | [
236,
154
] | python | en | ['en', 'en', 'en'] | True |
inclusion_only_unlimited_args | (*args) | Expected inclusion_only_unlimited_args __doc__ | Expected inclusion_only_unlimited_args __doc__ | def inclusion_only_unlimited_args(*args):
"""Expected inclusion_only_unlimited_args __doc__"""
return {"result": "inclusion_only_unlimited_args - Expected result: %s" % (', '.join(six.text_type(arg) for arg in args))} | [
"def",
"inclusion_only_unlimited_args",
"(",
"*",
"args",
")",
":",
"return",
"{",
"\"result\"",
":",
"\"inclusion_only_unlimited_args - Expected result: %s\"",
"%",
"(",
"', '",
".",
"join",
"(",
"six",
".",
"text_type",
"(",
"arg",
")",
"for",
"arg",
"in",
"ar... | [
241,
0
] | [
243,
126
] | python | en | ['en', 'en', 'en'] | True |
inclusion_only_unlimited_args_from_template | (*args) | Expected inclusion_only_unlimited_args_from_template __doc__ | Expected inclusion_only_unlimited_args_from_template __doc__ | def inclusion_only_unlimited_args_from_template(*args):
"""Expected inclusion_only_unlimited_args_from_template __doc__"""
return {"result": "inclusion_only_unlimited_args_from_template - Expected result: %s" % (', '.join(six.text_type(arg) for arg in args))} | [
"def",
"inclusion_only_unlimited_args_from_template",
"(",
"*",
"args",
")",
":",
"return",
"{",
"\"result\"",
":",
"\"inclusion_only_unlimited_args_from_template - Expected result: %s\"",
"%",
"(",
"', '",
".",
"join",
"(",
"six",
".",
"text_type",
"(",
"arg",
")",
"... | [
248,
0
] | [
250,
140
] | python | en | ['en', 'en', 'en'] | True |
inclusion_tag_current_app | (context) | Expected inclusion_tag_current_app __doc__ | Expected inclusion_tag_current_app __doc__ | def inclusion_tag_current_app(context):
"""Expected inclusion_tag_current_app __doc__"""
return {} | [
"def",
"inclusion_tag_current_app",
"(",
"context",
")",
":",
"return",
"{",
"}"
] | [
255,
0
] | [
257,
13
] | python | en | ['en', 'en', 'en'] | True |
inclusion_tag_use_l10n | (context) | Expected inclusion_tag_use_l10n __doc__ | Expected inclusion_tag_use_l10n __doc__ | def inclusion_tag_use_l10n(context):
"""Expected inclusion_tag_use_l10n __doc__"""
return {} | [
"def",
"inclusion_tag_use_l10n",
"(",
"context",
")",
":",
"return",
"{",
"}"
] | [
262,
0
] | [
264,
13
] | python | en | ['en', 'en', 'en'] | True |
inclusion_unlimited_args_kwargs | (one, two='hi', *args, **kwargs) | Expected inclusion_unlimited_args_kwargs __doc__ | Expected inclusion_unlimited_args_kwargs __doc__ | def inclusion_unlimited_args_kwargs(one, two='hi', *args, **kwargs):
"""Expected inclusion_unlimited_args_kwargs __doc__"""
# Sort the dictionary by key to guarantee the order for testing.
sorted_kwarg = sorted(six.iteritems(kwargs), key=operator.itemgetter(0))
return {"result": "inclusion_unlimited_arg... | [
"def",
"inclusion_unlimited_args_kwargs",
"(",
"one",
",",
"two",
"=",
"'hi'",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Sort the dictionary by key to guarantee the order for testing.",
"sorted_kwarg",
"=",
"sorted",
"(",
"six",
".",
"iteritems",
"(",
... | [
269,
0
] | [
276,
6
] | python | en | ['en', 'en', 'en'] | True |
inclusion_tag_without_context_parameter | (arg) | Expected inclusion_tag_without_context_parameter __doc__ | Expected inclusion_tag_without_context_parameter __doc__ | def inclusion_tag_without_context_parameter(arg):
"""Expected inclusion_tag_without_context_parameter __doc__"""
return {} | [
"def",
"inclusion_tag_without_context_parameter",
"(",
"arg",
")",
":",
"return",
"{",
"}"
] | [
281,
0
] | [
283,
13
] | python | en | ['en', 'en', 'en'] | True |
assignment_no_params | () | Expected assignment_no_params __doc__ | Expected assignment_no_params __doc__ | def assignment_no_params():
"""Expected assignment_no_params __doc__"""
return "assignment_no_params - Expected result" | [
"def",
"assignment_no_params",
"(",
")",
":",
"return",
"\"assignment_no_params - Expected result\""
] | [
288,
0
] | [
290,
51
] | python | en | ['en', 'en', 'en'] | True |
assignment_one_param | (arg) | Expected assignment_one_param __doc__ | Expected assignment_one_param __doc__ | def assignment_one_param(arg):
"""Expected assignment_one_param __doc__"""
return "assignment_one_param - Expected result: %s" % arg | [
"def",
"assignment_one_param",
"(",
"arg",
")",
":",
"return",
"\"assignment_one_param - Expected result: %s\"",
"%",
"arg"
] | [
295,
0
] | [
297,
61
] | python | en | ['en', 'en', 'en'] | True |
assignment_explicit_no_context | (arg) | Expected assignment_explicit_no_context __doc__ | Expected assignment_explicit_no_context __doc__ | def assignment_explicit_no_context(arg):
"""Expected assignment_explicit_no_context __doc__"""
return "assignment_explicit_no_context - Expected result: %s" % arg | [
"def",
"assignment_explicit_no_context",
"(",
"arg",
")",
":",
"return",
"\"assignment_explicit_no_context - Expected result: %s\"",
"%",
"arg"
] | [
302,
0
] | [
304,
71
] | python | en | ['en', 'ca', 'en'] | True |
assignment_no_params_with_context | (context) | Expected assignment_no_params_with_context __doc__ | Expected assignment_no_params_with_context __doc__ | def assignment_no_params_with_context(context):
"""Expected assignment_no_params_with_context __doc__"""
return "assignment_no_params_with_context - Expected result (context value: %s)" % context['value'] | [
"def",
"assignment_no_params_with_context",
"(",
"context",
")",
":",
"return",
"\"assignment_no_params_with_context - Expected result (context value: %s)\"",
"%",
"context",
"[",
"'value'",
"]"
] | [
309,
0
] | [
311,
103
] | python | en | ['en', 'en', 'en'] | True |
assignment_params_and_context | (context, arg) | Expected assignment_params_and_context __doc__ | Expected assignment_params_and_context __doc__ | def assignment_params_and_context(context, arg):
"""Expected assignment_params_and_context __doc__"""
return "assignment_params_and_context - Expected result (context value: %s): %s" % (context['value'], arg) | [
"def",
"assignment_params_and_context",
"(",
"context",
",",
"arg",
")",
":",
"return",
"\"assignment_params_and_context - Expected result (context value: %s): %s\"",
"%",
"(",
"context",
"[",
"'value'",
"]",
",",
"arg",
")"
] | [
316,
0
] | [
318,
110
] | python | en | ['en', 'en', 'en'] | True |
assignment_two_params | (one, two) | Expected assignment_two_params __doc__ | Expected assignment_two_params __doc__ | def assignment_two_params(one, two):
"""Expected assignment_two_params __doc__"""
return "assignment_two_params - Expected result: %s, %s" % (one, two) | [
"def",
"assignment_two_params",
"(",
"one",
",",
"two",
")",
":",
"return",
"\"assignment_two_params - Expected result: %s, %s\"",
"%",
"(",
"one",
",",
"two",
")"
] | [
323,
0
] | [
325,
73
] | python | en | ['en', 'en', 'en'] | True |
assignment_one_default | (one, two='hi') | Expected assignment_one_default __doc__ | Expected assignment_one_default __doc__ | def assignment_one_default(one, two='hi'):
"""Expected assignment_one_default __doc__"""
return "assignment_one_default - Expected result: %s, %s" % (one, two) | [
"def",
"assignment_one_default",
"(",
"one",
",",
"two",
"=",
"'hi'",
")",
":",
"return",
"\"assignment_one_default - Expected result: %s, %s\"",
"%",
"(",
"one",
",",
"two",
")"
] | [
330,
0
] | [
332,
74
] | python | en | ['en', 'en', 'en'] | True |
assignment_unlimited_args | (one, two='hi', *args) | Expected assignment_unlimited_args __doc__ | Expected assignment_unlimited_args __doc__ | def assignment_unlimited_args(one, two='hi', *args):
"""Expected assignment_unlimited_args __doc__"""
return "assignment_unlimited_args - Expected result: %s" % (', '.join(six.text_type(arg) for arg in [one, two] + list(args))) | [
"def",
"assignment_unlimited_args",
"(",
"one",
",",
"two",
"=",
"'hi'",
",",
"*",
"args",
")",
":",
"return",
"\"assignment_unlimited_args - Expected result: %s\"",
"%",
"(",
"', '",
".",
"join",
"(",
"six",
".",
"text_type",
"(",
"arg",
")",
"for",
"arg",
... | [
337,
0
] | [
339,
129
] | python | en | ['en', 'en', 'en'] | True |
assignment_only_unlimited_args | (*args) | Expected assignment_only_unlimited_args __doc__ | Expected assignment_only_unlimited_args __doc__ | def assignment_only_unlimited_args(*args):
"""Expected assignment_only_unlimited_args __doc__"""
return "assignment_only_unlimited_args - Expected result: %s" % ', '.join(six.text_type(arg) for arg in args) | [
"def",
"assignment_only_unlimited_args",
"(",
"*",
"args",
")",
":",
"return",
"\"assignment_only_unlimited_args - Expected result: %s\"",
"%",
"', '",
".",
"join",
"(",
"six",
".",
"text_type",
"(",
"arg",
")",
"for",
"arg",
"in",
"args",
")"
] | [
344,
0
] | [
346,
113
] | python | en | ['en', 'en', 'en'] | True |
assignment_unlimited_args_kwargs | (one, two='hi', *args, **kwargs) | Expected assignment_unlimited_args_kwargs __doc__ | Expected assignment_unlimited_args_kwargs __doc__ | def assignment_unlimited_args_kwargs(one, two='hi', *args, **kwargs):
"""Expected assignment_unlimited_args_kwargs __doc__"""
# Sort the dictionary by key to guarantee the order for testing.
sorted_kwarg = sorted(six.iteritems(kwargs), key=operator.itemgetter(0))
return "assignment_unlimited_args_kwargs... | [
"def",
"assignment_unlimited_args_kwargs",
"(",
"one",
",",
"two",
"=",
"'hi'",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Sort the dictionary by key to guarantee the order for testing.",
"sorted_kwarg",
"=",
"sorted",
"(",
"six",
".",
"iteritems",
"(",... | [
351,
0
] | [
358,
5
] | python | en | ['en', 'en', 'en'] | True |
assignment_tag_without_context_parameter | (arg) | Expected assignment_tag_without_context_parameter __doc__ | Expected assignment_tag_without_context_parameter __doc__ | def assignment_tag_without_context_parameter(arg):
"""Expected assignment_tag_without_context_parameter __doc__"""
return "Expected result" | [
"def",
"assignment_tag_without_context_parameter",
"(",
"arg",
")",
":",
"return",
"\"Expected result\""
] | [
363,
0
] | [
365,
28
] | python | en | ['en', 'en', 'en'] | True |
parse_bdist_wininst | (name) | Return (base,pyversion) or (None,None) for possible .exe name | Return (base,pyversion) or (None,None) for possible .exe name | def parse_bdist_wininst(name):
"""Return (base,pyversion) or (None,None) for possible .exe name"""
lower = name.lower()
base, py_ver, plat = None, None, None
if lower.endswith('.exe'):
if lower.endswith('.win32.exe'):
base = name[:-10]
plat = 'win32'
elif lower.... | [
"def",
"parse_bdist_wininst",
"(",
"name",
")",
":",
"lower",
"=",
"name",
".",
"lower",
"(",
")",
"base",
",",
"py_ver",
",",
"plat",
"=",
"None",
",",
"None",
",",
"None",
"if",
"lower",
".",
"endswith",
"(",
"'.exe'",
")",
":",
"if",
"lower",
".... | [
61,
0
] | [
82,
29
] | python | en | ['en', 'en', 'en'] | True |
distros_for_url | (url, metadata=None) | Yield egg or source distribution objects that might be found at a URL | Yield egg or source distribution objects that might be found at a URL | def distros_for_url(url, metadata=None):
"""Yield egg or source distribution objects that might be found at a URL"""
base, fragment = egg_info_for_url(url)
for dist in distros_for_location(url, base, metadata):
yield dist
if fragment:
match = EGG_FRAGMENT.match(fragment)
if match... | [
"def",
"distros_for_url",
"(",
"url",
",",
"metadata",
"=",
"None",
")",
":",
"base",
",",
"fragment",
"=",
"egg_info_for_url",
"(",
"url",
")",
"for",
"dist",
"in",
"distros_for_location",
"(",
"url",
",",
"base",
",",
"metadata",
")",
":",
"yield",
"di... | [
96,
0
] | [
107,
26
] | python | en | ['en', 'en', 'en'] | True |
distros_for_location | (location, basename, metadata=None) | Yield egg or source distribution objects based on basename | Yield egg or source distribution objects based on basename | def distros_for_location(location, basename, metadata=None):
"""Yield egg or source distribution objects based on basename"""
if basename.endswith('.egg.zip'):
basename = basename[:-4] # strip the .zip
if basename.endswith('.egg') and '-' in basename:
# only one, unambiguous interpretation
... | [
"def",
"distros_for_location",
"(",
"location",
",",
"basename",
",",
"metadata",
"=",
"None",
")",
":",
"if",
"basename",
".",
"endswith",
"(",
"'.egg.zip'",
")",
":",
"basename",
"=",
"basename",
"[",
":",
"-",
"4",
"]",
"# strip the .zip",
"if",
"basena... | [
110,
0
] | [
140,
13
] | python | en | ['en', 'en', 'en'] | True |
distros_for_filename | (filename, metadata=None) | Yield possible egg or source distribution objects based on a filename | Yield possible egg or source distribution objects based on a filename | def distros_for_filename(filename, metadata=None):
"""Yield possible egg or source distribution objects based on a filename"""
return distros_for_location(
normalize_path(filename), os.path.basename(filename), metadata
) | [
"def",
"distros_for_filename",
"(",
"filename",
",",
"metadata",
"=",
"None",
")",
":",
"return",
"distros_for_location",
"(",
"normalize_path",
"(",
"filename",
")",
",",
"os",
".",
"path",
".",
"basename",
"(",
"filename",
")",
",",
"metadata",
")"
] | [
143,
0
] | [
147,
5
] | python | en | ['en', 'en', 'en'] | True |
interpret_distro_name | (
location, basename, metadata, py_version=None, precedence=SOURCE_DIST,
platform=None
) | Generate alternative interpretations of a source distro name
Note: if `location` is a filesystem filename, you should call
``pkg_resources.normalize_path()`` on it before passing it to this
routine!
| Generate alternative interpretations of a source distro name | def interpret_distro_name(
location, basename, metadata, py_version=None, precedence=SOURCE_DIST,
platform=None
):
"""Generate alternative interpretations of a source distro name
Note: if `location` is a filesystem filename, you should call
``pkg_resources.normalize_path()`` on it before pa... | [
"def",
"interpret_distro_name",
"(",
"location",
",",
"basename",
",",
"metadata",
",",
"py_version",
"=",
"None",
",",
"precedence",
"=",
"SOURCE_DIST",
",",
"platform",
"=",
"None",
")",
":",
"# Generate alternative interpretations of a source distro name",
"# Because... | [
150,
0
] | [
182,
9
] | python | en | ['en', 'it', 'en'] | True |
unique_everseen | (iterable, key=None) | List unique elements, preserving order. Remember all elements ever seen. | List unique elements, preserving order. Remember all elements ever seen. | def unique_everseen(iterable, key=None):
"List unique elements, preserving order. Remember all elements ever seen."
# unique_everseen('AAAABBBCCDAABBB') --> A B C D
# unique_everseen('ABBCcAD', str.lower) --> A B C D
seen = set()
seen_add = seen.add
if key is None:
for element in six.mov... | [
"def",
"unique_everseen",
"(",
"iterable",
",",
"key",
"=",
"None",
")",
":",
"# unique_everseen('AAAABBBCCDAABBB') --> A B C D",
"# unique_everseen('ABBCcAD', str.lower) --> A B C D",
"seen",
"=",
"set",
"(",
")",
"seen_add",
"=",
"seen",
".",
"add",
"if",
"key",
"is... | [
186,
0
] | [
201,
29
] | python | ca | ['ca', 'ca', 'en'] | True |
unique_values | (func) |
Wrap a function returning an iterable such that the resulting iterable
only ever yields unique items.
|
Wrap a function returning an iterable such that the resulting iterable
only ever yields unique items.
| def unique_values(func):
"""
Wrap a function returning an iterable such that the resulting iterable
only ever yields unique items.
"""
@wraps(func)
def wrapper(*args, **kwargs):
return unique_everseen(func(*args, **kwargs))
return wrapper | [
"def",
"unique_values",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"unique_everseen",
"(",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
")",
"... | [
204,
0
] | [
214,
18
] | python | en | ['en', 'error', 'th'] | False |
find_external_links | (url, page) | Find rel="homepage" and rel="download" links in `page`, yielding URLs | Find rel="homepage" and rel="download" links in `page`, yielding URLs | def find_external_links(url, page):
"""Find rel="homepage" and rel="download" links in `page`, yielding URLs"""
for match in REL.finditer(page):
tag, rel = match.groups()
rels = set(map(str.strip, rel.lower().split(',')))
if 'homepage' in rels or 'download' in rels:
for matc... | [
"def",
"find_external_links",
"(",
"url",
",",
"page",
")",
":",
"for",
"match",
"in",
"REL",
".",
"finditer",
"(",
"page",
")",
":",
"tag",
",",
"rel",
"=",
"match",
".",
"groups",
"(",
")",
"rels",
"=",
"set",
"(",
"map",
"(",
"str",
".",
"stri... | [
222,
0
] | [
237,
75
] | python | en | ['en', 'en', 'en'] | True |
htmldecode | (text) |
Decode HTML entities in the given text.
>>> htmldecode(
... 'https://../package_name-0.1.2.tar.gz'
... '?tokena=A&tokenb=B">package_name-0.1.2.tar.gz')
'https://../package_name-0.1.2.tar.gz?tokena=A&tokenb=B">package_name-0.1.2.tar.gz'
|
Decode HTML entities in the given text. | def htmldecode(text):
"""
Decode HTML entities in the given text.
>>> htmldecode(
... 'https://../package_name-0.1.2.tar.gz'
... '?tokena=A&tokenb=B">package_name-0.1.2.tar.gz')
'https://../package_name-0.1.2.tar.gz?tokena=A&tokenb=B">package_name-0.1.2.tar.gz'
"""
return en... | [
"def",
"htmldecode",
"(",
"text",
")",
":",
"return",
"entity_sub",
"(",
"decode_entity",
",",
"text",
")"
] | [
945,
0
] | [
954,
42
] | python | en | ['en', 'error', 'th'] | False |
_encode_auth | (auth) |
A function compatible with Python 2.3-3.3 that will encode
auth from a URL suitable for an HTTP header.
>>> str(_encode_auth('username%3Apassword'))
'dXNlcm5hbWU6cGFzc3dvcmQ='
Long auth strings should not cause a newline to be inserted.
>>> long_auth = 'username:' + 'password'*10
>>> chr(1... |
A function compatible with Python 2.3-3.3 that will encode
auth from a URL suitable for an HTTP header.
>>> str(_encode_auth('username%3Apassword'))
'dXNlcm5hbWU6cGFzc3dvcmQ=' | def _encode_auth(auth):
"""
A function compatible with Python 2.3-3.3 that will encode
auth from a URL suitable for an HTTP header.
>>> str(_encode_auth('username%3Apassword'))
'dXNlcm5hbWU6cGFzc3dvcmQ='
Long auth strings should not cause a newline to be inserted.
>>> long_auth = 'username:... | [
"def",
"_encode_auth",
"(",
"auth",
")",
":",
"auth_s",
"=",
"urllib",
".",
"parse",
".",
"unquote",
"(",
"auth",
")",
"# convert to bytes",
"auth_bytes",
"=",
"auth_s",
".",
"encode",
"(",
")",
"encoded_bytes",
"=",
"base64",
".",
"b64encode",
"(",
"auth_... | [
972,
0
] | [
991,
36
] | python | en | ['en', 'error', 'th'] | False |
open_with_auth | (url, opener=urllib.request.urlopen) | Open a urllib2 request, handling HTTP authentication | Open a urllib2 request, handling HTTP authentication | def open_with_auth(url, opener=urllib.request.urlopen):
"""Open a urllib2 request, handling HTTP authentication"""
parsed = urllib.parse.urlparse(url)
scheme, netloc, path, params, query, frag = parsed
# Double scheme does not raise on macOS as revealed by a
# failing test. We would expect "nonnum... | [
"def",
"open_with_auth",
"(",
"url",
",",
"opener",
"=",
"urllib",
".",
"request",
".",
"urlopen",
")",
":",
"parsed",
"=",
"urllib",
".",
"parse",
".",
"urlparse",
"(",
"url",
")",
"scheme",
",",
"netloc",
",",
"path",
",",
"params",
",",
"query",
"... | [
1049,
0
] | [
1092,
13
] | python | en | ['en', 'lb', 'en'] | True |
_splituser | (host) | splituser('user[:passwd]@host[:port]')
--> 'user[:passwd]', 'host[:port]'. | splituser('user[:passwd] | def _splituser(host):
"""splituser('user[:passwd]@host[:port]')
--> 'user[:passwd]', 'host[:port]'."""
user, delim, host = host.rpartition('@')
return (user if delim else None), host | [
"def",
"_splituser",
"(",
"host",
")",
":",
"user",
",",
"delim",
",",
"host",
"=",
"host",
".",
"rpartition",
"(",
"'@'",
")",
"return",
"(",
"user",
"if",
"delim",
"else",
"None",
")",
",",
"host"
] | [
1096,
0
] | [
1100,
42
] | python | en | ['en', 'no', 'sw'] | False |
local_open | (url) | Read a local path, with special support for directories | Read a local path, with special support for directories | def local_open(url):
"""Read a local path, with special support for directories"""
scheme, server, path, param, query, frag = urllib.parse.urlparse(url)
filename = urllib.request.url2pathname(path)
if os.path.isfile(filename):
return urllib.request.urlopen(url)
elif path.endswith('/') and os... | [
"def",
"local_open",
"(",
"url",
")",
":",
"scheme",
",",
"server",
",",
"path",
",",
"param",
",",
"query",
",",
"frag",
"=",
"urllib",
".",
"parse",
".",
"urlparse",
"(",
"url",
")",
"filename",
"=",
"urllib",
".",
"request",
".",
"url2pathname",
"... | [
1111,
0
] | [
1139,
77
] | python | en | ['en', 'en', 'en'] | True |
ContentChecker.feed | (self, block) |
Feed a block of data to the hash.
|
Feed a block of data to the hash.
| def feed(self, block):
"""
Feed a block of data to the hash.
"""
return | [
"def",
"feed",
"(",
"self",
",",
"block",
")",
":",
"return"
] | [
245,
4
] | [
249,
14
] | python | en | ['en', 'error', 'th'] | False |
ContentChecker.is_valid | (self) |
Check the hash. Return False if validation fails.
|
Check the hash. Return False if validation fails.
| def is_valid(self):
"""
Check the hash. Return False if validation fails.
"""
return True | [
"def",
"is_valid",
"(",
"self",
")",
":",
"return",
"True"
] | [
251,
4
] | [
255,
19
] | python | en | ['en', 'error', 'th'] | False |
ContentChecker.report | (self, reporter, template) |
Call reporter with information about the checker (hash name)
substituted into the template.
|
Call reporter with information about the checker (hash name)
substituted into the template.
| def report(self, reporter, template):
"""
Call reporter with information about the checker (hash name)
substituted into the template.
"""
return | [
"def",
"report",
"(",
"self",
",",
"reporter",
",",
"template",
")",
":",
"return"
] | [
257,
4
] | [
262,
14
] | python | en | ['en', 'error', 'th'] | False |
HashChecker.from_url | (cls, url) | Construct a (possibly null) ContentChecker from a URL | Construct a (possibly null) ContentChecker from a URL | def from_url(cls, url):
"Construct a (possibly null) ContentChecker from a URL"
fragment = urllib.parse.urlparse(url)[-1]
if not fragment:
return ContentChecker()
match = cls.pattern.search(fragment)
if not match:
return ContentChecker()
return cls... | [
"def",
"from_url",
"(",
"cls",
",",
"url",
")",
":",
"fragment",
"=",
"urllib",
".",
"parse",
".",
"urlparse",
"(",
"url",
")",
"[",
"-",
"1",
"]",
"if",
"not",
"fragment",
":",
"return",
"ContentChecker",
"(",
")",
"match",
"=",
"cls",
".",
"patte... | [
277,
4
] | [
285,
39
] | python | en | ['en', 'en', 'en'] | True |
PackageIndex.process_url | (self, url, retrieve=False) | Evaluate a URL as a possible download, and maybe retrieve it | Evaluate a URL as a possible download, and maybe retrieve it | def process_url(self, url, retrieve=False):
"""Evaluate a URL as a possible download, and maybe retrieve it"""
if url in self.scanned_urls and not retrieve:
return
self.scanned_urls[url] = True
if not URL_SCHEME(url):
self.process_filename(url)
return
... | [
"def",
"process_url",
"(",
"self",
",",
"url",
",",
"retrieve",
"=",
"False",
")",
":",
"if",
"url",
"in",
"self",
".",
"scanned_urls",
"and",
"not",
"retrieve",
":",
"return",
"self",
".",
"scanned_urls",
"[",
"url",
"]",
"=",
"True",
"if",
"not",
"... | [
322,
4
] | [
373,
48
] | python | en | ['en', 'en', 'en'] | True |
PackageIndex.process_index | (self, url, page) | Process the contents of a PyPI page | Process the contents of a PyPI page | def process_index(self, url, page):
"""Process the contents of a PyPI page"""
def scan(link):
# Process a URL to see if it's for a package page
if link.startswith(self.index_url):
parts = list(map(
urllib.parse.unquote, link[len(self.index_url... | [
"def",
"process_index",
"(",
"self",
",",
"url",
",",
"page",
")",
":",
"def",
"scan",
"(",
"link",
")",
":",
"# Process a URL to see if it's for a package page",
"if",
"link",
".",
"startswith",
"(",
"self",
".",
"index_url",
")",
":",
"parts",
"=",
"list",... | [
430,
4
] | [
471,
21
] | python | en | ['en', 'en', 'en'] | True |
PackageIndex.check_hash | (self, checker, filename, tfp) |
checker is a ContentChecker
|
checker is a ContentChecker
| def check_hash(self, checker, filename, tfp):
"""
checker is a ContentChecker
"""
checker.report(
self.debug,
"Validating %%s checksum for %s" % filename)
if not checker.is_valid():
tfp.close()
os.unlink(filename)
raise ... | [
"def",
"check_hash",
"(",
"self",
",",
"checker",
",",
"filename",
",",
"tfp",
")",
":",
"checker",
".",
"report",
"(",
"self",
".",
"debug",
",",
"\"Validating %%s checksum for %s\"",
"%",
"filename",
")",
"if",
"not",
"checker",
".",
"is_valid",
"(",
")"... | [
512,
4
] | [
526,
13
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.add_find_links | (self, urls) | Add `urls` to the list that will be prescanned for searches | Add `urls` to the list that will be prescanned for searches | def add_find_links(self, urls):
"""Add `urls` to the list that will be prescanned for searches"""
for url in urls:
if (
self.to_scan is None # if we have already "gone online"
or not URL_SCHEME(url) # or it's a local file/directory
or url.sta... | [
"def",
"add_find_links",
"(",
"self",
",",
"urls",
")",
":",
"for",
"url",
"in",
"urls",
":",
"if",
"(",
"self",
".",
"to_scan",
"is",
"None",
"# if we have already \"gone online\"",
"or",
"not",
"URL_SCHEME",
"(",
"url",
")",
"# or it's a local file/directory",... | [
528,
4
] | [
541,
40
] | python | en | ['en', 'en', 'en'] | True |
PackageIndex.prescan | (self) | Scan urls scheduled for prescanning (e.g. --find-links) | Scan urls scheduled for prescanning (e.g. --find-links) | def prescan(self):
"""Scan urls scheduled for prescanning (e.g. --find-links)"""
if self.to_scan:
list(map(self.scan_url, self.to_scan))
self.to_scan = None | [
"def",
"prescan",
"(",
"self",
")",
":",
"if",
"self",
".",
"to_scan",
":",
"list",
"(",
"map",
"(",
"self",
".",
"scan_url",
",",
"self",
".",
"to_scan",
")",
")",
"self",
".",
"to_scan",
"=",
"None"
] | [
543,
4
] | [
547,
27
] | python | en | ['en', 'de', 'en'] | True |
PackageIndex.download | (self, spec, tmpdir) | Locate and/or download `spec` to `tmpdir`, returning a local path
`spec` may be a ``Requirement`` object, or a string containing a URL,
an existing local filename, or a project/version requirement spec
(i.e. the string form of a ``Requirement`` object). If it is the URL
of a .py file w... | Locate and/or download `spec` to `tmpdir`, returning a local path | def download(self, spec, tmpdir):
"""Locate and/or download `spec` to `tmpdir`, returning a local path
`spec` may be a ``Requirement`` object, or a string containing a URL,
an existing local filename, or a project/version requirement spec
(i.e. the string form of a ``Requirement`` objec... | [
"def",
"download",
"(",
"self",
",",
"spec",
",",
"tmpdir",
")",
":",
"if",
"not",
"isinstance",
"(",
"spec",
",",
"Requirement",
")",
":",
"scheme",
"=",
"URL_SCHEME",
"(",
"spec",
")",
"if",
"scheme",
":",
"# It's a url, download it to tmpdir",
"found",
... | [
559,
4
] | [
591,
79
] | python | en | ['en', 'en', 'en'] | True |
PackageIndex.fetch_distribution | (
self, requirement, tmpdir, force_scan=False, source=False,
develop_ok=False, local_index=None) | Obtain a distribution suitable for fulfilling `requirement`
`requirement` must be a ``pkg_resources.Requirement`` instance.
If necessary, or if the `force_scan` flag is set, the requirement is
searched for in the (online) package index as well as the locally
installed packages. If a di... | Obtain a distribution suitable for fulfilling `requirement` | def fetch_distribution(
self, requirement, tmpdir, force_scan=False, source=False,
develop_ok=False, local_index=None):
"""Obtain a distribution suitable for fulfilling `requirement`
`requirement` must be a ``pkg_resources.Requirement`` instance.
If necessary, or if the ... | [
"def",
"fetch_distribution",
"(",
"self",
",",
"requirement",
",",
"tmpdir",
",",
"force_scan",
"=",
"False",
",",
"source",
"=",
"False",
",",
"develop_ok",
"=",
"False",
",",
"local_index",
"=",
"None",
")",
":",
"# process a Requirement",
"self",
".",
"in... | [
593,
4
] | [
667,
62
] | python | en | ['en', 'en', 'en'] | True |
PackageIndex.fetch | (self, requirement, tmpdir, force_scan=False, source=False) | Obtain a file suitable for fulfilling `requirement`
DEPRECATED; use the ``fetch_distribution()`` method now instead. For
backward compatibility, this routine is identical but returns the
``location`` of the downloaded distribution instead of a distribution
object.
| Obtain a file suitable for fulfilling `requirement` | def fetch(self, requirement, tmpdir, force_scan=False, source=False):
"""Obtain a file suitable for fulfilling `requirement`
DEPRECATED; use the ``fetch_distribution()`` method now instead. For
backward compatibility, this routine is identical but returns the
``location`` of the downlo... | [
"def",
"fetch",
"(",
"self",
",",
"requirement",
",",
"tmpdir",
",",
"force_scan",
"=",
"False",
",",
"source",
"=",
"False",
")",
":",
"dist",
"=",
"self",
".",
"fetch_distribution",
"(",
"requirement",
",",
"tmpdir",
",",
"force_scan",
",",
"source",
"... | [
669,
4
] | [
680,
19
] | python | en | ['en', 'en', 'en'] | True |
PyPIConfig.__init__ | (self) |
Load from ~/.pypirc
|
Load from ~/.pypirc
| def __init__(self):
"""
Load from ~/.pypirc
"""
defaults = dict.fromkeys(['username', 'password', 'repository'], '')
configparser.RawConfigParser.__init__(self, defaults)
rc = os.path.join(os.path.expanduser('~'), '.pypirc')
if os.path.exists(rc):
sel... | [
"def",
"__init__",
"(",
"self",
")",
":",
"defaults",
"=",
"dict",
".",
"fromkeys",
"(",
"[",
"'username'",
",",
"'password'",
",",
"'repository'",
"]",
",",
"''",
")",
"configparser",
".",
"RawConfigParser",
".",
"__init__",
"(",
"self",
",",
"defaults",
... | [
1012,
4
] | [
1021,
25
] | python | en | ['en', 'error', 'th'] | False |
PyPIConfig.find_credential | (self, url) |
If the URL indicated appears to be a repository defined in this
config, return the credential for that repository.
|
If the URL indicated appears to be a repository defined in this
config, return the credential for that repository.
| def find_credential(self, url):
"""
If the URL indicated appears to be a repository defined in this
config, return the credential for that repository.
"""
for repository, cred in self.creds_by_repository.items():
if url.startswith(repository):
return c... | [
"def",
"find_credential",
"(",
"self",
",",
"url",
")",
":",
"for",
"repository",
",",
"cred",
"in",
"self",
".",
"creds_by_repository",
".",
"items",
"(",
")",
":",
"if",
"url",
".",
"startswith",
"(",
"repository",
")",
":",
"return",
"cred"
] | [
1039,
4
] | [
1046,
27
] | python | en | ['en', 'error', 'th'] | False |
PostGISAdapter.__init__ | (self, geom) | Initializes on the geometry. | Initializes on the geometry. | def __init__(self, geom):
"Initializes on the geometry."
# Getting the WKB (in string form, to allow easy pickling of
# the adaptor) and the SRID from the geometry.
self.ewkb = bytes(geom.ewkb)
self.srid = geom.srid
self._adapter = Binary(self.ewkb) | [
"def",
"__init__",
"(",
"self",
",",
"geom",
")",
":",
"# Getting the WKB (in string form, to allow easy pickling of",
"# the adaptor) and the SRID from the geometry.",
"self",
".",
"ewkb",
"=",
"bytes",
"(",
"geom",
".",
"ewkb",
")",
"self",
".",
"srid",
"=",
"geom",... | [
10,
4
] | [
16,
41
] | python | en | ['en', 'en', 'en'] | True |
PostGISAdapter.prepare | (self, conn) |
This method allows escaping the binary in the style required by the
server's `standard_conforming_string` setting.
|
This method allows escaping the binary in the style required by the
server's `standard_conforming_string` setting.
| def prepare(self, conn):
"""
This method allows escaping the binary in the style required by the
server's `standard_conforming_string` setting.
"""
self._adapter.prepare(conn) | [
"def",
"prepare",
"(",
"self",
",",
"conn",
")",
":",
"self",
".",
"_adapter",
".",
"prepare",
"(",
"conn",
")"
] | [
33,
4
] | [
38,
35
] | python | en | ['en', 'error', 'th'] | False |
PostGISAdapter.getquoted | (self) | Returns a properly quoted string for use in PostgreSQL/PostGIS. | Returns a properly quoted string for use in PostgreSQL/PostGIS. | def getquoted(self):
"Returns a properly quoted string for use in PostgreSQL/PostGIS."
# psycopg will figure out whether to use E'\\000' or '\000'
return str('ST_GeomFromEWKB(%s)' % self._adapter.getquoted().decode()) | [
"def",
"getquoted",
"(",
"self",
")",
":",
"# psycopg will figure out whether to use E'\\\\000' or '\\000'",
"return",
"str",
"(",
"'ST_GeomFromEWKB(%s)'",
"%",
"self",
".",
"_adapter",
".",
"getquoted",
"(",
")",
".",
"decode",
"(",
")",
")"
] | [
40,
4
] | [
43,
78
] | python | en | ['en', 'en', 'en'] | True |
stringfilter | (func) |
Decorator for filters which should only receive strings. The object
passed as the first positional argument will be converted to a string.
|
Decorator for filters which should only receive strings. The object
passed as the first positional argument will be converted to a string.
| def stringfilter(func):
"""
Decorator for filters which should only receive strings. The object
passed as the first positional argument will be converted to a string.
"""
def _dec(*args, **kwargs):
args = list(args)
args[0] = str(args[0])
if (isinstance(args[0], SafeData) and... | [
"def",
"stringfilter",
"(",
"func",
")",
":",
"def",
"_dec",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"list",
"(",
"args",
")",
"args",
"[",
"0",
"]",
"=",
"str",
"(",
"args",
"[",
"0",
"]",
")",
"if",
"(",
"isinstanc... | [
34,
0
] | [
52,
28
] | python | en | ['en', 'error', 'th'] | False |
addslashes | (value) |
Add slashes before quotes. Useful for escaping strings in CSV, for
example. Less useful for escaping JavaScript; use the ``escapejs``
filter instead.
|
Add slashes before quotes. Useful for escaping strings in CSV, for
example. Less useful for escaping JavaScript; use the ``escapejs``
filter instead.
| def addslashes(value):
"""
Add slashes before quotes. Useful for escaping strings in CSV, for
example. Less useful for escaping JavaScript; use the ``escapejs``
filter instead.
"""
return value.replace('\\', '\\\\').replace('"', '\\"').replace("'", "\\'") | [
"def",
"addslashes",
"(",
"value",
")",
":",
"return",
"value",
".",
"replace",
"(",
"'\\\\'",
",",
"'\\\\\\\\'",
")",
".",
"replace",
"(",
"'\"'",
",",
"'\\\\\"'",
")",
".",
"replace",
"(",
"\"'\"",
",",
"\"\\\\'\"",
")"
] | [
61,
0
] | [
67,
78
] | python | en | ['en', 'error', 'th'] | False |
capfirst | (value) | Capitalize the first character of the value. | Capitalize the first character of the value. | def capfirst(value):
"""Capitalize the first character of the value."""
return value and value[0].upper() + value[1:] | [
"def",
"capfirst",
"(",
"value",
")",
":",
"return",
"value",
"and",
"value",
"[",
"0",
"]",
".",
"upper",
"(",
")",
"+",
"value",
"[",
"1",
":",
"]"
] | [
72,
0
] | [
74,
49
] | python | en | ['en', 'en', 'en'] | True |
escapejs_filter | (value) | Hex encode characters for use in JavaScript strings. | Hex encode characters for use in JavaScript strings. | def escapejs_filter(value):
"""Hex encode characters for use in JavaScript strings."""
return escapejs(value) | [
"def",
"escapejs_filter",
"(",
"value",
")",
":",
"return",
"escapejs",
"(",
"value",
")"
] | [
79,
0
] | [
81,
26
] | python | en | ['en', 'en', 'en'] | True |
json_script | (value, element_id) |
Output value JSON-encoded, wrapped in a <script type="application/json">
tag.
|
Output value JSON-encoded, wrapped in a <script type="application/json">
tag.
| def json_script(value, element_id):
"""
Output value JSON-encoded, wrapped in a <script type="application/json">
tag.
"""
return _json_script(value, element_id) | [
"def",
"json_script",
"(",
"value",
",",
"element_id",
")",
":",
"return",
"_json_script",
"(",
"value",
",",
"element_id",
")"
] | [
85,
0
] | [
90,
42
] | python | en | ['en', 'error', 'th'] | False |
floatformat | (text, arg=-1) |
Display a float to a specified number of decimal places.
If called without an argument, display the floating point number with one
decimal place -- but only if there's a decimal place to be displayed:
* num1 = 34.23234
* num2 = 34.00000
* num3 = 34.26000
* {{ num1|floatformat }} displays ... |
Display a float to a specified number of decimal places. | def floatformat(text, arg=-1):
"""
Display a float to a specified number of decimal places.
If called without an argument, display the floating point number with one
decimal place -- but only if there's a decimal place to be displayed:
* num1 = 34.23234
* num2 = 34.00000
* num3 = 34.26000
... | [
"def",
"floatformat",
"(",
"text",
",",
"arg",
"=",
"-",
"1",
")",
":",
"try",
":",
"input_val",
"=",
"repr",
"(",
"text",
")",
"d",
"=",
"Decimal",
"(",
"input_val",
")",
"except",
"InvalidOperation",
":",
"try",
":",
"d",
"=",
"Decimal",
"(",
"st... | [
94,
0
] | [
162,
59
] | python | en | ['en', 'error', 'th'] | False |
iriencode | (value) | Escape an IRI value for use in a URL. | Escape an IRI value for use in a URL. | def iriencode(value):
"""Escape an IRI value for use in a URL."""
return iri_to_uri(value) | [
"def",
"iriencode",
"(",
"value",
")",
":",
"return",
"iri_to_uri",
"(",
"value",
")"
] | [
167,
0
] | [
169,
28
] | python | en | ['en', 'en', 'en'] | True |
linenumbers | (value, autoescape=True) | Display text with line numbers. | Display text with line numbers. | def linenumbers(value, autoescape=True):
"""Display text with line numbers."""
lines = value.split('\n')
# Find the maximum width of the line count, for use with zero padding
# string format command
width = str(len(str(len(lines))))
if not autoescape or isinstance(value, SafeData):
for i... | [
"def",
"linenumbers",
"(",
"value",
",",
"autoescape",
"=",
"True",
")",
":",
"lines",
"=",
"value",
".",
"split",
"(",
"'\\n'",
")",
"# Find the maximum width of the line count, for use with zero padding",
"# string format command",
"width",
"=",
"str",
"(",
"len",
... | [
174,
0
] | [
186,
38
] | python | en | ['en', 'en', 'en'] | True |
lower | (value) | Convert a string into all lowercase. | Convert a string into all lowercase. | def lower(value):
"""Convert a string into all lowercase."""
return value.lower() | [
"def",
"lower",
"(",
"value",
")",
":",
"return",
"value",
".",
"lower",
"(",
")"
] | [
191,
0
] | [
193,
24
] | python | en | ['en', 'en', 'en'] | True |
make_list | (value) |
Return the value turned into a list.
For an integer, it's a list of digits.
For a string, it's a list of characters.
|
Return the value turned into a list. | def make_list(value):
"""
Return the value turned into a list.
For an integer, it's a list of digits.
For a string, it's a list of characters.
"""
return list(value) | [
"def",
"make_list",
"(",
"value",
")",
":",
"return",
"list",
"(",
"value",
")"
] | [
198,
0
] | [
205,
22
] | python | en | ['en', 'error', 'th'] | False |
slugify | (value) |
Convert to ASCII. Convert spaces to hyphens. Remove characters that aren't
alphanumerics, underscores, or hyphens. Convert to lowercase. Also strip
leading and trailing whitespace.
|
Convert to ASCII. Convert spaces to hyphens. Remove characters that aren't
alphanumerics, underscores, or hyphens. Convert to lowercase. Also strip
leading and trailing whitespace.
| def slugify(value):
"""
Convert to ASCII. Convert spaces to hyphens. Remove characters that aren't
alphanumerics, underscores, or hyphens. Convert to lowercase. Also strip
leading and trailing whitespace.
"""
return _slugify(value) | [
"def",
"slugify",
"(",
"value",
")",
":",
"return",
"_slugify",
"(",
"value",
")"
] | [
210,
0
] | [
216,
26
] | python | en | ['en', 'error', 'th'] | False |
stringformat | (value, arg) |
Format the variable according to the arg, a string formatting specifier.
This specifier uses Python string formatting syntax, with the exception
that the leading "%" is dropped.
See https://docs.python.org/library/stdtypes.html#printf-style-string-formatting
for documentation of Python string for... |
Format the variable according to the arg, a string formatting specifier. | def stringformat(value, arg):
"""
Format the variable according to the arg, a string formatting specifier.
This specifier uses Python string formatting syntax, with the exception
that the leading "%" is dropped.
See https://docs.python.org/library/stdtypes.html#printf-style-string-formatting
f... | [
"def",
"stringformat",
"(",
"value",
",",
"arg",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"tuple",
")",
":",
"value",
"=",
"str",
"(",
"value",
")",
"try",
":",
"return",
"(",
"\"%\"",
"+",
"str",
"(",
"arg",
")",
")",
"%",
"value",
"exce... | [
220,
0
] | [
235,
17
] | python | en | ['en', 'error', 'th'] | False |
title | (value) | Convert a string into titlecase. | Convert a string into titlecase. | def title(value):
"""Convert a string into titlecase."""
t = re.sub("([a-z])'([A-Z])", lambda m: m.group(0).lower(), value.title())
return re.sub(r"\d([A-Z])", lambda m: m.group(0).lower(), t) | [
"def",
"title",
"(",
"value",
")",
":",
"t",
"=",
"re",
".",
"sub",
"(",
"\"([a-z])'([A-Z])\"",
",",
"lambda",
"m",
":",
"m",
".",
"group",
"(",
"0",
")",
".",
"lower",
"(",
")",
",",
"value",
".",
"title",
"(",
")",
")",
"return",
"re",
".",
... | [
240,
0
] | [
243,
64
] | python | en | ['en', 'gl', 'en'] | True |
truncatechars | (value, arg) | Truncate a string after `arg` number of characters. | Truncate a string after `arg` number of characters. | def truncatechars(value, arg):
"""Truncate a string after `arg` number of characters."""
try:
length = int(arg)
except ValueError: # Invalid literal for int().
return value # Fail silently.
return Truncator(value).chars(length) | [
"def",
"truncatechars",
"(",
"value",
",",
"arg",
")",
":",
"try",
":",
"length",
"=",
"int",
"(",
"arg",
")",
"except",
"ValueError",
":",
"# Invalid literal for int().",
"return",
"value",
"# Fail silently.",
"return",
"Truncator",
"(",
"value",
")",
".",
... | [
248,
0
] | [
254,
41
] | python | en | ['en', 'en', 'en'] | True |
truncatechars_html | (value, arg) |
Truncate HTML after `arg` number of chars.
Preserve newlines in the HTML.
|
Truncate HTML after `arg` number of chars.
Preserve newlines in the HTML.
| def truncatechars_html(value, arg):
"""
Truncate HTML after `arg` number of chars.
Preserve newlines in the HTML.
"""
try:
length = int(arg)
except ValueError: # invalid literal for int()
return value # Fail silently.
return Truncator(value).chars(length, html=True) | [
"def",
"truncatechars_html",
"(",
"value",
",",
"arg",
")",
":",
"try",
":",
"length",
"=",
"int",
"(",
"arg",
")",
"except",
"ValueError",
":",
"# invalid literal for int()",
"return",
"value",
"# Fail silently.",
"return",
"Truncator",
"(",
"value",
")",
"."... | [
259,
0
] | [
268,
52
] | python | en | ['en', 'error', 'th'] | False |
truncatewords | (value, arg) |
Truncate a string after `arg` number of words.
Remove newlines within the string.
|
Truncate a string after `arg` number of words.
Remove newlines within the string.
| def truncatewords(value, arg):
"""
Truncate a string after `arg` number of words.
Remove newlines within the string.
"""
try:
length = int(arg)
except ValueError: # Invalid literal for int().
return value # Fail silently.
return Truncator(value).words(length, truncate=' …') | [
"def",
"truncatewords",
"(",
"value",
",",
"arg",
")",
":",
"try",
":",
"length",
"=",
"int",
"(",
"arg",
")",
"except",
"ValueError",
":",
"# Invalid literal for int().",
"return",
"value",
"# Fail silently.",
"return",
"Truncator",
"(",
"value",
")",
".",
... | [
273,
0
] | [
282,
58
] | python | en | ['en', 'error', 'th'] | False |
truncatewords_html | (value, arg) |
Truncate HTML after `arg` number of words.
Preserve newlines in the HTML.
|
Truncate HTML after `arg` number of words.
Preserve newlines in the HTML.
| def truncatewords_html(value, arg):
"""
Truncate HTML after `arg` number of words.
Preserve newlines in the HTML.
"""
try:
length = int(arg)
except ValueError: # invalid literal for int()
return value # Fail silently.
return Truncator(value).words(length, html=True, truncat... | [
"def",
"truncatewords_html",
"(",
"value",
",",
"arg",
")",
":",
"try",
":",
"length",
"=",
"int",
"(",
"arg",
")",
"except",
"ValueError",
":",
"# invalid literal for int()",
"return",
"value",
"# Fail silently.",
"return",
"Truncator",
"(",
"value",
")",
"."... | [
287,
0
] | [
296,
69
] | python | en | ['en', 'error', 'th'] | False |
upper | (value) | Convert a string into all uppercase. | Convert a string into all uppercase. | def upper(value):
"""Convert a string into all uppercase."""
return value.upper() | [
"def",
"upper",
"(",
"value",
")",
":",
"return",
"value",
".",
"upper",
"(",
")"
] | [
301,
0
] | [
303,
24
] | python | en | ['en', 'en', 'en'] | True |
urlencode | (value, safe=None) |
Escape a value for use in a URL.
The ``safe`` parameter determines the characters which should not be
escaped by Python's quote() function. If not provided, use the default safe
characters (but an empty string can be provided when *all* characters
should be escaped).
|
Escape a value for use in a URL. | def urlencode(value, safe=None):
"""
Escape a value for use in a URL.
The ``safe`` parameter determines the characters which should not be
escaped by Python's quote() function. If not provided, use the default safe
characters (but an empty string can be provided when *all* characters
should be ... | [
"def",
"urlencode",
"(",
"value",
",",
"safe",
"=",
"None",
")",
":",
"kwargs",
"=",
"{",
"}",
"if",
"safe",
"is",
"not",
"None",
":",
"kwargs",
"[",
"'safe'",
"]",
"=",
"safe",
"return",
"quote",
"(",
"value",
",",
"*",
"*",
"kwargs",
")"
] | [
308,
0
] | [
320,
33
] | python | en | ['en', 'error', 'th'] | False |
urlize | (value, autoescape=True) | Convert URLs in plain text into clickable links. | Convert URLs in plain text into clickable links. | def urlize(value, autoescape=True):
"""Convert URLs in plain text into clickable links."""
return mark_safe(_urlize(value, nofollow=True, autoescape=autoescape)) | [
"def",
"urlize",
"(",
"value",
",",
"autoescape",
"=",
"True",
")",
":",
"return",
"mark_safe",
"(",
"_urlize",
"(",
"value",
",",
"nofollow",
"=",
"True",
",",
"autoescape",
"=",
"autoescape",
")",
")"
] | [
325,
0
] | [
327,
74
] | python | en | ['en', 'lb', 'en'] | True |
urlizetrunc | (value, limit, autoescape=True) |
Convert URLs into clickable links, truncating URLs to the given character
limit, and adding 'rel=nofollow' attribute to discourage spamming.
Argument: Length to truncate URLs to.
|
Convert URLs into clickable links, truncating URLs to the given character
limit, and adding 'rel=nofollow' attribute to discourage spamming. | def urlizetrunc(value, limit, autoescape=True):
"""
Convert URLs into clickable links, truncating URLs to the given character
limit, and adding 'rel=nofollow' attribute to discourage spamming.
Argument: Length to truncate URLs to.
"""
return mark_safe(_urlize(value, trim_url_limit=int(limit), n... | [
"def",
"urlizetrunc",
"(",
"value",
",",
"limit",
",",
"autoescape",
"=",
"True",
")",
":",
"return",
"mark_safe",
"(",
"_urlize",
"(",
"value",
",",
"trim_url_limit",
"=",
"int",
"(",
"limit",
")",
",",
"nofollow",
"=",
"True",
",",
"autoescape",
"=",
... | [
332,
0
] | [
339,
101
] | python | en | ['en', 'error', 'th'] | False |
wordcount | (value) | Return the number of words. | Return the number of words. | def wordcount(value):
"""Return the number of words."""
return len(value.split()) | [
"def",
"wordcount",
"(",
"value",
")",
":",
"return",
"len",
"(",
"value",
".",
"split",
"(",
")",
")"
] | [
344,
0
] | [
346,
29
] | 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.