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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
pad | (image, size, method=Image.BICUBIC, color=None, centering=(0.5, 0.5)) |
Returns a sized and padded version of the image, expanded to fill the
requested aspect ratio and size.
:param image: The image to size and crop.
:param size: The requested output size in pixels, given as a
(width, height) tuple.
:param method: What resampling method to use. Defaul... |
Returns a sized and padded version of the image, expanded to fill the
requested aspect ratio and size. | def pad(image, size, method=Image.BICUBIC, color=None, centering=(0.5, 0.5)):
"""
Returns a sized and padded version of the image, expanded to fill the
requested aspect ratio and size.
:param image: The image to size and crop.
:param size: The requested output size in pixels, given as a
... | [
"def",
"pad",
"(",
"image",
",",
"size",
",",
"method",
"=",
"Image",
".",
"BICUBIC",
",",
"color",
"=",
"None",
",",
"centering",
"=",
"(",
"0.5",
",",
"0.5",
")",
")",
":",
"im_ratio",
"=",
"image",
".",
"width",
"/",
"image",
".",
"height",
"d... | [
230,
0
] | [
272,
14
] | python | en | ['en', 'error', 'th'] | False |
crop | (image, border=0) |
Remove border from image. The same amount of pixels are removed
from all four sides. This function works on all image modes.
.. seealso:: :py:meth:`~PIL.Image.Image.crop`
:param image: The image to crop.
:param border: The number of pixels to remove.
:return: An image.
|
Remove border from image. The same amount of pixels are removed
from all four sides. This function works on all image modes. | def crop(image, border=0):
"""
Remove border from image. The same amount of pixels are removed
from all four sides. This function works on all image modes.
.. seealso:: :py:meth:`~PIL.Image.Image.crop`
:param image: The image to crop.
:param border: The number of pixels to remove.
:retur... | [
"def",
"crop",
"(",
"image",
",",
"border",
"=",
"0",
")",
":",
"left",
",",
"top",
",",
"right",
",",
"bottom",
"=",
"_border",
"(",
"border",
")",
"return",
"image",
".",
"crop",
"(",
"(",
"left",
",",
"top",
",",
"image",
".",
"size",
"[",
"... | [
275,
0
] | [
287,
81
] | python | en | ['en', 'error', 'th'] | False |
scale | (image, factor, resample=Image.BICUBIC) |
Returns a rescaled image by a specific factor given in parameter.
A factor greater than 1 expands the image, between 0 and 1 contracts the
image.
:param image: The image to rescale.
:param factor: The expansion factor, as a float.
:param resample: What resampling method to use. Default is
... |
Returns a rescaled image by a specific factor given in parameter.
A factor greater than 1 expands the image, between 0 and 1 contracts the
image. | def scale(image, factor, resample=Image.BICUBIC):
"""
Returns a rescaled image by a specific factor given in parameter.
A factor greater than 1 expands the image, between 0 and 1 contracts the
image.
:param image: The image to rescale.
:param factor: The expansion factor, as a float.
:param... | [
"def",
"scale",
"(",
"image",
",",
"factor",
",",
"resample",
"=",
"Image",
".",
"BICUBIC",
")",
":",
"if",
"factor",
"==",
"1",
":",
"return",
"image",
".",
"copy",
"(",
")",
"elif",
"factor",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"the facto... | [
290,
0
] | [
308,
43
] | python | en | ['en', 'error', 'th'] | False |
deform | (image, deformer, resample=Image.BILINEAR) |
Deform the image.
:param image: The image to deform.
:param deformer: A deformer object. Any object that implements a
``getmesh`` method can be used.
:param resample: An optional resampling filter. Same values possible as
in the PIL.Image.transform function.
:return: An... |
Deform the image. | def deform(image, deformer, resample=Image.BILINEAR):
"""
Deform the image.
:param image: The image to deform.
:param deformer: A deformer object. Any object that implements a
``getmesh`` method can be used.
:param resample: An optional resampling filter. Same values possible a... | [
"def",
"deform",
"(",
"image",
",",
"deformer",
",",
"resample",
"=",
"Image",
".",
"BILINEAR",
")",
":",
"return",
"image",
".",
"transform",
"(",
"image",
".",
"size",
",",
"Image",
".",
"MESH",
",",
"deformer",
".",
"getmesh",
"(",
"image",
")",
"... | [
311,
0
] | [
322,
85
] | python | en | ['en', 'error', 'th'] | False |
equalize | (image, mask=None) |
Equalize the image histogram. This function applies a non-linear
mapping to the input image, in order to create a uniform
distribution of grayscale values in the output image.
:param image: The image to equalize.
:param mask: An optional mask. If given, only the pixels selected by
... |
Equalize the image histogram. This function applies a non-linear
mapping to the input image, in order to create a uniform
distribution of grayscale values in the output image. | def equalize(image, mask=None):
"""
Equalize the image histogram. This function applies a non-linear
mapping to the input image, in order to create a uniform
distribution of grayscale values in the output image.
:param image: The image to equalize.
:param mask: An optional mask. If given, only... | [
"def",
"equalize",
"(",
"image",
",",
"mask",
"=",
"None",
")",
":",
"if",
"image",
".",
"mode",
"==",
"\"P\"",
":",
"image",
"=",
"image",
".",
"convert",
"(",
"\"RGB\"",
")",
"h",
"=",
"image",
".",
"histogram",
"(",
"mask",
")",
"lut",
"=",
"[... | [
325,
0
] | [
353,
27
] | python | en | ['en', 'error', 'th'] | False |
expand | (image, border=0, fill=0) |
Add border to the image
:param image: The image to expand.
:param border: Border width, in pixels.
:param fill: Pixel fill value (a color value). Default is 0 (black).
:return: An image.
|
Add border to the image | def expand(image, border=0, fill=0):
"""
Add border to the image
:param image: The image to expand.
:param border: Border width, in pixels.
:param fill: Pixel fill value (a color value). Default is 0 (black).
:return: An image.
"""
left, top, right, bottom = _border(border)
width =... | [
"def",
"expand",
"(",
"image",
",",
"border",
"=",
"0",
",",
"fill",
"=",
"0",
")",
":",
"left",
",",
"top",
",",
"right",
",",
"bottom",
"=",
"_border",
"(",
"border",
")",
"width",
"=",
"left",
"+",
"image",
".",
"size",
"[",
"0",
"]",
"+",
... | [
356,
0
] | [
370,
14
] | python | en | ['en', 'error', 'th'] | False |
fit | (image, size, method=Image.BICUBIC, bleed=0.0, centering=(0.5, 0.5)) |
Returns a sized and cropped version of the image, cropped to the
requested aspect ratio and size.
This function was contributed by Kevin Cazabon.
:param image: The image to size and crop.
:param size: The requested output size in pixels, given as a
(width, height) tuple.
:par... |
Returns a sized and cropped version of the image, cropped to the
requested aspect ratio and size. | def fit(image, size, method=Image.BICUBIC, bleed=0.0, centering=(0.5, 0.5)):
"""
Returns a sized and cropped version of the image, cropped to the
requested aspect ratio and size.
This function was contributed by Kevin Cazabon.
:param image: The image to size and crop.
:param size: The requeste... | [
"def",
"fit",
"(",
"image",
",",
"size",
",",
"method",
"=",
"Image",
".",
"BICUBIC",
",",
"bleed",
"=",
"0.0",
",",
"centering",
"=",
"(",
"0.5",
",",
"0.5",
")",
")",
":",
"# by Kevin Cazabon, Feb 17/2000",
"# kevin@cazabon.com",
"# http://www.cazabon.com",
... | [
373,
0
] | [
455,
47
] | python | en | ['en', 'error', 'th'] | False |
flip | (image) |
Flip the image vertically (top to bottom).
:param image: The image to flip.
:return: An image.
|
Flip the image vertically (top to bottom). | def flip(image):
"""
Flip the image vertically (top to bottom).
:param image: The image to flip.
:return: An image.
"""
return image.transpose(Image.FLIP_TOP_BOTTOM) | [
"def",
"flip",
"(",
"image",
")",
":",
"return",
"image",
".",
"transpose",
"(",
"Image",
".",
"FLIP_TOP_BOTTOM",
")"
] | [
458,
0
] | [
465,
49
] | python | en | ['en', 'error', 'th'] | False |
grayscale | (image) |
Convert the image to grayscale.
:param image: The image to convert.
:return: An image.
|
Convert the image to grayscale. | def grayscale(image):
"""
Convert the image to grayscale.
:param image: The image to convert.
:return: An image.
"""
return image.convert("L") | [
"def",
"grayscale",
"(",
"image",
")",
":",
"return",
"image",
".",
"convert",
"(",
"\"L\"",
")"
] | [
468,
0
] | [
475,
29
] | python | en | ['en', 'error', 'th'] | False |
invert | (image) |
Invert (negate) the image.
:param image: The image to invert.
:return: An image.
|
Invert (negate) the image. | def invert(image):
"""
Invert (negate) the image.
:param image: The image to invert.
:return: An image.
"""
lut = []
for i in range(256):
lut.append(255 - i)
return _lut(image, lut) | [
"def",
"invert",
"(",
"image",
")",
":",
"lut",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"256",
")",
":",
"lut",
".",
"append",
"(",
"255",
"-",
"i",
")",
"return",
"_lut",
"(",
"image",
",",
"lut",
")"
] | [
478,
0
] | [
488,
27
] | python | en | ['en', 'error', 'th'] | False |
mirror | (image) |
Flip image horizontally (left to right).
:param image: The image to mirror.
:return: An image.
|
Flip image horizontally (left to right). | def mirror(image):
"""
Flip image horizontally (left to right).
:param image: The image to mirror.
:return: An image.
"""
return image.transpose(Image.FLIP_LEFT_RIGHT) | [
"def",
"mirror",
"(",
"image",
")",
":",
"return",
"image",
".",
"transpose",
"(",
"Image",
".",
"FLIP_LEFT_RIGHT",
")"
] | [
491,
0
] | [
498,
49
] | python | en | ['en', 'error', 'th'] | False |
posterize | (image, bits) |
Reduce the number of bits for each color channel.
:param image: The image to posterize.
:param bits: The number of bits to keep for each channel (1-8).
:return: An image.
|
Reduce the number of bits for each color channel. | def posterize(image, bits):
"""
Reduce the number of bits for each color channel.
:param image: The image to posterize.
:param bits: The number of bits to keep for each channel (1-8).
:return: An image.
"""
lut = []
mask = ~(2 ** (8 - bits) - 1)
for i in range(256):
lut.appe... | [
"def",
"posterize",
"(",
"image",
",",
"bits",
")",
":",
"lut",
"=",
"[",
"]",
"mask",
"=",
"~",
"(",
"2",
"**",
"(",
"8",
"-",
"bits",
")",
"-",
"1",
")",
"for",
"i",
"in",
"range",
"(",
"256",
")",
":",
"lut",
".",
"append",
"(",
"i",
"... | [
501,
0
] | [
513,
27
] | python | en | ['en', 'error', 'th'] | False |
solarize | (image, threshold=128) |
Invert all pixel values above a threshold.
:param image: The image to solarize.
:param threshold: All pixels above this greyscale level are inverted.
:return: An image.
|
Invert all pixel values above a threshold. | def solarize(image, threshold=128):
"""
Invert all pixel values above a threshold.
:param image: The image to solarize.
:param threshold: All pixels above this greyscale level are inverted.
:return: An image.
"""
lut = []
for i in range(256):
if i < threshold:
lut.ap... | [
"def",
"solarize",
"(",
"image",
",",
"threshold",
"=",
"128",
")",
":",
"lut",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"256",
")",
":",
"if",
"i",
"<",
"threshold",
":",
"lut",
".",
"append",
"(",
"i",
")",
"else",
":",
"lut",
".",
"a... | [
516,
0
] | [
530,
27
] | python | en | ['en', 'error', 'th'] | False |
exif_transpose | (image) |
If an image has an EXIF Orientation tag, return a new image that is
transposed accordingly. Otherwise, return a copy of the image.
:param image: The image to transpose.
:return: An image.
|
If an image has an EXIF Orientation tag, return a new image that is
transposed accordingly. Otherwise, return a copy of the image. | def exif_transpose(image):
"""
If an image has an EXIF Orientation tag, return a new image that is
transposed accordingly. Otherwise, return a copy of the image.
:param image: The image to transpose.
:return: An image.
"""
exif = image.getexif()
orientation = exif.get(0x0112)
method... | [
"def",
"exif_transpose",
"(",
"image",
")",
":",
"exif",
"=",
"image",
".",
"getexif",
"(",
")",
"orientation",
"=",
"exif",
".",
"get",
"(",
"0x0112",
")",
"method",
"=",
"{",
"2",
":",
"Image",
".",
"FLIP_LEFT_RIGHT",
",",
"3",
":",
"Image",
".",
... | [
533,
0
] | [
557,
23
] | python | en | ['en', 'error', 'th'] | False |
transform_hits | (hits) |
The list from pypi is really a list of versions. We want a list of
packages with the list of versions stored inline. This converts the
list from pypi into one we can use.
|
The list from pypi is really a list of versions. We want a list of
packages with the list of versions stored inline. This converts the
list from pypi into one we can use.
| def transform_hits(hits):
# type: (List[Dict[str, str]]) -> List[TransformedHit]
"""
The list from pypi is really a list of versions. We want a list of
packages with the list of versions stored inline. This converts the
list from pypi into one we can use.
"""
packages = OrderedDict() # type... | [
"def",
"transform_hits",
"(",
"hits",
")",
":",
"# type: (List[Dict[str, str]]) -> List[TransformedHit]",
"packages",
"=",
"OrderedDict",
"(",
")",
"# type: OrderedDict[str, TransformedHit]",
"for",
"hit",
"in",
"hits",
":",
"name",
"=",
"hit",
"[",
"'name'",
"]",
"su... | [
85,
0
] | [
111,
34
] | python | en | ['en', 'error', 'th'] | False |
_find_egg_info | (directory) | Find an .egg-info subdirectory in `directory`.
| Find an .egg-info subdirectory in `directory`.
| def _find_egg_info(directory):
# type: (str) -> str
"""Find an .egg-info subdirectory in `directory`.
"""
filenames = [
f for f in os.listdir(directory) if f.endswith(".egg-info")
]
if not filenames:
raise InstallationError(
"No .egg-info directory found in {}".forma... | [
"def",
"_find_egg_info",
"(",
"directory",
")",
":",
"# type: (str) -> str",
"filenames",
"=",
"[",
"f",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"directory",
")",
"if",
"f",
".",
"endswith",
"(",
"\".egg-info\"",
")",
"]",
"if",
"not",
"filenames",
... | [
18,
0
] | [
38,
48
] | python | en | ['en', 'en', 'en'] | True |
generate_metadata | (
build_env, # type: BuildEnvironment
setup_py_path, # type: str
source_dir, # type: str
isolated, # type: bool
details, # type: str
) | Generate metadata using setup.py-based defacto mechanisms.
Returns the generated metadata directory.
| Generate metadata using setup.py-based defacto mechanisms. | def generate_metadata(
build_env, # type: BuildEnvironment
setup_py_path, # type: str
source_dir, # type: str
isolated, # type: bool
details, # type: str
):
# type: (...) -> str
"""Generate metadata using setup.py-based defacto mechanisms.
Returns the generated metadata directory.
... | [
"def",
"generate_metadata",
"(",
"build_env",
",",
"# type: BuildEnvironment",
"setup_py_path",
",",
"# type: str",
"source_dir",
",",
"# type: str",
"isolated",
",",
"# type: bool",
"details",
",",
"# type: str",
")",
":",
"# type: (...) -> str",
"logger",
".",
"debug"... | [
41,
0
] | [
76,
39
] | python | en | ['en', 'zu', 'en'] | True |
rf_permutation_importance.__init__ | (self, use_data='all') |
Parameters
----------
use_data : str
If 'all' use all availible data when training RF model. Else use
an 80/20 split of the data.
Returns
----------
None
|
Parameters
----------
use_data : str
If 'all' use all availible data when training RF model. Else use
an 80/20 split of the data.
Returns
----------
None
| def __init__(self, use_data='all'):
"""
Parameters
----------
use_data : str
If 'all' use all availible data when training RF model. Else use
an 80/20 split of the data.
Returns
----------
None
"""
... | [
"def",
"__init__",
"(",
"self",
",",
"use_data",
"=",
"'all'",
")",
":",
"self",
".",
"importance_type",
"=",
"use_data",
"self",
".",
"model",
"=",
"RandomForestRegressor",
"(",
"n_jobs",
"=",
"-",
"1",
",",
"random_state",
"=",
"10",
",",
"n_estimators",... | [
18,
4
] | [
38,
63
] | python | en | ['en', 'ja', 'th'] | False |
rf_permutation_importance.run | (self, df, target, n_repeats=5, random_state=1) | Fit model and compute permutation importance.
Parameters
----------
df : pandas.DataFrame
DataFrame containing experimental data.
target : 'str'
Column name for target (e.g., 'yield').
n_repeats : int
Number of times to permuate in ord... | Fit model and compute permutation importance.
Parameters
----------
df : pandas.DataFrame
DataFrame containing experimental data.
target : 'str'
Column name for target (e.g., 'yield').
n_repeats : int
Number of times to permuate in ord... | def run(self, df, target, n_repeats=5, random_state=1):
"""Fit model and compute permutation importance.
Parameters
----------
df : pandas.DataFrame
DataFrame containing experimental data.
target : 'str'
Column name for target (e.g., 'yield').
... | [
"def",
"run",
"(",
"self",
",",
"df",
",",
"target",
",",
"n_repeats",
"=",
"5",
",",
"random_state",
"=",
"1",
")",
":",
"# Select training and test data",
"if",
"self",
".",
"importance_type",
"==",
"'all'",
":",
"X_train",
"=",
"df",
".",
"drop",
"(",... | [
42,
4
] | [
88,
64
] | python | en | ['en', 'en', 'en'] | True |
rf_permutation_importance.plot_importances | (self, top_k=10, export_path=None) | Plot a importances as a box plot.
Parameters
----------
top_k : int
Show top_k features according to permutation importance.
export_path : None, str
Export impotance plot to export_path as an SVG.
Returns
----------
matplo... | Plot a importances as a box plot.
Parameters
----------
top_k : int
Show top_k features according to permutation importance.
export_path : None, str
Export impotance plot to export_path as an SVG.
Returns
----------
matplo... | def plot_importances(self, top_k=10, export_path=None):
"""Plot a importances as a box plot.
Parameters
----------
top_k : int
Show top_k features according to permutation importance.
export_path : None, str
Export impotance plot to export_path as... | [
"def",
"plot_importances",
"(",
"self",
",",
"top_k",
"=",
"10",
",",
"export_path",
"=",
"None",
")",
":",
"perm_sorted_idx",
"=",
"self",
".",
"result",
".",
"importances_mean",
".",
"argsort",
"(",
")",
"plot_data",
"=",
"self",
".",
"result",
".",
"i... | [
90,
4
] | [
119,
25
] | python | en | ['en', 'hu', 'en'] | True |
rf_permutation_importance.get_best | (self, threshold) | Return descriptors with importance above threshold.
Parameters
----------
threshold : float
Return a list of descriptors with importance above the specified
threshold.
Returns
----------
numpy.array
Array of descriptor... | Return descriptors with importance above threshold.
Parameters
----------
threshold : float
Return a list of descriptors with importance above the specified
threshold.
Returns
----------
numpy.array
Array of descriptor... | def get_best(self, threshold):
"""Return descriptors with importance above threshold.
Parameters
----------
threshold : float
Return a list of descriptors with importance above the specified
threshold.
Returns
----------
n... | [
"def",
"get_best",
"(",
"self",
",",
"threshold",
")",
":",
"best",
"=",
"self",
".",
"importances",
"[",
"self",
".",
"importances",
"[",
"'mean'",
"]",
">",
"threshold",
"]",
"s",
"=",
"best",
"[",
"'mean'",
"]",
".",
"sum",
"(",
")",
"tot",
"=",... | [
121,
4
] | [
143,
32
] | python | en | ['en', 'en', 'en'] | True |
is_iterable | (obj) |
Are we being asked to look up a list of things, instead of a single thing?
We check for the `__iter__` attribute so that this can cover types that
don't have to be known by this module, such as NumPy arrays.
Strings, however, should be considered as atomic values to look up, not
iterables. The sam... |
Are we being asked to look up a list of things, instead of a single thing?
We check for the `__iter__` attribute so that this can cover types that
don't have to be known by this module, such as NumPy arrays. | def is_iterable(obj):
"""
Are we being asked to look up a list of things, instead of a single thing?
We check for the `__iter__` attribute so that this can cover types that
don't have to be known by this module, such as NumPy arrays.
Strings, however, should be considered as atomic values to look u... | [
"def",
"is_iterable",
"(",
"obj",
")",
":",
"return",
"(",
"hasattr",
"(",
"obj",
",",
"\"__iter__\"",
")",
"and",
"not",
"isinstance",
"(",
"obj",
",",
"str",
")",
"and",
"not",
"isinstance",
"(",
"obj",
",",
"tuple",
")",
")"
] | [
21,
0
] | [
38,
5
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.__len__ | (self) |
Returns the number of unique elements in the ordered set
Example:
>>> len(OrderedSet([]))
0
>>> len(OrderedSet([1, 2]))
2
|
Returns the number of unique elements in the ordered set | def __len__(self):
"""
Returns the number of unique elements in the ordered set
Example:
>>> len(OrderedSet([]))
0
>>> len(OrderedSet([1, 2]))
2
"""
return len(self.items) | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"items",
")"
] | [
57,
4
] | [
67,
30
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.__getitem__ | (self, index) |
Get the item at a given index.
If `index` is a slice, you will get back that slice of items, as a
new OrderedSet.
If `index` is a list or a similar iterable, you'll get a list of
items corresponding to those indices. This is similar to NumPy's
"fancy indexing". The res... |
Get the item at a given index. | def __getitem__(self, index):
"""
Get the item at a given index.
If `index` is a slice, you will get back that slice of items, as a
new OrderedSet.
If `index` is a list or a similar iterable, you'll get a list of
items corresponding to those indices. This is similar to ... | [
"def",
"__getitem__",
"(",
"self",
",",
"index",
")",
":",
"if",
"isinstance",
"(",
"index",
",",
"slice",
")",
"and",
"index",
"==",
"SLICE_ALL",
":",
"return",
"self",
".",
"copy",
"(",
")",
"elif",
"is_iterable",
"(",
"index",
")",
":",
"return",
... | [
69,
4
] | [
98,
82
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.copy | (self) |
Return a shallow copy of this object.
Example:
>>> this = OrderedSet([1, 2, 3])
>>> other = this.copy()
>>> this == other
True
>>> this is other
False
|
Return a shallow copy of this object. | def copy(self):
"""
Return a shallow copy of this object.
Example:
>>> this = OrderedSet([1, 2, 3])
>>> other = this.copy()
>>> this == other
True
>>> this is other
False
"""
return self.__class__(self) | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"self",
".",
"__class__",
"(",
"self",
")"
] | [
100,
4
] | [
112,
35
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.__contains__ | (self, key) |
Test if the item is in this ordered set
Example:
>>> 1 in OrderedSet([1, 3, 2])
True
>>> 5 in OrderedSet([1, 3, 2])
False
|
Test if the item is in this ordered set | def __contains__(self, key):
"""
Test if the item is in this ordered set
Example:
>>> 1 in OrderedSet([1, 3, 2])
True
>>> 5 in OrderedSet([1, 3, 2])
False
"""
return key in self.map | [
"def",
"__contains__",
"(",
"self",
",",
"key",
")",
":",
"return",
"key",
"in",
"self",
".",
"map"
] | [
132,
4
] | [
142,
30
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.add | (self, key) |
Add `key` as an item to this OrderedSet, then return its index.
If `key` is already in the OrderedSet, return the index it already
had.
Example:
>>> oset = OrderedSet()
>>> oset.append(3)
0
>>> print(oset)
OrderedSet([3])
... |
Add `key` as an item to this OrderedSet, then return its index. | def add(self, key):
"""
Add `key` as an item to this OrderedSet, then return its index.
If `key` is already in the OrderedSet, return the index it already
had.
Example:
>>> oset = OrderedSet()
>>> oset.append(3)
0
>>> print(oset)
... | [
"def",
"add",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"map",
":",
"self",
".",
"map",
"[",
"key",
"]",
"=",
"len",
"(",
"self",
".",
"items",
")",
"self",
".",
"items",
".",
"append",
"(",
"key",
")",
"return... | [
144,
4
] | [
161,
28
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.update | (self, sequence) |
Update the set with the given iterable sequence, then return the index
of the last element inserted.
Example:
>>> oset = OrderedSet([1, 2, 3])
>>> oset.update([3, 1, 5, 1, 4])
4
>>> print(oset)
OrderedSet([1, 2, 3, 5, 4])
|
Update the set with the given iterable sequence, then return the index
of the last element inserted. | def update(self, sequence):
"""
Update the set with the given iterable sequence, then return the index
of the last element inserted.
Example:
>>> oset = OrderedSet([1, 2, 3])
>>> oset.update([3, 1, 5, 1, 4])
4
>>> print(oset)
O... | [
"def",
"update",
"(",
"self",
",",
"sequence",
")",
":",
"item_index",
"=",
"None",
"try",
":",
"for",
"item",
"in",
"sequence",
":",
"item_index",
"=",
"self",
".",
"add",
"(",
"item",
")",
"except",
"TypeError",
":",
"raise",
"ValueError",
"(",
"\"Ar... | [
165,
4
] | [
185,
25
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.index | (self, key) |
Get the index of a given entry, raising an IndexError if it's not
present.
`key` can be an iterable of entries that is not a string, in which case
this returns a list of indices.
Example:
>>> oset = OrderedSet([1, 2, 3])
>>> oset.index(2)
1
... |
Get the index of a given entry, raising an IndexError if it's not
present. | def index(self, key):
"""
Get the index of a given entry, raising an IndexError if it's not
present.
`key` can be an iterable of entries that is not a string, in which case
this returns a list of indices.
Example:
>>> oset = OrderedSet([1, 2, 3])
... | [
"def",
"index",
"(",
"self",
",",
"key",
")",
":",
"if",
"is_iterable",
"(",
"key",
")",
":",
"return",
"[",
"self",
".",
"index",
"(",
"subkey",
")",
"for",
"subkey",
"in",
"key",
"]",
"return",
"self",
".",
"map",
"[",
"key",
"]"
] | [
187,
4
] | [
202,
28
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.pop | (self) |
Remove and return the last element from the set.
Raises KeyError if the set is empty.
Example:
>>> oset = OrderedSet([1, 2, 3])
>>> oset.pop()
3
|
Remove and return the last element from the set. | def pop(self):
"""
Remove and return the last element from the set.
Raises KeyError if the set is empty.
Example:
>>> oset = OrderedSet([1, 2, 3])
>>> oset.pop()
3
"""
if not self.items:
raise KeyError("Set is empty")
... | [
"def",
"pop",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"items",
":",
"raise",
"KeyError",
"(",
"\"Set is empty\"",
")",
"elem",
"=",
"self",
".",
"items",
"[",
"-",
"1",
"]",
"del",
"self",
".",
"items",
"[",
"-",
"1",
"]",
"del",
"self",... | [
208,
4
] | [
225,
19
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.discard | (self, key) |
Remove an element. Do not raise an exception if absent.
The MutableSet mixin uses this to implement the .remove() method, which
*does* raise an error when asked to remove a non-existent item.
Example:
>>> oset = OrderedSet([1, 2, 3])
>>> oset.discard(2)
... |
Remove an element. Do not raise an exception if absent. | def discard(self, key):
"""
Remove an element. Do not raise an exception if absent.
The MutableSet mixin uses this to implement the .remove() method, which
*does* raise an error when asked to remove a non-existent item.
Example:
>>> oset = OrderedSet([1, 2, 3])
... | [
"def",
"discard",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
":",
"i",
"=",
"self",
".",
"map",
"[",
"key",
"]",
"del",
"self",
".",
"items",
"[",
"i",
"]",
"del",
"self",
".",
"map",
"[",
"key",
"]",
"for",
"k",
",",
"v"... | [
227,
4
] | [
249,
39
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.clear | (self) |
Remove all items from this OrderedSet.
|
Remove all items from this OrderedSet.
| def clear(self):
"""
Remove all items from this OrderedSet.
"""
del self.items[:]
self.map.clear() | [
"def",
"clear",
"(",
"self",
")",
":",
"del",
"self",
".",
"items",
"[",
":",
"]",
"self",
".",
"map",
".",
"clear",
"(",
")"
] | [
251,
4
] | [
256,
24
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.__iter__ | (self) |
Example:
>>> list(iter(OrderedSet([1, 2, 3])))
[1, 2, 3]
|
Example:
>>> list(iter(OrderedSet([1, 2, 3])))
[1, 2, 3]
| def __iter__(self):
"""
Example:
>>> list(iter(OrderedSet([1, 2, 3])))
[1, 2, 3]
"""
return iter(self.items) | [
"def",
"__iter__",
"(",
"self",
")",
":",
"return",
"iter",
"(",
"self",
".",
"items",
")"
] | [
258,
4
] | [
264,
31
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.__reversed__ | (self) |
Example:
>>> list(reversed(OrderedSet([1, 2, 3])))
[3, 2, 1]
|
Example:
>>> list(reversed(OrderedSet([1, 2, 3])))
[3, 2, 1]
| def __reversed__(self):
"""
Example:
>>> list(reversed(OrderedSet([1, 2, 3])))
[3, 2, 1]
"""
return reversed(self.items) | [
"def",
"__reversed__",
"(",
"self",
")",
":",
"return",
"reversed",
"(",
"self",
".",
"items",
")"
] | [
266,
4
] | [
272,
35
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.__eq__ | (self, other) |
Returns true if the containers have the same items. If `other` is a
Sequence, then order is checked, otherwise it is ignored.
Example:
>>> oset = OrderedSet([1, 3, 2])
>>> oset == [1, 3, 2]
True
>>> oset == [1, 2, 3]
False
... |
Returns true if the containers have the same items. If `other` is a
Sequence, then order is checked, otherwise it is ignored. | def __eq__(self, other):
"""
Returns true if the containers have the same items. If `other` is a
Sequence, then order is checked, otherwise it is ignored.
Example:
>>> oset = OrderedSet([1, 3, 2])
>>> oset == [1, 3, 2]
True
>>> oset == [1,... | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"# In Python 2 deque is not a Sequence, so treat it as one for",
"# consistent behavior with Python 3.",
"if",
"isinstance",
"(",
"other",
",",
"(",
"Sequence",
",",
"deque",
")",
")",
":",
"# Check that this OrderedSe... | [
279,
4
] | [
307,
44
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.union | (self, *sets) |
Combines all unique items.
Each items order is defined by its first appearance.
Example:
>>> oset = OrderedSet.union(OrderedSet([3, 1, 4, 1, 5]), [1, 3], [2, 0])
>>> print(oset)
OrderedSet([3, 1, 4, 5, 2, 0])
>>> oset.union([8, 9])
Or... |
Combines all unique items.
Each items order is defined by its first appearance. | def union(self, *sets):
"""
Combines all unique items.
Each items order is defined by its first appearance.
Example:
>>> oset = OrderedSet.union(OrderedSet([3, 1, 4, 1, 5]), [1, 3], [2, 0])
>>> print(oset)
OrderedSet([3, 1, 4, 5, 2, 0])
>>... | [
"def",
"union",
"(",
"self",
",",
"*",
"sets",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"if",
"isinstance",
"(",
"self",
",",
"OrderedSet",
")",
"else",
"OrderedSet",
"containers",
"=",
"map",
"(",
"list",
",",
"it",
".",
"chain",
"(",
"[",
... | [
309,
4
] | [
326,
25
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.intersection | (self, *sets) |
Returns elements in common between all sets. Order is defined only
by the first set.
Example:
>>> oset = OrderedSet.intersection(OrderedSet([0, 1, 2, 3]), [1, 2, 3])
>>> print(oset)
OrderedSet([1, 2, 3])
>>> oset.intersection([2, 4, 5], [1, 2, 3,... |
Returns elements in common between all sets. Order is defined only
by the first set. | def intersection(self, *sets):
"""
Returns elements in common between all sets. Order is defined only
by the first set.
Example:
>>> oset = OrderedSet.intersection(OrderedSet([0, 1, 2, 3]), [1, 2, 3])
>>> print(oset)
OrderedSet([1, 2, 3])
... | [
"def",
"intersection",
"(",
"self",
",",
"*",
"sets",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"if",
"isinstance",
"(",
"self",
",",
"OrderedSet",
")",
"else",
"OrderedSet",
"if",
"sets",
":",
"common",
"=",
"set",
".",
"intersection",
"(",
"*",... | [
332,
4
] | [
352,
25
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.difference | (self, *sets) |
Returns all elements that are in this set but not the others.
Example:
>>> OrderedSet([1, 2, 3]).difference(OrderedSet([2]))
OrderedSet([1, 3])
>>> OrderedSet([1, 2, 3]).difference(OrderedSet([2]), OrderedSet([3]))
OrderedSet([1])
>>> Ordered... |
Returns all elements that are in this set but not the others. | def difference(self, *sets):
"""
Returns all elements that are in this set but not the others.
Example:
>>> OrderedSet([1, 2, 3]).difference(OrderedSet([2]))
OrderedSet([1, 3])
>>> OrderedSet([1, 2, 3]).difference(OrderedSet([2]), OrderedSet([3]))
... | [
"def",
"difference",
"(",
"self",
",",
"*",
"sets",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"if",
"sets",
":",
"other",
"=",
"set",
".",
"union",
"(",
"*",
"map",
"(",
"set",
",",
"sets",
")",
")",
"items",
"=",
"(",
"item",
"for",
"ite... | [
354,
4
] | [
374,
25
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.issubset | (self, other) |
Report whether another set contains this set.
Example:
>>> OrderedSet([1, 2, 3]).issubset({1, 2})
False
>>> OrderedSet([1, 2, 3]).issubset({1, 2, 3, 4})
True
>>> OrderedSet([1, 2, 3]).issubset({1, 4, 3, 5})
False
|
Report whether another set contains this set. | def issubset(self, other):
"""
Report whether another set contains this set.
Example:
>>> OrderedSet([1, 2, 3]).issubset({1, 2})
False
>>> OrderedSet([1, 2, 3]).issubset({1, 2, 3, 4})
True
>>> OrderedSet([1, 2, 3]).issubset({1, 4, 3, 5... | [
"def",
"issubset",
"(",
"self",
",",
"other",
")",
":",
"if",
"len",
"(",
"self",
")",
">",
"len",
"(",
"other",
")",
":",
"# Fast check for obvious cases",
"return",
"False",
"return",
"all",
"(",
"item",
"in",
"other",
"for",
"item",
"in",
"self",
")... | [
376,
4
] | [
390,
50
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.issuperset | (self, other) |
Report whether this set contains another set.
Example:
>>> OrderedSet([1, 2]).issuperset([1, 2, 3])
False
>>> OrderedSet([1, 2, 3, 4]).issuperset({1, 2, 3})
True
>>> OrderedSet([1, 4, 3, 5]).issuperset({1, 2, 3})
False
|
Report whether this set contains another set. | def issuperset(self, other):
"""
Report whether this set contains another set.
Example:
>>> OrderedSet([1, 2]).issuperset([1, 2, 3])
False
>>> OrderedSet([1, 2, 3, 4]).issuperset({1, 2, 3})
True
>>> OrderedSet([1, 4, 3, 5]).issuperset(... | [
"def",
"issuperset",
"(",
"self",
",",
"other",
")",
":",
"if",
"len",
"(",
"self",
")",
"<",
"len",
"(",
"other",
")",
":",
"# Fast check for obvious cases",
"return",
"False",
"return",
"all",
"(",
"item",
"in",
"self",
"for",
"item",
"in",
"other",
... | [
392,
4
] | [
406,
50
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.symmetric_difference | (self, other) |
Return the symmetric difference of two OrderedSets as a new set.
That is, the new set will contain all elements that are in exactly
one of the sets.
Their order will be preserved, with elements from `self` preceding
elements from `other`.
Example:
>>> this ... |
Return the symmetric difference of two OrderedSets as a new set.
That is, the new set will contain all elements that are in exactly
one of the sets. | def symmetric_difference(self, other):
"""
Return the symmetric difference of two OrderedSets as a new set.
That is, the new set will contain all elements that are in exactly
one of the sets.
Their order will be preserved, with elements from `self` preceding
elements fro... | [
"def",
"symmetric_difference",
"(",
"self",
",",
"other",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"if",
"isinstance",
"(",
"self",
",",
"OrderedSet",
")",
"else",
"OrderedSet",
"diff1",
"=",
"cls",
"(",
"self",
")",
".",
"difference",
"(",
"other... | [
408,
4
] | [
426,
33
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet._update_items | (self, items) |
Replace the 'items' list of this OrderedSet with a new one, updating
self.map accordingly.
|
Replace the 'items' list of this OrderedSet with a new one, updating
self.map accordingly.
| def _update_items(self, items):
"""
Replace the 'items' list of this OrderedSet with a new one, updating
self.map accordingly.
"""
self.items = items
self.map = {item: idx for (idx, item) in enumerate(items)} | [
"def",
"_update_items",
"(",
"self",
",",
"items",
")",
":",
"self",
".",
"items",
"=",
"items",
"self",
".",
"map",
"=",
"{",
"item",
":",
"idx",
"for",
"(",
"idx",
",",
"item",
")",
"in",
"enumerate",
"(",
"items",
")",
"}"
] | [
428,
4
] | [
434,
66
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.difference_update | (self, *sets) |
Update this OrderedSet to remove items from one or more other sets.
Example:
>>> this = OrderedSet([1, 2, 3])
>>> this.difference_update(OrderedSet([2, 4]))
>>> print(this)
OrderedSet([1, 3])
>>> this = OrderedSet([1, 2, 3, 4, 5])
... |
Update this OrderedSet to remove items from one or more other sets. | def difference_update(self, *sets):
"""
Update this OrderedSet to remove items from one or more other sets.
Example:
>>> this = OrderedSet([1, 2, 3])
>>> this.difference_update(OrderedSet([2, 4]))
>>> print(this)
OrderedSet([1, 3])
>>... | [
"def",
"difference_update",
"(",
"self",
",",
"*",
"sets",
")",
":",
"items_to_remove",
"=",
"set",
"(",
")",
"for",
"other",
"in",
"sets",
":",
"items_to_remove",
"|=",
"set",
"(",
"other",
")",
"self",
".",
"_update_items",
"(",
"[",
"item",
"for",
"... | [
436,
4
] | [
454,
88
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.intersection_update | (self, other) |
Update this OrderedSet to keep only items in another set, preserving
their order in this set.
Example:
>>> this = OrderedSet([1, 4, 3, 5, 7])
>>> other = OrderedSet([9, 7, 1, 3, 2])
>>> this.intersection_update(other)
>>> print(this)
... |
Update this OrderedSet to keep only items in another set, preserving
their order in this set. | def intersection_update(self, other):
"""
Update this OrderedSet to keep only items in another set, preserving
their order in this set.
Example:
>>> this = OrderedSet([1, 4, 3, 5, 7])
>>> other = OrderedSet([9, 7, 1, 3, 2])
>>> this.intersection_updat... | [
"def",
"intersection_update",
"(",
"self",
",",
"other",
")",
":",
"other",
"=",
"set",
"(",
"other",
")",
"self",
".",
"_update_items",
"(",
"[",
"item",
"for",
"item",
"in",
"self",
".",
"items",
"if",
"item",
"in",
"other",
"]",
")"
] | [
456,
4
] | [
469,
74
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.symmetric_difference_update | (self, other) |
Update this OrderedSet to remove items from another set, then
add items from the other set that were not present in this set.
Example:
>>> this = OrderedSet([1, 4, 3, 5, 7])
>>> other = OrderedSet([9, 7, 1, 3, 2])
>>> this.symmetric_difference_update(other)
... |
Update this OrderedSet to remove items from another set, then
add items from the other set that were not present in this set. | def symmetric_difference_update(self, other):
"""
Update this OrderedSet to remove items from another set, then
add items from the other set that were not present in this set.
Example:
>>> this = OrderedSet([1, 4, 3, 5, 7])
>>> other = OrderedSet([9, 7, 1, 3, 2])... | [
"def",
"symmetric_difference_update",
"(",
"self",
",",
"other",
")",
":",
"items_to_add",
"=",
"[",
"item",
"for",
"item",
"in",
"other",
"if",
"item",
"not",
"in",
"self",
"]",
"items_to_remove",
"=",
"set",
"(",
"other",
")",
"self",
".",
"_update_items... | [
471,
4
] | [
487,
9
] | python | en | ['en', 'error', 'th'] | False |
can_choose_page | (page, permission_proxy, desired_classes, can_choose_root=True, user_perm=None) | Returns boolean indicating of the user can choose page.
will check if the root page can be selected and if user permissions
should be checked.
| Returns boolean indicating of the user can choose page.
will check if the root page can be selected and if user permissions
should be checked.
| def can_choose_page(page, permission_proxy, desired_classes, can_choose_root=True, user_perm=None):
"""Returns boolean indicating of the user can choose page.
will check if the root page can be selected and if user permissions
should be checked.
"""
if not issubclass(page.specific_class or Page, des... | [
"def",
"can_choose_page",
"(",
"page",
",",
"permission_proxy",
",",
"desired_classes",
",",
"can_choose_root",
"=",
"True",
",",
"user_perm",
"=",
"None",
")",
":",
"if",
"not",
"issubclass",
"(",
"page",
".",
"specific_class",
"or",
"Page",
",",
"desired_cla... | [
49,
0
] | [
61,
15
] | python | en | ['en', 'en', 'en'] | True |
build_user_profile | (
avatar_source: str,
date_joined: Any,
delivery_email: str,
email: str,
full_name: str,
id: int,
is_active: bool,
role: int,
is_mirror_dummy: bool,
realm_id: int,
short_name: str,
timezone: Optional[str],
) |
Even though short_name is no longer in the Zulip
UserProfile, it's helpful to have it in our import
dictionaries for legacy reasons.
|
Even though short_name is no longer in the Zulip
UserProfile, it's helpful to have it in our import
dictionaries for legacy reasons.
| def build_user_profile(
avatar_source: str,
date_joined: Any,
delivery_email: str,
email: str,
full_name: str,
id: int,
is_active: bool,
role: int,
is_mirror_dummy: bool,
realm_id: int,
short_name: str,
timezone: Optional[str],
) -> ZerverFieldsT:
obj = UserProfile(
... | [
"def",
"build_user_profile",
"(",
"avatar_source",
":",
"str",
",",
"date_joined",
":",
"Any",
",",
"delivery_email",
":",
"str",
",",
"email",
":",
"str",
",",
"full_name",
":",
"str",
",",
"id",
":",
"int",
",",
"is_active",
":",
"bool",
",",
"role",
... | [
77,
0
] | [
112,
14
] | python | en | ['en', 'error', 'th'] | False |
make_subscriber_map | (zerver_subscription: List[ZerverFieldsT]) |
This can be convenient for building up UserMessage
rows.
|
This can be convenient for building up UserMessage
rows.
| def make_subscriber_map(zerver_subscription: List[ZerverFieldsT]) -> Dict[int, Set[int]]:
"""
This can be convenient for building up UserMessage
rows.
"""
subscriber_map: Dict[int, Set[int]] = {}
for sub in zerver_subscription:
user_id = sub["user_profile"]
recipient_id = sub["re... | [
"def",
"make_subscriber_map",
"(",
"zerver_subscription",
":",
"List",
"[",
"ZerverFieldsT",
"]",
")",
"->",
"Dict",
"[",
"int",
",",
"Set",
"[",
"int",
"]",
"]",
":",
"subscriber_map",
":",
"Dict",
"[",
"int",
",",
"Set",
"[",
"int",
"]",
"]",
"=",
... | [
136,
0
] | [
149,
25
] | python | en | ['en', 'error', 'th'] | False |
build_public_stream_subscriptions | (
zerver_userprofile: List[ZerverFieldsT],
zerver_recipient: List[ZerverFieldsT],
zerver_stream: List[ZerverFieldsT],
) |
This function was only used for HipChat, but it may apply to
future conversions. We often did't get full subscriber data in
the HipChat export, so this function just autosubscribes all
users to every public stream. This returns a list of Subscription
dicts.
|
This function was only used for HipChat, but it may apply to
future conversions. We often did't get full subscriber data in
the HipChat export, so this function just autosubscribes all
users to every public stream. This returns a list of Subscription
dicts.
| def build_public_stream_subscriptions(
zerver_userprofile: List[ZerverFieldsT],
zerver_recipient: List[ZerverFieldsT],
zerver_stream: List[ZerverFieldsT],
) -> List[ZerverFieldsT]:
"""
This function was only used for HipChat, but it may apply to
future conversions. We often did't get full subsc... | [
"def",
"build_public_stream_subscriptions",
"(",
"zerver_userprofile",
":",
"List",
"[",
"ZerverFieldsT",
"]",
",",
"zerver_recipient",
":",
"List",
"[",
"ZerverFieldsT",
"]",
",",
"zerver_stream",
":",
"List",
"[",
"ZerverFieldsT",
"]",
",",
")",
"->",
"List",
... | [
190,
0
] | [
223,
24
] | python | en | ['en', 'error', 'th'] | False |
build_recipients | (
zerver_userprofile: Iterable[ZerverFieldsT],
zerver_stream: Iterable[ZerverFieldsT],
zerver_huddle: Iterable[ZerverFieldsT] = [],
) |
This function was only used HipChat import, this function may be
required for future conversions. The Slack and Gitter conversions do it more
tightly integrated with creating other objects.
|
This function was only used HipChat import, this function may be
required for future conversions. The Slack and Gitter conversions do it more
tightly integrated with creating other objects.
| def build_recipients(
zerver_userprofile: Iterable[ZerverFieldsT],
zerver_stream: Iterable[ZerverFieldsT],
zerver_huddle: Iterable[ZerverFieldsT] = [],
) -> List[ZerverFieldsT]:
"""
This function was only used HipChat import, this function may be
required for future conversions. The Slack and Gi... | [
"def",
"build_recipients",
"(",
"zerver_userprofile",
":",
"Iterable",
"[",
"ZerverFieldsT",
"]",
",",
"zerver_stream",
":",
"Iterable",
"[",
"ZerverFieldsT",
"]",
",",
"zerver_huddle",
":",
"Iterable",
"[",
"ZerverFieldsT",
"]",
"=",
"[",
"]",
",",
")",
"->",... | [
320,
0
] | [
365,
21
] | python | en | ['en', 'error', 'th'] | False |
build_attachment | (
realm_id: int,
message_ids: Set[int],
user_id: int,
fileinfo: ZerverFieldsT,
s3_path: str,
zerver_attachment: List[ZerverFieldsT],
) |
This function should be passed a 'fileinfo' dictionary, which contains
information about 'size', 'created' (created time) and ['name'] (filename).
|
This function should be passed a 'fileinfo' dictionary, which contains
information about 'size', 'created' (created time) and ['name'] (filename).
| def build_attachment(
realm_id: int,
message_ids: Set[int],
user_id: int,
fileinfo: ZerverFieldsT,
s3_path: str,
zerver_attachment: List[ZerverFieldsT],
) -> None:
"""
This function should be passed a 'fileinfo' dictionary, which contains
information about 'size', 'created' (created ... | [
"def",
"build_attachment",
"(",
"realm_id",
":",
"int",
",",
"message_ids",
":",
"Set",
"[",
"int",
"]",
",",
"user_id",
":",
"int",
",",
"fileinfo",
":",
"ZerverFieldsT",
",",
"s3_path",
":",
"str",
",",
"zerver_attachment",
":",
"List",
"[",
"ZerverField... | [
519,
0
] | [
547,
45
] | python | en | ['en', 'error', 'th'] | False |
process_avatars | (
avatar_list: List[ZerverFieldsT],
avatar_dir: str,
realm_id: int,
threads: int,
size_url_suffix: str = "",
) |
This function gets the avatar of the user and saves it in the
user's avatar directory with both the extensions '.png' and '.original'
Required parameters:
1. avatar_list: List of avatars to be mapped in avatars records.json file
2. avatar_dir: Folder where the downloaded avatars are saved
3. r... |
This function gets the avatar of the user and saves it in the
user's avatar directory with both the extensions '.png' and '.original'
Required parameters: | def process_avatars(
avatar_list: List[ZerverFieldsT],
avatar_dir: str,
realm_id: int,
threads: int,
size_url_suffix: str = "",
) -> List[ZerverFieldsT]:
"""
This function gets the avatar of the user and saves it in the
user's avatar directory with both the extensions '.png' and '.origin... | [
"def",
"process_avatars",
"(",
"avatar_list",
":",
"List",
"[",
"ZerverFieldsT",
"]",
",",
"avatar_dir",
":",
"str",
",",
"realm_id",
":",
"int",
",",
"threads",
":",
"int",
",",
"size_url_suffix",
":",
"str",
"=",
"\"\"",
",",
")",
"->",
"List",
"[",
... | [
562,
0
] | [
611,
45
] | python | en | ['en', 'error', 'th'] | False |
write_avatar_png | (avatar_folder: str, realm_id: int, user_id: int, bits: bytes) |
Use this function for conversions like HipChat where
the bits for the .png file come in something like
a users.json file, and where we don't have to
fetch avatar images externally.
|
Use this function for conversions like HipChat where
the bits for the .png file come in something like
a users.json file, and where we don't have to
fetch avatar images externally.
| def write_avatar_png(avatar_folder: str, realm_id: int, user_id: int, bits: bytes) -> ZerverFieldsT:
"""
Use this function for conversions like HipChat where
the bits for the .png file come in something like
a users.json file, and where we don't have to
fetch avatar images externally.
"""
av... | [
"def",
"write_avatar_png",
"(",
"avatar_folder",
":",
"str",
",",
"realm_id",
":",
"int",
",",
"user_id",
":",
"int",
",",
"bits",
":",
"bytes",
")",
"->",
"ZerverFieldsT",
":",
"avatar_hash",
"=",
"user_avatar_path_from_ids",
"(",
"user_profile_id",
"=",
"use... | [
614,
0
] | [
642,
19
] | python | en | ['en', 'error', 'th'] | False |
process_uploads | (
upload_list: List[ZerverFieldsT], upload_dir: str, threads: int
) |
This function downloads the uploads and saves it in the realm's upload directory.
Required parameters:
1. upload_list: List of uploads to be mapped in uploads records.json file
2. upload_dir: Folder where the downloaded uploads are saved
|
This function downloads the uploads and saves it in the realm's upload directory.
Required parameters: | def process_uploads(
upload_list: List[ZerverFieldsT], upload_dir: str, threads: int
) -> List[ZerverFieldsT]:
"""
This function downloads the uploads and saves it in the realm's upload directory.
Required parameters:
1. upload_list: List of uploads to be mapped in uploads records.json file
2. ... | [
"def",
"process_uploads",
"(",
"upload_list",
":",
"List",
"[",
"ZerverFieldsT",
"]",
",",
"upload_dir",
":",
"str",
",",
"threads",
":",
"int",
")",
"->",
"List",
"[",
"ZerverFieldsT",
"]",
":",
"logging",
".",
"info",
"(",
"\"######### GETTING ATTACHMENTS ##... | [
679,
0
] | [
702,
22
] | python | en | ['en', 'error', 'th'] | False |
process_emojis | (
zerver_realmemoji: List[ZerverFieldsT],
emoji_dir: str,
emoji_url_map: ZerverFieldsT,
threads: int,
) |
This function downloads the custom emojis and saves in the output emoji folder.
Required parameters:
1. zerver_realmemoji: List of all RealmEmoji objects to be imported
2. emoji_dir: Folder where the downloaded emojis are saved
3. emoji_url_map: Maps emoji name to its url
|
This function downloads the custom emojis and saves in the output emoji folder.
Required parameters: | def process_emojis(
zerver_realmemoji: List[ZerverFieldsT],
emoji_dir: str,
emoji_url_map: ZerverFieldsT,
threads: int,
) -> List[ZerverFieldsT]:
"""
This function downloads the custom emojis and saves in the output emoji folder.
Required parameters:
1. zerver_realmemoji: List of all Re... | [
"def",
"process_emojis",
"(",
"zerver_realmemoji",
":",
"List",
"[",
"ZerverFieldsT",
"]",
",",
"emoji_dir",
":",
"str",
",",
"emoji_url_map",
":",
"ZerverFieldsT",
",",
"threads",
":",
"int",
",",
")",
"->",
"List",
"[",
"ZerverFieldsT",
"]",
":",
"emoji_re... | [
727,
0
] | [
765,
24
] | python | en | ['en', 'error', 'th'] | False |
BaseStreamBlock.get_default | (self) |
Default values set on a StreamBlock should be a list of (type_name, value) tuples -
we can't use StreamValue directly, because that would require a reference back to
the StreamBlock that hasn't been built yet.
For consistency, then, we need to convert it to a StreamValue here for Strea... |
Default values set on a StreamBlock should be a list of (type_name, value) tuples -
we can't use StreamValue directly, because that would require a reference back to
the StreamBlock that hasn't been built yet. | def get_default(self):
"""
Default values set on a StreamBlock should be a list of (type_name, value) tuples -
we can't use StreamValue directly, because that would require a reference back to
the StreamBlock that hasn't been built yet.
For consistency, then, we need to convert ... | [
"def",
"get_default",
"(",
"self",
")",
":",
"return",
"StreamValue",
"(",
"self",
",",
"self",
".",
"meta",
".",
"default",
")"
] | [
69,
4
] | [
78,
51
] | python | en | ['en', 'error', 'th'] | False |
BaseStreamBlock.sorted_child_blocks | (self) | Child blocks, sorted in to their groups. | Child blocks, sorted in to their groups. | def sorted_child_blocks(self):
"""Child blocks, sorted in to their groups."""
return sorted(self.child_blocks.values(),
key=lambda child_block: child_block.meta.group) | [
"def",
"sorted_child_blocks",
"(",
"self",
")",
":",
"return",
"sorted",
"(",
"self",
".",
"child_blocks",
".",
"values",
"(",
")",
",",
"key",
"=",
"lambda",
"child_block",
":",
"child_block",
".",
"meta",
".",
"group",
")"
] | [
80,
4
] | [
83,
69
] | python | en | ['en', 'en', 'en'] | True |
BaseStreamBlock.grouped_child_blocks | (self) |
The available child block types of this stream block, organised into groups according to
their meta.group attribute.
Returned as an iterable of (group_name, list_of_blocks) tuples
|
The available child block types of this stream block, organised into groups according to
their meta.group attribute.
Returned as an iterable of (group_name, list_of_blocks) tuples
| def grouped_child_blocks(self):
"""
The available child block types of this stream block, organised into groups according to
their meta.group attribute.
Returned as an iterable of (group_name, list_of_blocks) tuples
"""
return itertools.groupby(
self.sorted_ch... | [
"def",
"grouped_child_blocks",
"(",
"self",
")",
":",
"return",
"itertools",
".",
"groupby",
"(",
"self",
".",
"sorted_child_blocks",
"(",
")",
",",
"key",
"=",
"lambda",
"child_block",
":",
"child_block",
".",
"meta",
".",
"group",
")"
] | [
85,
4
] | [
93,
9
] | python | en | ['en', 'error', 'th'] | False |
BaseStreamBlock.deconstruct | (self) |
Always deconstruct StreamBlock instances as if they were plain StreamBlocks with all of the
field definitions passed to the constructor - even if in reality this is a subclass of StreamBlock
with the fields defined declaratively, or some combination of the two.
This ensures that the fi... |
Always deconstruct StreamBlock instances as if they were plain StreamBlocks with all of the
field definitions passed to the constructor - even if in reality this is a subclass of StreamBlock
with the fields defined declaratively, or some combination of the two. | def deconstruct(self):
"""
Always deconstruct StreamBlock instances as if they were plain StreamBlocks with all of the
field definitions passed to the constructor - even if in reality this is a subclass of StreamBlock
with the fields defined declaratively, or some combination of the two.... | [
"def",
"deconstruct",
"(",
"self",
")",
":",
"path",
"=",
"'wagtail.core.blocks.StreamBlock'",
"args",
"=",
"[",
"list",
"(",
"self",
".",
"child_blocks",
".",
"items",
"(",
")",
")",
"]",
"kwargs",
"=",
"self",
".",
"_constructor_kwargs",
"return",
"(",
"... | [
295,
4
] | [
307,
35
] | python | en | ['en', 'error', 'th'] | False |
StreamValue.__init__ | (self, stream_block, stream_data, is_lazy=False, raw_text=None) |
Construct a StreamValue linked to the given StreamBlock,
with child values given in stream_data.
Passing is_lazy=True means that stream_data is raw JSONish data as stored
in the database, and needs to be converted to native values
(using block.to_python()) when accessed. In thi... |
Construct a StreamValue linked to the given StreamBlock,
with child values given in stream_data. | def __init__(self, stream_block, stream_data, is_lazy=False, raw_text=None):
"""
Construct a StreamValue linked to the given StreamBlock,
with child values given in stream_data.
Passing is_lazy=True means that stream_data is raw JSONish data as stored
in the database, and needs ... | [
"def",
"__init__",
"(",
"self",
",",
"stream_block",
",",
"stream_data",
",",
"is_lazy",
"=",
"False",
",",
"raw_text",
"=",
"None",
")",
":",
"self",
".",
"stream_block",
"=",
"stream_block",
"# the StreamBlock object that handles this value",
"self",
".",
"is_la... | [
418,
4
] | [
453,
13
] | python | en | ['en', 'error', 'th'] | False |
StreamValue._construct_stream_child | (self, item) |
Create a StreamChild instance from a (type, value, id) or (type, value) tuple,
or return item if it's already a StreamChild
|
Create a StreamChild instance from a (type, value, id) or (type, value) tuple,
or return item if it's already a StreamChild
| def _construct_stream_child(self, item):
"""
Create a StreamChild instance from a (type, value, id) or (type, value) tuple,
or return item if it's already a StreamChild
"""
if isinstance(item, StreamValue.StreamChild):
return item
try:
type_name, ... | [
"def",
"_construct_stream_child",
"(",
"self",
",",
"item",
")",
":",
"if",
"isinstance",
"(",
"item",
",",
"StreamValue",
".",
"StreamChild",
")",
":",
"return",
"item",
"try",
":",
"type_name",
",",
"value",
",",
"block_id",
"=",
"item",
"except",
"Value... | [
455,
4
] | [
470,
69
] | python | en | ['en', 'error', 'th'] | False |
StreamValue._prefetch_blocks | (self, type_name) |
Populate _bound_blocks with all items in this stream of type `type_name` that exist in
_raw_data but do not already exist in _bound_blocks.
Fetching is done via the block's bulk_to_python method, so that database lookups are
batched into a single query where possible.
|
Populate _bound_blocks with all items in this stream of type `type_name` that exist in
_raw_data but do not already exist in _bound_blocks. | def _prefetch_blocks(self, type_name):
"""
Populate _bound_blocks with all items in this stream of type `type_name` that exist in
_raw_data but do not already exist in _bound_blocks.
Fetching is done via the block's bulk_to_python method, so that database lookups are
batched int... | [
"def",
"_prefetch_blocks",
"(",
"self",
",",
"type_name",
")",
":",
"child_block",
"=",
"self",
".",
"stream_block",
".",
"child_blocks",
"[",
"type_name",
"]",
"# create a mapping of all the child blocks matching the given block type,",
"# mapping (index within the stream) => ... | [
498,
4
] | [
521,
13
] | python | en | ['en', 'error', 'th'] | False |
i18n_patterns | (*urls, **kwargs) |
Adds the language code prefix to every URL pattern within this
function. This may only be used in the root URLconf, not in an included
URLconf.
|
Adds the language code prefix to every URL pattern within this
function. This may only be used in the root URLconf, not in an included
URLconf.
| def i18n_patterns(*urls, **kwargs):
"""
Adds the language code prefix to every URL pattern within this
function. This may only be used in the root URLconf, not in an included
URLconf.
"""
if not settings.USE_I18N:
return list(urls)
prefix_default_language = kwargs.pop('prefix_default... | [
"def",
"i18n_patterns",
"(",
"*",
"urls",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"settings",
".",
"USE_I18N",
":",
"return",
"list",
"(",
"urls",
")",
"prefix_default_language",
"=",
"kwargs",
".",
"pop",
"(",
"'prefix_default_language'",
",",
"Tr... | [
7,
0
] | [
17,
96
] | python | en | ['en', 'error', 'th'] | False |
is_language_prefix_patterns_used | (urlconf) |
Return a tuple of two booleans: (
`True` if LocaleRegexURLResolver` is used in the `urlconf`,
`True` if the default language should be prefixed
)
|
Return a tuple of two booleans: (
`True` if LocaleRegexURLResolver` is used in the `urlconf`,
`True` if the default language should be prefixed
)
| def is_language_prefix_patterns_used(urlconf):
"""
Return a tuple of two booleans: (
`True` if LocaleRegexURLResolver` is used in the `urlconf`,
`True` if the default language should be prefixed
)
"""
for url_pattern in get_resolver(urlconf).url_patterns:
if isinstance(url_pa... | [
"def",
"is_language_prefix_patterns_used",
"(",
"urlconf",
")",
":",
"for",
"url_pattern",
"in",
"get_resolver",
"(",
"urlconf",
")",
".",
"url_patterns",
":",
"if",
"isinstance",
"(",
"url_pattern",
",",
"LocaleRegexURLResolver",
")",
":",
"return",
"True",
",",
... | [
21,
0
] | [
31,
23
] | python | en | ['en', 'error', 'th'] | False |
mock_auth_stuff | () | Some really specific session-related stuff is done for changing or setting
passwords, so we will just avoid that here.
| Some really specific session-related stuff is done for changing or setting
passwords, so we will just avoid that here.
| def mock_auth_stuff():
"""Some really specific session-related stuff is done for changing or setting
passwords, so we will just avoid that here.
"""
with mock.patch('awx.api.serializers.update_session_auth_hash'):
yield | [
"def",
"mock_auth_stuff",
"(",
")",
":",
"with",
"mock",
".",
"patch",
"(",
"'awx.api.serializers.update_session_auth_hash'",
")",
":",
"yield"
] | [
12,
0
] | [
17,
13
] | python | en | ['en', 'en', 'en'] | True |
extract_symbols | (lib_file) |
Extract and return a list of symbols extracted from a dynamic library.
The symbols are extracted using NM. They are then filtered and formated.
Finally they symbols are made unique.
|
Extract and return a list of symbols extracted from a dynamic library.
The symbols are extracted using NM. They are then filtered and formated.
Finally they symbols are made unique.
| def extract_symbols(lib_file):
"""
Extract and return a list of symbols extracted from a dynamic library.
The symbols are extracted using NM. They are then filtered and formated.
Finally they symbols are made unique.
"""
if ReadElfExtractor.find_tool():
extractor = ReadElfExtractor()
... | [
"def",
"extract_symbols",
"(",
"lib_file",
")",
":",
"if",
"ReadElfExtractor",
".",
"find_tool",
"(",
")",
":",
"extractor",
"=",
"ReadElfExtractor",
"(",
")",
"else",
":",
"extractor",
"=",
"NMExtractor",
"(",
")",
"return",
"extractor",
".",
"extract",
"("... | [
183,
0
] | [
193,
38
] | python | en | ['en', 'error', 'th'] | False |
NMExtractor.find_tool | () |
Search for the nm executable and return the path.
|
Search for the nm executable and return the path.
| def find_tool():
"""
Search for the nm executable and return the path.
"""
return distutils.spawn.find_executable('nm') | [
"def",
"find_tool",
"(",
")",
":",
"return",
"distutils",
".",
"spawn",
".",
"find_executable",
"(",
"'nm'",
")"
] | [
27,
4
] | [
31,
52
] | python | en | ['en', 'error', 'th'] | False |
NMExtractor.__init__ | (self) |
Initialize the nm executable and flags that will be used to extract
symbols from shared libraries.
|
Initialize the nm executable and flags that will be used to extract
symbols from shared libraries.
| def __init__(self):
"""
Initialize the nm executable and flags that will be used to extract
symbols from shared libraries.
"""
self.nm_exe = self.find_tool()
if self.nm_exe is None:
# ERROR no NM found
print("ERROR: Could not find nm")
... | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"nm_exe",
"=",
"self",
".",
"find_tool",
"(",
")",
"if",
"self",
".",
"nm_exe",
"is",
"None",
":",
"# ERROR no NM found",
"print",
"(",
"\"ERROR: Could not find nm\"",
")",
"sys",
".",
"exit",
"(",
"... | [
33,
4
] | [
43,
33
] | python | en | ['en', 'error', 'th'] | False |
NMExtractor.extract | (self, lib) |
Extract symbols from a library and return the results as a dict of
parsed symbols.
|
Extract symbols from a library and return the results as a dict of
parsed symbols.
| def extract(self, lib):
"""
Extract symbols from a library and return the results as a dict of
parsed symbols.
"""
cmd = [self.nm_exe] + self.flags + [lib]
out, _, exit_code = libcxx.util.executeCommandVerbose(cmd)
if exit_code != 0:
raise RuntimeError... | [
"def",
"extract",
"(",
"self",
",",
"lib",
")",
":",
"cmd",
"=",
"[",
"self",
".",
"nm_exe",
"]",
"+",
"self",
".",
"flags",
"+",
"[",
"lib",
"]",
"out",
",",
"_",
",",
"exit_code",
"=",
"libcxx",
".",
"util",
".",
"executeCommandVerbose",
"(",
"... | [
45,
4
] | [
61,
49
] | python | en | ['en', 'error', 'th'] | False |
NMExtractor._want_sym | (sym) |
Check that s is a valid symbol that we want to keep.
|
Check that s is a valid symbol that we want to keep.
| def _want_sym(sym):
"""
Check that s is a valid symbol that we want to keep.
"""
if sym is None or len(sym) < 2:
return False
if sym['name'] in extract_ignore_names:
return False
bad_types = ['t', 'b', 'r', 'd', 'w']
return (sym['type'] not... | [
"def",
"_want_sym",
"(",
"sym",
")",
":",
"if",
"sym",
"is",
"None",
"or",
"len",
"(",
"sym",
")",
"<",
"2",
":",
"return",
"False",
"if",
"sym",
"[",
"'name'",
"]",
"in",
"extract_ignore_names",
":",
"return",
"False",
"bad_types",
"=",
"[",
"'t'",
... | [
81,
4
] | [
91,
73
] | python | en | ['en', 'error', 'th'] | False |
NMExtractor._transform_sym_type | (sym) |
Map the nm single letter output for type to either FUNC or OBJECT.
If the type is not recognized it is left unchanged.
|
Map the nm single letter output for type to either FUNC or OBJECT.
If the type is not recognized it is left unchanged.
| def _transform_sym_type(sym):
"""
Map the nm single letter output for type to either FUNC or OBJECT.
If the type is not recognized it is left unchanged.
"""
func_types = ['T', 'W']
obj_types = ['B', 'D', 'R', 'V', 'S']
if sym['type'] in func_types:
sym... | [
"def",
"_transform_sym_type",
"(",
"sym",
")",
":",
"func_types",
"=",
"[",
"'T'",
",",
"'W'",
"]",
"obj_types",
"=",
"[",
"'B'",
",",
"'D'",
",",
"'R'",
",",
"'V'",
",",
"'S'",
"]",
"if",
"sym",
"[",
"'type'",
"]",
"in",
"func_types",
":",
"sym",
... | [
94,
4
] | [
105,
18
] | python | en | ['en', 'error', 'th'] | False |
ReadElfExtractor.find_tool | () |
Search for the readelf executable and return the path.
|
Search for the readelf executable and return the path.
| def find_tool():
"""
Search for the readelf executable and return the path.
"""
return distutils.spawn.find_executable('readelf') | [
"def",
"find_tool",
"(",
")",
":",
"return",
"distutils",
".",
"spawn",
".",
"find_executable",
"(",
"'readelf'",
")"
] | [
113,
4
] | [
117,
57
] | python | en | ['en', 'error', 'th'] | False |
ReadElfExtractor.__init__ | (self) |
Initialize the readelf executable and flags that will be used to
extract symbols from shared libraries.
|
Initialize the readelf executable and flags that will be used to
extract symbols from shared libraries.
| def __init__(self):
"""
Initialize the readelf executable and flags that will be used to
extract symbols from shared libraries.
"""
self.tool = self.find_tool()
if self.tool is None:
# ERROR no NM found
print("ERROR: Could not find readelf")
... | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"tool",
"=",
"self",
".",
"find_tool",
"(",
")",
"if",
"self",
".",
"tool",
"is",
"None",
":",
"# ERROR no NM found",
"print",
"(",
"\"ERROR: Could not find readelf\"",
")",
"sys",
".",
"exit",
"(",
... | [
119,
4
] | [
129,
44
] | python | en | ['en', 'error', 'th'] | False |
ReadElfExtractor.extract | (self, lib) |
Extract symbols from a library and return the results as a dict of
parsed symbols.
|
Extract symbols from a library and return the results as a dict of
parsed symbols.
| def extract(self, lib):
"""
Extract symbols from a library and return the results as a dict of
parsed symbols.
"""
cmd = [self.tool] + self.flags + [lib]
out, _, exit_code = libcxx.util.executeCommandVerbose(cmd)
if exit_code != 0:
raise RuntimeError('... | [
"def",
"extract",
"(",
"self",
",",
"lib",
")",
":",
"cmd",
"=",
"[",
"self",
".",
"tool",
"]",
"+",
"self",
".",
"flags",
"+",
"[",
"lib",
"]",
"out",
",",
"_",
",",
"exit_code",
"=",
"libcxx",
".",
"util",
".",
"executeCommandVerbose",
"(",
"cm... | [
131,
4
] | [
141,
42
] | python | en | ['en', 'error', 'th'] | False |
parse_wininst_info | (wininfo_name, egginfo_name) | Extract metadata from filenames.
Extracts the 4 metadataitems needed (name, version, pyversion, arch) from
the installer filename and the name of the egg-info directory embedded in
the zipfile (if any).
The egginfo filename has the format::
name-ver(-pyver)(-arch).egg-info
The installer ... | Extract metadata from filenames. | def parse_wininst_info(wininfo_name, egginfo_name):
"""Extract metadata from filenames.
Extracts the 4 metadataitems needed (name, version, pyversion, arch) from
the installer filename and the name of the egg-info directory embedded in
the zipfile (if any).
The egginfo filename has the format::
... | [
"def",
"parse_wininst_info",
"(",
"wininfo_name",
",",
"egginfo_name",
")",
":",
"egginfo",
"=",
"None",
"if",
"egginfo_name",
":",
"egginfo",
"=",
"egg_info_re",
".",
"search",
"(",
"egginfo_name",
")",
"if",
"not",
"egginfo",
":",
"raise",
"ValueError",
"(",... | [
90,
0
] | [
158,
75
] | python | en | ['en', 'en', 'en'] | True |
TradeManager.get_coins_of_interest | (
self,
) |
Returns list of coins we want to check if they are included in filter,
These will include coins that belong to us and coins that that on other side of treade
|
Returns list of coins we want to check if they are included in filter,
These will include coins that belong to us and coins that that on other side of treade
| async def get_coins_of_interest(
self,
) -> Tuple[Dict[bytes32, Coin], Dict[bytes32, Coin]]:
"""
Returns list of coins we want to check if they are included in filter,
These will include coins that belong to us and coins that that on other side of treade
"""
all_pendi... | [
"async",
"def",
"get_coins_of_interest",
"(",
"self",
",",
")",
"->",
"Tuple",
"[",
"Dict",
"[",
"bytes32",
",",
"Coin",
"]",
",",
"Dict",
"[",
"bytes32",
",",
"Coin",
"]",
"]",
":",
"all_pending",
"=",
"[",
"]",
"pending_accept",
"=",
"await",
"self",... | [
64,
4
] | [
87,
34
] | python | en | ['en', 'error', 'th'] | False |
TradeManager.coins_of_interest_farmed | (self, removals: List[Coin], additions: List[Coin], height: uint32) |
If both our coins and other coins in trade got removed that means that trade was successfully executed
If coins from other side of trade got farmed without ours, that means that trade failed because either someone
else completed trade or other side of trade canceled the trade by doing a spend.
... |
If both our coins and other coins in trade got removed that means that trade was successfully executed
If coins from other side of trade got farmed without ours, that means that trade failed because either someone
else completed trade or other side of trade canceled the trade by doing a spend.
... | async def coins_of_interest_farmed(self, removals: List[Coin], additions: List[Coin], height: uint32):
"""
If both our coins and other coins in trade got removed that means that trade was successfully executed
If coins from other side of trade got farmed without ours, that means that trade faile... | [
"async",
"def",
"coins_of_interest_farmed",
"(",
"self",
",",
"removals",
":",
"List",
"[",
"Coin",
"]",
",",
"additions",
":",
"List",
"[",
"Coin",
"]",
",",
"height",
":",
"uint32",
")",
":",
"removal_dict",
"=",
"{",
"}",
"addition_dict",
"=",
"{",
... | [
100,
4
] | [
152,
99
] | python | en | ['en', 'error', 'th'] | False |
TradeManager.get_locked_coins | (self, wallet_id: int = None) | Returns a dictionary of confirmed coins that are locked by a trade. | Returns a dictionary of confirmed coins that are locked by a trade. | async def get_locked_coins(self, wallet_id: int = None) -> Dict[bytes32, WalletCoinRecord]:
""" Returns a dictionary of confirmed coins that are locked by a trade. """
all_pending = []
pending_accept = await self.get_offers_with_status(TradeStatus.PENDING_ACCEPT)
pending_confirm = await ... | [
"async",
"def",
"get_locked_coins",
"(",
"self",
",",
"wallet_id",
":",
"int",
"=",
"None",
")",
"->",
"Dict",
"[",
"bytes32",
",",
"WalletCoinRecord",
"]",
":",
"all_pending",
"=",
"[",
"]",
"pending_accept",
"=",
"await",
"self",
".",
"get_offers_with_stat... | [
154,
4
] | [
176,
21
] | python | en | ['en', 'en', 'en'] | True |
TradeManager.get_locked_coins_in_spend_bundle | (self, bundle: SpendBundle) | Returns a list of coin records that are used in this SpendBundle | Returns a list of coin records that are used in this SpendBundle | async def get_locked_coins_in_spend_bundle(self, bundle: SpendBundle) -> Dict[bytes32, WalletCoinRecord]:
""" Returns a list of coin records that are used in this SpendBundle"""
result = {}
removals = bundle.removals()
for coin in removals:
coin_record = await self.wallet_sta... | [
"async",
"def",
"get_locked_coins_in_spend_bundle",
"(",
"self",
",",
"bundle",
":",
"SpendBundle",
")",
"->",
"Dict",
"[",
"bytes32",
",",
"WalletCoinRecord",
"]",
":",
"result",
"=",
"{",
"}",
"removals",
"=",
"bundle",
".",
"removals",
"(",
")",
"for",
... | [
186,
4
] | [
195,
21
] | python | en | ['en', 'en', 'en'] | True |
TradeManager.cancel_pending_offer_safely | (self, trade_id: bytes32) | This will create a transaction that includes coins that were offered | This will create a transaction that includes coins that were offered | async def cancel_pending_offer_safely(self, trade_id: bytes32):
""" This will create a transaction that includes coins that were offered"""
self.log.info(f"Secure-Cancel pending offer with id trade_id {trade_id.hex()}")
trade = await self.trade_store.get_trade_record(trade_id)
if trade i... | [
"async",
"def",
"cancel_pending_offer_safely",
"(",
"self",
",",
"trade_id",
":",
"bytes32",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"f\"Secure-Cancel pending offer with id trade_id {trade_id.hex()}\"",
")",
"trade",
"=",
"await",
"self",
".",
"trade_store",
... | [
200,
4
] | [
226,
19
] | python | en | ['en', 'en', 'en'] | True |
TradeManager._create_offer_for_ids | (self, offer: Dict[int, int]) |
Offer is dictionary of wallet ids and amount
|
Offer is dictionary of wallet ids and amount
| async def _create_offer_for_ids(self, offer: Dict[int, int]) -> Tuple[bool, Optional[TradeRecord], Optional[str]]:
"""
Offer is dictionary of wallet ids and amount
"""
spend_bundle = None
try:
for id in offer.keys():
amount = offer[id]
... | [
"async",
"def",
"_create_offer_for_ids",
"(",
"self",
",",
"offer",
":",
"Dict",
"[",
"int",
",",
"int",
"]",
")",
"->",
"Tuple",
"[",
"bool",
",",
"Optional",
"[",
"TradeRecord",
"]",
",",
"Optional",
"[",
"str",
"]",
"]",
":",
"spend_bundle",
"=",
... | [
242,
4
] | [
314,
38
] | python | en | ['en', 'error', 'th'] | False |
to_datetimepicker_format | (python_format_string) |
Given a python datetime format string, attempts to convert it to
the nearest PHP datetime format string possible.
|
Given a python datetime format string, attempts to convert it to
the nearest PHP datetime format string possible.
| def to_datetimepicker_format(python_format_string):
"""
Given a python datetime format string, attempts to convert it to
the nearest PHP datetime format string possible.
"""
python2PHP = {
"%a": "D",
"%A": "l",
"%b": "M",
"%B": "F",
"%c": "",
"%d": "d"... | [
"def",
"to_datetimepicker_format",
"(",
"python_format_string",
")",
":",
"python2PHP",
"=",
"{",
"\"%a\"",
":",
"\"D\"",
",",
"\"%A\"",
":",
"\"l\"",
",",
"\"%b\"",
":",
"\"M\"",
",",
"\"%B\"",
":",
"\"F\"",
",",
"\"%c\"",
":",
"\"\"",
",",
"\"%d\"",
":",... | [
4,
0
] | [
37,
28
] | python | en | ['en', 'error', 'th'] | False |
test_managed_injector_redaction | (injector_cls) | See awx.main.models.inventory.PluginFileInjector._get_shared_env
The ordering within awx.main.tasks.BaseTask and contract with build_env
requires that all managed injectors are safely redacted by the
static method build_safe_env without having to employ the safe namespace
as in inject_credential
Th... | See awx.main.models.inventory.PluginFileInjector._get_shared_env
The ordering within awx.main.tasks.BaseTask and contract with build_env
requires that all managed injectors are safely redacted by the
static method build_safe_env without having to employ the safe namespace
as in inject_credential | def test_managed_injector_redaction(injector_cls):
"""See awx.main.models.inventory.PluginFileInjector._get_shared_env
The ordering within awx.main.tasks.BaseTask and contract with build_env
requires that all managed injectors are safely redacted by the
static method build_safe_env without having to emp... | [
"def",
"test_managed_injector_redaction",
"(",
"injector_cls",
")",
":",
"secrets",
"=",
"set",
"(",
")",
"for",
"element",
"in",
"injector_cls",
".",
"inputs",
".",
"get",
"(",
"'fields'",
",",
"[",
"]",
")",
":",
"if",
"element",
".",
"get",
"(",
"'sec... | [
1920,
0
] | [
1938,
62
] | python | en | ['sl', 'en', 'en'] | False |
TestJobCredentials.test_custom_environment_injectors_with_secret_extra_vars | (self, job, private_data_dir) |
extra_vars that contain secret field values should be censored in the DB
|
extra_vars that contain secret field values should be censored in the DB
| def test_custom_environment_injectors_with_secret_extra_vars(self, job, private_data_dir):
"""
extra_vars that contain secret field values should be censored in the DB
"""
task = tasks.RunJob()
some_cloud = CredentialType(
kind='cloud',
name='SomeCloud',
... | [
"def",
"test_custom_environment_injectors_with_secret_extra_vars",
"(",
"self",
",",
"job",
",",
"private_data_dir",
")",
":",
"task",
"=",
"tasks",
".",
"RunJob",
"(",
")",
"some_cloud",
"=",
"CredentialType",
"(",
"kind",
"=",
"'cloud'",
",",
"name",
"=",
"'So... | [
1228,
4
] | [
1248,
59
] | python | en | ['en', 'error', 'th'] | False |
test_default_to_jobs_default | (set_up_defaults, organization) | Under normal operation, the default EE should be from the list of global job EEs
which are populated by the installer
| Under normal operation, the default EE should be from the list of global job EEs
which are populated by the installer
| def test_default_to_jobs_default(set_up_defaults, organization):
"""Under normal operation, the default EE should be from the list of global job EEs
which are populated by the installer
"""
# Fill in some other unrelated EEs
ExecutionEnvironment.objects.create(name='Steves environment', image='quay.... | [
"def",
"test_default_to_jobs_default",
"(",
"set_up_defaults",
",",
"organization",
")",
":",
"# Fill in some other unrelated EEs",
"ExecutionEnvironment",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"'Steves environment'",
",",
"image",
"=",
"'quay.io/ansible/awx-ee'"... | [
16,
0
] | [
25,
83
] | python | en | ['en', 'en', 'en'] | True |
test_default_to_control_plane | (set_up_defaults) | If all of the job execution environments are job execution environments have gone missing
then it will refuse to use the control plane execution environment as the default
| If all of the job execution environments are job execution environments have gone missing
then it will refuse to use the control plane execution environment as the default
| def test_default_to_control_plane(set_up_defaults):
"""If all of the job execution environments are job execution environments have gone missing
then it will refuse to use the control plane execution environment as the default
"""
for ee in ExecutionEnvironment.objects.all():
if ee.name == 'Cont... | [
"def",
"test_default_to_control_plane",
"(",
"set_up_defaults",
")",
":",
"for",
"ee",
"in",
"ExecutionEnvironment",
".",
"objects",
".",
"all",
"(",
")",
":",
"if",
"ee",
".",
"name",
"==",
"'Control Plane Execution Environment'",
":",
"continue",
"ee",
".",
"d... | [
29,
0
] | [
37,
54
] | python | en | ['en', 'en', 'en'] | True |
test_user_default | (set_up_defaults) | If superuser has configured a default, then their preference should come first, of course | If superuser has configured a default, then their preference should come first, of course | def test_user_default(set_up_defaults):
"""If superuser has configured a default, then their preference should come first, of course"""
ee = ExecutionEnvironment.objects.create(name='Steves environment', image='quay.io/ansible/awx-ee')
with override_settings(DEFAULT_EXECUTION_ENVIRONMENT=ee):
assert... | [
"def",
"test_user_default",
"(",
"set_up_defaults",
")",
":",
"ee",
"=",
"ExecutionEnvironment",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"'Steves environment'",
",",
"image",
"=",
"'quay.io/ansible/awx-ee'",
")",
"with",
"override_settings",
"(",
"DEFAULT_E... | [
41,
0
] | [
45,
56
] | python | en | ['en', 'en', 'en'] | True |
offBoard | (board, entity_pos) |
Returns True if the entity position is out of bounds
|
Returns True if the entity position is out of bounds
| def offBoard(board, entity_pos):
"""
Returns True if the entity position is out of bounds
"""
if (entity_pos[0] < 0 or entity_pos[0] >= board['width']) or entity_pos[1] < 0 or entity_pos[1] >= board['height']: # Checks if either the x/y is over the board state range.
return True
return False | [
"def",
"offBoard",
"(",
"board",
",",
"entity_pos",
")",
":",
"if",
"(",
"entity_pos",
"[",
"0",
"]",
"<",
"0",
"or",
"entity_pos",
"[",
"0",
"]",
">=",
"board",
"[",
"'width'",
"]",
")",
"or",
"entity_pos",
"[",
"1",
"]",
"<",
"0",
"or",
"entity... | [
0,
0
] | [
6,
13
] | python | en | ['en', 'error', 'th'] | False |
equal_coords | (a, b) | Checks if coords are equal | Checks if coords are equal | def equal_coords(a, b) -> bool:
""" Checks if coords are equal"""
return a[0] == b[0] and a[1]==b[1] | [
"def",
"equal_coords",
"(",
"a",
",",
"b",
")",
"->",
"bool",
":",
"return",
"a",
"[",
"0",
"]",
"==",
"b",
"[",
"0",
"]",
"and",
"a",
"[",
"1",
"]",
"==",
"b",
"[",
"1",
"]"
] | [
21,
0
] | [
23,
35
] | python | en | ['en', 'en', 'en'] | True |
DatabaseSchemaEditor._alter_field_type_workaround | (self, model, old_field, new_field) |
Oracle refuses to change from some type to other type.
What we need to do instead is:
- Add a nullable version of the desired field with a temporary name
- Update the table to transfer values from old to new
- Drop old column
- Rename the new column and possibly drop the... |
Oracle refuses to change from some type to other type.
What we need to do instead is:
- Add a nullable version of the desired field with a temporary name
- Update the table to transfer values from old to new
- Drop old column
- Rename the new column and possibly drop the... | def _alter_field_type_workaround(self, model, old_field, new_field):
"""
Oracle refuses to change from some type to other type.
What we need to do instead is:
- Add a nullable version of the desired field with a temporary name
- Update the table to transfer values from old to new... | [
"def",
"_alter_field_type_workaround",
"(",
"self",
",",
"model",
",",
"old_field",
",",
"new_field",
")",
":",
"# Make a new field that's like the new one but with a temporary",
"# column name.",
"new_temp_field",
"=",
"copy",
".",
"deepcopy",
"(",
"new_field",
")",
"new... | [
62,
4
] | [
103,
87
] | python | en | ['en', 'error', 'th'] | False |
DatabaseSchemaEditor.normalize_name | (self, name) |
Get the properly shortened and uppercased identifier as returned by
quote_name(), but without the actual quotes.
|
Get the properly shortened and uppercased identifier as returned by
quote_name(), but without the actual quotes.
| def normalize_name(self, name):
"""
Get the properly shortened and uppercased identifier as returned by
quote_name(), but without the actual quotes.
"""
nn = self.quote_name(name)
if nn[0] == '"' and nn[-1] == '"':
nn = nn[1:-1]
return nn | [
"def",
"normalize_name",
"(",
"self",
",",
"name",
")",
":",
"nn",
"=",
"self",
".",
"quote_name",
"(",
"name",
")",
"if",
"nn",
"[",
"0",
"]",
"==",
"'\"'",
"and",
"nn",
"[",
"-",
"1",
"]",
"==",
"'\"'",
":",
"nn",
"=",
"nn",
"[",
"1",
":",
... | [
105,
4
] | [
113,
17
] | python | en | ['en', 'error', 'th'] | False |
DatabaseSchemaEditor._generate_temp_name | (self, for_name) |
Generates temporary names for workarounds that need temp columns
|
Generates temporary names for workarounds that need temp columns
| def _generate_temp_name(self, for_name):
"""
Generates temporary names for workarounds that need temp columns
"""
suffix = hex(hash(for_name)).upper()[1:]
return self.normalize_name(for_name + "_" + suffix) | [
"def",
"_generate_temp_name",
"(",
"self",
",",
"for_name",
")",
":",
"suffix",
"=",
"hex",
"(",
"hash",
"(",
"for_name",
")",
")",
".",
"upper",
"(",
")",
"[",
"1",
":",
"]",
"return",
"self",
".",
"normalize_name",
"(",
"for_name",
"+",
"\"_\"",
"+... | [
115,
4
] | [
120,
59
] | python | en | ['en', 'error', 'th'] | False |
look_for_fixme | (func) | Decorator to fail test if text argument starts with "FIXME". | Decorator to fail test if text argument starts with "FIXME". | def look_for_fixme(func):
"""Decorator to fail test if text argument starts with "FIXME"."""
def inner(arg):
if (arg is not None) and \
isinstance(arg, str) and \
arg.lstrip().startswith('FIXME'):
return False
return func(arg)
return inner | [
"def",
"look_for_fixme",
"(",
"func",
")",
":",
"def",
"inner",
"(",
"arg",
")",
":",
"if",
"(",
"arg",
"is",
"not",
"None",
")",
"and",
"isinstance",
"(",
"arg",
",",
"str",
")",
"and",
"arg",
".",
"lstrip",
"(",
")",
".",
"startswith",
"(",
"'F... | [
70,
0
] | [
79,
16
] | python | en | ['en', 'en', 'en'] | True |
check_layout | (layout) | "layout" in YAML header must be "workshop". | "layout" in YAML header must be "workshop". | def check_layout(layout):
'''"layout" in YAML header must be "workshop".'''
return layout == 'workshop' | [
"def",
"check_layout",
"(",
"layout",
")",
":",
"return",
"layout",
"==",
"'workshop'"
] | [
83,
0
] | [
86,
31
] | python | en | ['en', 'en', 'en'] | True |
check_carpentry | (layout) | "carpentry" in YAML header must be "dc", "swc", "lc", or "cp". | "carpentry" in YAML header must be "dc", "swc", "lc", or "cp". | def check_carpentry(layout):
'''"carpentry" in YAML header must be "dc", "swc", "lc", or "cp".'''
return layout in CARPENTRIES | [
"def",
"check_carpentry",
"(",
"layout",
")",
":",
"return",
"layout",
"in",
"CARPENTRIES"
] | [
90,
0
] | [
93,
32
] | python | en | ['en', 'en', 'sw'] | True |
check_country | (country) | "country" must be a lowercase ISO-3166 two-letter code. | "country" must be a lowercase ISO-3166 two-letter code. | def check_country(country):
'''"country" must be a lowercase ISO-3166 two-letter code.'''
return country in ISO_COUNTRY | [
"def",
"check_country",
"(",
"country",
")",
":",
"return",
"country",
"in",
"ISO_COUNTRY"
] | [
97,
0
] | [
100,
33
] | python | en | ['en', 'en', 'en'] | True |
check_language | (language) | "language" must be a lowercase ISO-639 two-letter code. | "language" must be a lowercase ISO-639 two-letter code. | def check_language(language):
'''"language" must be a lowercase ISO-639 two-letter code.'''
return language in ISO_LANGUAGE | [
"def",
"check_language",
"(",
"language",
")",
":",
"return",
"language",
"in",
"ISO_LANGUAGE"
] | [
104,
0
] | [
107,
35
] | python | en | ['en', 'en', 'en'] | True |
check_humandate | (date) |
'humandate' must be a human-readable date with a 3-letter month
and 4-digit year. Examples include 'Feb 18-20, 2025' and 'Feb 18
and 20, 2025'. It may be in languages other than English, but the
month name should be kept short to aid formatting of the main
Carpentries web site.
|
'humandate' must be a human-readable date with a 3-letter month
and 4-digit year. Examples include 'Feb 18-20, 2025' and 'Feb 18
and 20, 2025'. It may be in languages other than English, but the
month name should be kept short to aid formatting of the main
Carpentries web site.
| def check_humandate(date):
"""
'humandate' must be a human-readable date with a 3-letter month
and 4-digit year. Examples include 'Feb 18-20, 2025' and 'Feb 18
and 20, 2025'. It may be in languages other than English, but the
month name should be kept short to aid formatting of the main
Carpen... | [
"def",
"check_humandate",
"(",
"date",
")",
":",
"if",
"','",
"not",
"in",
"date",
":",
"return",
"False",
"month_dates",
",",
"year",
"=",
"date",
".",
"split",
"(",
"','",
")",
"# The first three characters of month_dates are not empty",
"month",
"=",
"month_d... | [
111,
0
] | [
140,
15
] | python | en | ['en', 'error', 'th'] | False |
check_humantime | (time) |
'humantime' is a human-readable start and end time for the
workshop, such as '09:00 - 16:00'.
|
'humantime' is a human-readable start and end time for the
workshop, such as '09:00 - 16:00'.
| def check_humantime(time):
"""
'humantime' is a human-readable start and end time for the
workshop, such as '09:00 - 16:00'.
"""
return bool(re.match(HUMANTIME_PATTERN, time.replace(' ', ''))) | [
"def",
"check_humantime",
"(",
"time",
")",
":",
"return",
"bool",
"(",
"re",
".",
"match",
"(",
"HUMANTIME_PATTERN",
",",
"time",
".",
"replace",
"(",
"' '",
",",
"''",
")",
")",
")"
] | [
144,
0
] | [
150,
67
] | python | en | ['en', 'error', 'th'] | False |
check_date | (this_date) |
'startdate' and 'enddate' are machine-readable start and end dates
for the workshop, and must be in YYYY-MM-DD format, e.g.,
'2015-07-01'.
|
'startdate' and 'enddate' are machine-readable start and end dates
for the workshop, and must be in YYYY-MM-DD format, e.g.,
'2015-07-01'.
| def check_date(this_date):
"""
'startdate' and 'enddate' are machine-readable start and end dates
for the workshop, and must be in YYYY-MM-DD format, e.g.,
'2015-07-01'.
"""
# YAML automatically loads valid dates as datetime.date.
return isinstance(this_date, date) | [
"def",
"check_date",
"(",
"this_date",
")",
":",
"# YAML automatically loads valid dates as datetime.date.",
"return",
"isinstance",
"(",
"this_date",
",",
"date",
")"
] | [
153,
0
] | [
161,
38
] | 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.