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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
TestSigma.test_axis | (self) | Test sigma calculation when axis is not None | Test sigma calculation when axis is not None | def test_axis(self):
"""Test sigma calculation when axis is not None"""
self.mean, self.sigma = sigmaclip.calcsigma(self.data2d, self.errors2d, errors_as_weight=True)
self.assertAlmostEqual(self.mean, 2.75)
self.assertAlmostEqual(self.sigma, 1.898753053)
self.mean, self.sigma... | [
"def",
"test_axis",
"(",
"self",
")",
":",
"self",
".",
"mean",
",",
"self",
".",
"sigma",
"=",
"sigmaclip",
".",
"calcsigma",
"(",
"self",
".",
"data2d",
",",
"self",
".",
"errors2d",
",",
"errors_as_weight",
"=",
"True",
")",
"self",
".",
"assertAlmo... | [
32,
4
] | [
71,
70
] | python | en | ['en', 'en', 'en'] | True |
TestClip.test_unweighted | (self) | Perform unweighted sigma clipping | Perform unweighted sigma clipping | def test_unweighted(self):
"""Perform unweighted sigma clipping"""
INDICES = numpy.ones(len(self.data), dtype=numpy.bool)
indices, niter = sigmaclip.sigmaclip(data=self.data, errors=None, niter=0,
siglow=1., sighigh=1., use_median=False)
self.assertEqual((ind... | [
"def",
"test_unweighted",
"(",
"self",
")",
":",
"INDICES",
"=",
"numpy",
".",
"ones",
"(",
"len",
"(",
"self",
".",
"data",
")",
",",
"dtype",
"=",
"numpy",
".",
"bool",
")",
"indices",
",",
"niter",
"=",
"sigmaclip",
".",
"sigmaclip",
"(",
"data",
... | [
83,
4
] | [
99,
58
] | python | en | ['de', 'en', 'en'] | True |
TestClip.test_weighted | (self) | Perform weighted sigma clipping | Perform weighted sigma clipping | def test_weighted(self):
"""Perform weighted sigma clipping"""
INDICES = numpy.ones(len(self.data), dtype=numpy.bool)
indices, niter = sigmaclip.sigmaclip(data=self.data, errors=self.errors, niter=0,
siglow=1., sighigh=1., use_median=False)
self.assertEqual((... | [
"def",
"test_weighted",
"(",
"self",
")",
":",
"INDICES",
"=",
"numpy",
".",
"ones",
"(",
"len",
"(",
"self",
".",
"data",
")",
",",
"dtype",
"=",
"numpy",
".",
"bool",
")",
"indices",
",",
"niter",
"=",
"sigmaclip",
".",
"sigmaclip",
"(",
"data",
... | [
101,
4
] | [
128,
58
] | python | en | ['de', 'en', 'en'] | True |
TestClip.test_clip2background | (self) | Clip until no more data are clipped | Clip until no more data are clipped | def test_clip2background(self):
"""Clip until no more data are clipped"""
indices, niter = sigmaclip.sigmaclip(data=self.data, errors=self.errors,
niter=-100, siglow=3., sighigh=3.)
self.assertEqual(niter, 2)
indices, niter = sigmaclip.sigmaclip(data=... | [
"def",
"test_clip2background",
"(",
"self",
")",
":",
"indices",
",",
"niter",
"=",
"sigmaclip",
".",
"sigmaclip",
"(",
"data",
"=",
"self",
".",
"data",
",",
"errors",
"=",
"self",
".",
"errors",
",",
"niter",
"=",
"-",
"100",
",",
"siglow",
"=",
"3... | [
130,
4
] | [
149,
34
] | python | en | ['en', 'it', 'en'] | True |
ifmeth | (parser, token) |
Used to mark template blocks for Swagger/OpenAPI output.
If the specified method matches the *current* method in Swagger/OpenAPI
generation, show the block. Otherwise, the block is omitted.
{% ifmeth GET %}
Make a GET request to...
{% endifmeth %}
{% ifmeth PUT PATCH %}
... |
Used to mark template blocks for Swagger/OpenAPI output.
If the specified method matches the *current* method in Swagger/OpenAPI
generation, show the block. Otherwise, the block is omitted. | def ifmeth(parser, token):
"""
Used to mark template blocks for Swagger/OpenAPI output.
If the specified method matches the *current* method in Swagger/OpenAPI
generation, show the block. Otherwise, the block is omitted.
{% ifmeth GET %}
Make a GET request to...
{% endifmeth %}... | [
"def",
"ifmeth",
"(",
"parser",
",",
"token",
")",
":",
"allowed_methods",
"=",
"[",
"m",
".",
"upper",
"(",
")",
"for",
"m",
"in",
"token",
".",
"split_contents",
"(",
")",
"[",
"1",
":",
"]",
"]",
"nodelist",
"=",
"parser",
".",
"parse",
"(",
"... | [
20,
0
] | [
37,
54
] | python | en | ['en', 'error', 'th'] | False |
check_module | (feature) |
Checks if a module is available.
:param feature: The module to check for.
:returns: ``True`` if available, ``False`` otherwise.
:raises ValueError: If the module is not defined in this version of Pillow.
|
Checks if a module is available. | def check_module(feature):
"""
Checks if a module is available.
:param feature: The module to check for.
:returns: ``True`` if available, ``False`` otherwise.
:raises ValueError: If the module is not defined in this version of Pillow.
"""
if not (feature in modules):
raise ValueErro... | [
"def",
"check_module",
"(",
"feature",
")",
":",
"if",
"not",
"(",
"feature",
"in",
"modules",
")",
":",
"raise",
"ValueError",
"(",
"f\"Unknown module {feature}\"",
")",
"module",
",",
"ver",
"=",
"modules",
"[",
"feature",
"]",
"try",
":",
"__import__",
... | [
18,
0
] | [
35,
20
] | python | en | ['en', 'error', 'th'] | False |
version_module | (feature) |
:param feature: The module to check for.
:returns:
The loaded version number as a string, or ``None`` if unknown or not available.
:raises ValueError: If the module is not defined in this version of Pillow.
|
:param feature: The module to check for.
:returns:
The loaded version number as a string, or ``None`` if unknown or not available.
:raises ValueError: If the module is not defined in this version of Pillow.
| def version_module(feature):
"""
:param feature: The module to check for.
:returns:
The loaded version number as a string, or ``None`` if unknown or not available.
:raises ValueError: If the module is not defined in this version of Pillow.
"""
if not check_module(feature):
return... | [
"def",
"version_module",
"(",
"feature",
")",
":",
"if",
"not",
"check_module",
"(",
"feature",
")",
":",
"return",
"None",
"module",
",",
"ver",
"=",
"modules",
"[",
"feature",
"]",
"if",
"ver",
"is",
"None",
":",
"return",
"None",
"return",
"getattr",
... | [
38,
0
] | [
53,
59
] | python | en | ['en', 'error', 'th'] | False |
get_supported_modules | () |
:returns: A list of all supported modules.
|
:returns: A list of all supported modules.
| def get_supported_modules():
"""
:returns: A list of all supported modules.
"""
return [f for f in modules if check_module(f)] | [
"def",
"get_supported_modules",
"(",
")",
":",
"return",
"[",
"f",
"for",
"f",
"in",
"modules",
"if",
"check_module",
"(",
"f",
")",
"]"
] | [
56,
0
] | [
60,
50
] | python | en | ['en', 'error', 'th'] | False |
check_codec | (feature) |
Checks if a codec is available.
:param feature: The codec to check for.
:returns: ``True`` if available, ``False`` otherwise.
:raises ValueError: If the codec is not defined in this version of Pillow.
|
Checks if a codec is available. | def check_codec(feature):
"""
Checks if a codec is available.
:param feature: The codec to check for.
:returns: ``True`` if available, ``False`` otherwise.
:raises ValueError: If the codec is not defined in this version of Pillow.
"""
if feature not in codecs:
raise ValueError(f"Unk... | [
"def",
"check_codec",
"(",
"feature",
")",
":",
"if",
"feature",
"not",
"in",
"codecs",
":",
"raise",
"ValueError",
"(",
"f\"Unknown codec {feature}\"",
")",
"codec",
",",
"lib",
"=",
"codecs",
"[",
"feature",
"]",
"return",
"codec",
"+",
"\"_encoder\"",
"in... | [
71,
0
] | [
84,
48
] | python | en | ['en', 'error', 'th'] | False |
version_codec | (feature) |
:param feature: The codec to check for.
:returns:
The version number as a string, or ``None`` if not available.
Checked at compile time for ``jpg``, run-time otherwise.
:raises ValueError: If the codec is not defined in this version of Pillow.
|
:param feature: The codec to check for.
:returns:
The version number as a string, or ``None`` if not available.
Checked at compile time for ``jpg``, run-time otherwise.
:raises ValueError: If the codec is not defined in this version of Pillow.
| def version_codec(feature):
"""
:param feature: The codec to check for.
:returns:
The version number as a string, or ``None`` if not available.
Checked at compile time for ``jpg``, run-time otherwise.
:raises ValueError: If the codec is not defined in this version of Pillow.
"""
... | [
"def",
"version_codec",
"(",
"feature",
")",
":",
"if",
"not",
"check_codec",
"(",
"feature",
")",
":",
"return",
"None",
"codec",
",",
"lib",
"=",
"codecs",
"[",
"feature",
"]",
"version",
"=",
"getattr",
"(",
"Image",
".",
"core",
",",
"lib",
"+",
... | [
87,
0
] | [
105,
18
] | python | en | ['en', 'error', 'th'] | False |
get_supported_codecs | () |
:returns: A list of all supported codecs.
|
:returns: A list of all supported codecs.
| def get_supported_codecs():
"""
:returns: A list of all supported codecs.
"""
return [f for f in codecs if check_codec(f)] | [
"def",
"get_supported_codecs",
"(",
")",
":",
"return",
"[",
"f",
"for",
"f",
"in",
"codecs",
"if",
"check_codec",
"(",
"f",
")",
"]"
] | [
108,
0
] | [
112,
48
] | python | en | ['en', 'error', 'th'] | False |
check_feature | (feature) |
Checks if a feature is available.
:param feature: The feature to check for.
:returns: ``True`` if available, ``False`` if unavailable, ``None`` if unknown.
:raises ValueError: If the feature is not defined in this version of Pillow.
|
Checks if a feature is available. | def check_feature(feature):
"""
Checks if a feature is available.
:param feature: The feature to check for.
:returns: ``True`` if available, ``False`` if unavailable, ``None`` if unknown.
:raises ValueError: If the feature is not defined in this version of Pillow.
"""
if feature not in feat... | [
"def",
"check_feature",
"(",
"feature",
")",
":",
"if",
"feature",
"not",
"in",
"features",
":",
"raise",
"ValueError",
"(",
"f\"Unknown feature {feature}\"",
")",
"module",
",",
"flag",
",",
"ver",
"=",
"features",
"[",
"feature",
"]",
"try",
":",
"imported... | [
126,
0
] | [
143,
19
] | python | en | ['en', 'error', 'th'] | False |
version_feature | (feature) |
:param feature: The feature to check for.
:returns: The version number as a string, or ``None`` if not available.
:raises ValueError: If the feature is not defined in this version of Pillow.
|
:param feature: The feature to check for.
:returns: The version number as a string, or ``None`` if not available.
:raises ValueError: If the feature is not defined in this version of Pillow.
| def version_feature(feature):
"""
:param feature: The feature to check for.
:returns: The version number as a string, or ``None`` if not available.
:raises ValueError: If the feature is not defined in this version of Pillow.
"""
if not check_feature(feature):
return None
module, fla... | [
"def",
"version_feature",
"(",
"feature",
")",
":",
"if",
"not",
"check_feature",
"(",
"feature",
")",
":",
"return",
"None",
"module",
",",
"flag",
",",
"ver",
"=",
"features",
"[",
"feature",
"]",
"if",
"ver",
"is",
"None",
":",
"return",
"None",
"re... | [
146,
0
] | [
160,
59
] | python | en | ['en', 'error', 'th'] | False |
get_supported_features | () |
:returns: A list of all supported features.
|
:returns: A list of all supported features.
| def get_supported_features():
"""
:returns: A list of all supported features.
"""
return [f for f in features if check_feature(f)] | [
"def",
"get_supported_features",
"(",
")",
":",
"return",
"[",
"f",
"for",
"f",
"in",
"features",
"if",
"check_feature",
"(",
"f",
")",
"]"
] | [
163,
0
] | [
167,
52
] | python | en | ['en', 'error', 'th'] | False |
check | (feature) |
:param feature: A module, codec, or feature name.
:returns:
``True`` if the module, codec, or feature is available,
``False`` or ``None`` otherwise.
|
:param feature: A module, codec, or feature name.
:returns:
``True`` if the module, codec, or feature is available,
``False`` or ``None`` otherwise.
| def check(feature):
"""
:param feature: A module, codec, or feature name.
:returns:
``True`` if the module, codec, or feature is available,
``False`` or ``None`` otherwise.
"""
if feature in modules:
return check_module(feature)
if feature in codecs:
return check... | [
"def",
"check",
"(",
"feature",
")",
":",
"if",
"feature",
"in",
"modules",
":",
"return",
"check_module",
"(",
"feature",
")",
"if",
"feature",
"in",
"codecs",
":",
"return",
"check_codec",
"(",
"feature",
")",
"if",
"feature",
"in",
"features",
":",
"r... | [
170,
0
] | [
185,
16
] | python | en | ['en', 'error', 'th'] | False |
version | (feature) |
:param feature:
The module, codec, or feature to check for.
:returns:
The version number as a string, or ``None`` if unknown or not available.
|
:param feature:
The module, codec, or feature to check for.
:returns:
The version number as a string, or ``None`` if unknown or not available.
| def version(feature):
"""
:param feature:
The module, codec, or feature to check for.
:returns:
The version number as a string, or ``None`` if unknown or not available.
"""
if feature in modules:
return version_module(feature)
if feature in codecs:
return version_... | [
"def",
"version",
"(",
"feature",
")",
":",
"if",
"feature",
"in",
"modules",
":",
"return",
"version_module",
"(",
"feature",
")",
"if",
"feature",
"in",
"codecs",
":",
"return",
"version_codec",
"(",
"feature",
")",
"if",
"feature",
"in",
"features",
":"... | [
188,
0
] | [
201,
15
] | python | en | ['en', 'error', 'th'] | False |
get_supported | () |
:returns: A list of all supported modules, features, and codecs.
|
:returns: A list of all supported modules, features, and codecs.
| def get_supported():
"""
:returns: A list of all supported modules, features, and codecs.
"""
ret = get_supported_modules()
ret.extend(get_supported_features())
ret.extend(get_supported_codecs())
return ret | [
"def",
"get_supported",
"(",
")",
":",
"ret",
"=",
"get_supported_modules",
"(",
")",
"ret",
".",
"extend",
"(",
"get_supported_features",
"(",
")",
")",
"ret",
".",
"extend",
"(",
"get_supported_codecs",
"(",
")",
")",
"return",
"ret"
] | [
204,
0
] | [
212,
14
] | python | en | ['en', 'error', 'th'] | False |
pilinfo | (out=None, supported_formats=True) |
Prints information about this installation of Pillow.
This function can be called with ``python -m PIL``.
:param out:
The output stream to print to. Defaults to ``sys.stdout`` if ``None``.
:param supported_formats:
If ``True``, a list of all supported image file formats will be printed... |
Prints information about this installation of Pillow.
This function can be called with ``python -m PIL``. | def pilinfo(out=None, supported_formats=True):
"""
Prints information about this installation of Pillow.
This function can be called with ``python -m PIL``.
:param out:
The output stream to print to. Defaults to ``sys.stdout`` if ``None``.
:param supported_formats:
If ``True``, a li... | [
"def",
"pilinfo",
"(",
"out",
"=",
"None",
",",
"supported_formats",
"=",
"True",
")",
":",
"if",
"out",
"is",
"None",
":",
"out",
"=",
"sys",
".",
"stdout",
"Image",
".",
"init",
"(",
")",
"print",
"(",
"\"-\"",
"*",
"68",
",",
"file",
"=",
"out... | [
215,
0
] | [
312,
37
] | python | en | ['en', 'error', 'th'] | False |
HashedFilesMixin.file_hash | (self, name, content=None) |
Return a hash of the file with the given name and optional content.
|
Return a hash of the file with the given name and optional content.
| def file_hash(self, name, content=None):
"""
Return a hash of the file with the given name and optional content.
"""
if content is None:
return None
md5 = hashlib.md5()
for chunk in content.chunks():
md5.update(chunk)
return md5.hexdigest()... | [
"def",
"file_hash",
"(",
"self",
",",
"name",
",",
"content",
"=",
"None",
")",
":",
"if",
"content",
"is",
"None",
":",
"return",
"None",
"md5",
"=",
"hashlib",
".",
"md5",
"(",
")",
"for",
"chunk",
"in",
"content",
".",
"chunks",
"(",
")",
":",
... | [
78,
4
] | [
87,
35
] | python | en | ['en', 'error', 'th'] | False |
HashedFilesMixin._url | (self, hashed_name_func, name, force=False, hashed_files=None) |
Return the non-hashed URL in DEBUG mode.
|
Return the non-hashed URL in DEBUG mode.
| def _url(self, hashed_name_func, name, force=False, hashed_files=None):
"""
Return the non-hashed URL in DEBUG mode.
"""
if settings.DEBUG and not force:
hashed_name, fragment = name, ''
else:
clean_name, fragment = urldefrag(name)
if urlsplit(... | [
"def",
"_url",
"(",
"self",
",",
"hashed_name_func",
",",
"name",
",",
"force",
"=",
"False",
",",
"hashed_files",
"=",
"None",
")",
":",
"if",
"settings",
".",
"DEBUG",
"and",
"not",
"force",
":",
"hashed_name",
",",
"fragment",
"=",
"name",
",",
"''"... | [
126,
4
] | [
155,
33
] | python | en | ['en', 'error', 'th'] | False |
HashedFilesMixin.url | (self, name, force=False) |
Return the non-hashed URL in DEBUG mode.
|
Return the non-hashed URL in DEBUG mode.
| def url(self, name, force=False):
"""
Return the non-hashed URL in DEBUG mode.
"""
return self._url(self.stored_name, name, force) | [
"def",
"url",
"(",
"self",
",",
"name",
",",
"force",
"=",
"False",
")",
":",
"return",
"self",
".",
"_url",
"(",
"self",
".",
"stored_name",
",",
"name",
",",
"force",
")"
] | [
157,
4
] | [
161,
55
] | python | en | ['en', 'error', 'th'] | False |
HashedFilesMixin.url_converter | (self, name, hashed_files, template=None) |
Return the custom URL converter for the given file name.
|
Return the custom URL converter for the given file name.
| def url_converter(self, name, hashed_files, template=None):
"""
Return the custom URL converter for the given file name.
"""
if template is None:
template = self.default_template
def converter(matchobj):
"""
Convert the matched URL to a normal... | [
"def",
"url_converter",
"(",
"self",
",",
"name",
",",
"hashed_files",
",",
"template",
"=",
"None",
")",
":",
"if",
"template",
"is",
"None",
":",
"template",
"=",
"self",
".",
"default_template",
"def",
"converter",
"(",
"matchobj",
")",
":",
"\"\"\"\n ... | [
163,
4
] | [
215,
24
] | python | en | ['en', 'error', 'th'] | False |
HashedFilesMixin.post_process | (self, paths, dry_run=False, **options) |
Post process the given OrderedDict of files (called from collectstatic).
Processing is actually two separate operations:
1. renaming files to include a hash of their content for cache-busting,
and copying those files to the target storage.
2. adjusting files which contain r... |
Post process the given OrderedDict of files (called from collectstatic). | def post_process(self, paths, dry_run=False, **options):
"""
Post process the given OrderedDict of files (called from collectstatic).
Processing is actually two separate operations:
1. renaming files to include a hash of their content for cache-busting,
and copying those fil... | [
"def",
"post_process",
"(",
"self",
",",
"paths",
",",
"dry_run",
"=",
"False",
",",
"*",
"*",
"options",
")",
":",
"# don't even dare to process the files if we're in dry run mode",
"if",
"dry_run",
":",
"return",
"# where to store the new paths",
"hashed_files",
"=",
... | [
217,
4
] | [
263,
46
] | python | en | ['en', 'error', 'th'] | False |
Mempool.get_min_fee_rate | (self, cost: int) |
Gets the minimum fpc rate that a transaction with specified cost will need in order to get included.
|
Gets the minimum fpc rate that a transaction with specified cost will need in order to get included.
| def get_min_fee_rate(self, cost: int) -> float:
"""
Gets the minimum fpc rate that a transaction with specified cost will need in order to get included.
"""
if self.at_full_capacity(cost):
current_cost = self.total_mempool_cost
# Iterates through all spends in i... | [
"def",
"get_min_fee_rate",
"(",
"self",
",",
"cost",
":",
"int",
")",
"->",
"float",
":",
"if",
"self",
".",
"at_full_capacity",
"(",
"cost",
")",
":",
"current_cost",
"=",
"self",
".",
"total_mempool_cost",
"# Iterates through all spends in increasing fee per cost"... | [
18,
4
] | [
37,
20
] | python | en | ['en', 'error', 'th'] | False |
Mempool.remove_from_pool | (self, item: MempoolItem) |
Removes an item from the mempool.
|
Removes an item from the mempool.
| def remove_from_pool(self, item: MempoolItem):
"""
Removes an item from the mempool.
"""
removals: List[Coin] = item.spend_bundle.removals()
additions: List[Coin] = item.spend_bundle.additions()
for rem in removals:
del self.removals[rem.name()]
for ad... | [
"def",
"remove_from_pool",
"(",
"self",
",",
"item",
":",
"MempoolItem",
")",
":",
"removals",
":",
"List",
"[",
"Coin",
"]",
"=",
"item",
".",
"spend_bundle",
".",
"removals",
"(",
")",
"additions",
":",
"List",
"[",
"Coin",
"]",
"=",
"item",
".",
"... | [
39,
4
] | [
55,
43
] | python | en | ['en', 'error', 'th'] | False |
Mempool.add_to_pool | (
self,
item: MempoolItem,
additions: List[Coin],
removals_dic: Dict[bytes32, Coin],
) |
Adds an item to the mempool by kicking out transactions (if it doesn't fit), in order of increasing fee per cost
|
Adds an item to the mempool by kicking out transactions (if it doesn't fit), in order of increasing fee per cost
| def add_to_pool(
self,
item: MempoolItem,
additions: List[Coin],
removals_dic: Dict[bytes32, Coin],
):
"""
Adds an item to the mempool by kicking out transactions (if it doesn't fit), in order of increasing fee per cost
"""
while self.at_full_capacity... | [
"def",
"add_to_pool",
"(",
"self",
",",
"item",
":",
"MempoolItem",
",",
"additions",
":",
"List",
"[",
"Coin",
"]",
",",
"removals_dic",
":",
"Dict",
"[",
"bytes32",
",",
"Coin",
"]",
",",
")",
":",
"while",
"self",
".",
"at_full_capacity",
"(",
"item... | [
57,
4
] | [
85,
44
] | python | en | ['en', 'error', 'th'] | False |
Mempool.at_full_capacity | (self, cost: int) |
Checks whether the mempool is at full capacity and cannot accept a transaction with size cost.
|
Checks whether the mempool is at full capacity and cannot accept a transaction with size cost.
| def at_full_capacity(self, cost: int) -> bool:
"""
Checks whether the mempool is at full capacity and cannot accept a transaction with size cost.
"""
return self.total_mempool_cost + cost > self.max_size_in_cost | [
"def",
"at_full_capacity",
"(",
"self",
",",
"cost",
":",
"int",
")",
"->",
"bool",
":",
"return",
"self",
".",
"total_mempool_cost",
"+",
"cost",
">",
"self",
".",
"max_size_in_cost"
] | [
87,
4
] | [
92,
69
] | python | en | ['en', 'error', 'th'] | False |
ogrinfo | (data_source, num_features=10) |
Walks the available layers in the supplied `data_source`, displaying
the fields for the first `num_features` features.
|
Walks the available layers in the supplied `data_source`, displaying
the fields for the first `num_features` features.
| def ogrinfo(data_source, num_features=10):
"""
Walks the available layers in the supplied `data_source`, displaying
the fields for the first `num_features` features.
"""
# Checking the parameters.
if isinstance(data_source, str):
data_source = DataSource(data_source)
elif isinstance... | [
"def",
"ogrinfo",
"(",
"data_source",
",",
"num_features",
"=",
"10",
")",
":",
"# Checking the parameters.",
"if",
"isinstance",
"(",
"data_source",
",",
"str",
")",
":",
"data_source",
"=",
"DataSource",
"(",
"data_source",
")",
"elif",
"isinstance",
"(",
"d... | [
10,
0
] | [
50,
29
] | python | en | ['en', 'error', 'th'] | False |
Loader.get_template_sources | (self, template_name, template_dirs=None) |
Return an Origin object pointing to an absolute path in each directory
in template_dirs. For security reasons, if a path doesn't lie inside
one of the template_dirs it is excluded from the result set.
|
Return an Origin object pointing to an absolute path in each directory
in template_dirs. For security reasons, if a path doesn't lie inside
one of the template_dirs it is excluded from the result set.
| def get_template_sources(self, template_name, template_dirs=None):
"""
Return an Origin object pointing to an absolute path in each directory
in template_dirs. For security reasons, if a path doesn't lie inside
one of the template_dirs it is excluded from the result set.
"""
... | [
"def",
"get_template_sources",
"(",
"self",
",",
"template_name",
",",
"template_dirs",
"=",
"None",
")",
":",
"if",
"not",
"template_dirs",
":",
"template_dirs",
"=",
"self",
".",
"get_dirs",
"(",
")",
"for",
"template_dir",
"in",
"template_dirs",
":",
"try",... | [
34,
4
] | [
54,
13
] | python | en | ['en', 'error', 'th'] | False |
csrf | (request) |
Context processor that provides a CSRF token, or the string 'NOTPROVIDED' if
it has not been provided by either a view decorator or the middleware
|
Context processor that provides a CSRF token, or the string 'NOTPROVIDED' if
it has not been provided by either a view decorator or the middleware
| def csrf(request):
"""
Context processor that provides a CSRF token, or the string 'NOTPROVIDED' if
it has not been provided by either a view decorator or the middleware
"""
def _get_val():
token = get_token(request)
if token is None:
# In order to be able to provide debu... | [
"def",
"csrf",
"(",
"request",
")",
":",
"def",
"_get_val",
"(",
")",
":",
"token",
"=",
"get_token",
"(",
"request",
")",
"if",
"token",
"is",
"None",
":",
"# In order to be able to provide debugging info in the",
"# case of misconfiguration, we use a sentinel value",
... | [
19,
0
] | [
34,
53
] | python | en | ['en', 'error', 'th'] | False |
debug | (request) |
Returns context variables helpful for debugging.
|
Returns context variables helpful for debugging.
| def debug(request):
"""
Returns context variables helpful for debugging.
"""
context_extras = {}
if settings.DEBUG and request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS:
context_extras['debug'] = True
from django.db import connections
# Return a lazy reference that com... | [
"def",
"debug",
"(",
"request",
")",
":",
"context_extras",
"=",
"{",
"}",
"if",
"settings",
".",
"DEBUG",
"and",
"request",
".",
"META",
".",
"get",
"(",
"'REMOTE_ADDR'",
")",
"in",
"settings",
".",
"INTERNAL_IPS",
":",
"context_extras",
"[",
"'debug'",
... | [
37,
0
] | [
51,
25
] | python | en | ['en', 'error', 'th'] | False |
static | (request) |
Adds static-related context variables to the context.
|
Adds static-related context variables to the context.
| def static(request):
"""
Adds static-related context variables to the context.
"""
return {'STATIC_URL': settings.STATIC_URL} | [
"def",
"static",
"(",
"request",
")",
":",
"return",
"{",
"'STATIC_URL'",
":",
"settings",
".",
"STATIC_URL",
"}"
] | [
68,
0
] | [
72,
46
] | python | en | ['en', 'error', 'th'] | False |
media | (request) |
Adds media-related context variables to the context.
|
Adds media-related context variables to the context.
| def media(request):
"""
Adds media-related context variables to the context.
"""
return {'MEDIA_URL': settings.MEDIA_URL} | [
"def",
"media",
"(",
"request",
")",
":",
"return",
"{",
"'MEDIA_URL'",
":",
"settings",
".",
"MEDIA_URL",
"}"
] | [
75,
0
] | [
79,
44
] | python | en | ['en', 'error', 'th'] | False |
BaseSearchHandler.search_queryset | (self, queryset, search_term, **kwargs) |
Returns an iterable of objects from ``queryset`` matching the
provided ``search_term``.
|
Returns an iterable of objects from ``queryset`` matching the
provided ``search_term``.
| def search_queryset(self, queryset, search_term, **kwargs):
"""
Returns an iterable of objects from ``queryset`` matching the
provided ``search_term``.
"""
raise NotImplementedError() | [
"def",
"search_queryset",
"(",
"self",
",",
"queryset",
",",
"search_term",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
14,
4
] | [
19,
35
] | python | en | ['en', 'error', 'th'] | False |
BaseSearchHandler.show_search_form | (self) |
Returns a boolean that determines whether a search form should be
displayed in the IndexView UI.
|
Returns a boolean that determines whether a search form should be
displayed in the IndexView UI.
| def show_search_form(self):
"""
Returns a boolean that determines whether a search form should be
displayed in the IndexView UI.
"""
return True | [
"def",
"show_search_form",
"(",
"self",
")",
":",
"return",
"True"
] | [
22,
4
] | [
27,
19
] | python | en | ['en', 'error', 'th'] | False |
settings | (request) |
This fixture initializes a Django settings object that wraps our
`awx.conf.settings.SettingsWrapper` and passes it as an argument into the
test function.
This mimics the work done by `awx.conf.settings.SettingsWrapper.initialize`
on `django.conf.settings`.
|
This fixture initializes a Django settings object that wraps our
`awx.conf.settings.SettingsWrapper` and passes it as an argument into the
test function. | def settings(request):
"""
This fixture initializes a Django settings object that wraps our
`awx.conf.settings.SettingsWrapper` and passes it as an argument into the
test function.
This mimics the work done by `awx.conf.settings.SettingsWrapper.initialize`
on `django.conf.settings`.
"""
... | [
"def",
"settings",
"(",
"request",
")",
":",
"cache",
"=",
"LocMemCache",
"(",
"str",
"(",
"uuid4",
"(",
")",
")",
",",
"{",
"}",
")",
"# make a new random cache each time",
"settings",
"=",
"LazySettings",
"(",
")",
"registry",
"=",
"SettingsRegistry",
"(",... | [
31,
0
] | [
56,
19
] | python | en | ['en', 'error', 'th'] | False |
test_unregistered_setting | (settings) | native Django settings are not stored in DB, and aren't cached | native Django settings are not stored in DB, and aren't cached | def test_unregistered_setting(settings):
"native Django settings are not stored in DB, and aren't cached"
assert settings.DEBUG is True
assert settings.cache.get('DEBUG') is None | [
"def",
"test_unregistered_setting",
"(",
"settings",
")",
":",
"assert",
"settings",
".",
"DEBUG",
"is",
"True",
"assert",
"settings",
".",
"cache",
".",
"get",
"(",
"'DEBUG'",
")",
"is",
"None"
] | [
60,
0
] | [
63,
46
] | python | en | ['en', 'en', 'en'] | True |
test_read_only_defaults_are_cached | (settings) | read-only settings are stored in the cache | read-only settings are stored in the cache | def test_read_only_defaults_are_cached(settings):
"read-only settings are stored in the cache"
settings.registry.register('AWX_SOME_SETTING', field_class=fields.CharField, category=_('System'), category_slug='system')
assert settings.AWX_SOME_SETTING == 'DEFAULT'
assert settings.cache.get('AWX_SOME_SETT... | [
"def",
"test_read_only_defaults_are_cached",
"(",
"settings",
")",
":",
"settings",
".",
"registry",
".",
"register",
"(",
"'AWX_SOME_SETTING'",
",",
"field_class",
"=",
"fields",
".",
"CharField",
",",
"category",
"=",
"_",
"(",
"'System'",
")",
",",
"category_... | [
104,
0
] | [
108,
62
] | python | en | ['en', 'en', 'en'] | True |
test_cache_respects_timeout | (settings) | only preload the cache every SETTING_CACHE_TIMEOUT settings | only preload the cache every SETTING_CACHE_TIMEOUT settings | def test_cache_respects_timeout(settings):
"only preload the cache every SETTING_CACHE_TIMEOUT settings"
settings.registry.register('AWX_SOME_SETTING', field_class=fields.CharField, category=_('System'), category_slug='system')
assert settings.AWX_SOME_SETTING == 'DEFAULT'
cache_expiration = settings.c... | [
"def",
"test_cache_respects_timeout",
"(",
"settings",
")",
":",
"settings",
".",
"registry",
".",
"register",
"(",
"'AWX_SOME_SETTING'",
",",
"field_class",
"=",
"fields",
".",
"CharField",
",",
"category",
"=",
"_",
"(",
"'System'",
")",
",",
"category_slug",
... | [
112,
0
] | [
121,
78
] | python | en | ['en', 'en', 'en'] | True |
test_default_setting | (settings, mocker) | settings that specify a default are inserted into the cache | settings that specify a default are inserted into the cache | def test_default_setting(settings, mocker):
"settings that specify a default are inserted into the cache"
settings.registry.register('AWX_SOME_SETTING', field_class=fields.CharField, category=_('System'), category_slug='system', default='DEFAULT')
settings_to_cache = mocker.Mock(**{'order_by.return_value':... | [
"def",
"test_default_setting",
"(",
"settings",
",",
"mocker",
")",
":",
"settings",
".",
"registry",
".",
"register",
"(",
"'AWX_SOME_SETTING'",
",",
"field_class",
"=",
"fields",
".",
"CharField",
",",
"category",
"=",
"_",
"(",
"'System'",
")",
",",
"cate... | [
124,
0
] | [
131,
66
] | python | en | ['en', 'en', 'en'] | True |
test_empty_setting | (settings, mocker) | settings with no default and no defined value are not valid | settings with no default and no defined value are not valid | def test_empty_setting(settings, mocker):
"settings with no default and no defined value are not valid"
settings.registry.register('AWX_SOME_SETTING', field_class=fields.CharField, category=_('System'), category_slug='system')
mocks = mocker.Mock(**{'order_by.return_value': mocker.Mock(**{'__iter__': lambd... | [
"def",
"test_empty_setting",
"(",
"settings",
",",
"mocker",
")",
":",
"settings",
".",
"registry",
".",
"register",
"(",
"'AWX_SOME_SETTING'",
",",
"field_class",
"=",
"fields",
".",
"CharField",
",",
"category",
"=",
"_",
"(",
"'System'",
")",
",",
"catego... | [
150,
0
] | [
158,
77
] | python | en | ['en', 'en', 'en'] | True |
test_setting_from_db | (settings, mocker) | settings can be loaded from the database | settings can be loaded from the database | def test_setting_from_db(settings, mocker):
"settings can be loaded from the database"
settings.registry.register('AWX_SOME_SETTING', field_class=fields.CharField, category=_('System'), category_slug='system', default='DEFAULT')
setting_from_db = mocker.Mock(key='AWX_SOME_SETTING', value='FROM_DB')
moc... | [
"def",
"test_setting_from_db",
"(",
"settings",
",",
"mocker",
")",
":",
"settings",
".",
"registry",
".",
"register",
"(",
"'AWX_SOME_SETTING'",
",",
"field_class",
"=",
"fields",
".",
"CharField",
",",
"category",
"=",
"_",
"(",
"'System'",
")",
",",
"cate... | [
161,
0
] | [
169,
66
] | python | en | ['en', 'en', 'en'] | True |
test_read_only_setting_assignment | (settings) | read-only settings cannot be overwritten | read-only settings cannot be overwritten | def test_read_only_setting_assignment(settings):
"read-only settings cannot be overwritten"
settings.registry.register('AWX_SOME_SETTING', field_class=fields.CharField, category=_('System'), category_slug='system')
assert settings.AWX_SOME_SETTING == 'DEFAULT'
with pytest.raises(ImproperlyConfigured):
... | [
"def",
"test_read_only_setting_assignment",
"(",
"settings",
")",
":",
"settings",
".",
"registry",
".",
"register",
"(",
"'AWX_SOME_SETTING'",
",",
"field_class",
"=",
"fields",
".",
"CharField",
",",
"category",
"=",
"_",
"(",
"'System'",
")",
",",
"category_s... | [
173,
0
] | [
179,
49
] | python | en | ['en', 'en', 'en'] | True |
test_db_setting_create | (settings, mocker) | settings are stored in the database when set for the first time | settings are stored in the database when set for the first time | def test_db_setting_create(settings, mocker):
"settings are stored in the database when set for the first time"
settings.registry.register('AWX_SOME_SETTING', field_class=fields.CharField, category=_('System'), category_slug='system')
setting_list = mocker.Mock(**{'order_by.return_value.first.return_value'... | [
"def",
"test_db_setting_create",
"(",
"settings",
",",
"mocker",
")",
":",
"settings",
".",
"registry",
".",
"register",
"(",
"'AWX_SOME_SETTING'",
",",
"field_class",
"=",
"fields",
".",
"CharField",
",",
"category",
"=",
"_",
"(",
"'System'",
")",
",",
"ca... | [
182,
0
] | [
195,
106
] | python | en | ['en', 'en', 'en'] | True |
test_db_setting_update | (settings, mocker) | settings are updated in the database when their value changes | settings are updated in the database when their value changes | def test_db_setting_update(settings, mocker):
"settings are updated in the database when their value changes"
settings.registry.register('AWX_SOME_SETTING', field_class=fields.CharField, category=_('System'), category_slug='system')
existing_setting = mocker.Mock(key='AWX_SOME_SETTING', value='FROM_DB')
... | [
"def",
"test_db_setting_update",
"(",
"settings",
",",
"mocker",
")",
":",
"settings",
".",
"registry",
".",
"register",
"(",
"'AWX_SOME_SETTING'",
",",
"field_class",
"=",
"fields",
".",
"CharField",
",",
"category",
"=",
"_",
"(",
"'System'",
")",
",",
"ca... | [
198,
0
] | [
208,
69
] | python | en | ['en', 'en', 'en'] | True |
test_db_setting_deletion | (settings, mocker) | settings are auto-deleted from the database | settings are auto-deleted from the database | def test_db_setting_deletion(settings, mocker):
"settings are auto-deleted from the database"
settings.registry.register('AWX_SOME_SETTING', field_class=fields.CharField, category=_('System'), category_slug='system')
existing_setting = mocker.Mock(key='AWX_SOME_SETTING', value='FROM_DB')
with mocker.pa... | [
"def",
"test_db_setting_deletion",
"(",
"settings",
",",
"mocker",
")",
":",
"settings",
".",
"registry",
".",
"register",
"(",
"'AWX_SOME_SETTING'",
",",
"field_class",
"=",
"fields",
".",
"CharField",
",",
"category",
"=",
"_",
"(",
"'System'",
")",
",",
"... | [
211,
0
] | [
219,
50
] | python | en | ['en', 'en', 'en'] | True |
test_read_only_setting_deletion | (settings) | read-only settings cannot be deleted | read-only settings cannot be deleted | def test_read_only_setting_deletion(settings):
"read-only settings cannot be deleted"
settings.registry.register('AWX_SOME_SETTING', field_class=fields.CharField, category=_('System'), category_slug='system')
assert settings.AWX_SOME_SETTING == 'DEFAULT'
with pytest.raises(ImproperlyConfigured):
... | [
"def",
"test_read_only_setting_deletion",
"(",
"settings",
")",
":",
"settings",
".",
"registry",
".",
"register",
"(",
"'AWX_SOME_SETTING'",
",",
"field_class",
"=",
"fields",
".",
"CharField",
",",
"category",
"=",
"_",
"(",
"'System'",
")",
",",
"category_slu... | [
223,
0
] | [
229,
49
] | python | en | ['en', 'en', 'en'] | True |
test_charfield_properly_sets_none | (settings, mocker) | see: https://github.com/ansible/ansible-tower/issues/5322 | see: https://github.com/ansible/ansible-tower/issues/5322 | def test_charfield_properly_sets_none(settings, mocker):
"see: https://github.com/ansible/ansible-tower/issues/5322"
settings.registry.register('AWX_SOME_SETTING', field_class=fields.CharField, category=_('System'), category_slug='system', allow_null=True)
setting_list = mocker.Mock(**{'order_by.return_val... | [
"def",
"test_charfield_properly_sets_none",
"(",
"settings",
",",
"mocker",
")",
":",
"settings",
".",
"registry",
".",
"register",
"(",
"'AWX_SOME_SETTING'",
",",
"field_class",
"=",
"fields",
".",
"CharField",
",",
"category",
"=",
"_",
"(",
"'System'",
")",
... | [
232,
0
] | [
245,
99
] | python | en | ['en', 'en', 'en'] | False |
test_sensitive_cache_data_is_encrypted | (settings, mocker) | fields marked as `encrypted` are stored in the cache with encryption | fields marked as `encrypted` are stored in the cache with encryption | def test_sensitive_cache_data_is_encrypted(settings, mocker):
"fields marked as `encrypted` are stored in the cache with encryption"
settings.registry.register('AWX_ENCRYPTED', field_class=fields.CharField, category=_('System'), category_slug='system', encrypted=True)
def rot13(obj, attribute):
ass... | [
"def",
"test_sensitive_cache_data_is_encrypted",
"(",
"settings",
",",
"mocker",
")",
":",
"settings",
".",
"registry",
".",
"register",
"(",
"'AWX_ENCRYPTED'",
",",
"field_class",
"=",
"fields",
".",
"CharField",
",",
"category",
"=",
"_",
"(",
"'System'",
")",... | [
268,
0
] | [
285,
61
] | python | en | ['en', 'en', 'en'] | True |
test_readonly_sensitive_cache_data_is_encrypted | (settings) | readonly fields marked as `encrypted` are stored in the cache with encryption | readonly fields marked as `encrypted` are stored in the cache with encryption | def test_readonly_sensitive_cache_data_is_encrypted(settings):
"readonly fields marked as `encrypted` are stored in the cache with encryption"
settings.registry.register('AWX_ENCRYPTED', field_class=fields.CharField, category=_('System'), category_slug='system', read_only=True, encrypted=True)
def rot13(ob... | [
"def",
"test_readonly_sensitive_cache_data_is_encrypted",
"(",
"settings",
")",
":",
"settings",
".",
"registry",
".",
"register",
"(",
"'AWX_ENCRYPTED'",
",",
"field_class",
"=",
"fields",
".",
"CharField",
",",
"category",
"=",
"_",
"(",
"'System'",
")",
",",
... | [
288,
0
] | [
300,
57
] | python | en | ['en', 'en', 'en'] | True |
HTTPHeaderDict.pop | (self, key, default=__marker) | D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised.
| D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised.
| def pop(self, key, default=__marker):
"""D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised.
"""
# Using the MutableMapping function directly fails due to the private marker.
# Usin... | [
"def",
"pop",
"(",
"self",
",",
"key",
",",
"default",
"=",
"__marker",
")",
":",
"# Using the MutableMapping function directly fails due to the private marker.",
"# Using ordinary dict.pop would expose the internal structures.",
"# So let's reinvent the wheel.",
"try",
":",
"value... | [
191,
4
] | [
206,
24
] | python | en | ['en', 'en', 'en'] | True |
HTTPHeaderDict.add | (self, key, val) | Adds a (name, value) pair, doesn't overwrite the value if it already
exists.
>>> headers = HTTPHeaderDict(foo='bar')
>>> headers.add('Foo', 'baz')
>>> headers['foo']
'bar, baz'
| Adds a (name, value) pair, doesn't overwrite the value if it already
exists. | def add(self, key, val):
"""Adds a (name, value) pair, doesn't overwrite the value if it already
exists.
>>> headers = HTTPHeaderDict(foo='bar')
>>> headers.add('Foo', 'baz')
>>> headers['foo']
'bar, baz'
"""
key_lower = key.lower()
new_vals = [ke... | [
"def",
"add",
"(",
"self",
",",
"key",
",",
"val",
")",
":",
"key_lower",
"=",
"key",
".",
"lower",
"(",
")",
"new_vals",
"=",
"[",
"key",
",",
"val",
"]",
"# Keep the common case aka no item present as fast as possible",
"vals",
"=",
"self",
".",
"_containe... | [
214,
4
] | [
228,
28
] | python | en | ['en', 'en', 'en'] | True |
HTTPHeaderDict.extend | (self, *args, **kwargs) | Generic import function for any type of header-like object.
Adapted version of MutableMapping.update in order to insert items
with self.add instead of self.__setitem__
| Generic import function for any type of header-like object.
Adapted version of MutableMapping.update in order to insert items
with self.add instead of self.__setitem__
| def extend(self, *args, **kwargs):
"""Generic import function for any type of header-like object.
Adapted version of MutableMapping.update in order to insert items
with self.add instead of self.__setitem__
"""
if len(args) > 1:
raise TypeError(
"extend... | [
"def",
"extend",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
">",
"1",
":",
"raise",
"TypeError",
"(",
"\"extend() takes at most 1 positional \"",
"\"arguments ({0} given)\"",
".",
"format",
"(",
"len",
... | [
230,
4
] | [
256,
32
] | python | en | ['en', 'en', 'en'] | True |
HTTPHeaderDict.getlist | (self, key, default=__marker) | Returns a list of all the values for the named field. Returns an
empty list if the key doesn't exist. | Returns a list of all the values for the named field. Returns an
empty list if the key doesn't exist. | def getlist(self, key, default=__marker):
"""Returns a list of all the values for the named field. Returns an
empty list if the key doesn't exist."""
try:
vals = self._container[key.lower()]
except KeyError:
if default is self.__marker:
return []
... | [
"def",
"getlist",
"(",
"self",
",",
"key",
",",
"default",
"=",
"__marker",
")",
":",
"try",
":",
"vals",
"=",
"self",
".",
"_container",
"[",
"key",
".",
"lower",
"(",
")",
"]",
"except",
"KeyError",
":",
"if",
"default",
"is",
"self",
".",
"__mar... | [
258,
4
] | [
268,
27
] | python | en | ['en', 'en', 'en'] | True |
HTTPHeaderDict.iteritems | (self) | Iterate over all header lines, including duplicate ones. | Iterate over all header lines, including duplicate ones. | def iteritems(self):
"""Iterate over all header lines, including duplicate ones."""
for key in self:
vals = self._container[key.lower()]
for val in vals[1:]:
yield vals[0], val | [
"def",
"iteritems",
"(",
"self",
")",
":",
"for",
"key",
"in",
"self",
":",
"vals",
"=",
"self",
".",
"_container",
"[",
"key",
".",
"lower",
"(",
")",
"]",
"for",
"val",
"in",
"vals",
"[",
"1",
":",
"]",
":",
"yield",
"vals",
"[",
"0",
"]",
... | [
294,
4
] | [
299,
34
] | python | en | ['en', 'en', 'en'] | True |
HTTPHeaderDict.itermerged | (self) | Iterate over all headers, merging duplicate ones together. | Iterate over all headers, merging duplicate ones together. | def itermerged(self):
"""Iterate over all headers, merging duplicate ones together."""
for key in self:
val = self._container[key.lower()]
yield val[0], ", ".join(val[1:]) | [
"def",
"itermerged",
"(",
"self",
")",
":",
"for",
"key",
"in",
"self",
":",
"val",
"=",
"self",
".",
"_container",
"[",
"key",
".",
"lower",
"(",
")",
"]",
"yield",
"val",
"[",
"0",
"]",
",",
"\", \"",
".",
"join",
"(",
"val",
"[",
"1",
":",
... | [
301,
4
] | [
305,
44
] | python | en | ['en', 'en', 'en'] | True |
HTTPHeaderDict.from_httplib | (cls, message) | Read headers from a Python 2 httplib message object. | Read headers from a Python 2 httplib message object. | def from_httplib(cls, message): # Python 2
"""Read headers from a Python 2 httplib message object."""
# python2.7 does not expose a proper API for exporting multiheaders
# efficiently. This function re-reads raw lines from the message
# object and extracts the multiheaders properly.
... | [
"def",
"from_httplib",
"(",
"cls",
",",
"message",
")",
":",
"# Python 2",
"# python2.7 does not expose a proper API for exporting multiheaders",
"# efficiently. This function re-reads raw lines from the message",
"# object and extracts the multiheaders properly.",
"obs_fold_continued_leader... | [
311,
4
] | [
336,
27
] | python | en | ['en', 'en', 'en'] | True |
BaseNNMixtureEstimator.mean_ | (self, x_cond, n_samples=None) | Mean of the fitted distribution conditioned on x_cond
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
Returns:
Means E[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y)
| Mean of the fitted distribution conditioned on x_cond
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) | def mean_(self, x_cond, n_samples=None):
""" Mean of the fitted distribution conditioned on x_cond
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
Returns:
Means E[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y)
"""
asser... | [
"def",
"mean_",
"(",
"self",
",",
"x_cond",
",",
"n_samples",
"=",
"None",
")",
":",
"assert",
"hasattr",
"(",
"self",
",",
"'_get_mixture_components'",
")",
"assert",
"self",
".",
"fitted",
",",
"\"model must be fitted\"",
"x_cond",
"=",
"self",
".",
"_hand... | [
13,
2
] | [
30,
16
] | python | en | ['en', 'en', 'en'] | True |
BaseNNMixtureEstimator.std_ | (self, x_cond, n_samples=10 ** 6) | Standard deviation of the fitted distribution conditioned on x_cond
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
Returns:
Standard deviations sqrt(Var[y|x]) corresponding to x_cond - numpy array of shape (n_values, ndim_y)
| Standard deviation of the fitted distribution conditioned on x_cond | def std_(self, x_cond, n_samples=10 ** 6):
""" Standard deviation of the fitted distribution conditioned on x_cond
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
Returns:
Standard deviations sqrt(Var[y|x]) corresponding to x_cond - numpy array of sh... | [
"def",
"std_",
"(",
"self",
",",
"x_cond",
",",
"n_samples",
"=",
"10",
"**",
"6",
")",
":",
"covs",
"=",
"self",
".",
"covariance",
"(",
"x_cond",
",",
"n_samples",
"=",
"n_samples",
")",
"return",
"np",
".",
"sqrt",
"(",
"np",
".",
"diagonal",
"(... | [
32,
2
] | [
42,
55
] | python | en | ['en', 'en', 'en'] | True |
BaseNNMixtureEstimator.covariance | (self, x_cond, n_samples=None) | Covariance of the fitted distribution conditioned on x_cond
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
Returns:
Covariances Cov[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y, ndim_y)
| Covariance of the fitted distribution conditioned on x_cond | def covariance(self, x_cond, n_samples=None):
""" Covariance of the fitted distribution conditioned on x_cond
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
Returns:
Covariances Cov[y|x] corresponding to x_cond - numpy array of shape (n_value... | [
"def",
"covariance",
"(",
"self",
",",
"x_cond",
",",
"n_samples",
"=",
"None",
")",
":",
"assert",
"self",
".",
"fitted",
",",
"\"model must be fitted\"",
"x_cond",
"=",
"self",
".",
"_handle_input_dimensionality",
"(",
"x_cond",
")",
"covs",
"=",
"np",
"."... | [
44,
2
] | [
72,
15
] | python | en | ['en', 'en', 'en'] | True |
BaseNNMixtureEstimator.mean_std | (self, x_cond, n_samples=None) | Computes Mean and Covariance of the fitted distribution conditioned on x_cond.
Computationally more efficient than calling mean and covariance computatio separately
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
Returns:
Means E[y|x] and Covaria... | Computes Mean and Covariance of the fitted distribution conditioned on x_cond.
Computationally more efficient than calling mean and covariance computatio separately | def mean_std(self, x_cond, n_samples=None):
""" Computes Mean and Covariance of the fitted distribution conditioned on x_cond.
Computationally more efficient than calling mean and covariance computatio separately
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, n... | [
"def",
"mean_std",
"(",
"self",
",",
"x_cond",
",",
"n_samples",
"=",
"None",
")",
":",
"mean",
"=",
"self",
".",
"mean_",
"(",
"x_cond",
",",
"n_samples",
"=",
"n_samples",
")",
"std",
"=",
"self",
".",
"std_",
"(",
"x_cond",
",",
"n_samples",
"=",
... | [
74,
2
] | [
86,
20
] | python | en | ['en', 'en', 'en'] | True |
BaseNNMixtureEstimator.sample | (self, X) | sample from the conditional mixture distributions - requires the model to be fitted
Args:
X: values to be conditioned on when sampling - numpy array of shape (n_instances, n_dim_x)
Returns: tuple (X, Y)
- X - the values to conditioned on that were provided as argument - numpy array of sha... | sample from the conditional mixture distributions - requires the model to be fitted | def sample(self, X):
""" sample from the conditional mixture distributions - requires the model to be fitted
Args:
X: values to be conditioned on when sampling - numpy array of shape (n_instances, n_dim_x)
Returns: tuple (X, Y)
- X - the values to conditioned on that were provided as a... | [
"def",
"sample",
"(",
"self",
",",
"X",
")",
":",
"assert",
"self",
".",
"fitted",
",",
"\"model must be fitted to compute likelihood score\"",
"assert",
"self",
".",
"can_sample",
"X",
"=",
"self",
".",
"_handle_input_dimensionality",
"(",
"X",
")",
"if",
"np",... | [
88,
2
] | [
106,
46
] | python | en | ['en', 'en', 'en'] | True |
BaseNNMixtureEstimator.conditional_value_at_risk | (self, x_cond, alpha=0.01, n_samples=10**7) | Computes the Conditional Value-at-Risk (CVaR) / Expected Shortfall of a GMM. Only if ndim_y = 1
Based on formulas from section 2.3.2 in "Expected shortfall for distributions in finance",
Simon A. Broda, Marc S. Paolella, 2011
Args:
x_cond: different x values to condition on - numpy ar... | Computes the Conditional Value-at-Risk (CVaR) / Expected Shortfall of a GMM. Only if ndim_y = 1 | def conditional_value_at_risk(self, x_cond, alpha=0.01, n_samples=10**7):
""" Computes the Conditional Value-at-Risk (CVaR) / Expected Shortfall of a GMM. Only if ndim_y = 1
Based on formulas from section 2.3.2 in "Expected shortfall for distributions in finance",
Simon A. Broda, Marc S. Paolella, ... | [
"def",
"conditional_value_at_risk",
"(",
"self",
",",
"x_cond",
",",
"alpha",
"=",
"0.01",
",",
"n_samples",
"=",
"10",
"**",
"7",
")",
":",
"assert",
"self",
".",
"fitted",
",",
"\"model must be fitted\"",
"assert",
"self",
".",
"ndim_y",
"==",
"1",
",",
... | [
108,
2
] | [
127,
77
] | python | en | ['en', 'en', 'en'] | True |
BaseNNMixtureEstimator.tail_risk_measures | (self, x_cond, alpha=0.01, n_samples=10 ** 7) | Computes the Value-at-Risk (VaR) and Conditional Value-at-Risk (CVaR)
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
alpha: quantile percentage of the distribution
n_samples: number of samples for monte carlo model_fitting
Retu... | Computes the Value-at-Risk (VaR) and Conditional Value-at-Risk (CVaR) | def tail_risk_measures(self, x_cond, alpha=0.01, n_samples=10 ** 7):
""" Computes the Value-at-Risk (VaR) and Conditional Value-at-Risk (CVaR)
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
alpha: quantile percentage of the distribution
... | [
"def",
"tail_risk_measures",
"(",
"self",
",",
"x_cond",
",",
"alpha",
"=",
"0.01",
",",
"n_samples",
"=",
"10",
"**",
"7",
")",
":",
"assert",
"self",
".",
"fitted",
",",
"\"model must be fitted\"",
"assert",
"self",
".",
"ndim_y",
"==",
"1",
",",
"\"Va... | [
129,
2
] | [
149,
22
] | python | en | ['en', 'en', 'en'] | True |
BaseNNMixtureEstimator._partial_fit | (self, X, Y, n_epoch=1, eval_set=None, verbose=True) |
update model
|
update model
| def _partial_fit(self, X, Y, n_epoch=1, eval_set=None, verbose=True):
"""
update model
"""
# loop over epochs
for i in range(n_epoch):
# run inference, update trainable variables of the model
info_dict = self.inference.update(feed_dict={self.X_ph: X, self.Y_ph: Y, self.train_phase: True... | [
"def",
"_partial_fit",
"(",
"self",
",",
"X",
",",
"Y",
",",
"n_epoch",
"=",
"1",
",",
"eval_set",
"=",
"None",
",",
"verbose",
"=",
"True",
")",
":",
"# loop over epochs",
"for",
"i",
"in",
"range",
"(",
"n_epoch",
")",
":",
"# run inference, update tra... | [
151,
2
] | [
176,
62
] | python | en | ['en', 'error', 'th'] | False |
BaseNNMixtureEstimator._conditional_value_at_risk_mixture | (self, VaRs, x_cond, alpha=0.01,) |
Based on formulas from section 2.3.2 in "Expected shortfall for distributions in finance",
Simon A. Broda, Marc S. Paolella, 2011
|
Based on formulas from section 2.3.2 in "Expected shortfall for distributions in finance",
Simon A. Broda, Marc S. Paolella, 2011
| def _conditional_value_at_risk_mixture(self, VaRs, x_cond, alpha=0.01,):
"""
Based on formulas from section 2.3.2 in "Expected shortfall for distributions in finance",
Simon A. Broda, Marc S. Paolella, 2011
"""
weights, locs, scales = self._get_mixture_components(x_cond)
locs = locs.reshape(lo... | [
"def",
"_conditional_value_at_risk_mixture",
"(",
"self",
",",
"VaRs",
",",
"x_cond",
",",
"alpha",
"=",
"0.01",
",",
")",
":",
"weights",
",",
"locs",
",",
"scales",
"=",
"self",
".",
"_get_mixture_components",
"(",
"x_cond",
")",
"locs",
"=",
"locs",
"."... | [
178,
2
] | [
201,
16
] | python | en | ['en', 'error', 'th'] | False |
BaseNNMixtureEstimator._sample_rows_same | (self, X) | uses efficient sklearn implementation to sample from gaussian mixture -> only works if all rows of X are the same | uses efficient sklearn implementation to sample from gaussian mixture -> only works if all rows of X are the same | def _sample_rows_same(self, X):
""" uses efficient sklearn implementation to sample from gaussian mixture -> only works if all rows of X are the same"""
weights, locs, scales = self._get_mixture_components(np.expand_dims(X[0], axis=0))
# make sure that sum of weights < 1
weights = weights.astype(np.flo... | [
"def",
"_sample_rows_same",
"(",
"self",
",",
"X",
")",
":",
"weights",
",",
"locs",
",",
"scales",
"=",
"self",
".",
"_get_mixture_components",
"(",
"np",
".",
"expand_dims",
"(",
"X",
"[",
"0",
"]",
",",
"axis",
"=",
"0",
")",
")",
"# make sure that ... | [
203,
2
] | [
220,
22
] | python | en | ['en', 'en', 'en'] | True |
BaseNNMixtureEstimator.cdf | (self, X, Y) | Predicts the conditional cumulative probability p(Y<=y|X=x). Requires the model to be fitted.
Args:
X: numpy array to be conditioned on - shape: (n_samples, n_dim_x)
Y: numpy array of y targets - shape: (n_samples, n_dim_y)
Returns:
conditional cumulative probability p(Y<=y|X... | Predicts the conditional cumulative probability p(Y<=y|X=x). Requires the model to be fitted. | def cdf(self, X, Y):
""" Predicts the conditional cumulative probability p(Y<=y|X=x). Requires the model to be fitted.
Args:
X: numpy array to be conditioned on - shape: (n_samples, n_dim_x)
Y: numpy array of y targets - shape: (n_samples, n_dim_y)
Returns:
conditional cum... | [
"def",
"cdf",
"(",
"self",
",",
"X",
",",
"Y",
")",
":",
"assert",
"self",
".",
"fitted",
",",
"\"model must be fitted to compute likelihood score\"",
"assert",
"hasattr",
"(",
"self",
",",
"'_get_mixture_components'",
")",
",",
"\"cdf computation requires _get_mixtur... | [
242,
2
] | [
264,
12
] | python | en | ['en', 'en', 'en'] | True |
BaseNNMixtureEstimator.reset_fit | (self) |
resets all tensorflow objects and
:return:
|
resets all tensorflow objects and
:return:
| def reset_fit(self):
"""
resets all tensorflow objects and
:return:
"""
tf.reset_default_graph()
self._build_model()
self.fitted = False | [
"def",
"reset_fit",
"(",
"self",
")",
":",
"tf",
".",
"reset_default_graph",
"(",
")",
"self",
".",
"_build_model",
"(",
")",
"self",
".",
"fitted",
"=",
"False"
] | [
266,
2
] | [
273,
23
] | python | en | ['en', 'error', 'th'] | False |
HookResponseMixin.run_hook | (self, hook_name, *args, **kwargs) |
Run the named hook, passing args and kwargs to each function registered under that hook name.
If any return an HttpResponse, stop processing and return that response
|
Run the named hook, passing args and kwargs to each function registered under that hook name.
If any return an HttpResponse, stop processing and return that response
| def run_hook(self, hook_name, *args, **kwargs):
"""
Run the named hook, passing args and kwargs to each function registered under that hook name.
If any return an HttpResponse, stop processing and return that response
"""
for fn in hooks.get_hooks(hook_name):
result =... | [
"def",
"run_hook",
"(",
"self",
",",
"hook_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"fn",
"in",
"hooks",
".",
"get_hooks",
"(",
"hook_name",
")",
":",
"result",
"=",
"fn",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
... | [
9,
4
] | [
17,
29
] | python | en | ['en', 'error', 'th'] | False |
WKBReader.read | (self, wkb) | Returns a GEOSGeometry for the given WKB buffer. | Returns a GEOSGeometry for the given WKB buffer. | def read(self, wkb):
"Returns a GEOSGeometry for the given WKB buffer."
return GEOSGeometry(super(WKBReader, self).read(wkb)) | [
"def",
"read",
"(",
"self",
",",
"wkb",
")",
":",
"return",
"GEOSGeometry",
"(",
"super",
"(",
"WKBReader",
",",
"self",
")",
".",
"read",
"(",
"wkb",
")",
")"
] | [
15,
4
] | [
17,
61
] | python | en | ['en', 'en', 'en'] | True |
WKTReader.read | (self, wkt) | Returns a GEOSGeometry for the given WKT string. | Returns a GEOSGeometry for the given WKT string. | def read(self, wkt):
"Returns a GEOSGeometry for the given WKT string."
return GEOSGeometry(super(WKTReader, self).read(wkt)) | [
"def",
"read",
"(",
"self",
",",
"wkt",
")",
":",
"return",
"GEOSGeometry",
"(",
"super",
"(",
"WKTReader",
",",
"self",
")",
".",
"read",
"(",
"wkt",
")",
")"
] | [
21,
4
] | [
23,
61
] | python | en | ['en', 'en', 'en'] | True |
parse_uri | (uri) | Parses a URI using the regex given in Appendix B of RFC 3986.
(scheme, authority, path, query, fragment) = parse_uri(uri)
| Parses a URI using the regex given in Appendix B of RFC 3986. | def parse_uri(uri):
"""Parses a URI using the regex given in Appendix B of RFC 3986.
(scheme, authority, path, query, fragment) = parse_uri(uri)
"""
groups = URI.match(uri).groups()
return (groups[1], groups[3], groups[4], groups[6], groups[8]) | [
"def",
"parse_uri",
"(",
"uri",
")",
":",
"groups",
"=",
"URI",
".",
"match",
"(",
"uri",
")",
".",
"groups",
"(",
")",
"return",
"(",
"groups",
"[",
"1",
"]",
",",
"groups",
"[",
"3",
"]",
",",
"groups",
"[",
"4",
"]",
",",
"groups",
"[",
"6... | [
20,
0
] | [
26,
66
] | python | en | ['en', 'en', 'en'] | True |
CacheController._urlnorm | (cls, uri) | Normalize the URL to create a safe key for the cache | Normalize the URL to create a safe key for the cache | def _urlnorm(cls, uri):
"""Normalize the URL to create a safe key for the cache"""
(scheme, authority, path, query, fragment) = parse_uri(uri)
if not scheme or not authority:
raise Exception("Only absolute URIs are allowed. uri = %s" % uri)
scheme = scheme.lower()
au... | [
"def",
"_urlnorm",
"(",
"cls",
",",
"uri",
")",
":",
"(",
"scheme",
",",
"authority",
",",
"path",
",",
"query",
",",
"fragment",
")",
"=",
"parse_uri",
"(",
"uri",
")",
"if",
"not",
"scheme",
"or",
"not",
"authority",
":",
"raise",
"Exception",
"(",... | [
42,
4
] | [
59,
25
] | python | en | ['en', 'en', 'en'] | True |
CacheController.cached_request | (self, request) |
Return a cached response if it exists in the cache, otherwise
return False.
|
Return a cached response if it exists in the cache, otherwise
return False.
| def cached_request(self, request):
"""
Return a cached response if it exists in the cache, otherwise
return False.
"""
cache_url = self.cache_url(request.url)
logger.debug('Looking up "%s" in the cache', cache_url)
cc = self.parse_cache_control(request.headers)
... | [
"def",
"cached_request",
"(",
"self",
",",
"request",
")",
":",
"cache_url",
"=",
"self",
".",
"cache_url",
"(",
"request",
".",
"url",
")",
"logger",
".",
"debug",
"(",
"'Looking up \"%s\" in the cache'",
",",
"cache_url",
")",
"cc",
"=",
"self",
".",
"pa... | [
119,
4
] | [
228,
20
] | python | en | ['en', 'error', 'th'] | False |
CacheController.cache_response | (self, request, response, body=None, status_codes=None) |
Algorithm for caching requests.
This assumes a requests Response object.
|
Algorithm for caching requests. | def cache_response(self, request, response, body=None, status_codes=None):
"""
Algorithm for caching requests.
This assumes a requests Response object.
"""
# From httplib2: Don't cache 206's since we aren't going to
# handle byte range requests
cac... | [
"def",
"cache_response",
"(",
"self",
",",
"request",
",",
"response",
",",
"body",
"=",
"None",
",",
"status_codes",
"=",
"None",
")",
":",
"# From httplib2: Don't cache 206's since we aren't going to",
"# handle byte range requests",
"cacheable_status_codes",... | [
246,
4
] | [
335,
21
] | python | en | ['en', 'error', 'th'] | False |
CacheController.update_cached_response | (self, request, response) | On a 304 we will get a new set of headers that we want to
update our cached value with, assuming we have one.
This should only ever be called when we've sent an ETag and
gotten a 304 as the response.
| On a 304 we will get a new set of headers that we want to
update our cached value with, assuming we have one. | def update_cached_response(self, request, response):
"""On a 304 we will get a new set of headers that we want to
update our cached value with, assuming we have one.
This should only ever be called when we've sent an ETag and
gotten a 304 as the response.
"""
cache_url =... | [
"def",
"update_cached_response",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"cache_url",
"=",
"self",
".",
"cache_url",
"(",
"request",
".",
"url",
")",
"cached_response",
"=",
"self",
".",
"serializer",
".",
"loads",
"(",
"request",
",",
"sel... | [
337,
4
] | [
375,
30
] | python | en | ['en', 'en', 'en'] | True |
pad_method_dict | (method_dict: Dict[str, bool]) | Pads an authentication methods dict to contain all auth backends
supported by the software, regardless of whether they are
configured on this server | Pads an authentication methods dict to contain all auth backends
supported by the software, regardless of whether they are
configured on this server | def pad_method_dict(method_dict: Dict[str, bool]) -> Dict[str, bool]:
"""Pads an authentication methods dict to contain all auth backends
supported by the software, regardless of whether they are
configured on this server"""
for key in AUTH_BACKEND_NAME_MAP:
if key not in method_dict:
... | [
"def",
"pad_method_dict",
"(",
"method_dict",
":",
"Dict",
"[",
"str",
",",
"bool",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"bool",
"]",
":",
"for",
"key",
"in",
"AUTH_BACKEND_NAME_MAP",
":",
"if",
"key",
"not",
"in",
"method_dict",
":",
"method_dict",
... | [
101,
0
] | [
108,
22
] | python | en | ['en', 'en', 'en'] | True |
any_social_backend_enabled | (realm: Optional[Realm] = None) | Used by the login page process to determine whether to show the
'OR' for login with Google | Used by the login page process to determine whether to show the
'OR' for login with Google | def any_social_backend_enabled(realm: Optional[Realm] = None) -> bool:
"""Used by the login page process to determine whether to show the
'OR' for login with Google"""
social_backend_names = [
social_auth_subclass.auth_backend_name for social_auth_subclass in EXTERNAL_AUTH_METHODS
]
return a... | [
"def",
"any_social_backend_enabled",
"(",
"realm",
":",
"Optional",
"[",
"Realm",
"]",
"=",
"None",
")",
"->",
"bool",
":",
"social_backend_names",
"=",
"[",
"social_auth_subclass",
".",
"auth_backend_name",
"for",
"social_auth_subclass",
"in",
"EXTERNAL_AUTH_METHODS"... | [
162,
0
] | [
168,
59
] | python | en | ['en', 'en', 'en'] | True |
common_get_active_user | (
email: str, realm: Realm, return_data: Optional[Dict[str, Any]] = None
) | This is the core common function used by essentially all
authentication backends to check if there's an active user account
with a given email address in the organization, handling both
user-level and realm-level deactivation correctly.
| This is the core common function used by essentially all
authentication backends to check if there's an active user account
with a given email address in the organization, handling both
user-level and realm-level deactivation correctly.
| def common_get_active_user(
email: str, realm: Realm, return_data: Optional[Dict[str, Any]] = None
) -> Optional[UserProfile]:
"""This is the core common function used by essentially all
authentication backends to check if there's an active user account
with a given email address in the organization, ha... | [
"def",
"common_get_active_user",
"(",
"email",
":",
"str",
",",
"realm",
":",
"Realm",
",",
"return_data",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"None",
")",
"->",
"Optional",
"[",
"UserProfile",
"]",
":",
"try",
":",
"... | [
195,
0
] | [
218,
23
] | python | en | ['en', 'en', 'en'] | True |
check_password_strength | (password: str) |
Returns True if the password is strong enough,
False otherwise.
|
Returns True if the password is strong enough,
False otherwise.
| def check_password_strength(password: str) -> bool:
"""
Returns True if the password is strong enough,
False otherwise.
"""
if len(password) < settings.PASSWORD_MIN_LENGTH:
return False
if password == "":
# zxcvbn throws an exception when passed the empty string, so
# we... | [
"def",
"check_password_strength",
"(",
"password",
":",
"str",
")",
"->",
"bool",
":",
"if",
"len",
"(",
"password",
")",
"<",
"settings",
".",
"PASSWORD_MIN_LENGTH",
":",
"return",
"False",
"if",
"password",
"==",
"\"\"",
":",
"# zxcvbn throws an exception when... | [
350,
0
] | [
366,
15
] | python | en | ['en', 'error', 'th'] | False |
find_ldap_users_by_email | (email: str) |
Returns list of _LDAPUsers matching the email search,
or None if no matches are found.
|
Returns list of _LDAPUsers matching the email search,
or None if no matches are found.
| def find_ldap_users_by_email(email: str) -> Optional[List[_LDAPUser]]:
"""
Returns list of _LDAPUsers matching the email search,
or None if no matches are found.
"""
email_search = LDAPReverseEmailSearch(LDAPBackend(), email)
return email_search.search_for_users(should_populate=False) | [
"def",
"find_ldap_users_by_email",
"(",
"email",
":",
"str",
")",
"->",
"Optional",
"[",
"List",
"[",
"_LDAPUser",
"]",
"]",
":",
"email_search",
"=",
"LDAPReverseEmailSearch",
"(",
"LDAPBackend",
"(",
")",
",",
"email",
")",
"return",
"email_search",
".",
"... | [
443,
0
] | [
449,
63
] | python | en | ['en', 'error', 'th'] | False |
email_belongs_to_ldap | (realm: Realm, email: str) | Used to make determinations on whether a user's email address is
managed by LDAP. For environments using both LDAP and
Email+Password authentication, we do not allow EmailAuthBackend
authentication for email addresses managed by LDAP (to avoid a
security issue where one create separate credentials for ... | Used to make determinations on whether a user's email address is
managed by LDAP. For environments using both LDAP and
Email+Password authentication, we do not allow EmailAuthBackend
authentication for email addresses managed by LDAP (to avoid a
security issue where one create separate credentials for ... | def email_belongs_to_ldap(realm: Realm, email: str) -> bool:
"""Used to make determinations on whether a user's email address is
managed by LDAP. For environments using both LDAP and
Email+Password authentication, we do not allow EmailAuthBackend
authentication for email addresses managed by LDAP (to a... | [
"def",
"email_belongs_to_ldap",
"(",
"realm",
":",
"Realm",
",",
"email",
":",
"str",
")",
"->",
"bool",
":",
"if",
"not",
"ldap_auth_enabled",
"(",
"realm",
")",
":",
"return",
"False",
"check_ldap_config",
"(",
")",
"if",
"settings",
".",
"LDAP_APPEND_DOMA... | [
452,
0
] | [
472,
20
] | python | en | ['en', 'en', 'en'] | True |
catch_ldap_error | (signal: Signal, **kwargs: Any) |
Inside django_auth_ldap populate_user(), if LDAPError is raised,
e.g. due to invalid connection credentials, the function catches it
and emits a signal (ldap_error) to communicate this error to others.
We normally don't use signals, but here there's no choice, so in this function
we essentially con... |
Inside django_auth_ldap populate_user(), if LDAPError is raised,
e.g. due to invalid connection credentials, the function catches it
and emits a signal (ldap_error) to communicate this error to others.
We normally don't use signals, but here there's no choice, so in this function
we essentially con... | def catch_ldap_error(signal: Signal, **kwargs: Any) -> None:
"""
Inside django_auth_ldap populate_user(), if LDAPError is raised,
e.g. due to invalid connection credentials, the function catches it
and emits a signal (ldap_error) to communicate this error to others.
We normally don't use signals, bu... | [
"def",
"catch_ldap_error",
"(",
"signal",
":",
"Signal",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"if",
"kwargs",
"[",
"\"context\"",
"]",
"==",
"\"populate_user\"",
":",
"# The exception message can contain the password (if it was invalid),",
"#... | [
967,
0
] | [
979,
75
] | python | en | ['en', 'error', 'th'] | False |
social_associate_user_helper | (
backend: BaseAuth, return_data: Dict[str, Any], *args: Any, **kwargs: Any
) | Responsible for doing the Zulip account lookup and validation parts
of the Zulip social auth pipeline (similar to the authenticate()
methods in most other auth backends in this file).
Returns a UserProfile object for successful authentication, and None otherwise.
| Responsible for doing the Zulip account lookup and validation parts
of the Zulip social auth pipeline (similar to the authenticate()
methods in most other auth backends in this file). | def social_associate_user_helper(
backend: BaseAuth, return_data: Dict[str, Any], *args: Any, **kwargs: Any
) -> Union[HttpResponse, Optional[UserProfile]]:
"""Responsible for doing the Zulip account lookup and validation parts
of the Zulip social auth pipeline (similar to the authenticate()
methods in ... | [
"def",
"social_associate_user_helper",
"(",
"backend",
":",
"BaseAuth",
",",
"return_data",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"*",
"args",
":",
"Any",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"Union",
"[",
"HttpResponse",
",",
"Opti... | [
1313,
0
] | [
1453,
23
] | python | en | ['en', 'en', 'en'] | True |
social_auth_associate_user | (
backend: BaseAuth, *args: Any, **kwargs: Any
) | A simple wrapper function to reformat the return data from
social_associate_user_helper as a dictionary. The
python-social-auth infrastructure will then pass those values into
later stages of settings.SOCIAL_AUTH_PIPELINE, such as
social_auth_finish, as kwargs.
| A simple wrapper function to reformat the return data from
social_associate_user_helper as a dictionary. The
python-social-auth infrastructure will then pass those values into
later stages of settings.SOCIAL_AUTH_PIPELINE, such as
social_auth_finish, as kwargs.
| def social_auth_associate_user(
backend: BaseAuth, *args: Any, **kwargs: Any
) -> Union[HttpResponse, Dict[str, Any]]:
"""A simple wrapper function to reformat the return data from
social_associate_user_helper as a dictionary. The
python-social-auth infrastructure will then pass those values into
l... | [
"def",
"social_auth_associate_user",
"(",
"backend",
":",
"BaseAuth",
",",
"*",
"args",
":",
"Any",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"Union",
"[",
"HttpResponse",
",",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"partial_token",
"=",
... | [
1457,
0
] | [
1478,
9
] | python | en | ['en', 'en', 'en'] | True |
social_auth_finish | (
backend: Any, details: Dict[str, Any], response: HttpResponse, *args: Any, **kwargs: Any
) | Given the determination in social_auth_associate_user for whether
the user should be authenticated, this takes care of actually
logging in the user (if appropriate) and redirecting the browser
to the appropriate next page depending on the situation. Read the
comments below as well as login_or_register_... | Given the determination in social_auth_associate_user for whether
the user should be authenticated, this takes care of actually
logging in the user (if appropriate) and redirecting the browser
to the appropriate next page depending on the situation. Read the
comments below as well as login_or_register_... | def social_auth_finish(
backend: Any, details: Dict[str, Any], response: HttpResponse, *args: Any, **kwargs: Any
) -> Optional[HttpResponse]:
"""Given the determination in social_auth_associate_user for whether
the user should be authenticated, this takes care of actually
logging in the user (if appropr... | [
"def",
"social_auth_finish",
"(",
"backend",
":",
"Any",
",",
"details",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"response",
":",
"HttpResponse",
",",
"*",
"args",
":",
"Any",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"Optional",
"[",
... | [
1481,
0
] | [
1630,
50
] | python | en | ['en', 'en', 'en'] | True |
ZulipAuthMixin.get_user | (self, user_profile_id: int) | Override the Django method for getting a UserProfile object from
the user_profile_id,. | Override the Django method for getting a UserProfile object from
the user_profile_id,. | def get_user(self, user_profile_id: int) -> Optional[UserProfile]:
"""Override the Django method for getting a UserProfile object from
the user_profile_id,."""
try:
return get_user_profile_by_id(user_profile_id)
except UserProfile.DoesNotExist:
return None | [
"def",
"get_user",
"(",
"self",
",",
"user_profile_id",
":",
"int",
")",
"->",
"Optional",
"[",
"UserProfile",
"]",
":",
"try",
":",
"return",
"get_user_profile_by_id",
"(",
"user_profile_id",
")",
"except",
"UserProfile",
".",
"DoesNotExist",
":",
"return",
"... | [
318,
4
] | [
324,
23
] | python | en | ['en', 'en', 'en'] | True |
EmailAuthBackend.authenticate | (
self,
request: HttpRequest,
*,
username: str,
password: str,
realm: Realm,
return_data: Optional[Dict[str, Any]] = None,
) | Authenticate a user based on email address as the user name. | Authenticate a user based on email address as the user name. | def authenticate(
self,
request: HttpRequest,
*,
username: str,
password: str,
realm: Realm,
return_data: Optional[Dict[str, Any]] = None,
) -> Optional[UserProfile]:
"""Authenticate a user based on email address as the user name."""
if not pas... | [
"def",
"authenticate",
"(",
"self",
",",
"request",
":",
"HttpRequest",
",",
"*",
",",
"username",
":",
"str",
",",
"password",
":",
"str",
",",
"realm",
":",
"Realm",
",",
"return_data",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]"... | [
379,
4
] | [
426,
19
] | python | en | ['en', 'en', 'en'] | True |
ZulipLDAPAuthBackendBase.django_to_ldap_username | (self, username: str) |
Translates django username (user_profile.delivery_email or whatever the user typed in the login
field when authenticating via the LDAP backend) into LDAP username.
Guarantees that the username it returns actually has an entry in the LDAP directory.
Raises ZulipLDAPExceptionNoMatchingLDA... |
Translates django username (user_profile.delivery_email or whatever the user typed in the login
field when authenticating via the LDAP backend) into LDAP username.
Guarantees that the username it returns actually has an entry in the LDAP directory.
Raises ZulipLDAPExceptionNoMatchingLDA... | def django_to_ldap_username(self, username: str) -> str:
"""
Translates django username (user_profile.delivery_email or whatever the user typed in the login
field when authenticating via the LDAP backend) into LDAP username.
Guarantees that the username it returns actually has an entry i... | [
"def",
"django_to_ldap_username",
"(",
"self",
",",
"username",
":",
"str",
")",
"->",
"str",
":",
"result",
"=",
"username",
"if",
"settings",
".",
"LDAP_APPEND_DOMAIN",
":",
"if",
"is_valid_email",
"(",
"username",
")",
":",
"if",
"not",
"username",
".",
... | [
534,
4
] | [
574,
21
] | python | en | ['en', 'error', 'th'] | False |
ZulipLDAPAuthBackendBase.ldap_to_django_username | (self, username: str) |
This is called inside django_auth_ldap with only one role:
to convert _LDAPUser._username to django username (so in Zulip, the email)
and pass that as "username" argument to get_or_build_user(username, ldapuser).
In many cases, the email is stored in the _LDAPUser's attributes, so it ca... |
This is called inside django_auth_ldap with only one role:
to convert _LDAPUser._username to django username (so in Zulip, the email)
and pass that as "username" argument to get_or_build_user(username, ldapuser).
In many cases, the email is stored in the _LDAPUser's attributes, so it ca... | def ldap_to_django_username(self, username: str) -> str:
"""
This is called inside django_auth_ldap with only one role:
to convert _LDAPUser._username to django username (so in Zulip, the email)
and pass that as "username" argument to get_or_build_user(username, ldapuser).
In man... | [
"def",
"ldap_to_django_username",
"(",
"self",
",",
"username",
":",
"str",
")",
"->",
"str",
":",
"return",
"username"
] | [
596,
4
] | [
606,
23
] | python | en | ['en', 'error', 'th'] | False |
ZulipLDAPAuthBackendBase.is_account_control_disabled_user | (self, ldap_user: _LDAPUser) | Implements the userAccountControl check for whether a user has been
disabled in an Active Directory server being integrated with
Zulip via LDAP. | Implements the userAccountControl check for whether a user has been
disabled in an Active Directory server being integrated with
Zulip via LDAP. | def is_account_control_disabled_user(self, ldap_user: _LDAPUser) -> bool:
"""Implements the userAccountControl check for whether a user has been
disabled in an Active Directory server being integrated with
Zulip via LDAP."""
account_control_value = ldap_user.attrs[
settings.A... | [
"def",
"is_account_control_disabled_user",
"(",
"self",
",",
"ldap_user",
":",
"_LDAPUser",
")",
"->",
"bool",
":",
"account_control_value",
"=",
"ldap_user",
".",
"attrs",
"[",
"settings",
".",
"AUTH_LDAP_USER_ATTR_MAP",
"[",
"\"userAccountControl\"",
"]",
"]",
"["... | [
642,
4
] | [
650,
28
] | python | en | ['en', 'en', 'en'] | True |
ZulipLDAPAuthBackendBase.get_mapped_name | (cls, ldap_user: _LDAPUser) | Constructs the user's Zulip full_name from the LDAP data | Constructs the user's Zulip full_name from the LDAP data | def get_mapped_name(cls, ldap_user: _LDAPUser) -> str:
"""Constructs the user's Zulip full_name from the LDAP data"""
if "full_name" in settings.AUTH_LDAP_USER_ATTR_MAP:
full_name_attr = settings.AUTH_LDAP_USER_ATTR_MAP["full_name"]
full_name = ldap_user.attrs[full_name_attr][0]
... | [
"def",
"get_mapped_name",
"(",
"cls",
",",
"ldap_user",
":",
"_LDAPUser",
")",
"->",
"str",
":",
"if",
"\"full_name\"",
"in",
"settings",
".",
"AUTH_LDAP_USER_ATTR_MAP",
":",
"full_name_attr",
"=",
"settings",
".",
"AUTH_LDAP_USER_ATTR_MAP",
"[",
"\"full_name\"",
... | [
695,
4
] | [
709,
24
] | python | en | ['en', 'en', 'en'] | True |
ZulipLDAPAuthBackend.get_or_build_user | (self, username: str, ldap_user: _LDAPUser) | The main function of our authentication backend extension of
django-auth-ldap. When this is called (from `authenticate`),
django-auth-ldap will already have verified that the provided
username and password match those in the LDAP database.
This function's responsibility is to check (1)... | The main function of our authentication backend extension of
django-auth-ldap. When this is called (from `authenticate`),
django-auth-ldap will already have verified that the provided
username and password match those in the LDAP database. | def get_or_build_user(self, username: str, ldap_user: _LDAPUser) -> Tuple[UserProfile, bool]:
"""The main function of our authentication backend extension of
django-auth-ldap. When this is called (from `authenticate`),
django-auth-ldap will already have verified that the provided
userna... | [
"def",
"get_or_build_user",
"(",
"self",
",",
"username",
":",
"str",
",",
"ldap_user",
":",
"_LDAPUser",
")",
"->",
"Tuple",
"[",
"UserProfile",
",",
"bool",
"]",
":",
"return_data",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"{",
"}",
"username",... | [
785,
4
] | [
885,
33
] | python | en | ['en', 'en', 'en'] | True |
ZulipLDAPUserPopulator.get_or_build_user | (
self, username: str, ldap_user: ZulipLDAPUser
) | This is used only in non-authentication contexts such as:
./manage.py sync_ldap_user_data
| This is used only in non-authentication contexts such as:
./manage.py sync_ldap_user_data
| def get_or_build_user(
self, username: str, ldap_user: ZulipLDAPUser
) -> Tuple[UserProfile, bool]:
"""This is used only in non-authentication contexts such as:
./manage.py sync_ldap_user_data
"""
# Obtain the django username from the ldap_user object:
username = self... | [
"def",
"get_or_build_user",
"(",
"self",
",",
"username",
":",
"str",
",",
"ldap_user",
":",
"ZulipLDAPUser",
")",
"->",
"Tuple",
"[",
"UserProfile",
",",
"bool",
"]",
":",
"# Obtain the django username from the ldap_user object:",
"username",
"=",
"self",
".",
"u... | [
923,
4
] | [
959,
28
] | python | en | ['en', 'en', 'en'] | True |
ExternalAuthMethod.dict_representation | (cls, realm: Optional[Realm] = None) |
Method returning dictionaries representing the authentication methods
corresponding to the backend that subclasses this. The documentation
for the external_authentication_methods field of the /server_settings endpoint
explains the details of these dictionaries.
This returns a li... |
Method returning dictionaries representing the authentication methods
corresponding to the backend that subclasses this. The documentation
for the external_authentication_methods field of the /server_settings endpoint
explains the details of these dictionaries.
This returns a li... | def dict_representation(cls, realm: Optional[Realm] = None) -> List[ExternalAuthMethodDictT]:
"""
Method returning dictionaries representing the authentication methods
corresponding to the backend that subclasses this. The documentation
for the external_authentication_methods field of th... | [
"def",
"dict_representation",
"(",
"cls",
",",
"realm",
":",
"Optional",
"[",
"Realm",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"ExternalAuthMethodDictT",
"]",
":"
] | [
1095,
4
] | [
1103,
11
] | python | en | ['en', 'error', 'th'] | False |
SocialAuthMixin.auth_complete | (self, *args: Any, **kwargs: Any) | This is a small wrapper around the core `auth_complete` method of
python-social-auth, designed primarily to prevent 500s for
exceptions in the social auth code from situations that are
really user errors. Returning `None` from this function will
redirect the browser to the login page.
... | This is a small wrapper around the core `auth_complete` method of
python-social-auth, designed primarily to prevent 500s for
exceptions in the social auth code from situations that are
really user errors. Returning `None` from this function will
redirect the browser to the login page.
... | def auth_complete(self, *args: Any, **kwargs: Any) -> Optional[HttpResponse]:
"""This is a small wrapper around the core `auth_complete` method of
python-social-auth, designed primarily to prevent 500s for
exceptions in the social auth code from situations that are
really user errors. R... | [
"def",
"auth_complete",
"(",
"self",
",",
"*",
"args",
":",
"Any",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"Optional",
"[",
"HttpResponse",
"]",
":",
"try",
":",
"# Call the auth_complete method of social_core.backends.oauth.BaseOAuth2",
"return",
"super",... | [
1648,
4
] | [
1670,
23
] | python | en | ['en', 'en', 'en'] | True |
ZulipSAMLIdentityProvider.get_user_details | (self, attributes: Dict[str, Any]) |
Overriden to support plumbing of additional Attributes
from the SAMLResponse.
|
Overriden to support plumbing of additional Attributes
from the SAMLResponse.
| def get_user_details(self, attributes: Dict[str, Any]) -> Dict[str, Any]:
"""
Overriden to support plumbing of additional Attributes
from the SAMLResponse.
"""
result = super().get_user_details(attributes)
extra_attr_names = self.conf.get("extra_attrs", [])
resul... | [
"def",
"get_user_details",
"(",
"self",
",",
"attributes",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"result",
"=",
"super",
"(",
")",
".",
"get_user_details",
"(",
"attributes",
")",
"extra_attr_nam... | [
2003,
4
] | [
2017,
21
] | python | en | ['en', 'error', 'th'] | False |
test_job_template_survey_password_redaction | (job_template_with_survey_passwords_unit) | Tests the JobTemplate model's funciton to redact passwords from
extra_vars - used when creating a new job | Tests the JobTemplate model's funciton to redact passwords from
extra_vars - used when creating a new job | def test_job_template_survey_password_redaction(job_template_with_survey_passwords_unit):
"""Tests the JobTemplate model's funciton to redact passwords from
extra_vars - used when creating a new job"""
assert job_template_with_survey_passwords_unit.survey_password_variables() == ['secret_key', 'SSN'] | [
"def",
"test_job_template_survey_password_redaction",
"(",
"job_template_with_survey_passwords_unit",
")",
":",
"assert",
"job_template_with_survey_passwords_unit",
".",
"survey_password_variables",
"(",
")",
"==",
"[",
"'secret_key'",
",",
"'SSN'",
"]"
] | [
29,
0
] | [
32,
103
] | python | en | ['en', 'en', 'en'] | True |
Chatters.all | (self) |
Get all chatters from all groups
:return: List of all chatters
|
Get all chatters from all groups
:return: List of all chatters
| def all(self) -> List[tmi.Chatter]:
"""
Get all chatters from all groups
:return: List of all chatters
"""
return self.broadcaster + self.vips + self.moderators + self.staff + self.admins + self.global_mods + self.viewers | [
"def",
"all",
"(",
"self",
")",
"->",
"List",
"[",
"tmi",
".",
"Chatter",
"]",
":",
"return",
"self",
".",
"broadcaster",
"+",
"self",
".",
"vips",
"+",
"self",
".",
"moderators",
"+",
"self",
".",
"staff",
"+",
"self",
".",
"admins",
"+",
"self",
... | [
42,
4
] | [
47,
122
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.