hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
79466977235c674fdc21cfda2762af2723e5757d | yzhang93/iree | build_tools/bazel_to_cmake/bazel_to_cmake_targets.py | [
"Apache-2.0"
] | Python | convert_target | <not_specific> | def convert_target(target):
"""Converts a Bazel target to a list of CMake targets.
IREE targets are expected to follow a standard form between Bazel and CMake
that facilitates conversion. External targets *may* have their own patterns,
or they may be purely special cases.
Multiple target in Bazel may map to... | Converts a Bazel target to a list of CMake targets.
IREE targets are expected to follow a standard form between Bazel and CMake
that facilitates conversion. External targets *may* have their own patterns,
or they may be purely special cases.
Multiple target in Bazel may map to a single target in CMake and a B... | Converts a Bazel target to a list of CMake targets.
IREE targets are expected to follow a standard form between Bazel and CMake
that facilitates conversion. External targets *may* have their own patterns,
or they may be purely special cases.
Multiple target in Bazel may map to a single target in CMake and a Bazel
targ... | [
"Converts",
"a",
"Bazel",
"target",
"to",
"a",
"list",
"of",
"CMake",
"targets",
".",
"IREE",
"targets",
"are",
"expected",
"to",
"follow",
"a",
"standard",
"form",
"between",
"Bazel",
"and",
"CMake",
"that",
"facilitates",
"conversion",
".",
"External",
"ta... | def convert_target(target):
if target in EXPLICIT_TARGET_MAPPING:
return EXPLICIT_TARGET_MAPPING[target]
if target.startswith("@llvm-project//llvm"):
return _convert_llvm_target(target)
if target.startswith("@llvm-project//mlir"):
return _convert_mlir_target(target)
if target.startswith("@"):
ra... | [
"def",
"convert_target",
"(",
"target",
")",
":",
"if",
"target",
"in",
"EXPLICIT_TARGET_MAPPING",
":",
"return",
"EXPLICIT_TARGET_MAPPING",
"[",
"target",
"]",
"if",
"target",
".",
"startswith",
"(",
"\"@llvm-project//llvm\"",
")",
":",
"return",
"_convert_llvm_tar... | Converts a Bazel target to a list of CMake targets. | [
"Converts",
"a",
"Bazel",
"target",
"to",
"a",
"list",
"of",
"CMake",
"targets",
"."
] | [
"\"\"\"Converts a Bazel target to a list of CMake targets.\n\n IREE targets are expected to follow a standard form between Bazel and CMake\n that facilitates conversion. External targets *may* have their own patterns,\n or they may be purely special cases.\n\n Multiple target in Bazel may map to a single target... | [
{
"param": "target",
"type": null
}
] | {
"returns": [
{
"docstring": "A list of converted targets if it was successfully converted.",
"docstring_tokens": [
"A",
"list",
"of",
"converted",
"targets",
"if",
"it",
"was",
"successfully",
"converted",
"."
... |
69a2b5990d23c9319fad1beb4504bedc88bd6e80 | cxlgo/cloudify-script-plugin | script_runner/tasks.py | [
"Apache-2.0"
] | Python | _get_process_environment | <not_specific> | def _get_process_environment(process, proxy):
"""Get env to be used by the script process.
This env must at the very least contain the proxy url, and a PATH
allowing bash scripts to use `ctx`, which is expected to live next to
the current executable.
"""
env = os.environ.copy()
process_env ... | Get env to be used by the script process.
This env must at the very least contain the proxy url, and a PATH
allowing bash scripts to use `ctx`, which is expected to live next to
the current executable.
| Get env to be used by the script process.
This env must at the very least contain the proxy url, and a PATH
allowing bash scripts to use `ctx`, which is expected to live next to
the current executable. | [
"Get",
"env",
"to",
"be",
"used",
"by",
"the",
"script",
"process",
".",
"This",
"env",
"must",
"at",
"the",
"very",
"least",
"contain",
"the",
"proxy",
"url",
"and",
"a",
"PATH",
"allowing",
"bash",
"scripts",
"to",
"use",
"`",
"ctx",
"`",
"which",
... | def _get_process_environment(process, proxy):
env = os.environ.copy()
process_env = process.get('env', {})
env.update(process_env)
env[CTX_SOCKET_URL] = proxy.socket_url
env_path = env.get('PATH')
bin_dir = os.path.dirname(sys.executable)
if env_path:
if bin_dir not in env_path.split... | [
"def",
"_get_process_environment",
"(",
"process",
",",
"proxy",
")",
":",
"env",
"=",
"os",
".",
"environ",
".",
"copy",
"(",
")",
"process_env",
"=",
"process",
".",
"get",
"(",
"'env'",
",",
"{",
"}",
")",
"env",
".",
"update",
"(",
"process_env",
... | Get env to be used by the script process. | [
"Get",
"env",
"to",
"be",
"used",
"by",
"the",
"script",
"process",
"."
] | [
"\"\"\"Get env to be used by the script process.\n\n This env must at the very least contain the proxy url, and a PATH\n allowing bash scripts to use `ctx`, which is expected to live next to\n the current executable.\n \"\"\""
] | [
{
"param": "process",
"type": null
},
{
"param": "proxy",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "process",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "proxy",
"type": null,
"docstring": null,
"docstring_tokens... |
b89a0c9556f51e08113342ee7893e4ca9e361e74 | shravan-mohan/num-tri | number_triangle.py | [
"MIT"
] | Python | base_representation | <not_specific> | def base_representation(num, base):
"""
This function generates the base representation of a number in a given base.
:param num: An integer.
:param base: The desired base.
:return: The representation of the number in the given base.
"""
r = []
t = num
while(t!=0):
r = r + [in... |
This function generates the base representation of a number in a given base.
:param num: An integer.
:param base: The desired base.
:return: The representation of the number in the given base.
| This function generates the base representation of a number in a given base. | [
"This",
"function",
"generates",
"the",
"base",
"representation",
"of",
"a",
"number",
"in",
"a",
"given",
"base",
"."
] | def base_representation(num, base):
r = []
t = num
while(t!=0):
r = r + [int(np.mod(t,base))]
t = t - np.mod(t,base)
t = t/base
s = str(r[::-1][0])
for k in r[::-1][1:]:
s = s + ',' + str(k)
return s | [
"def",
"base_representation",
"(",
"num",
",",
"base",
")",
":",
"r",
"=",
"[",
"]",
"t",
"=",
"num",
"while",
"(",
"t",
"!=",
"0",
")",
":",
"r",
"=",
"r",
"+",
"[",
"int",
"(",
"np",
".",
"mod",
"(",
"t",
",",
"base",
")",
")",
"]",
"t"... | This function generates the base representation of a number in a given base. | [
"This",
"function",
"generates",
"the",
"base",
"representation",
"of",
"a",
"number",
"in",
"a",
"given",
"base",
"."
] | [
"\"\"\"\n This function generates the base representation of a number in a given base.\n :param num: An integer.\n :param base: The desired base.\n :return: The representation of the number in the given base.\n \"\"\""
] | [
{
"param": "num",
"type": null
},
{
"param": "base",
"type": null
}
] | {
"returns": [
{
"docstring": "The representation of the number in the given base.",
"docstring_tokens": [
"The",
"representation",
"of",
"the",
"number",
"in",
"the",
"given",
"base",
"."
],
"type": null
}... |
b89a0c9556f51e08113342ee7893e4ca9e361e74 | shravan-mohan/num-tri | number_triangle.py | [
"MIT"
] | Python | xor_base | <not_specific> | def xor_base(x1, x2, base):
"""
This function returns the XOR in a given base (modula the base).
:param x1: First integer.
:param x2: Second integer.
:param base: The desired base.
:return: The resulting equivalence class.
"""
return np.mod(x1+x2, base) |
This function returns the XOR in a given base (modula the base).
:param x1: First integer.
:param x2: Second integer.
:param base: The desired base.
:return: The resulting equivalence class.
| This function returns the XOR in a given base (modula the base). | [
"This",
"function",
"returns",
"the",
"XOR",
"in",
"a",
"given",
"base",
"(",
"modula",
"the",
"base",
")",
"."
] | def xor_base(x1, x2, base):
return np.mod(x1+x2, base) | [
"def",
"xor_base",
"(",
"x1",
",",
"x2",
",",
"base",
")",
":",
"return",
"np",
".",
"mod",
"(",
"x1",
"+",
"x2",
",",
"base",
")"
] | This function returns the XOR in a given base (modula the base). | [
"This",
"function",
"returns",
"the",
"XOR",
"in",
"a",
"given",
"base",
"(",
"modula",
"the",
"base",
")",
"."
] | [
"\"\"\"\n This function returns the XOR in a given base (modula the base).\n :param x1: First integer.\n :param x2: Second integer.\n :param base: The desired base.\n :return: The resulting equivalence class.\n \"\"\""
] | [
{
"param": "x1",
"type": null
},
{
"param": "x2",
"type": null
},
{
"param": "base",
"type": null
}
] | {
"returns": [
{
"docstring": "The resulting equivalence class.",
"docstring_tokens": [
"The",
"resulting",
"equivalence",
"class",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "x1",
"type": null,
... |
b89a0c9556f51e08113342ee7893e4ca9e361e74 | shravan-mohan/num-tri | number_triangle.py | [
"MIT"
] | Python | plot | null | def plot(A, limlow, limhigh, xshift, yshift, base, colors, ax):
"""
This function plots the number triangle for a given integer.
:param A: The matrix resulting from getMat function.
:param limlow: The lower xlim and ylim for plot.
:param limhigh: The higher xlim and ylim for plot.
:param xshift:... |
This function plots the number triangle for a given integer.
:param A: The matrix resulting from getMat function.
:param limlow: The lower xlim and ylim for plot.
:param limhigh: The higher xlim and ylim for plot.
:param xshift: The x-translation desired.
:param yshift: The y-translation desire... | This function plots the number triangle for a given integer. | [
"This",
"function",
"plots",
"the",
"number",
"triangle",
"for",
"a",
"given",
"integer",
"."
] | def plot(A, limlow, limhigh, xshift, yshift, base, colors, ax):
r = (limhigh-limlow)/(A.shape[0])/2
for k in range(A.shape[0]):
if (np.mod(k, 2) == 0):
count = 0
for l in range(A.shape[1]):
for u in range(base):
if(A[k,l] == u):
... | [
"def",
"plot",
"(",
"A",
",",
"limlow",
",",
"limhigh",
",",
"xshift",
",",
"yshift",
",",
"base",
",",
"colors",
",",
"ax",
")",
":",
"r",
"=",
"(",
"limhigh",
"-",
"limlow",
")",
"/",
"(",
"A",
".",
"shape",
"[",
"0",
"]",
")",
"/",
"2",
... | This function plots the number triangle for a given integer. | [
"This",
"function",
"plots",
"the",
"number",
"triangle",
"for",
"a",
"given",
"integer",
"."
] | [
"\"\"\"\n This function plots the number triangle for a given integer.\n :param A: The matrix resulting from getMat function.\n :param limlow: The lower xlim and ylim for plot.\n :param limhigh: The higher xlim and ylim for plot.\n :param xshift: The x-translation desired.\n :param yshift: The y-t... | [
{
"param": "A",
"type": null
},
{
"param": "limlow",
"type": null
},
{
"param": "limhigh",
"type": null
},
{
"param": "xshift",
"type": null
},
{
"param": "yshift",
"type": null
},
{
"param": "base",
"type": null
},
{
"param": "colors",
... | {
"returns": [
{
"docstring": "Plot of the colored circles representing the number triangle.",
"docstring_tokens": [
"Plot",
"of",
"the",
"colored",
"circles",
"representing",
"the",
"number",
"triangle",
"."
],
... |
194c163c9b50fa877885e800d8c07f6a0c24eadd | annliirosales/msanalysis | msanalysis/data_extraction/utils.py | [
"MIT"
] | Python | read_exported_txt | tuple | def read_exported_txt(filename: str, pts_per_amu=27, overwrite=False) -> tuple:
"""Reads the large text files exported by the merlin software and returns NumPy objects.
Since the files can be large (> 1GB) and reading text files is slow, a binary version
of the data is saved after the text file is parsed. ... | Reads the large text files exported by the merlin software and returns NumPy objects.
Since the files can be large (> 1GB) and reading text files is slow, a binary version
of the data is saved after the text file is parsed. If the function finds a binary
file (look for .npz) extension, it will skip parsing... | Reads the large text files exported by the merlin software and returns NumPy objects.
Since the files can be large (> 1GB) and reading text files is slow, a binary version
of the data is saved after the text file is parsed. If the function finds a binary
file (look for .npz) extension, it will skip parsing the data fro... | [
"Reads",
"the",
"large",
"text",
"files",
"exported",
"by",
"the",
"merlin",
"software",
"and",
"returns",
"NumPy",
"objects",
".",
"Since",
"the",
"files",
"can",
"be",
"large",
"(",
">",
"1GB",
")",
"and",
"reading",
"text",
"files",
"is",
"slow",
"a",... | def read_exported_txt(filename: str, pts_per_amu=27, overwrite=False) -> tuple:
npy_filename = filename[:-4] + ".npz"
if os.path.exists(npy_filename) and overwrite == False:
t0 = time.time()
npzfile = np.load(npy_filename)
mz, intensities = (npzfile["mz"], npzfile["intensities"])
... | [
"def",
"read_exported_txt",
"(",
"filename",
":",
"str",
",",
"pts_per_amu",
"=",
"27",
",",
"overwrite",
"=",
"False",
")",
"->",
"tuple",
":",
"npy_filename",
"=",
"filename",
"[",
":",
"-",
"4",
"]",
"+",
"\".npz\"",
"if",
"os",
".",
"path",
".",
... | Reads the large text files exported by the merlin software and returns NumPy objects. | [
"Reads",
"the",
"large",
"text",
"files",
"exported",
"by",
"the",
"merlin",
"software",
"and",
"returns",
"NumPy",
"objects",
"."
] | [
"\"\"\"Reads the large text files exported by the merlin software and returns NumPy objects.\n\n Since the files can be large (> 1GB) and reading text files is slow, a binary version\n of the data is saved after the text file is parsed. If the function finds a binary\n file (look for .npz) extension, it wi... | [
{
"param": "filename",
"type": "str"
},
{
"param": "pts_per_amu",
"type": null
},
{
"param": "overwrite",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filename",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pts_per_amu",
"type": null,
"docstring": null,
"docstrin... |
67a1564071fa4845794b95d79e077a59b66389c2 | annliirosales/msanalysis | msanalysis/data_processing/peak_detection.py | [
"MIT"
] | Python | deconvolute_spectrum | (np.ndarray, list) | def deconvolute_spectrum(
data_dict: dict, species: list, decimals: int = 0, return_embedded: bool = False
) -> (np.ndarray, list):
"""Disentangle spectrum in `data_dict` given that the chemical species in the list
`species` are the only systems present in the current mass window.
Parameters
--... | Disentangle spectrum in `data_dict` given that the chemical species in the list
`species` are the only systems present in the current mass window.
Parameters
----------
data_dict : dict
The spectrum, where data["mz"] is an array of the mass/charge ratios
and data["intensity"... | Disentangle spectrum in `data_dict` given that the chemical species in the list
`species` are the only systems present in the current mass window.
Parameters
data_dict : dict
The spectrum, where data["mz"] is an array of the mass/charge ratios
and data["intensity"] is an array of the intensities.
species : list
A lis... | [
"Disentangle",
"spectrum",
"in",
"`",
"data_dict",
"`",
"given",
"that",
"the",
"chemical",
"species",
"in",
"the",
"list",
"`",
"species",
"`",
"are",
"the",
"only",
"systems",
"present",
"in",
"the",
"current",
"mass",
"window",
".",
"Parameters",
"data_di... | def deconvolute_spectrum(
data_dict: dict, species: list, decimals: int = 0, return_embedded: bool = False
) -> (np.ndarray, list):
species_spectra = [calculate_abundance(sp) for sp in species]
for sp in species_spectra:
sp["mz"] = np.round(sp["mz"], decimals=decimals)
all_mz = species_spectra[0... | [
"def",
"deconvolute_spectrum",
"(",
"data_dict",
":",
"dict",
",",
"species",
":",
"list",
",",
"decimals",
":",
"int",
"=",
"0",
",",
"return_embedded",
":",
"bool",
"=",
"False",
")",
"->",
"(",
"np",
".",
"ndarray",
",",
"list",
")",
":",
"species_s... | Disentangle spectrum in `data_dict` given that the chemical species in the list
`species` are the only systems present in the current mass window. | [
"Disentangle",
"spectrum",
"in",
"`",
"data_dict",
"`",
"given",
"that",
"the",
"chemical",
"species",
"in",
"the",
"list",
"`",
"species",
"`",
"are",
"the",
"only",
"systems",
"present",
"in",
"the",
"current",
"mass",
"window",
"."
] | [
"\"\"\"Disentangle spectrum in `data_dict` given that the chemical species in the list\n `species` are the only systems present in the current mass window.\n \n Parameters\n ----------\n data_dict : dict \n The spectrum, where data[\"mz\"] is an array of the mass/charge ratios\n ... | [
{
"param": "data_dict",
"type": "dict"
},
{
"param": "species",
"type": "list"
},
{
"param": "decimals",
"type": "int"
},
{
"param": "return_embedded",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data_dict",
"type": "dict",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "species",
"type": "list",
"docstring": null,
"docstrin... |
41716184d770963b8763131128ed7a12c70e08cc | pombredanne/vulnerability-assessment-kb | prospector/processing/commit/preprocessor.py | [
"Apache-2.0"
] | Python | preprocess_commit | DatamodelCommit | def preprocess_commit(git_commit: GitCommit) -> DatamodelCommit:
# TODO need to recheck these docstring, it may contains some outdated info
"""
This function is responsible of translating a (git)Commit
into a preprocessed-Commit, that can be saved to the DB
and later used by the ranking/ML module.
... |
This function is responsible of translating a (git)Commit
into a preprocessed-Commit, that can be saved to the DB
and later used by the ranking/ML module.
The structure of this module is straightforward and should
remain simple and clear for the sake of maintainability
and extensibility.
... | This function is responsible of translating a (git)Commit
into a preprocessed-Commit, that can be saved to the DB
and later used by the ranking/ML module.
The structure of this module is straightforward and should
remain simple and clear for the sake of maintainability
and extensibility.
Add as many "extractor" funct... | [
"This",
"function",
"is",
"responsible",
"of",
"translating",
"a",
"(",
"git",
")",
"Commit",
"into",
"a",
"preprocessed",
"-",
"Commit",
"that",
"can",
"be",
"saved",
"to",
"the",
"DB",
"and",
"later",
"used",
"by",
"the",
"ranking",
"/",
"ML",
"module"... | def preprocess_commit(git_commit: GitCommit) -> DatamodelCommit:
commit_id = git_commit.get_id()
repository_url = git_commit._repository._url
commit = DatamodelCommit(commit_id=commit_id, repository=repository_url)
Note: all attributes that do not depend on a particular query
(that is, that do not... | [
"def",
"preprocess_commit",
"(",
"git_commit",
":",
"GitCommit",
")",
"->",
"DatamodelCommit",
":",
"commit_id",
"=",
"git_commit",
".",
"get_id",
"(",
")",
"repository_url",
"=",
"git_commit",
".",
"_repository",
".",
"_url",
"commit",
"=",
"DatamodelCommit",
"... | This function is responsible of translating a (git)Commit
into a preprocessed-Commit, that can be saved to the DB
and later used by the ranking/ML module. | [
"This",
"function",
"is",
"responsible",
"of",
"translating",
"a",
"(",
"git",
")",
"Commit",
"into",
"a",
"preprocessed",
"-",
"Commit",
"that",
"can",
"be",
"saved",
"to",
"the",
"DB",
"and",
"later",
"used",
"by",
"the",
"ranking",
"/",
"ML",
"module"... | [
"# TODO need to recheck these docstring, it may contains some outdated info",
"\"\"\"\n This function is responsible of translating a (git)Commit\n into a preprocessed-Commit, that can be saved to the DB\n and later used by the ranking/ML module.\n\n The structure of this module is straightforward and... | [
{
"param": "git_commit",
"type": "GitCommit"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "git_commit",
"type": "GitCommit",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ad6dc7de0031d4763989c9b16b958bece9f55c4 | pombredanne/vulnerability-assessment-kb | prospector/ranking/utils/model_loader.py | [
"Apache-2.0"
] | Python | load_model | <not_specific> | def load_model(model_name: str):
"""
Serves for loading existing pre-trained modules from disk. Takes string model name as an input (the name of the
saved model - can be with or without file extension) and returns the loaded model.
If the requested model is not found, the function returns "Model not fou... |
Serves for loading existing pre-trained modules from disk. Takes string model name as an input (the name of the
saved model - can be with or without file extension) and returns the loaded model.
If the requested model is not found, the function returns "Model not found" exception.
| Serves for loading existing pre-trained modules from disk. Takes string model name as an input (the name of the
saved model - can be with or without file extension) and returns the loaded model.
If the requested model is not found, the function returns "Model not found" exception. | [
"Serves",
"for",
"loading",
"existing",
"pre",
"-",
"trained",
"modules",
"from",
"disk",
".",
"Takes",
"string",
"model",
"name",
"as",
"an",
"input",
"(",
"the",
"name",
"of",
"the",
"saved",
"model",
"-",
"can",
"be",
"with",
"or",
"without",
"file",
... | def load_model(model_name: str):
model_path = get_model_path(model_name)
if not os.path.exists(model_path):
raise Exception("Model {} not found".format(model_name))
return load(model_path) | [
"def",
"load_model",
"(",
"model_name",
":",
"str",
")",
":",
"model_path",
"=",
"get_model_path",
"(",
"model_name",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"model_path",
")",
":",
"raise",
"Exception",
"(",
"\"Model {} not found\"",
".",
... | Serves for loading existing pre-trained modules from disk. | [
"Serves",
"for",
"loading",
"existing",
"pre",
"-",
"trained",
"modules",
"from",
"disk",
"."
] | [
"\"\"\"\n Serves for loading existing pre-trained modules from disk. Takes string model name as an input (the name of the\n saved model - can be with or without file extension) and returns the loaded model.\n If the requested model is not found, the function returns \"Model not found\" exception.\n \"\"... | [
{
"param": "model_name",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "model_name",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ad6dc7de0031d4763989c9b16b958bece9f55c4 | pombredanne/vulnerability-assessment-kb | prospector/ranking/utils/model_loader.py | [
"Apache-2.0"
] | Python | save_model | str | def save_model(model, model_name: str) -> str:
"""
Serves for saving pre-trained models to disk. Takes <model, model_name> as input (the name of the
saved model - can be with or without file extension).
Raises Exception if the model cannot be saved to disk.
"""
model_path = get_model_path(model_... |
Serves for saving pre-trained models to disk. Takes <model, model_name> as input (the name of the
saved model - can be with or without file extension).
Raises Exception if the model cannot be saved to disk.
| Serves for saving pre-trained models to disk. Takes as input (the name of the
saved model - can be with or without file extension).
Raises Exception if the model cannot be saved to disk. | [
"Serves",
"for",
"saving",
"pre",
"-",
"trained",
"models",
"to",
"disk",
".",
"Takes",
"as",
"input",
"(",
"the",
"name",
"of",
"the",
"saved",
"model",
"-",
"can",
"be",
"with",
"or",
"without",
"file",
"extension",
")",
".",
"Raises",
"Exception",
"... | def save_model(model, model_name: str) -> str:
model_path = get_model_path(model_name)
dump(model, model_path)
return model_path | [
"def",
"save_model",
"(",
"model",
",",
"model_name",
":",
"str",
")",
"->",
"str",
":",
"model_path",
"=",
"get_model_path",
"(",
"model_name",
")",
"dump",
"(",
"model",
",",
"model_path",
")",
"return",
"model_path"
] | Serves for saving pre-trained models to disk. | [
"Serves",
"for",
"saving",
"pre",
"-",
"trained",
"models",
"to",
"disk",
"."
] | [
"\"\"\"\n Serves for saving pre-trained models to disk. Takes <model, model_name> as input (the name of the\n saved model - can be with or without file extension).\n Raises Exception if the model cannot be saved to disk.\n \"\"\""
] | [
{
"param": "model",
"type": null
},
{
"param": "model_name",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "model",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "model_name",
"type": "str",
"docstring": null,
"docstring_to... |
6738053821c56b5bf801351155525fb9ade3f85b | pombredanne/vulnerability-assessment-kb | prospector/util/inspection.py | [
"Apache-2.0"
] | Python | caller_name | Tuple[str, ...] | def caller_name(skip=2) -> Tuple[str, ...]:
"""Get a name of a caller in the format module.class.method
Note: It will not work correctly for static methods in classes.
`skip` specifies how many levels of stack to skip while getting caller
name. skip=1 means "who calls me", skip=2 "who calls my caller" ... | Get a name of a caller in the format module.class.method
Note: It will not work correctly for static methods in classes.
`skip` specifies how many levels of stack to skip while getting caller
name. skip=1 means "who calls me", skip=2 "who calls my caller" etc.
An empty string is returned if skipped le... | Get a name of a caller in the format module.class.method
Note: It will not work correctly for static methods in classes.
`skip` specifies how many levels of stack to skip while getting caller
name. skip=1 means "who calls me", skip=2 "who calls my caller" etc.
An empty string is returned if skipped levels exceed stac... | [
"Get",
"a",
"name",
"of",
"a",
"caller",
"in",
"the",
"format",
"module",
".",
"class",
".",
"method",
"Note",
":",
"It",
"will",
"not",
"work",
"correctly",
"for",
"static",
"methods",
"in",
"classes",
".",
"`",
"skip",
"`",
"specifies",
"how",
"many"... | def caller_name(skip=2) -> Tuple[str, ...]:
stack = inspect.stack()
start = 0 + skip
if len(stack) < start + 1:
return tuple()
parent_frame = stack[start][0]
name = []
module = inspect.getmodule(parent_frame)
if module:
name.extend(module.__name__.split("."))
if "self" in... | [
"def",
"caller_name",
"(",
"skip",
"=",
"2",
")",
"->",
"Tuple",
"[",
"str",
",",
"...",
"]",
":",
"stack",
"=",
"inspect",
".",
"stack",
"(",
")",
"start",
"=",
"0",
"+",
"skip",
"if",
"len",
"(",
"stack",
")",
"<",
"start",
"+",
"1",
":",
"... | Get a name of a caller in the format module.class.method
Note: It will not work correctly for static methods in classes. | [
"Get",
"a",
"name",
"of",
"a",
"caller",
"in",
"the",
"format",
"module",
".",
"class",
".",
"method",
"Note",
":",
"It",
"will",
"not",
"work",
"correctly",
"for",
"static",
"methods",
"in",
"classes",
"."
] | [
"\"\"\"Get a name of a caller in the format module.class.method\n Note: It will not work correctly for static methods in classes.\n\n `skip` specifies how many levels of stack to skip while getting caller\n name. skip=1 means \"who calls me\", skip=2 \"who calls my caller\" etc.\n\n An empty string is r... | [
{
"param": "skip",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "skip",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3729e238f70a5e002b74ab7e255fd87720556218 | pombredanne/vulnerability-assessment-kb | prospector/git/git.py | [
"Apache-2.0"
] | Python | clone_repo_multiple | <not_specific> | def clone_repo_multiple(
url_list,
output_folder,
proxy="",
shallow=False,
skip_existing=False,
concurrent=multiprocessing.cpu_count(),
):
"""
This is the parallelized version of clone_repo (works with a list of repositories).
"""
_logger.info(f"Using {concurrent} parallel worker... |
This is the parallelized version of clone_repo (works with a list of repositories).
| This is the parallelized version of clone_repo (works with a list of repositories). | [
"This",
"is",
"the",
"parallelized",
"version",
"of",
"clone_repo",
"(",
"works",
"with",
"a",
"list",
"of",
"repositories",
")",
"."
] | def clone_repo_multiple(
url_list,
output_folder,
proxy="",
shallow=False,
skip_existing=False,
concurrent=multiprocessing.cpu_count(),
):
_logger.info(f"Using {concurrent} parallel workers")
with multiprocessing.Pool(concurrent) as pool:
args = ((url, output_folder, proxy, shall... | [
"def",
"clone_repo_multiple",
"(",
"url_list",
",",
"output_folder",
",",
"proxy",
"=",
"\"\"",
",",
"shallow",
"=",
"False",
",",
"skip_existing",
"=",
"False",
",",
"concurrent",
"=",
"multiprocessing",
".",
"cpu_count",
"(",
")",
",",
")",
":",
"_logger",... | This is the parallelized version of clone_repo (works with a list of repositories). | [
"This",
"is",
"the",
"parallelized",
"version",
"of",
"clone_repo",
"(",
"works",
"with",
"a",
"list",
"of",
"repositories",
")",
"."
] | [
"\"\"\"\n This is the parallelized version of clone_repo (works with a list of repositories).\n \"\"\""
] | [
{
"param": "url_list",
"type": null
},
{
"param": "output_folder",
"type": null
},
{
"param": "proxy",
"type": null
},
{
"param": "shallow",
"type": null
},
{
"param": "skip_existing",
"type": null
},
{
"param": "concurrent",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url_list",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "output_folder",
"type": null,
"docstring": null,
"docstri... |
3729e238f70a5e002b74ab7e255fd87720556218 | pombredanne/vulnerability-assessment-kb | prospector/git/git.py | [
"Apache-2.0"
] | Python | clone | <not_specific> | def clone(self, shallow=None, skip_existing=False):
"""
Clones the specified repository checking out the default branch in a subdir of output_folder.
Shallow=true speeds up considerably the operation, but gets no history.
"""
if shallow:
self._shallow_clone = shallow
... |
Clones the specified repository checking out the default branch in a subdir of output_folder.
Shallow=true speeds up considerably the operation, but gets no history.
| Clones the specified repository checking out the default branch in a subdir of output_folder.
Shallow=true speeds up considerably the operation, but gets no history. | [
"Clones",
"the",
"specified",
"repository",
"checking",
"out",
"the",
"default",
"branch",
"in",
"a",
"subdir",
"of",
"output_folder",
".",
"Shallow",
"=",
"true",
"speeds",
"up",
"considerably",
"the",
"operation",
"but",
"gets",
"no",
"history",
"."
] | def clone(self, shallow=None, skip_existing=False):
if shallow:
self._shallow_clone = shallow
if not self._url:
_logger.error("Invalid url specified.")
sys.exit(-1)
if os.path.isdir(os.path.join(self._path, ".git")):
if skip_existing:
... | [
"def",
"clone",
"(",
"self",
",",
"shallow",
"=",
"None",
",",
"skip_existing",
"=",
"False",
")",
":",
"if",
"shallow",
":",
"self",
".",
"_shallow_clone",
"=",
"shallow",
"if",
"not",
"self",
".",
"_url",
":",
"_logger",
".",
"error",
"(",
"\"Invalid... | Clones the specified repository checking out the default branch in a subdir of output_folder. | [
"Clones",
"the",
"specified",
"repository",
"checking",
"out",
"the",
"default",
"branch",
"in",
"a",
"subdir",
"of",
"output_folder",
"."
] | [
"\"\"\"\n Clones the specified repository checking out the default branch in a subdir of output_folder.\n Shallow=true speeds up considerably the operation, but gets no history.\n \"\"\"",
"# TODO rearrange order of checks",
"# , cwd=self._path, timeout=self._exec_timeout)",
"# , cwd=sel... | [
{
"param": "self",
"type": null
},
{
"param": "shallow",
"type": null
},
{
"param": "skip_existing",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "shallow",
"type": null,
"docstring": null,
"docstring_tokens"... |
3729e238f70a5e002b74ab7e255fd87720556218 | pombredanne/vulnerability-assessment-kb | prospector/git/git.py | [
"Apache-2.0"
] | Python | equals | <not_specific> | def equals(self, other_commit):
"""
Return true if the two commits contain the same changes (despite different commit messages)
"""
return self.get_fingerprint() == other_commit.get_fingerprint() |
Return true if the two commits contain the same changes (despite different commit messages)
| Return true if the two commits contain the same changes (despite different commit messages) | [
"Return",
"true",
"if",
"the",
"two",
"commits",
"contain",
"the",
"same",
"changes",
"(",
"despite",
"different",
"commit",
"messages",
")"
] | def equals(self, other_commit):
return self.get_fingerprint() == other_commit.get_fingerprint() | [
"def",
"equals",
"(",
"self",
",",
"other_commit",
")",
":",
"return",
"self",
".",
"get_fingerprint",
"(",
")",
"==",
"other_commit",
".",
"get_fingerprint",
"(",
")"
] | Return true if the two commits contain the same changes (despite different commit messages) | [
"Return",
"true",
"if",
"the",
"two",
"commits",
"contain",
"the",
"same",
"changes",
"(",
"despite",
"different",
"commit",
"messages",
")"
] | [
"\"\"\"\n Return true if the two commits contain the same changes (despite different commit messages)\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "other_commit",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "other_commit",
"type": null,
"docstring": null,
"docstring_to... |
d1d6802e95ef4b5240a17045c731c71c253b720b | pombredanne/vulnerability-assessment-kb | prospector/git/version_to_tag.py | [
"Apache-2.0"
] | Python | recursively_split_version_string | <not_specific> | def recursively_split_version_string(input_version: str, output_version: list = []):
"""
Splits a version/tag string into a list with integers and strings
i.e. "8.0.0.RC10" --> [8, '.', 0, '.', 0, '.RC', 10]
Input:
input_version (str): a version or tag i.e. "8.0.0.RC10"
output_versio... |
Splits a version/tag string into a list with integers and strings
i.e. "8.0.0.RC10" --> [8, '.', 0, '.', 0, '.RC', 10]
Input:
input_version (str): a version or tag i.e. "8.0.0.RC10"
output_version (list): an empty list, which will be filled iteratively
Returns:
list: the ver... | Splits a version/tag string into a list with integers and strings
i.e. | [
"Splits",
"a",
"version",
"/",
"tag",
"string",
"into",
"a",
"list",
"with",
"integers",
"and",
"strings",
"i",
".",
"e",
"."
] | def recursively_split_version_string(input_version: str, output_version: list = []):
if type(input_version) != str:
raise TypeError(
"The provided version should be a str data type but is of type {}.".format(
type(input_version)
)
)
if (
input_vers... | [
"def",
"recursively_split_version_string",
"(",
"input_version",
":",
"str",
",",
"output_version",
":",
"list",
"=",
"[",
"]",
")",
":",
"if",
"type",
"(",
"input_version",
")",
"!=",
"str",
":",
"raise",
"TypeError",
"(",
"\"The provided version should be a str ... | Splits a version/tag string into a list with integers and strings
i.e. | [
"Splits",
"a",
"version",
"/",
"tag",
"string",
"into",
"a",
"list",
"with",
"integers",
"and",
"strings",
"i",
".",
"e",
"."
] | [
"\"\"\"\n Splits a version/tag string into a list with integers and strings\n i.e. \"8.0.0.RC10\" --> [8, '.', 0, '.', 0, '.RC', 10]\n Input:\n input_version (str): a version or tag i.e. \"8.0.0.RC10\"\n output_version (list): an empty list, which will be filled iteratively\n Returns:\... | [
{
"param": "input_version",
"type": "str"
},
{
"param": "output_version",
"type": "list"
}
] | {
"returns": [
{
"docstring": "the version/tag string in a list with integers and strings i.e.",
"docstring_tokens": [
"the",
"version",
"/",
"tag",
"string",
"in",
"a",
"list",
"with",
"integers",
"and",
"... |
a76da5bb2856346608ba1901c8d686af00999e3b | pombredanne/vulnerability-assessment-kb | prospector/commitdb/postgres.py | [
"Apache-2.0"
] | Python | reset | null | def reset(self):
"""
Resets the database by dropping its tables and recreating them afresh.
If the database does not exist, or any tables are missing, they
are created.
"""
if not self.connection:
raise Exception("Invalid connection")
self._run_sql_s... |
Resets the database by dropping its tables and recreating them afresh.
If the database does not exist, or any tables are missing, they
are created.
| Resets the database by dropping its tables and recreating them afresh.
If the database does not exist, or any tables are missing, they
are created. | [
"Resets",
"the",
"database",
"by",
"dropping",
"its",
"tables",
"and",
"recreating",
"them",
"afresh",
".",
"If",
"the",
"database",
"does",
"not",
"exist",
"or",
"any",
"tables",
"are",
"missing",
"they",
"are",
"created",
"."
] | def reset(self):
if not self.connection:
raise Exception("Invalid connection")
self._run_sql_script("ddl/commit.sql")
self._run_sql_script("ddl/users.sql") | [
"def",
"reset",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"connection",
":",
"raise",
"Exception",
"(",
"\"Invalid connection\"",
")",
"self",
".",
"_run_sql_script",
"(",
"\"ddl/commit.sql\"",
")",
"self",
".",
"_run_sql_script",
"(",
"\"ddl/users.sql\""... | Resets the database by dropping its tables and recreating them afresh. | [
"Resets",
"the",
"database",
"by",
"dropping",
"its",
"tables",
"and",
"recreating",
"them",
"afresh",
"."
] | [
"\"\"\"\n Resets the database by dropping its tables and recreating them afresh.\n If the database does not exist, or any tables are missing, they\n are created.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3b4c87dd133d6f9c3aea20cab8c5915e6c4c59c0 | pombredanne/vulnerability-assessment-kb | prospector/ranking/rules.py | [
"Apache-2.0"
] | Python | apply_rule_changes_relevant_path | str | def apply_rule_changes_relevant_path(
candidate: Commit, advisory_record: AdvisoryRecord
) -> str:
"""
This rule matches commits that touch some file that is mentioned
in the text of the advisory.
"""
relevant_paths = []
explanation_template = "This commit touches the following relevant pa... |
This rule matches commits that touch some file that is mentioned
in the text of the advisory.
| This rule matches commits that touch some file that is mentioned
in the text of the advisory. | [
"This",
"rule",
"matches",
"commits",
"that",
"touch",
"some",
"file",
"that",
"is",
"mentioned",
"in",
"the",
"text",
"of",
"the",
"advisory",
"."
] | def apply_rule_changes_relevant_path(
candidate: Commit, advisory_record: AdvisoryRecord
) -> str:
relevant_paths = []
explanation_template = "This commit touches the following relevant paths: {}"
relevant_paths = set(
[
path
for path in candidate.changed_files
... | [
"def",
"apply_rule_changes_relevant_path",
"(",
"candidate",
":",
"Commit",
",",
"advisory_record",
":",
"AdvisoryRecord",
")",
"->",
"str",
":",
"relevant_paths",
"=",
"[",
"]",
"explanation_template",
"=",
"\"This commit touches the following relevant paths: {}\"",
"relev... | This rule matches commits that touch some file that is mentioned
in the text of the advisory. | [
"This",
"rule",
"matches",
"commits",
"that",
"touch",
"some",
"file",
"that",
"is",
"mentioned",
"in",
"the",
"text",
"of",
"the",
"advisory",
"."
] | [
"\"\"\"\n This rule matches commits that touch some file that is mentioned\n in the text of the advisory.\n \"\"\""
] | [
{
"param": "candidate",
"type": "Commit"
},
{
"param": "advisory_record",
"type": "AdvisoryRecord"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "candidate",
"type": "Commit",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "advisory_record",
"type": "AdvisoryRecord",
"docstring": n... |
3b4c87dd133d6f9c3aea20cab8c5915e6c4c59c0 | pombredanne/vulnerability-assessment-kb | prospector/ranking/rules.py | [
"Apache-2.0"
] | Python | apply_rule_code_tokens_in_msg | str | def apply_rule_code_tokens_in_msg(
candidate: Commit, advisory_record: AdvisoryRecord
) -> str:
"""
This rule matches commits whose commit message contain some of the special "code tokens"
extracted from the advisory.
"""
explanation_template = "The commit message includes the following keyword... |
This rule matches commits whose commit message contain some of the special "code tokens"
extracted from the advisory.
| This rule matches commits whose commit message contain some of the special "code tokens"
extracted from the advisory. | [
"This",
"rule",
"matches",
"commits",
"whose",
"commit",
"message",
"contain",
"some",
"of",
"the",
"special",
"\"",
"code",
"tokens",
"\"",
"extracted",
"from",
"the",
"advisory",
"."
] | def apply_rule_code_tokens_in_msg(
candidate: Commit, advisory_record: AdvisoryRecord
) -> str:
explanation_template = "The commit message includes the following keywords: {}"
matching_keywords = set(
[kw for kw in advisory_record.code_tokens if kw in candidate.message]
)
if len(matching_key... | [
"def",
"apply_rule_code_tokens_in_msg",
"(",
"candidate",
":",
"Commit",
",",
"advisory_record",
":",
"AdvisoryRecord",
")",
"->",
"str",
":",
"explanation_template",
"=",
"\"The commit message includes the following keywords: {}\"",
"matching_keywords",
"=",
"set",
"(",
"[... | This rule matches commits whose commit message contain some of the special "code tokens"
extracted from the advisory. | [
"This",
"rule",
"matches",
"commits",
"whose",
"commit",
"message",
"contain",
"some",
"of",
"the",
"special",
"\"",
"code",
"tokens",
"\"",
"extracted",
"from",
"the",
"advisory",
"."
] | [
"\"\"\"\n This rule matches commits whose commit message contain some of the special \"code tokens\"\n extracted from the advisory.\n \"\"\""
] | [
{
"param": "candidate",
"type": "Commit"
},
{
"param": "advisory_record",
"type": "AdvisoryRecord"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "candidate",
"type": "Commit",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "advisory_record",
"type": "AdvisoryRecord",
"docstring": n... |
3b4c87dd133d6f9c3aea20cab8c5915e6c4c59c0 | pombredanne/vulnerability-assessment-kb | prospector/ranking/rules.py | [
"Apache-2.0"
] | Python | apply_rule_code_tokens_in_diff | str | def apply_rule_code_tokens_in_diff(
candidate: Commit, advisory_record: AdvisoryRecord
) -> str:
"""
This rule matches commits whose diff contain some of the special "code tokens"
extracted from the advisory.
"""
explanation_template = "The commit diff includes the following keywords: {}"
... |
This rule matches commits whose diff contain some of the special "code tokens"
extracted from the advisory.
| This rule matches commits whose diff contain some of the special "code tokens"
extracted from the advisory. | [
"This",
"rule",
"matches",
"commits",
"whose",
"diff",
"contain",
"some",
"of",
"the",
"special",
"\"",
"code",
"tokens",
"\"",
"extracted",
"from",
"the",
"advisory",
"."
] | def apply_rule_code_tokens_in_diff(
candidate: Commit, advisory_record: AdvisoryRecord
) -> str:
explanation_template = "The commit diff includes the following keywords: {}"
matching_keywords = set(
[
kw
for kw in advisory_record.code_tokens
for diff_line in candi... | [
"def",
"apply_rule_code_tokens_in_diff",
"(",
"candidate",
":",
"Commit",
",",
"advisory_record",
":",
"AdvisoryRecord",
")",
"->",
"str",
":",
"explanation_template",
"=",
"\"The commit diff includes the following keywords: {}\"",
"matching_keywords",
"=",
"set",
"(",
"[",... | This rule matches commits whose diff contain some of the special "code tokens"
extracted from the advisory. | [
"This",
"rule",
"matches",
"commits",
"whose",
"diff",
"contain",
"some",
"of",
"the",
"special",
"\"",
"code",
"tokens",
"\"",
"extracted",
"from",
"the",
"advisory",
"."
] | [
"\"\"\"\n This rule matches commits whose diff contain some of the special \"code tokens\"\n extracted from the advisory.\n \"\"\""
] | [
{
"param": "candidate",
"type": "Commit"
},
{
"param": "advisory_record",
"type": "AdvisoryRecord"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "candidate",
"type": "Commit",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "advisory_record",
"type": "AdvisoryRecord",
"docstring": n... |
3b4c87dd133d6f9c3aea20cab8c5915e6c4c59c0 | pombredanne/vulnerability-assessment-kb | prospector/ranking/rules.py | [
"Apache-2.0"
] | Python | apply_rule_security_keyword_in_msg | str | def apply_rule_security_keyword_in_msg(
candidate: Commit, advisory_record: AdvisoryRecord
) -> str:
"""
This rule matches commits whose message contains one or more "security-related" keywords
"""
SEC_KEYWORDS = [
"vuln",
"exploit",
"attack",
"secur",
"xxe",... |
This rule matches commits whose message contains one or more "security-related" keywords
| This rule matches commits whose message contains one or more "security-related" keywords | [
"This",
"rule",
"matches",
"commits",
"whose",
"message",
"contains",
"one",
"or",
"more",
"\"",
"security",
"-",
"related",
"\"",
"keywords"
] | def apply_rule_security_keyword_in_msg(
candidate: Commit, advisory_record: AdvisoryRecord
) -> str:
SEC_KEYWORDS = [
"vuln",
"exploit",
"attack",
"secur",
"xxe",
"dos",
"insecur",
"inject",
]
explanation_template = "The commit message incl... | [
"def",
"apply_rule_security_keyword_in_msg",
"(",
"candidate",
":",
"Commit",
",",
"advisory_record",
":",
"AdvisoryRecord",
")",
"->",
"str",
":",
"SEC_KEYWORDS",
"=",
"[",
"\"vuln\"",
",",
"\"exploit\"",
",",
"\"attack\"",
",",
"\"secur\"",
",",
"\"xxe\"",
",",
... | This rule matches commits whose message contains one or more "security-related" keywords | [
"This",
"rule",
"matches",
"commits",
"whose",
"message",
"contains",
"one",
"or",
"more",
"\"",
"security",
"-",
"related",
"\"",
"keywords"
] | [
"\"\"\"\n This rule matches commits whose message contains one or more \"security-related\" keywords\n \"\"\""
] | [
{
"param": "candidate",
"type": "Commit"
},
{
"param": "advisory_record",
"type": "AdvisoryRecord"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "candidate",
"type": "Commit",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "advisory_record",
"type": "AdvisoryRecord",
"docstring": n... |
3b4c87dd133d6f9c3aea20cab8c5915e6c4c59c0 | pombredanne/vulnerability-assessment-kb | prospector/ranking/rules.py | [
"Apache-2.0"
] | Python | apply_rule_code_token_in_paths | str | def apply_rule_code_token_in_paths(
candidate: Commit, advisory_record: AdvisoryRecord
) -> str:
"""
This rule matches commits that modify paths that correspond to a code token extracted
from the advisory.
"""
explanation_template = "The commit modifies the following paths: {}"
matches = s... |
This rule matches commits that modify paths that correspond to a code token extracted
from the advisory.
| This rule matches commits that modify paths that correspond to a code token extracted
from the advisory. | [
"This",
"rule",
"matches",
"commits",
"that",
"modify",
"paths",
"that",
"correspond",
"to",
"a",
"code",
"token",
"extracted",
"from",
"the",
"advisory",
"."
] | def apply_rule_code_token_in_paths(
candidate: Commit, advisory_record: AdvisoryRecord
) -> str:
explanation_template = "The commit modifies the following paths: {}"
matches = set(
[
(p, token)
for p in candidate.changed_files
for token in advisory_record.code_tok... | [
"def",
"apply_rule_code_token_in_paths",
"(",
"candidate",
":",
"Commit",
",",
"advisory_record",
":",
"AdvisoryRecord",
")",
"->",
"str",
":",
"explanation_template",
"=",
"\"The commit modifies the following paths: {}\"",
"matches",
"=",
"set",
"(",
"[",
"(",
"p",
"... | This rule matches commits that modify paths that correspond to a code token extracted
from the advisory. | [
"This",
"rule",
"matches",
"commits",
"that",
"modify",
"paths",
"that",
"correspond",
"to",
"a",
"code",
"token",
"extracted",
"from",
"the",
"advisory",
"."
] | [
"\"\"\"\n This rule matches commits that modify paths that correspond to a code token extracted\n from the advisory.\n \"\"\""
] | [
{
"param": "candidate",
"type": "Commit"
},
{
"param": "advisory_record",
"type": "AdvisoryRecord"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "candidate",
"type": "Commit",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "advisory_record",
"type": "AdvisoryRecord",
"docstring": n... |
dd8a860b2e0384f8cb332a40e880d899da58d69f | pombredanne/vulnerability-assessment-kb | prospector/processing/nlp.py | [
"Apache-2.0"
] | Python | extract_special_terms | Tuple[str, ...] | def extract_special_terms(description: str) -> Tuple[str, ...]:
"""
Extract all words (space delimited) which presumably cannot be part of an natural language sentence.
These are usually code fragments and names of code entities, or paths.
"""
result = []
for word in description.split():
... |
Extract all words (space delimited) which presumably cannot be part of an natural language sentence.
These are usually code fragments and names of code entities, or paths.
| Extract all words (space delimited) which presumably cannot be part of an natural language sentence.
These are usually code fragments and names of code entities, or paths. | [
"Extract",
"all",
"words",
"(",
"space",
"delimited",
")",
"which",
"presumably",
"cannot",
"be",
"part",
"of",
"an",
"natural",
"language",
"sentence",
".",
"These",
"are",
"usually",
"code",
"fragments",
"and",
"names",
"of",
"code",
"entities",
"or",
"pat... | def extract_special_terms(description: str) -> Tuple[str, ...]:
result = []
for word in description.split():
no_punctation_word = word.rstrip(").,;:?!\"'").lstrip("(")
contains_non_word_char = re.search(r"\W", no_punctation_word)
contains_non_initial_upper_case = re.search(r"\B[A-Z]", no... | [
"def",
"extract_special_terms",
"(",
"description",
":",
"str",
")",
"->",
"Tuple",
"[",
"str",
",",
"...",
"]",
":",
"result",
"=",
"[",
"]",
"for",
"word",
"in",
"description",
".",
"split",
"(",
")",
":",
"no_punctation_word",
"=",
"word",
".",
"rst... | Extract all words (space delimited) which presumably cannot be part of an natural language sentence. | [
"Extract",
"all",
"words",
"(",
"space",
"delimited",
")",
"which",
"presumably",
"cannot",
"be",
"part",
"of",
"an",
"natural",
"language",
"sentence",
"."
] | [
"\"\"\"\n Extract all words (space delimited) which presumably cannot be part of an natural language sentence.\n These are usually code fragments and names of code entities, or paths.\n \"\"\""
] | [
{
"param": "description",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "description",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dd8a860b2e0384f8cb332a40e880d899da58d69f | pombredanne/vulnerability-assessment-kb | prospector/processing/nlp.py | [
"Apache-2.0"
] | Python | extract_versions | List[str] | def extract_versions(text: str) -> List[str]:
"""
Extract all versions mentioned in the text
"""
return re.findall(r"[0-9]+\.[0-9]+[0-9a-z.]*", text) |
Extract all versions mentioned in the text
| Extract all versions mentioned in the text | [
"Extract",
"all",
"versions",
"mentioned",
"in",
"the",
"text"
] | def extract_versions(text: str) -> List[str]:
return re.findall(r"[0-9]+\.[0-9]+[0-9a-z.]*", text) | [
"def",
"extract_versions",
"(",
"text",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"re",
".",
"findall",
"(",
"r\"[0-9]+\\.[0-9]+[0-9a-z.]*\"",
",",
"text",
")"
] | Extract all versions mentioned in the text | [
"Extract",
"all",
"versions",
"mentioned",
"in",
"the",
"text"
] | [
"\"\"\"\n Extract all versions mentioned in the text\n \"\"\""
] | [
{
"param": "text",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "text",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dd8a860b2e0384f8cb332a40e880d899da58d69f | pombredanne/vulnerability-assessment-kb | prospector/processing/nlp.py | [
"Apache-2.0"
] | Python | extract_products | List[str] | def extract_products(text: str) -> List[str]:
"""
Extract product names from advisory text
"""
# TODO implement this properly
regex = r"([A-Z]+[a-z\b]+)"
result = list(set(re.findall(regex, text)))
return [p for p in result if len(p) > 2] |
Extract product names from advisory text
| Extract product names from advisory text | [
"Extract",
"product",
"names",
"from",
"advisory",
"text"
] | def extract_products(text: str) -> List[str]:
regex = r"([A-Z]+[a-z\b]+)"
result = list(set(re.findall(regex, text)))
return [p for p in result if len(p) > 2] | [
"def",
"extract_products",
"(",
"text",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"regex",
"=",
"r\"([A-Z]+[a-z\\b]+)\"",
"result",
"=",
"list",
"(",
"set",
"(",
"re",
".",
"findall",
"(",
"regex",
",",
"text",
")",
")",
")",
"return",
"["... | Extract product names from advisory text | [
"Extract",
"product",
"names",
"from",
"advisory",
"text"
] | [
"\"\"\"\n Extract product names from advisory text\n \"\"\"",
"# TODO implement this properly"
] | [
{
"param": "text",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "text",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dd8a860b2e0384f8cb332a40e880d899da58d69f | pombredanne/vulnerability-assessment-kb | prospector/processing/nlp.py | [
"Apache-2.0"
] | Python | extract_path_tokens | List[str] | def extract_path_tokens(text: str, strict_extensions: bool = False) -> List[str]:
"""
Used to look for paths in the text (i.e. vulnerability description)
Input:
text (str)
strict_extensions (bool): this function will always extract tokens with (back) slashes,
but it will only ma... |
Used to look for paths in the text (i.e. vulnerability description)
Input:
text (str)
strict_extensions (bool): this function will always extract tokens with (back) slashes,
but it will only match single file names if they have the correct extension, if this argument is True
R... | Used to look for paths in the text
Input:
text (str)
strict_extensions (bool): this function will always extract tokens with (back) slashes,
but it will only match single file names if they have the correct extension, if this argument is True | [
"Used",
"to",
"look",
"for",
"paths",
"in",
"the",
"text",
"Input",
":",
"text",
"(",
"str",
")",
"strict_extensions",
"(",
"bool",
")",
":",
"this",
"function",
"will",
"always",
"extract",
"tokens",
"with",
"(",
"back",
")",
"slashes",
"but",
"it",
"... | def extract_path_tokens(text: str, strict_extensions: bool = False) -> List[str]:
tokens = re.split(r"\s+", text)
tokens = [
token.strip(",.:;-+!?)]}'\"") for token in tokens
]
paths = []
for token in tokens:
contains_path_separators = ("\\" in token) or ("/" in token)
se... | [
"def",
"extract_path_tokens",
"(",
"text",
":",
"str",
",",
"strict_extensions",
":",
"bool",
"=",
"False",
")",
"->",
"List",
"[",
"str",
"]",
":",
"tokens",
"=",
"re",
".",
"split",
"(",
"r\"\\s+\"",
",",
"text",
")",
"tokens",
"=",
"[",
"token",
"... | Used to look for paths in the text (i.e. | [
"Used",
"to",
"look",
"for",
"paths",
"in",
"the",
"text",
"(",
"i",
".",
"e",
"."
] | [
"\"\"\"\n Used to look for paths in the text (i.e. vulnerability description)\n\n Input:\n text (str)\n strict_extensions (bool): this function will always extract tokens with (back) slashes,\n but it will only match single file names if they have the correct extension, if this argume... | [
{
"param": "text",
"type": "str"
},
{
"param": "strict_extensions",
"type": "bool"
}
] | {
"returns": [
{
"docstring": "a list of paths that are found",
"docstring_tokens": [
"a",
"list",
"of",
"paths",
"that",
"are",
"found"
],
"type": "list"
}
],
"raises": [],
"params": [
{
"identifier": "text",
... |
dd8a860b2e0384f8cb332a40e880d899da58d69f | pombredanne/vulnerability-assessment-kb | prospector/processing/nlp.py | [
"Apache-2.0"
] | Python | extract_ghissue_references | List[str] | def extract_ghissue_references(text: str) -> List[str]:
"""
Extract identifiers that are (=look like) references to GH issues
"""
return [result.group(0) for result in re.finditer(r"#\d+", text)] |
Extract identifiers that are (=look like) references to GH issues
| Extract identifiers that are (=look like) references to GH issues | [
"Extract",
"identifiers",
"that",
"are",
"(",
"=",
"look",
"like",
")",
"references",
"to",
"GH",
"issues"
] | def extract_ghissue_references(text: str) -> List[str]:
return [result.group(0) for result in re.finditer(r"#\d+", text)] | [
"def",
"extract_ghissue_references",
"(",
"text",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"[",
"result",
".",
"group",
"(",
"0",
")",
"for",
"result",
"in",
"re",
".",
"finditer",
"(",
"r\"#\\d+\"",
",",
"text",
")",
"]"
] | Extract identifiers that are (=look like) references to GH issues | [
"Extract",
"identifiers",
"that",
"are",
"(",
"=",
"look",
"like",
")",
"references",
"to",
"GH",
"issues"
] | [
"\"\"\"\n Extract identifiers that are (=look like) references to GH issues\n \"\"\""
] | [
{
"param": "text",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "text",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dd8a860b2e0384f8cb332a40e880d899da58d69f | pombredanne/vulnerability-assessment-kb | prospector/processing/nlp.py | [
"Apache-2.0"
] | Python | extract_jira_references | List[str] | def extract_jira_references(text: str) -> List[str]:
"""
Extract identifiers that point to Jira tickets
"""
return [result.group(0) for result in re.finditer(r"\w+-\d+", text)] |
Extract identifiers that point to Jira tickets
| Extract identifiers that point to Jira tickets | [
"Extract",
"identifiers",
"that",
"point",
"to",
"Jira",
"tickets"
] | def extract_jira_references(text: str) -> List[str]:
return [result.group(0) for result in re.finditer(r"\w+-\d+", text)] | [
"def",
"extract_jira_references",
"(",
"text",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"[",
"result",
".",
"group",
"(",
"0",
")",
"for",
"result",
"in",
"re",
".",
"finditer",
"(",
"r\"\\w+-\\d+\"",
",",
"text",
")",
"]"
] | Extract identifiers that point to Jira tickets | [
"Extract",
"identifiers",
"that",
"point",
"to",
"Jira",
"tickets"
] | [
"\"\"\"\n Extract identifiers that point to Jira tickets\n \"\"\""
] | [
{
"param": "text",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "text",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cda5ef3e7274802a9797d57c9fb243f0639edac6 | pombredanne/vulnerability-assessment-kb | prospector/ranking/rank.py | [
"Apache-2.0"
] | Python | rank | "list[Commit]" | def rank(candidates: "list[Commit]", model_name: str) -> "list[Commit]":
"""
Takes in input a list of Commit and augments them with ML generated annotations.
Returns the initial list of Commit augmented with annotations.
"""
return candidates |
Takes in input a list of Commit and augments them with ML generated annotations.
Returns the initial list of Commit augmented with annotations.
| Takes in input a list of Commit and augments them with ML generated annotations.
Returns the initial list of Commit augmented with annotations. | [
"Takes",
"in",
"input",
"a",
"list",
"of",
"Commit",
"and",
"augments",
"them",
"with",
"ML",
"generated",
"annotations",
".",
"Returns",
"the",
"initial",
"list",
"of",
"Commit",
"augmented",
"with",
"annotations",
"."
] | def rank(candidates: "list[Commit]", model_name: str) -> "list[Commit]":
return candidates | [
"def",
"rank",
"(",
"candidates",
":",
"\"list[Commit]\"",
",",
"model_name",
":",
"str",
")",
"->",
"\"list[Commit]\"",
":",
"return",
"candidates"
] | Takes in input a list of Commit and augments them with ML generated annotations. | [
"Takes",
"in",
"input",
"a",
"list",
"of",
"Commit",
"and",
"augments",
"them",
"with",
"ML",
"generated",
"annotations",
"."
] | [
"\"\"\"\n Takes in input a list of Commit and augments them with ML generated annotations.\n Returns the initial list of Commit augmented with annotations.\n \"\"\""
] | [
{
"param": "candidates",
"type": "\"list[Commit]\""
},
{
"param": "model_name",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "candidates",
"type": "\"list[Commit]\"",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "model_name",
"type": "str",
"docstring": null,
... |
cda5ef3e7274802a9797d57c9fb243f0639edac6 | pombredanne/vulnerability-assessment-kb | prospector/ranking/rank.py | [
"Apache-2.0"
] | Python | predict | float | def predict(model_name: str, candidate: Commit) -> float:
"""
The function computes the similarity score for the given commit
"""
# model = load_model(model_name)
# compute the actual value here
# value = model.predict(commit_features)
return (
random.random() * 2 - 1
) |
The function computes the similarity score for the given commit
| The function computes the similarity score for the given commit | [
"The",
"function",
"computes",
"the",
"similarity",
"score",
"for",
"the",
"given",
"commit"
] | def predict(model_name: str, candidate: Commit) -> float:
return (
random.random() * 2 - 1
) | [
"def",
"predict",
"(",
"model_name",
":",
"str",
",",
"candidate",
":",
"Commit",
")",
"->",
"float",
":",
"return",
"(",
"random",
".",
"random",
"(",
")",
"*",
"2",
"-",
"1",
")"
] | The function computes the similarity score for the given commit | [
"The",
"function",
"computes",
"the",
"similarity",
"score",
"for",
"the",
"given",
"commit"
] | [
"\"\"\"\n The function computes the similarity score for the given commit\n \"\"\"",
"# model = load_model(model_name)",
"# compute the actual value here",
"# value = model.predict(commit_features)"
] | [
{
"param": "model_name",
"type": "str"
},
{
"param": "candidate",
"type": "Commit"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "model_name",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "candidate",
"type": "Commit",
"docstring": null,
"docs... |
cda5ef3e7274802a9797d57c9fb243f0639edac6 | pombredanne/vulnerability-assessment-kb | prospector/ranking/rank.py | [
"Apache-2.0"
] | Python | train | str | def train(
model_name: str,
data_filename=TRAINING_DATA,
num_elem_training_data=NUM_ELEMENTS_TRAINING_DATA,
) -> str:
"""
Takes in input a dataset and produces a trained model that is persisted to disk.
Dataset file contains triples: (vuln_id,fix_id,repository,commit_id)
Returns the path to... |
Takes in input a dataset and produces a trained model that is persisted to disk.
Dataset file contains triples: (vuln_id,fix_id,repository,commit_id)
Returns the path to the saved model
| Takes in input a dataset and produces a trained model that is persisted to disk.
Dataset file contains triples: (vuln_id,fix_id,repository,commit_id)
Returns the path to the saved model | [
"Takes",
"in",
"input",
"a",
"dataset",
"and",
"produces",
"a",
"trained",
"model",
"that",
"is",
"persisted",
"to",
"disk",
".",
"Dataset",
"file",
"contains",
"triples",
":",
"(",
"vuln_id",
"fix_id",
"repository",
"commit_id",
")",
"Returns",
"the",
"path... | def train(
model_name: str,
data_filename=TRAINING_DATA,
num_elem_training_data=NUM_ELEMENTS_TRAINING_DATA,
) -> str:
df = make_dataframe(data_filename, num_elem_training_data)
if df is None:
return ""
model = ""
return save_model(model, model_name) | [
"def",
"train",
"(",
"model_name",
":",
"str",
",",
"data_filename",
"=",
"TRAINING_DATA",
",",
"num_elem_training_data",
"=",
"NUM_ELEMENTS_TRAINING_DATA",
",",
")",
"->",
"str",
":",
"df",
"=",
"make_dataframe",
"(",
"data_filename",
",",
"num_elem_training_data",... | Takes in input a dataset and produces a trained model that is persisted to disk. | [
"Takes",
"in",
"input",
"a",
"dataset",
"and",
"produces",
"a",
"trained",
"model",
"that",
"is",
"persisted",
"to",
"disk",
"."
] | [
"\"\"\"\n Takes in input a dataset and produces a trained model that is persisted to disk.\n Dataset file contains triples: (vuln_id,fix_id,repository,commit_id)\n Returns the path to the saved model\n \"\"\"",
"# read data_filename content in list of lines",
"# foreach l in line:",
"# get (com... | [
{
"param": "model_name",
"type": "str"
},
{
"param": "data_filename",
"type": null
},
{
"param": "num_elem_training_data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "model_name",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data_filename",
"type": null,
"docstring": null,
"docs... |
cda5ef3e7274802a9797d57c9fb243f0639edac6 | pombredanne/vulnerability-assessment-kb | prospector/ranking/rank.py | [
"Apache-2.0"
] | Python | make_dataframe | <not_specific> | def make_dataframe(
data_filename=TRAINING_DATA, num_elem_training_data=NUM_ELEMENTS_TRAINING_DATA
):
"""
This is the helper function to construct the pandas dataframe object for the training data.
It returns pandas dataframe if succeeds and None otherwise
"""
commits = []
try:
with ... |
This is the helper function to construct the pandas dataframe object for the training data.
It returns pandas dataframe if succeeds and None otherwise
| This is the helper function to construct the pandas dataframe object for the training data.
It returns pandas dataframe if succeeds and None otherwise | [
"This",
"is",
"the",
"helper",
"function",
"to",
"construct",
"the",
"pandas",
"dataframe",
"object",
"for",
"the",
"training",
"data",
".",
"It",
"returns",
"pandas",
"dataframe",
"if",
"succeeds",
"and",
"None",
"otherwise"
] | def make_dataframe(
data_filename=TRAINING_DATA, num_elem_training_data=NUM_ELEMENTS_TRAINING_DATA
):
commits = []
try:
with open(data_filename, "r", encoding="utf8") as f_in:
count = 0
for line in f_in:
line = line.strip()
line = re.sub(r"[\['... | [
"def",
"make_dataframe",
"(",
"data_filename",
"=",
"TRAINING_DATA",
",",
"num_elem_training_data",
"=",
"NUM_ELEMENTS_TRAINING_DATA",
")",
":",
"commits",
"=",
"[",
"]",
"try",
":",
"with",
"open",
"(",
"data_filename",
",",
"\"r\"",
",",
"encoding",
"=",
"\"ut... | This is the helper function to construct the pandas dataframe object for the training data. | [
"This",
"is",
"the",
"helper",
"function",
"to",
"construct",
"the",
"pandas",
"dataframe",
"object",
"for",
"the",
"training",
"data",
"."
] | [
"\"\"\"\n This is the helper function to construct the pandas dataframe object for the training data.\n It returns pandas dataframe if succeeds and None otherwise\n \"\"\"",
"# cve_id = line[0]",
"# dash = line[3] # column 3",
"# technologies = [line[tech] for tech in range(4, len(line) - 1)] # col... | [
{
"param": "data_filename",
"type": null
},
{
"param": "num_elem_training_data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data_filename",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "num_elem_training_data",
"type": null,
"docstring": null,
... |
d4b0c5615dd2d4bab8fa19c8df64243b55778d8c | pombredanne/vulnerability-assessment-kb | prospector/filtering/filter.py | [
"Apache-2.0"
] | Python | filter_commits | "list[Commit]" | def filter_commits(
candidates: "list[Commit]",
) -> "list[Commit]":
"""
Takes in input a set of candidate (datamodel) commits (coming from the commitdb)
and returns in output a filtered list obtained by discarding the irrelevant
ones based on different criteria (timestamp of commit compared to advi... |
Takes in input a set of candidate (datamodel) commits (coming from the commitdb)
and returns in output a filtered list obtained by discarding the irrelevant
ones based on different criteria (timestamp of commit compared to advisory record date,
extensions of the files modified in the commit, and the li... | Takes in input a set of candidate (datamodel) commits (coming from the commitdb)
and returns in output a filtered list obtained by discarding the irrelevant
ones based on different criteria (timestamp of commit compared to advisory record date,
extensions of the files modified in the commit, and the like) | [
"Takes",
"in",
"input",
"a",
"set",
"of",
"candidate",
"(",
"datamodel",
")",
"commits",
"(",
"coming",
"from",
"the",
"commitdb",
")",
"and",
"returns",
"in",
"output",
"a",
"filtered",
"list",
"obtained",
"by",
"discarding",
"the",
"irrelevant",
"ones",
... | def filter_commits(
candidates: "list[Commit]",
) -> "list[Commit]":
print("WARNING: filter_commits() not implemented yet")
return candidates | [
"def",
"filter_commits",
"(",
"candidates",
":",
"\"list[Commit]\"",
",",
")",
"->",
"\"list[Commit]\"",
":",
"print",
"(",
"\"WARNING: filter_commits() not implemented yet\"",
")",
"return",
"candidates"
] | Takes in input a set of candidate (datamodel) commits (coming from the commitdb)
and returns in output a filtered list obtained by discarding the irrelevant
ones based on different criteria (timestamp of commit compared to advisory record date,
extensions of the files modified in the commit, and the like) | [
"Takes",
"in",
"input",
"a",
"set",
"of",
"candidate",
"(",
"datamodel",
")",
"commits",
"(",
"coming",
"from",
"the",
"commitdb",
")",
"and",
"returns",
"in",
"output",
"a",
"filtered",
"list",
"obtained",
"by",
"discarding",
"the",
"irrelevant",
"ones",
... | [
"\"\"\"\n Takes in input a set of candidate (datamodel) commits (coming from the commitdb)\n and returns in output a filtered list obtained by discarding the irrelevant\n ones based on different criteria (timestamp of commit compared to advisory record date,\n extensions of the files modified in the com... | [
{
"param": "candidates",
"type": "\"list[Commit]\""
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "candidates",
"type": "\"list[Commit]\"",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
894095bb26e179aea2a59e3cc99dbcfa91ab1858 | pombredanne/vulnerability-assessment-kb | prospector/datamodel/advisory.py | [
"Apache-2.0"
] | Python | _get_from_nvd | <not_specific> | def _get_from_nvd(self, vuln_id: str, nvd_rest_endpoint: str = NVD_REST_ENDPOINT):
"""
populate object field using NVD data
returns: description, published_timestamp, last_modified timestamp, list of links
"""
try:
response = requests.get(nvd_rest_endpoint + vuln_id)... |
populate object field using NVD data
returns: description, published_timestamp, last_modified timestamp, list of links
| populate object field using NVD data
returns: description, published_timestamp, last_modified timestamp, list of links | [
"populate",
"object",
"field",
"using",
"NVD",
"data",
"returns",
":",
"description",
"published_timestamp",
"last_modified",
"timestamp",
"list",
"of",
"links"
] | def _get_from_nvd(self, vuln_id: str, nvd_rest_endpoint: str = NVD_REST_ENDPOINT):
try:
response = requests.get(nvd_rest_endpoint + vuln_id)
if response.status_code != 200:
return
data = response.json()
self.published_timestamp = int(
... | [
"def",
"_get_from_nvd",
"(",
"self",
",",
"vuln_id",
":",
"str",
",",
"nvd_rest_endpoint",
":",
"str",
"=",
"NVD_REST_ENDPOINT",
")",
":",
"try",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"nvd_rest_endpoint",
"+",
"vuln_id",
")",
"if",
"response",
... | populate object field using NVD data
returns: description, published_timestamp, last_modified timestamp, list of links | [
"populate",
"object",
"field",
"using",
"NVD",
"data",
"returns",
":",
"description",
"published_timestamp",
"last_modified",
"timestamp",
"list",
"of",
"links"
] | [
"\"\"\"\n populate object field using NVD data\n returns: description, published_timestamp, last_modified timestamp, list of links\n \"\"\"",
"# data = response.json()[\"result\"][\"CVE_Items\"][0]"
] | [
{
"param": "self",
"type": null
},
{
"param": "vuln_id",
"type": "str"
},
{
"param": "nvd_rest_endpoint",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vuln_id",
"type": "str",
"docstring": null,
"docstring_tokens... |
280b1c1e05c06c54f5ecb702060e078784d3404f | unt-libraries/django-invite | invite/views.py | [
"BSD-3-Clause"
] | Python | reset | <not_specific> | def reset(request):
'''users land here to reset their django user passwords'''
if request.method == 'POST':
reset_code = request.GET.get('reset_code')
form = forms.ResetForm(request.POST)
if form.is_valid():
# get invitation object so we can deleted it afterwards
... | users land here to reset their django user passwords | users land here to reset their django user passwords | [
"users",
"land",
"here",
"to",
"reset",
"their",
"django",
"user",
"passwords"
] | def reset(request):
if request.method == 'POST':
reset_code = request.GET.get('reset_code')
form = forms.ResetForm(request.POST)
if form.is_valid():
pri = (PasswordResetInvitation
.objects
.get(activation_code=reset_code))
user = ... | [
"def",
"reset",
"(",
"request",
")",
":",
"if",
"request",
".",
"method",
"==",
"'POST'",
":",
"reset_code",
"=",
"request",
".",
"GET",
".",
"get",
"(",
"'reset_code'",
")",
"form",
"=",
"forms",
".",
"ResetForm",
"(",
"request",
".",
"POST",
")",
"... | users land here to reset their django user passwords | [
"users",
"land",
"here",
"to",
"reset",
"their",
"django",
"user",
"passwords"
] | [
"'''users land here to reset their django user passwords'''",
"# get invitation object so we can deleted it afterwards",
"# determine user from password reset invitation.",
"# they come bearing a reset_code",
"# set expiration for activation_code at the end of next day",
"# or an email address",
"# othe... | [
{
"param": "request",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
280b1c1e05c06c54f5ecb702060e078784d3404f | unt-libraries/django-invite | invite/views.py | [
"BSD-3-Clause"
] | Python | check | <not_specific> | def check(request):
"""Check to see if username or email address is taken by a user."""
if request.GET.get('username', None):
try:
User.objects.get(username__iexact=request.GET['username'].strip())
result = True
except User.DoesNotExist:
result = False
eli... | Check to see if username or email address is taken by a user. | Check to see if username or email address is taken by a user. | [
"Check",
"to",
"see",
"if",
"username",
"or",
"email",
"address",
"is",
"taken",
"by",
"a",
"user",
"."
] | def check(request):
if request.GET.get('username', None):
try:
User.objects.get(username__iexact=request.GET['username'].strip())
result = True
except User.DoesNotExist:
result = False
elif request.GET.get('email', None):
try:
User.objects.... | [
"def",
"check",
"(",
"request",
")",
":",
"if",
"request",
".",
"GET",
".",
"get",
"(",
"'username'",
",",
"None",
")",
":",
"try",
":",
"User",
".",
"objects",
".",
"get",
"(",
"username__iexact",
"=",
"request",
".",
"GET",
"[",
"'username'",
"]",
... | Check to see if username or email address is taken by a user. | [
"Check",
"to",
"see",
"if",
"username",
"or",
"email",
"address",
"is",
"taken",
"by",
"a",
"user",
"."
] | [
"\"\"\"Check to see if username or email address is taken by a user.\"\"\""
] | [
{
"param": "request",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31cd3de4564d25ea48c17e0b023b6e8c057cb79b | Haebuk/FSDL-2021-futureskill | lab1/text_recognizer/data/util.py | [
"MIT"
] | Python | convert_strings_to_labels | torch.Tensor | def convert_strings_to_labels(strings: Sequence[str], mapping: Dict[str, int], length: int) -> torch.Tensor:
"""
Convert sequence of N strings to a (N, length) ndarray, with each string wrapped with <S> and <E> tokens,
and padded with the <P> token.
"""
labels = torch.ones((len(strings), length), dt... |
Convert sequence of N strings to a (N, length) ndarray, with each string wrapped with <S> and <E> tokens,
and padded with the <P> token.
| Convert sequence of N strings to a (N, length) ndarray, with each string wrapped with and tokens,
and padded with the token. | [
"Convert",
"sequence",
"of",
"N",
"strings",
"to",
"a",
"(",
"N",
"length",
")",
"ndarray",
"with",
"each",
"string",
"wrapped",
"with",
"and",
"tokens",
"and",
"padded",
"with",
"the",
"token",
"."
] | def convert_strings_to_labels(strings: Sequence[str], mapping: Dict[str, int], length: int) -> torch.Tensor:
labels = torch.ones((len(strings), length), dtype=torch.long) * mapping["<P>"]
for i, string in enumerate(strings):
tokens = list(string)
tokens = ["<S>", *tokens, "<E>"]
for ii, ... | [
"def",
"convert_strings_to_labels",
"(",
"strings",
":",
"Sequence",
"[",
"str",
"]",
",",
"mapping",
":",
"Dict",
"[",
"str",
",",
"int",
"]",
",",
"length",
":",
"int",
")",
"->",
"torch",
".",
"Tensor",
":",
"labels",
"=",
"torch",
".",
"ones",
"(... | Convert sequence of N strings to a (N, length) ndarray, with each string wrapped with <S> and <E> tokens,
and padded with the <P> token. | [
"Convert",
"sequence",
"of",
"N",
"strings",
"to",
"a",
"(",
"N",
"length",
")",
"ndarray",
"with",
"each",
"string",
"wrapped",
"with",
"<S",
">",
"and",
"<E",
">",
"tokens",
"and",
"padded",
"with",
"the",
"<P",
">",
"token",
"."
] | [
"\"\"\"\n Convert sequence of N strings to a (N, length) ndarray, with each string wrapped with <S> and <E> tokens,\n and padded with the <P> token.\n \"\"\""
] | [
{
"param": "strings",
"type": "Sequence[str]"
},
{
"param": "mapping",
"type": "Dict[str, int]"
},
{
"param": "length",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "strings",
"type": "Sequence[str]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mapping",
"type": "Dict[str, int]",
"docstring": null... |
bfb437d97ed2e2b4b5b23ad8c5ef363bf9cf0c7a | mitfik/aries-acapy-plugin-toolbox | acapy_plugin_toolbox/static_connections.py | [
"Apache-2.0"
] | Python | handle | <not_specific> | async def handle(self, context: RequestContext, responder: BaseResponder):
"""Handle static connection creation request."""
connection_mgr = ConnectionManager(context)
wallet: BaseWallet = await context.inject(BaseWallet)
# Make our info for the connection
my_info = await walle... | Handle static connection creation request. | Handle static connection creation request. | [
"Handle",
"static",
"connection",
"creation",
"request",
"."
] | async def handle(self, context: RequestContext, responder: BaseResponder):
connection_mgr = ConnectionManager(context)
wallet: BaseWallet = await context.inject(BaseWallet)
my_info = await wallet.create_local_did()
connection = ConnectionRecord(
initiator=ConnectionRecord.INI... | [
"async",
"def",
"handle",
"(",
"self",
",",
"context",
":",
"RequestContext",
",",
"responder",
":",
"BaseResponder",
")",
":",
"connection_mgr",
"=",
"ConnectionManager",
"(",
"context",
")",
"wallet",
":",
"BaseWallet",
"=",
"await",
"context",
".",
"inject"... | Handle static connection creation request. | [
"Handle",
"static",
"connection",
"creation",
"request",
"."
] | [
"\"\"\"Handle static connection creation request.\"\"\"",
"# Make our info for the connection",
"# Create connection record",
"# Construct their did doc from the basic components in message",
"# Save",
"# Prepare response"
] | [
{
"param": "self",
"type": null
},
{
"param": "context",
"type": "RequestContext"
},
{
"param": "responder",
"type": "BaseResponder"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "context",
"type": "RequestContext",
"docstring": null,
"docst... |
bfb437d97ed2e2b4b5b23ad8c5ef363bf9cf0c7a | mitfik/aries-acapy-plugin-toolbox | acapy_plugin_toolbox/static_connections.py | [
"Apache-2.0"
] | Python | handle | <not_specific> | async def handle(self, context: RequestContext, responder: BaseResponder):
"""Handle static connection get list request."""
connection_mgr = ConnectionManager(context)
wallet: BaseWallet = await context.inject(BaseWallet)
try:
tag_filter = dict(
filter(lambda ... | Handle static connection get list request. | Handle static connection get list request. | [
"Handle",
"static",
"connection",
"get",
"list",
"request",
"."
] | async def handle(self, context: RequestContext, responder: BaseResponder):
connection_mgr = ConnectionManager(context)
wallet: BaseWallet = await context.inject(BaseWallet)
try:
tag_filter = dict(
filter(lambda item: item[1] is not None, {
'my_did'... | [
"async",
"def",
"handle",
"(",
"self",
",",
"context",
":",
"RequestContext",
",",
"responder",
":",
"BaseResponder",
")",
":",
"connection_mgr",
"=",
"ConnectionManager",
"(",
"context",
")",
"wallet",
":",
"BaseWallet",
"=",
"await",
"context",
".",
"inject"... | Handle static connection get list request. | [
"Handle",
"static",
"connection",
"get",
"list",
"request",
"."
] | [
"\"\"\"Handle static connection get list request.\"\"\"",
"\"\"\"Map for flattening results.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "context",
"type": "RequestContext"
},
{
"param": "responder",
"type": "BaseResponder"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "context",
"type": "RequestContext",
"docstring": null,
"docst... |
5d0d4137d8132ce62935148847f283d8e586b062 | mitfik/aries-acapy-plugin-toolbox | acapy_plugin_toolbox/util.py | [
"Apache-2.0"
] | Python | require_role | <not_specific> | def require_role(role):
"""
Verify that the current connection has a given role.
Verify that the current connection has a given role; otherwise, send a
problem report.
"""
def _require_role(func):
@functools.wraps(func)
async def _wrapped(
handler,
... |
Verify that the current connection has a given role.
Verify that the current connection has a given role; otherwise, send a
problem report.
| Verify that the current connection has a given role.
Verify that the current connection has a given role; otherwise, send a
problem report. | [
"Verify",
"that",
"the",
"current",
"connection",
"has",
"a",
"given",
"role",
".",
"Verify",
"that",
"the",
"current",
"connection",
"has",
"a",
"given",
"role",
";",
"otherwise",
"send",
"a",
"problem",
"report",
"."
] | def require_role(role):
def _require_role(func):
@functools.wraps(func)
async def _wrapped(
handler,
context: RequestContext,
responder: BaseResponder):
if not context.connection_record \
or context.connection_record.the... | [
"def",
"require_role",
"(",
"role",
")",
":",
"def",
"_require_role",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"async",
"def",
"_wrapped",
"(",
"handler",
",",
"context",
":",
"RequestContext",
",",
"responder",
":",
"Base... | Verify that the current connection has a given role. | [
"Verify",
"that",
"the",
"current",
"connection",
"has",
"a",
"given",
"role",
"."
] | [
"\"\"\"\n Verify that the current connection has a given role.\n\n Verify that the current connection has a given role; otherwise, send a\n problem report.\n \"\"\""
] | [
{
"param": "role",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "role",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5d0d4137d8132ce62935148847f283d8e586b062 | mitfik/aries-acapy-plugin-toolbox | acapy_plugin_toolbox/util.py | [
"Apache-2.0"
] | Python | generate_model_schema | <not_specific> | def generate_model_schema(
name: str,
handler: str,
msg_type: str,
schema: dict
):
"""
Generate a Message model class and schema class programmatically.
The following would result in a class named XYZ inheriting from AgentMessage
and XYZSchema inheriting from Age... |
Generate a Message model class and schema class programmatically.
The following would result in a class named XYZ inheriting from AgentMessage
and XYZSchema inheriting from AgentMessageSchema.
XYZ, XYZSchema = generate_model_schema(
'XYZ',
'aries_cloudagent.admin.handlers.XYZHandler',... | Generate a Message model class and schema class programmatically.
The following would result in a class named XYZ inheriting from AgentMessage
and XYZSchema inheriting from AgentMessageSchema.
The attributes of XYZ are determined by schema_dict's keys. The actual
schema of XYZSchema is defined by the field-value com... | [
"Generate",
"a",
"Message",
"model",
"class",
"and",
"schema",
"class",
"programmatically",
".",
"The",
"following",
"would",
"result",
"in",
"a",
"class",
"named",
"XYZ",
"inheriting",
"from",
"AgentMessage",
"and",
"XYZSchema",
"inheriting",
"from",
"AgentMessag... | def generate_model_schema(
name: str,
handler: str,
msg_type: str,
schema: dict
):
if isinstance(schema, dict):
slots = list(schema.keys())
schema_dict = schema
elif hasattr(schema, '_declared_fields'):
slots = list(schema._declared_fields.keys())
... | [
"def",
"generate_model_schema",
"(",
"name",
":",
"str",
",",
"handler",
":",
"str",
",",
"msg_type",
":",
"str",
",",
"schema",
":",
"dict",
")",
":",
"if",
"isinstance",
"(",
"schema",
",",
"dict",
")",
":",
"slots",
"=",
"list",
"(",
"schema",
"."... | Generate a Message model class and schema class programmatically. | [
"Generate",
"a",
"Message",
"model",
"class",
"and",
"schema",
"class",
"programmatically",
"."
] | [
"\"\"\"\n Generate a Message model class and schema class programmatically.\n\n The following would result in a class named XYZ inheriting from AgentMessage\n and XYZSchema inheriting from AgentMessageSchema.\n\n XYZ, XYZSchema = generate_model_schema(\n 'XYZ',\n 'aries_cloudagent.admin.ha... | [
{
"param": "name",
"type": "str"
},
{
"param": "handler",
"type": "str"
},
{
"param": "msg_type",
"type": "str"
},
{
"param": "schema",
"type": "dict"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "name",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "handler",
"type": "str",
"docstring": null,
"docstring_token... |
b7e01f0a93e1169166866ab468b89a10de0fcc82 | SlipknotTN/covid_italia_analisi | utility/metrics.py | [
"MIT"
] | Python | rt_rki | pd.Series | def rt_rki(smoothed_new_positives: pd.Series) -> pd.Series:
"""
L'istituto RKI, Robert Koch Institut, calcola come il rapporto tra la somma del numero di contagiati
negli ultimi 4 giorni e la somma del numero dei contagiati nei 4 giorni precedenti.
:param smoothed_new_positives: nuovi positivi giornali... |
L'istituto RKI, Robert Koch Institut, calcola come il rapporto tra la somma del numero di contagiati
negli ultimi 4 giorni e la somma del numero dei contagiati nei 4 giorni precedenti.
:param smoothed_new_positives: nuovi positivi giornalieri smoothed
:return: serie Rt calcolate con formula RKI
| L'istituto RKI, Robert Koch Institut, calcola come il rapporto tra la somma del numero di contagiati
negli ultimi 4 giorni e la somma del numero dei contagiati nei 4 giorni precedenti. | [
"L",
"'",
"istituto",
"RKI",
"Robert",
"Koch",
"Institut",
"calcola",
"come",
"il",
"rapporto",
"tra",
"la",
"somma",
"del",
"numero",
"di",
"contagiati",
"negli",
"ultimi",
"4",
"giorni",
"e",
"la",
"somma",
"del",
"numero",
"dei",
"contagiati",
"nei",
"4... | def rt_rki(smoothed_new_positives: pd.Series) -> pd.Series:
last_8_days = deque(maxlen=8)
rt_values = dict()
for index, new_daily_positives_value in smoothed_new_positives.items():
if math.isnan(new_daily_positives_value) is False:
last_8_days.append(new_daily_positives_value)
if... | [
"def",
"rt_rki",
"(",
"smoothed_new_positives",
":",
"pd",
".",
"Series",
")",
"->",
"pd",
".",
"Series",
":",
"last_8_days",
"=",
"deque",
"(",
"maxlen",
"=",
"8",
")",
"rt_values",
"=",
"dict",
"(",
")",
"for",
"index",
",",
"new_daily_positives_value",
... | L'istituto RKI, Robert Koch Institut, calcola come il rapporto tra la somma del numero di contagiati
negli ultimi 4 giorni e la somma del numero dei contagiati nei 4 giorni precedenti. | [
"L",
"'",
"istituto",
"RKI",
"Robert",
"Koch",
"Institut",
"calcola",
"come",
"il",
"rapporto",
"tra",
"la",
"somma",
"del",
"numero",
"di",
"contagiati",
"negli",
"ultimi",
"4",
"giorni",
"e",
"la",
"somma",
"del",
"numero",
"dei",
"contagiati",
"nei",
"4... | [
"\"\"\"\n L'istituto RKI, Robert Koch Institut, calcola come il rapporto tra la somma del numero di contagiati\n negli ultimi 4 giorni e la somma del numero dei contagiati nei 4 giorni precedenti.\n :param smoothed_new_positives: nuovi positivi giornalieri smoothed\n :return: serie Rt calcolate con for... | [
{
"param": "smoothed_new_positives",
"type": "pd.Series"
}
] | {
"returns": [
{
"docstring": "serie Rt calcolate con formula RKI",
"docstring_tokens": [
"serie",
"Rt",
"calcolate",
"con",
"formula",
"RKI"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "smoothed_new_pos... |
d2a77fe1b520f10ee3a430d6593ea0d74e19f789 | Xarthisius/dataverse-corere | corere/main/utils.py | [
"MIT"
] | Python | fsm_check_transition_perm | <not_specific> | def fsm_check_transition_perm(bound_method, user):
"""
Returns True if model in state allows to call bound_method and user have rights on it
"""
if not hasattr(bound_method, '_django_fsm'):
im_func = getattr(bound_method, 'im_func', getattr(bound_method, '__func__'))
raise TypeError('%s ... |
Returns True if model in state allows to call bound_method and user have rights on it
| Returns True if model in state allows to call bound_method and user have rights on it | [
"Returns",
"True",
"if",
"model",
"in",
"state",
"allows",
"to",
"call",
"bound_method",
"and",
"user",
"have",
"rights",
"on",
"it"
] | def fsm_check_transition_perm(bound_method, user):
if not hasattr(bound_method, '_django_fsm'):
im_func = getattr(bound_method, 'im_func', getattr(bound_method, '__func__'))
raise TypeError('%s method is not transition' % im_func.__name__)
meta = bound_method._django_fsm
im_self = getattr(bo... | [
"def",
"fsm_check_transition_perm",
"(",
"bound_method",
",",
"user",
")",
":",
"if",
"not",
"hasattr",
"(",
"bound_method",
",",
"'_django_fsm'",
")",
":",
"im_func",
"=",
"getattr",
"(",
"bound_method",
",",
"'im_func'",
",",
"getattr",
"(",
"bound_method",
... | Returns True if model in state allows to call bound_method and user have rights on it | [
"Returns",
"True",
"if",
"model",
"in",
"state",
"allows",
"to",
"call",
"bound_method",
"and",
"user",
"have",
"rights",
"on",
"it"
] | [
"\"\"\"\n Returns True if model in state allows to call bound_method and user have rights on it\n \"\"\"",
"#We removed the two below functions because we just want to check the permissions, nothing more",
"#meta.has_transition(current_state) and",
"#meta.conditions_met(im_self, current_state) and"
] | [
{
"param": "bound_method",
"type": null
},
{
"param": "user",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bound_method",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "user",
"type": null,
"docstring": null,
"docstring_to... |
a130c5ec8a21051a93b03e3305497580573e9323 | KB-Bank-AI/KB-ALBERT-KO | kb-albert-char-v1/examples/utils_nsmc.py | [
"Apache-2.0"
] | Python | convert_examples_to_features | List[InputFeatures] | def convert_examples_to_features(
examples: List[InputExample],
max_seq_len: int,
tokenizer: PreTrainedTokenizer,
cls_token_segment_id=0,
pad_token_segment_id=0,
sequence_a_segment_id=0,
mask_padding_with_zero=True,
) -> List[InputFeatures]:
"""Loads a data file into a list of `InputFeat... | Loads a data file into a list of `InputFeatures` | Loads a data file into a list of `InputFeatures` | [
"Loads",
"a",
"data",
"file",
"into",
"a",
"list",
"of",
"`",
"InputFeatures",
"`"
] | def convert_examples_to_features(
examples: List[InputExample],
max_seq_len: int,
tokenizer: PreTrainedTokenizer,
cls_token_segment_id=0,
pad_token_segment_id=0,
sequence_a_segment_id=0,
mask_padding_with_zero=True,
) -> List[InputFeatures]:
cls_token = tokenizer.cls_token
sep_token ... | [
"def",
"convert_examples_to_features",
"(",
"examples",
":",
"List",
"[",
"InputExample",
"]",
",",
"max_seq_len",
":",
"int",
",",
"tokenizer",
":",
"PreTrainedTokenizer",
",",
"cls_token_segment_id",
"=",
"0",
",",
"pad_token_segment_id",
"=",
"0",
",",
"sequenc... | Loads a data file into a list of `InputFeatures` | [
"Loads",
"a",
"data",
"file",
"into",
"a",
"list",
"of",
"`",
"InputFeatures",
"`"
] | [
"\"\"\"Loads a data file into a list of `InputFeatures`\"\"\"",
"# Setting based on the current model type",
"# Account for [CLS] and [SEP]",
"# Add [SEP] token",
"# Add [CLS] token",
"# The mask has 1 for real tokens and 0 for padding tokens. Only real",
"# tokens are attended to.",
"# Zero-pad up to... | [
{
"param": "examples",
"type": "List[InputExample]"
},
{
"param": "max_seq_len",
"type": "int"
},
{
"param": "tokenizer",
"type": "PreTrainedTokenizer"
},
{
"param": "cls_token_segment_id",
"type": null
},
{
"param": "pad_token_segment_id",
"type": null
},
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "examples",
"type": "List[InputExample]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "max_seq_len",
"type": "int",
"docstring": null,... |
0658604302e0312c9c90c1a6bb9f8a998f91556f | simark/gerrit | tools/bzl/maven_jar.bzl | [
"Apache-2.0"
] | Python | _maven_release | <not_specific> | def _maven_release(ctx, parts):
"""induce jar and url name from maven coordinates."""
if len(parts) not in [3, 4]:
fail('%s:\nexpected id="groupId:artifactId:version[:classifier]"' %
ctx.attr.artifact)
if len(parts) == 4:
group, artifact, version, classifier = parts
file... | induce jar and url name from maven coordinates. | induce jar and url name from maven coordinates. | [
"induce",
"jar",
"and",
"url",
"name",
"from",
"maven",
"coordinates",
"."
] | def _maven_release(ctx, parts):
if len(parts) not in [3, 4]:
fail('%s:\nexpected id="groupId:artifactId:version[:classifier]"' %
ctx.attr.artifact)
if len(parts) == 4:
group, artifact, version, classifier = parts
file_version = version + "-" + classifier
else:
gr... | [
"def",
"_maven_release",
"(",
"ctx",
",",
"parts",
")",
":",
"if",
"len",
"(",
"parts",
")",
"not",
"in",
"[",
"3",
",",
"4",
"]",
":",
"fail",
"(",
"'%s:\\nexpected id=\"groupId:artifactId:version[:classifier]\"'",
"%",
"ctx",
".",
"attr",
".",
"artifact",
... | induce jar and url name from maven coordinates. | [
"induce",
"jar",
"and",
"url",
"name",
"from",
"maven",
"coordinates",
"."
] | [
"\"\"\"induce jar and url name from maven coordinates.\"\"\""
] | [
{
"param": "ctx",
"type": null
},
{
"param": "parts",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "parts",
"type": null,
"docstring": null,
"docstring_tokens": [... |
0658604302e0312c9c90c1a6bb9f8a998f91556f | simark/gerrit | tools/bzl/maven_jar.bzl | [
"Apache-2.0"
] | Python | _maven_jar_impl | null | def _maven_jar_impl(ctx):
"""rule to download a Maven archive."""
coordinates = _create_coordinates(ctx.attr.artifact)
name = ctx.name
sha1 = ctx.attr.sha1
parts = ctx.attr.artifact.split(":")
# TODO(davido): Only releases for now, implement handling snapshots
jar, url = _maven_release(ct... | rule to download a Maven archive. | rule to download a Maven archive. | [
"rule",
"to",
"download",
"a",
"Maven",
"archive",
"."
] | def _maven_jar_impl(ctx):
coordinates = _create_coordinates(ctx.attr.artifact)
name = ctx.name
sha1 = ctx.attr.sha1
parts = ctx.attr.artifact.split(":")
jar, url = _maven_release(ctx, parts)
binjar = jar + ".jar"
binjar_path = ctx.path("/".join(["jar", binjar]))
binurl = url + ".jar"
... | [
"def",
"_maven_jar_impl",
"(",
"ctx",
")",
":",
"coordinates",
"=",
"_create_coordinates",
"(",
"ctx",
".",
"attr",
".",
"artifact",
")",
"name",
"=",
"ctx",
".",
"name",
"sha1",
"=",
"ctx",
".",
"attr",
".",
"sha1",
"parts",
"=",
"ctx",
".",
"attr",
... | rule to download a Maven archive. | [
"rule",
"to",
"download",
"a",
"Maven",
"archive",
"."
] | [
"\"\"\"rule to download a Maven archive.\"\"\"",
"# TODO(davido): Only releases for now, implement handling snapshots"
] | [
{
"param": "ctx",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
772d255491cf5b51d9fd1ebf49a65a3acd213f86 | gawseed/processing | gawseed/algorithm/dns.py | [
"MIT"
] | Python | dns_label_count | <not_specific> | def dns_label_count(rows, args):
"""Returns the number of labels in a given domain (eg: www.example.com = 3)"""
label = rows[args[0]]
parts = label.split(".")
# deal with www.exmaple.com. with a trailing dot
if parts[-1] == "":
return (str(len(parts)-1),'')
return (str(len(parts)),'') | Returns the number of labels in a given domain (eg: www.example.com = 3) | Returns the number of labels in a given domain | [
"Returns",
"the",
"number",
"of",
"labels",
"in",
"a",
"given",
"domain"
] | def dns_label_count(rows, args):
label = rows[args[0]]
parts = label.split(".")
if parts[-1] == "":
return (str(len(parts)-1),'')
return (str(len(parts)),'') | [
"def",
"dns_label_count",
"(",
"rows",
",",
"args",
")",
":",
"label",
"=",
"rows",
"[",
"args",
"[",
"0",
"]",
"]",
"parts",
"=",
"label",
".",
"split",
"(",
"\".\"",
")",
"if",
"parts",
"[",
"-",
"1",
"]",
"==",
"\"\"",
":",
"return",
"(",
"s... | Returns the number of labels in a given domain (eg: www.example.com = 3) | [
"Returns",
"the",
"number",
"of",
"labels",
"in",
"a",
"given",
"domain",
"(",
"eg",
":",
"www",
".",
"example",
".",
"com",
"=",
"3",
")"
] | [
"\"\"\"Returns the number of labels in a given domain (eg: www.example.com = 3)\"\"\"",
"# deal with www.exmaple.com. with a trailing dot"
] | [
{
"param": "rows",
"type": null
},
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "rows",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [... |
772d255491cf5b51d9fd1ebf49a65a3acd213f86 | gawseed/processing | gawseed/algorithm/dns.py | [
"MIT"
] | Python | dnsPrefixFraction | <not_specific> | def dnsPrefixFraction(bundle, key, subkey, thisone, args):
"""Check the fraction of prefixes vs the base domain.
Arguments should be [']"""
if 'psldom' in thisone: # only process ones that are domains
prefix_unique_count = lookup(bundle, key, subkey, thisone, [key, 'unique', 'pslpre_unique'])
... | Check the fraction of prefixes vs the base domain.
Arguments should be ['] | Check the fraction of prefixes vs the base domain.
Arguments should be ['] | [
"Check",
"the",
"fraction",
"of",
"prefixes",
"vs",
"the",
"base",
"domain",
".",
"Arguments",
"should",
"be",
"[",
"'",
"]"
] | def dnsPrefixFraction(bundle, key, subkey, thisone, args):
if 'psldom' in thisone:
prefix_unique_count = lookup(bundle, key, subkey, thisone, [key, 'unique', 'pslpre_unique'])
if prefix_unique_count:
return(float(prefix_unique_count) / float(thisone['psldom'])) | [
"def",
"dnsPrefixFraction",
"(",
"bundle",
",",
"key",
",",
"subkey",
",",
"thisone",
",",
"args",
")",
":",
"if",
"'psldom'",
"in",
"thisone",
":",
"prefix_unique_count",
"=",
"lookup",
"(",
"bundle",
",",
"key",
",",
"subkey",
",",
"thisone",
",",
"[",... | Check the fraction of prefixes vs the base domain. | [
"Check",
"the",
"fraction",
"of",
"prefixes",
"vs",
"the",
"base",
"domain",
"."
] | [
"\"\"\"Check the fraction of prefixes vs the base domain.\n Arguments should be [']\"\"\"",
"# only process ones that are domains"
] | [
{
"param": "bundle",
"type": null
},
{
"param": "key",
"type": null
},
{
"param": "subkey",
"type": null
},
{
"param": "thisone",
"type": null
},
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bundle",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key",
"type": null,
"docstring": null,
"docstring_tokens": ... |
0deb4a67abc677a30181d5e8364f2136326c38a3 | gawseed/processing | gawseed/averageWindow.py | [
"MIT"
] | Python | add_element | null | def add_element(self, new_element):
"""Add an element to the current slot, stored in a rotating buffer"""
# update the total counts
if self._middle_size > 0:
self.lhs = self.lhs - self.lhs_data[self.index] + self.middle_data[self.middle]
self.lhs_data[self.index] = self.... | Add an element to the current slot, stored in a rotating buffer | Add an element to the current slot, stored in a rotating buffer | [
"Add",
"an",
"element",
"to",
"the",
"current",
"slot",
"stored",
"in",
"a",
"rotating",
"buffer"
] | def add_element(self, new_element):
if self._middle_size > 0:
self.lhs = self.lhs - self.lhs_data[self.index] + self.middle_data[self.middle]
self.lhs_data[self.index] = self.middle_data[self.middle]
self.middle_data[self.middle] = self.rhs_data[self.index]
self.m... | [
"def",
"add_element",
"(",
"self",
",",
"new_element",
")",
":",
"if",
"self",
".",
"_middle_size",
">",
"0",
":",
"self",
".",
"lhs",
"=",
"self",
".",
"lhs",
"-",
"self",
".",
"lhs_data",
"[",
"self",
".",
"index",
"]",
"+",
"self",
".",
"middle_... | Add an element to the current slot, stored in a rotating buffer | [
"Add",
"an",
"element",
"to",
"the",
"current",
"slot",
"stored",
"in",
"a",
"rotating",
"buffer"
] | [
"\"\"\"Add an element to the current slot, stored in a rotating buffer\"\"\"",
"# update the total counts",
"# update the middle index",
"# rhs side updating is always the same regardless of middle",
"# update the array data",
"# handle lhs and rhs index cycling"
] | [
{
"param": "self",
"type": null
},
{
"param": "new_element",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "new_element",
"type": null,
"docstring": null,
"docstring_tok... |
0deb4a67abc677a30181d5e8364f2136326c38a3 | gawseed/processing | gawseed/averageWindow.py | [
"MIT"
] | Python | dump | null | def dump(self):
"Debugging routine to print the contents of the current data"
print("----")
print("size: " + str(self._window_size))
print("indx: " + str(self.index))
print("left: " + str(self.lhs_data))
print("rght: " + str(self.rhs_data))
print("msiz: " + str(s... | Debugging routine to print the contents of the current data | Debugging routine to print the contents of the current data | [
"Debugging",
"routine",
"to",
"print",
"the",
"contents",
"of",
"the",
"current",
"data"
] | def dump(self):
print("----")
print("size: " + str(self._window_size))
print("indx: " + str(self.index))
print("left: " + str(self.lhs_data))
print("rght: " + str(self.rhs_data))
print("msiz: " + str(self._middle_size))
print("mid: " + str(self.middle_data))
... | [
"def",
"dump",
"(",
"self",
")",
":",
"print",
"(",
"\"----\"",
")",
"print",
"(",
"\"size: \"",
"+",
"str",
"(",
"self",
".",
"_window_size",
")",
")",
"print",
"(",
"\"indx: \"",
"+",
"str",
"(",
"self",
".",
"index",
")",
")",
"print",
"(",
"\"l... | Debugging routine to print the contents of the current data | [
"Debugging",
"routine",
"to",
"print",
"the",
"contents",
"of",
"the",
"current",
"data"
] | [
"\"Debugging routine to print the contents of the current data\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ce242fbe95a01d7e7b279f5e94eb2398de971cd1 | gawseed/processing | gawseed/algorithm/aggregator.py | [
"MIT"
] | Python | stringSplitter | null | def stringSplitter(index, key, subkey, value, results, args = []):
"""Splits a value string into a series of new keys inside a new index
(named in argument 1, or else old_index + '_split')"""
# XXX: allow subkey to be specified other than ''
subkey = ''
split_index = None
if len(args) > 0:
... | Splits a value string into a series of new keys inside a new index
(named in argument 1, or else old_index + '_split') | Splits a value string into a series of new keys inside a new index
(named in argument 1, or else old_index + '_split') | [
"Splits",
"a",
"value",
"string",
"into",
"a",
"series",
"of",
"new",
"keys",
"inside",
"a",
"new",
"index",
"(",
"named",
"in",
"argument",
"1",
"or",
"else",
"old_index",
"+",
"'",
"_split",
"'",
")"
] | def stringSplitter(index, key, subkey, value, results, args = []):
subkey = ''
split_index = None
if len(args) > 0:
split_index = args[0]
else:
split_index = index + "_split"
if split_index not in results:
results[split_index] = {}
for newkey in key.split():
if newkey ... | [
"def",
"stringSplitter",
"(",
"index",
",",
"key",
",",
"subkey",
",",
"value",
",",
"results",
",",
"args",
"=",
"[",
"]",
")",
":",
"subkey",
"=",
"''",
"split_index",
"=",
"None",
"if",
"len",
"(",
"args",
")",
">",
"0",
":",
"split_index",
"=",... | Splits a value string into a series of new keys inside a new index
(named in argument 1, or else old_index + '_split') | [
"Splits",
"a",
"value",
"string",
"into",
"a",
"series",
"of",
"new",
"keys",
"inside",
"a",
"new",
"index",
"(",
"named",
"in",
"argument",
"1",
"or",
"else",
"old_index",
"+",
"'",
"_split",
"'",
")"
] | [
"\"\"\"Splits a value string into a series of new keys inside a new index\n (named in argument 1, or else old_index + '_split')\"\"\"",
"# XXX: allow subkey to be specified other than ''",
"# create the index slots if they don't exist yet",
"# create new keys by splitting the old key",
"# XXX: accept ... | [
{
"param": "index",
"type": null
},
{
"param": "key",
"type": null
},
{
"param": "subkey",
"type": null
},
{
"param": "value",
"type": null
},
{
"param": "results",
"type": null
},
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "index",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key",
"type": null,
"docstring": null,
"docstring_tokens": [... |
66783e9c9847b2fa87e6876f81d728c222372272 | gawseed/processing | gawseed/algorithm/generic_ext.py | [
"MIT"
] | Python | re_match_both | <not_specific> | def re_match_both( item, args ):
"""Matches a regex with a group (argument 2) against the column (number in argument 1)"""
import re
# setup
(re_col1, re_expr1, re_col2, re_expr2 ) = args
if re_expr1 not in compiled_res:
compiled_res[re_expr1] = re.compile(re_expr1)
if re_expr2 not in c... | Matches a regex with a group (argument 2) against the column (number in argument 1) | Matches a regex with a group (argument 2) against the column (number in argument 1) | [
"Matches",
"a",
"regex",
"with",
"a",
"group",
"(",
"argument",
"2",
")",
"against",
"the",
"column",
"(",
"number",
"in",
"argument",
"1",
")"
] | def re_match_both( item, args ):
import re
(re_col1, re_expr1, re_col2, re_expr2 ) = args
if re_expr1 not in compiled_res:
compiled_res[re_expr1] = re.compile(re_expr1)
if re_expr2 not in compiled_res:
compiled_res[re_expr2] = re.compile(re_expr2)
match1 = compiled_res[re_expr1].sear... | [
"def",
"re_match_both",
"(",
"item",
",",
"args",
")",
":",
"import",
"re",
"(",
"re_col1",
",",
"re_expr1",
",",
"re_col2",
",",
"re_expr2",
")",
"=",
"args",
"if",
"re_expr1",
"not",
"in",
"compiled_res",
":",
"compiled_res",
"[",
"re_expr1",
"]",
"=",... | Matches a regex with a group (argument 2) against the column (number in argument 1) | [
"Matches",
"a",
"regex",
"with",
"a",
"group",
"(",
"argument",
"2",
")",
"against",
"the",
"column",
"(",
"number",
"in",
"argument",
"1",
")"
] | [
"\"\"\"Matches a regex with a group (argument 2) against the column (number in argument 1)\"\"\"",
"# setup",
"# test if a match occurred"
] | [
{
"param": "item",
"type": null
},
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "item",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [... |
66783e9c9847b2fa87e6876f81d728c222372272 | gawseed/processing | gawseed/algorithm/generic_ext.py | [
"MIT"
] | Python | re_match_both2 | <not_specific> | def re_match_both2( item, args ):
"""Matches a regex with a group (argument 2) against the column (number in argument 1)"""
import re
# setup
(re_col1, re_expr1, re_col2, re_expr2 ) = args
if re_expr1 not in compiled_res:
compiled_res[re_expr1] = re.compile(re_expr1)
if re_expr2 not in ... | Matches a regex with a group (argument 2) against the column (number in argument 1) | Matches a regex with a group (argument 2) against the column (number in argument 1) | [
"Matches",
"a",
"regex",
"with",
"a",
"group",
"(",
"argument",
"2",
")",
"against",
"the",
"column",
"(",
"number",
"in",
"argument",
"1",
")"
] | def re_match_both2( item, args ):
import re
(re_col1, re_expr1, re_col2, re_expr2 ) = args
if re_expr1 not in compiled_res:
compiled_res[re_expr1] = re.compile(re_expr1)
if re_expr2 not in compiled_res:
compiled_res[re_expr2] = re.compile(re_expr2)
match1 = compiled_res[re_expr1].sea... | [
"def",
"re_match_both2",
"(",
"item",
",",
"args",
")",
":",
"import",
"re",
"(",
"re_col1",
",",
"re_expr1",
",",
"re_col2",
",",
"re_expr2",
")",
"=",
"args",
"if",
"re_expr1",
"not",
"in",
"compiled_res",
":",
"compiled_res",
"[",
"re_expr1",
"]",
"="... | Matches a regex with a group (argument 2) against the column (number in argument 1) | [
"Matches",
"a",
"regex",
"with",
"a",
"group",
"(",
"argument",
"2",
")",
"against",
"the",
"column",
"(",
"number",
"in",
"argument",
"1",
")"
] | [
"\"\"\"Matches a regex with a group (argument 2) against the column (number in argument 1)\"\"\"",
"# setup",
"# test if a match occurred"
] | [
{
"param": "item",
"type": null
},
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "item",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [... |
66783e9c9847b2fa87e6876f81d728c222372272 | gawseed/processing | gawseed/algorithm/generic_ext.py | [
"MIT"
] | Python | re_match_two | <not_specific> | def re_match_two(item, args):
"""Matches a regex with a group (argument 2) against the column (number in argument 1)"""
import re
# setup
(re_col, re_expr) = args
if re_expr not in compiled_res:
compiled_res[re_expr] = re.compile(re_expr)
# test if a match occurred
match = compiled... | Matches a regex with a group (argument 2) against the column (number in argument 1) | Matches a regex with a group (argument 2) against the column (number in argument 1) | [
"Matches",
"a",
"regex",
"with",
"a",
"group",
"(",
"argument",
"2",
")",
"against",
"the",
"column",
"(",
"number",
"in",
"argument",
"1",
")"
] | def re_match_two(item, args):
import re
(re_col, re_expr) = args
if re_expr not in compiled_res:
compiled_res[re_expr] = re.compile(re_expr)
match = compiled_res[re_expr].search(item[re_col])
if match:
return [match.group(2), '']
return ['',''] | [
"def",
"re_match_two",
"(",
"item",
",",
"args",
")",
":",
"import",
"re",
"(",
"re_col",
",",
"re_expr",
")",
"=",
"args",
"if",
"re_expr",
"not",
"in",
"compiled_res",
":",
"compiled_res",
"[",
"re_expr",
"]",
"=",
"re",
".",
"compile",
"(",
"re_expr... | Matches a regex with a group (argument 2) against the column (number in argument 1) | [
"Matches",
"a",
"regex",
"with",
"a",
"group",
"(",
"argument",
"2",
")",
"against",
"the",
"column",
"(",
"number",
"in",
"argument",
"1",
")"
] | [
"\"\"\"Matches a regex with a group (argument 2) against the column (number in argument 1)\"\"\"",
"# setup",
"# test if a match occurred"
] | [
{
"param": "item",
"type": null
},
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "item",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [... |
2282a5676b8559161421d30c1ca9eb14f863785b | gawseed/processing | gawseed/algorithm/filter.py | [
"MIT"
] | Python | exclude_exprs | <not_specific> | def exclude_exprs(row, args):
"""Searches for matches against ROW column args[0] against any number
of regexp matches in args[1:]. Uses re.search, which will match
anywhere in a string.
Returns FALSE on a match, to offer matches as an exclude list.
"""
global comps
for m in args[1:]:
... | Searches for matches against ROW column args[0] against any number
of regexp matches in args[1:]. Uses re.search, which will match
anywhere in a string.
Returns FALSE on a match, to offer matches as an exclude list.
| Searches for matches against ROW column args[0] against any number
of regexp matches in args[1:]. Uses re.search, which will match
anywhere in a string.
Returns FALSE on a match, to offer matches as an exclude list. | [
"Searches",
"for",
"matches",
"against",
"ROW",
"column",
"args",
"[",
"0",
"]",
"against",
"any",
"number",
"of",
"regexp",
"matches",
"in",
"args",
"[",
"1",
":",
"]",
".",
"Uses",
"re",
".",
"search",
"which",
"will",
"match",
"anywhere",
"in",
"a",... | def exclude_exprs(row, args):
global comps
for m in args[1:]:
if m not in comps:
comps[m] = re.compile(m)
if comps[m].search(row[args[0]]):
return False
return True | [
"def",
"exclude_exprs",
"(",
"row",
",",
"args",
")",
":",
"global",
"comps",
"for",
"m",
"in",
"args",
"[",
"1",
":",
"]",
":",
"if",
"m",
"not",
"in",
"comps",
":",
"comps",
"[",
"m",
"]",
"=",
"re",
".",
"compile",
"(",
"m",
")",
"if",
"co... | Searches for matches against ROW column args[0] against any number
of regexp matches in args[1:]. | [
"Searches",
"for",
"matches",
"against",
"ROW",
"column",
"args",
"[",
"0",
"]",
"against",
"any",
"number",
"of",
"regexp",
"matches",
"in",
"args",
"[",
"1",
":",
"]",
"."
] | [
"\"\"\"Searches for matches against ROW column args[0] against any number\n of regexp matches in args[1:]. Uses re.search, which will match\n anywhere in a string.\n\n Returns FALSE on a match, to offer matches as an exclude list.\n \"\"\"",
"# inverse since we're excluding"
] | [
{
"param": "row",
"type": null
},
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "row",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": []... |
2282a5676b8559161421d30c1ca9eb14f863785b | gawseed/processing | gawseed/algorithm/filter.py | [
"MIT"
] | Python | include_exprs | <not_specific> | def include_exprs(row, args):
"""Searches for matches against ROW column args[0] against any number
of regexp matches in args[1:]. Uses re.search, which will match
anywhere in a string.
Returns TRUE on a match, to offer matches as an include list.
"""
global comps
for m in args[1:]:
... | Searches for matches against ROW column args[0] against any number
of regexp matches in args[1:]. Uses re.search, which will match
anywhere in a string.
Returns TRUE on a match, to offer matches as an include list.
| Searches for matches against ROW column args[0] against any number
of regexp matches in args[1:]. Uses re.search, which will match
anywhere in a string.
Returns TRUE on a match, to offer matches as an include list. | [
"Searches",
"for",
"matches",
"against",
"ROW",
"column",
"args",
"[",
"0",
"]",
"against",
"any",
"number",
"of",
"regexp",
"matches",
"in",
"args",
"[",
"1",
":",
"]",
".",
"Uses",
"re",
".",
"search",
"which",
"will",
"match",
"anywhere",
"in",
"a",... | def include_exprs(row, args):
global comps
for m in args[1:]:
if m not in comps:
comps[m] = re.compile(m)
if comps[m].search(row[args[0]]):
return True
return False | [
"def",
"include_exprs",
"(",
"row",
",",
"args",
")",
":",
"global",
"comps",
"for",
"m",
"in",
"args",
"[",
"1",
":",
"]",
":",
"if",
"m",
"not",
"in",
"comps",
":",
"comps",
"[",
"m",
"]",
"=",
"re",
".",
"compile",
"(",
"m",
")",
"if",
"co... | Searches for matches against ROW column args[0] against any number
of regexp matches in args[1:]. | [
"Searches",
"for",
"matches",
"against",
"ROW",
"column",
"args",
"[",
"0",
"]",
"against",
"any",
"number",
"of",
"regexp",
"matches",
"in",
"args",
"[",
"1",
":",
"]",
"."
] | [
"\"\"\"Searches for matches against ROW column args[0] against any number\n of regexp matches in args[1:]. Uses re.search, which will match\n anywhere in a string.\n\n Returns TRUE on a match, to offer matches as an include list.\n \"\"\""
] | [
{
"param": "row",
"type": null
},
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "row",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": []... |
84fd730a4f99047e1675fabbaf3904d9d35e26dd | gawseed/processing | gawseed/algorithm/generic.py | [
"MIT"
] | Python | re_match_one | <not_specific> | def re_match_one(item, args):
"""Matches a regex with a group (argument 2) against the column (number in argument 1)"""
import re
# setup
(re_col, re_expr) = args
if re_expr not in compiled_res:
compiled_res[re_expr] = re.compile(re_expr)
# test if a match occurred
match = compiled... | Matches a regex with a group (argument 2) against the column (number in argument 1) | Matches a regex with a group (argument 2) against the column (number in argument 1) | [
"Matches",
"a",
"regex",
"with",
"a",
"group",
"(",
"argument",
"2",
")",
"against",
"the",
"column",
"(",
"number",
"in",
"argument",
"1",
")"
] | def re_match_one(item, args):
import re
(re_col, re_expr) = args
if re_expr not in compiled_res:
compiled_res[re_expr] = re.compile(re_expr)
match = compiled_res[re_expr].search(item[re_col])
if match:
return [match.group(1), '']
return ['',''] | [
"def",
"re_match_one",
"(",
"item",
",",
"args",
")",
":",
"import",
"re",
"(",
"re_col",
",",
"re_expr",
")",
"=",
"args",
"if",
"re_expr",
"not",
"in",
"compiled_res",
":",
"compiled_res",
"[",
"re_expr",
"]",
"=",
"re",
".",
"compile",
"(",
"re_expr... | Matches a regex with a group (argument 2) against the column (number in argument 1) | [
"Matches",
"a",
"regex",
"with",
"a",
"group",
"(",
"argument",
"2",
")",
"against",
"the",
"column",
"(",
"number",
"in",
"argument",
"1",
")"
] | [
"\"\"\"Matches a regex with a group (argument 2) against the column (number in argument 1)\"\"\"",
"# setup",
"# test if a match occurred"
] | [
{
"param": "item",
"type": null
},
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "item",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [... |
84fd730a4f99047e1675fabbaf3904d9d35e26dd | gawseed/processing | gawseed/algorithm/generic.py | [
"MIT"
] | Python | column_value_int | <not_specific> | def column_value_int(item, args):
"""Return the value stored in a column cast to an int.
YAML usage:
outputs:
outcol:
function: identity
arguments: [col(KEYCOL)]
value: column_value_int
value_arguments: [col(VALUECOL)]
... | Return the value stored in a column cast to an int.
YAML usage:
outputs:
outcol:
function: identity
arguments: [col(KEYCOL)]
value: column_value_int
value_arguments: [col(VALUECOL)]
| Return the value stored in a column cast to an int.
YAML usage.
| [
"Return",
"the",
"value",
"stored",
"in",
"a",
"column",
"cast",
"to",
"an",
"int",
".",
"YAML",
"usage",
"."
] | def column_value_int(item, args):
try:
return int(item[args[0]])
except:
return 0 | [
"def",
"column_value_int",
"(",
"item",
",",
"args",
")",
":",
"try",
":",
"return",
"int",
"(",
"item",
"[",
"args",
"[",
"0",
"]",
"]",
")",
"except",
":",
"return",
"0"
] | Return the value stored in a column cast to an int. | [
"Return",
"the",
"value",
"stored",
"in",
"a",
"column",
"cast",
"to",
"an",
"int",
"."
] | [
"\"\"\"Return the value stored in a column cast to an int.\n\n YAML usage:\n\n outputs:\n outcol:\n function: identity\n arguments: [col(KEYCOL)]\n value: column_value_int\n value_arguments: [col(VALUECOL)]\n \"\"\""
] | [
{
"param": "item",
"type": null
},
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "item",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [... |
84fd730a4f99047e1675fabbaf3904d9d35e26dd | gawseed/processing | gawseed/algorithm/generic.py | [
"MIT"
] | Python | column_value_float | <not_specific> | def column_value_float(item, args):
"""Return the value stored in a column cast to a float.
YAML usage:
outputs:
outcol:
function: identity
arguments: [col(KEYCOL)]
value: column_value_float
value_arguments: [col(VALUECO... | Return the value stored in a column cast to a float.
YAML usage:
outputs:
outcol:
function: identity
arguments: [col(KEYCOL)]
value: column_value_float
value_arguments: [col(VALUECOL)]
| Return the value stored in a column cast to a float.
YAML usage.
| [
"Return",
"the",
"value",
"stored",
"in",
"a",
"column",
"cast",
"to",
"a",
"float",
".",
"YAML",
"usage",
"."
] | def column_value_float(item, args):
try:
return float(item[args[0]])
except:
return 0.0 | [
"def",
"column_value_float",
"(",
"item",
",",
"args",
")",
":",
"try",
":",
"return",
"float",
"(",
"item",
"[",
"args",
"[",
"0",
"]",
"]",
")",
"except",
":",
"return",
"0.0"
] | Return the value stored in a column cast to a float. | [
"Return",
"the",
"value",
"stored",
"in",
"a",
"column",
"cast",
"to",
"a",
"float",
"."
] | [
"\"\"\"Return the value stored in a column cast to a float.\n\n YAML usage:\n\n outputs:\n outcol:\n function: identity\n arguments: [col(KEYCOL)]\n value: column_value_float\n value_arguments: [col(VALUECOL)]\n \"\"\""
] | [
{
"param": "item",
"type": null
},
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "item",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [... |
84fd730a4f99047e1675fabbaf3904d9d35e26dd | gawseed/processing | gawseed/algorithm/generic.py | [
"MIT"
] | Python | fraction | <not_specific> | def fraction(item, args): # args = numerator_col, denominatior_col
"""Return the value stored in a column divided by the value in another
YAML usage:
outputs:
outcol:
function: identity
arguments: [col(KEYCOL)]
value: fraction
... | Return the value stored in a column divided by the value in another
YAML usage:
outputs:
outcol:
function: identity
arguments: [col(KEYCOL)]
value: fraction
value_arguments: [VALCOL_NUMERATOR, VALCOL_DENOMINATOR]
| Return the value stored in a column divided by the value in another
YAML usage.
| [
"Return",
"the",
"value",
"stored",
"in",
"a",
"column",
"divided",
"by",
"the",
"value",
"in",
"another",
"YAML",
"usage",
"."
] | def fraction(item, args):
return float(item[args[0]]) / float(item[args[1]]) | [
"def",
"fraction",
"(",
"item",
",",
"args",
")",
":",
"return",
"float",
"(",
"item",
"[",
"args",
"[",
"0",
"]",
"]",
")",
"/",
"float",
"(",
"item",
"[",
"args",
"[",
"1",
"]",
"]",
")"
] | Return the value stored in a column divided by the value in another
YAML usage: | [
"Return",
"the",
"value",
"stored",
"in",
"a",
"column",
"divided",
"by",
"the",
"value",
"in",
"another",
"YAML",
"usage",
":"
] | [
"# args = numerator_col, denominatior_col",
"\"\"\"Return the value stored in a column divided by the value in another\n\n YAML usage:\n\n outputs:\n outcol:\n function: identity\n arguments: [col(KEYCOL)]\n value: fraction\n va... | [
{
"param": "item",
"type": null
},
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "item",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [... |
9167600d8e9c2cb5a5deba544038ada93dacf9ee | TimHire/Ia-flood-risk | test_plot.py | [
"MIT"
] | Python | testing_best_fit_plotting | null | def testing_best_fit_plotting():
""" Function for testing the plotting of the line of best fit """
dates = list(range(0, 50))
levels = [x**5 + 4 * x**4 - 2 * x + 156 for x in dates]
n = 5
p_coeff = np.polyfit(dates, levels, n)
poly = np.poly1d(p_coeff)
assert round(poly(156)) == 9475854... | Function for testing the plotting of the line of best fit | Function for testing the plotting of the line of best fit | [
"Function",
"for",
"testing",
"the",
"plotting",
"of",
"the",
"line",
"of",
"best",
"fit"
] | def testing_best_fit_plotting():
dates = list(range(0, 50))
levels = [x**5 + 4 * x**4 - 2 * x + 156 for x in dates]
n = 5
p_coeff = np.polyfit(dates, levels, n)
poly = np.poly1d(p_coeff)
assert round(poly(156)) == 94758543204 | [
"def",
"testing_best_fit_plotting",
"(",
")",
":",
"dates",
"=",
"list",
"(",
"range",
"(",
"0",
",",
"50",
")",
")",
"levels",
"=",
"[",
"x",
"**",
"5",
"+",
"4",
"*",
"x",
"**",
"4",
"-",
"2",
"*",
"x",
"+",
"156",
"for",
"x",
"in",
"dates"... | Function for testing the plotting of the line of best fit | [
"Function",
"for",
"testing",
"the",
"plotting",
"of",
"the",
"line",
"of",
"best",
"fit"
] | [
"\"\"\" Function for testing the plotting of the line of best fit \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
ad7f153b97942a5aaed040ad941fc5471546e1db | TimHire/Ia-flood-risk | test_geo.py | [
"MIT"
] | Python | testing_rivers_by_station_number | null | def testing_rivers_by_station_number():
""" Test to check can increase the number of a value of a dictionary """
test_dict = {}
test_list = [1, 4, 5, 45, 85, 88, 93, 99, 100]
for number in test_list:
if number % 2 == 0:
if "even" in test_dict.keys():
test_dict["even"... | Test to check can increase the number of a value of a dictionary | Test to check can increase the number of a value of a dictionary | [
"Test",
"to",
"check",
"can",
"increase",
"the",
"number",
"of",
"a",
"value",
"of",
"a",
"dictionary"
] | def testing_rivers_by_station_number():
test_dict = {}
test_list = [1, 4, 5, 45, 85, 88, 93, 99, 100]
for number in test_list:
if number % 2 == 0:
if "even" in test_dict.keys():
test_dict["even"] += 1
else:
test_dict["even"] = 1
else:
... | [
"def",
"testing_rivers_by_station_number",
"(",
")",
":",
"test_dict",
"=",
"{",
"}",
"test_list",
"=",
"[",
"1",
",",
"4",
",",
"5",
",",
"45",
",",
"85",
",",
"88",
",",
"93",
",",
"99",
",",
"100",
"]",
"for",
"number",
"in",
"test_list",
":",
... | Test to check can increase the number of a value of a dictionary | [
"Test",
"to",
"check",
"can",
"increase",
"the",
"number",
"of",
"a",
"value",
"of",
"a",
"dictionary"
] | [
"\"\"\" Test to check can increase the number of a value of a dictionary \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
ee5b14782bcc72b26a84f71b8eb922fef9232506 | fabbox/coeffExpress | autopy/autopy.py | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | Python | clean_header | <not_specific> | def clean_header(in_str):
""" remove part of string to rewrite uniform header
"""
to_remove = ['EDHEC', # must be before HEC
'HEC',
'ESCP Europe',
'ESC',
'ESSEC',
'EMLyon',
'emlyon',
'SKEM... | remove part of string to rewrite uniform header
| remove part of string to rewrite uniform header | [
"remove",
"part",
"of",
"string",
"to",
"rewrite",
"uniform",
"header"
] | def clean_header(in_str):
to_remove = ['EDHEC',
'HEC',
'ESCP Europe',
'ESC',
'ESSEC',
'EMLyon',
'emlyon',
'SKEMA',
'GRENOBLE',
'STRASBOURG',
'LA... | [
"def",
"clean_header",
"(",
"in_str",
")",
":",
"to_remove",
"=",
"[",
"'EDHEC'",
",",
"'HEC'",
",",
"'ESCP Europe'",
",",
"'ESC'",
",",
"'ESSEC'",
",",
"'EMLyon'",
",",
"'emlyon'",
",",
"'SKEMA'",
",",
"'GRENOBLE'",
",",
"'STRASBOURG'",
",",
"'LA ROCHELLE'"... | remove part of string to rewrite uniform header | [
"remove",
"part",
"of",
"string",
"to",
"rewrite",
"uniform",
"header"
] | [
"\"\"\" remove part of string to rewrite uniform header\n \"\"\"",
"# must be before HEC"
] | [
{
"param": "in_str",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "in_str",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0c03aa6e4bb71ae6b2cddc76532d768db1c6e7ec | anned20/scrapman | parser.py | [
"MIT"
] | Python | parse_page | <not_specific> | def parse_page(text):
"""Parse the page and return a BeautifulSoup object
Keyword Arguments:
text : string
"""
soup = BeautifulSoup(text, 'html.parser')
logger.debug(f'Title of page is {soup.title.string}')
return soup | Parse the page and return a BeautifulSoup object
Keyword Arguments:
text : string
| Parse the page and return a BeautifulSoup object
Keyword Arguments:
text : string | [
"Parse",
"the",
"page",
"and",
"return",
"a",
"BeautifulSoup",
"object",
"Keyword",
"Arguments",
":",
"text",
":",
"string"
] | def parse_page(text):
soup = BeautifulSoup(text, 'html.parser')
logger.debug(f'Title of page is {soup.title.string}')
return soup | [
"def",
"parse_page",
"(",
"text",
")",
":",
"soup",
"=",
"BeautifulSoup",
"(",
"text",
",",
"'html.parser'",
")",
"logger",
".",
"debug",
"(",
"f'Title of page is {soup.title.string}'",
")",
"return",
"soup"
] | Parse the page and return a BeautifulSoup object
Keyword Arguments:
text : string | [
"Parse",
"the",
"page",
"and",
"return",
"a",
"BeautifulSoup",
"object",
"Keyword",
"Arguments",
":",
"text",
":",
"string"
] | [
"\"\"\"Parse the page and return a BeautifulSoup object\n Keyword Arguments:\n text : string\n \"\"\""
] | [
{
"param": "text",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "text",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2d267ba6884d03547e59ecd3c93cd0799e6a77c0 | anned20/scrapman | serializer.py | [
"MIT"
] | Python | serialize_dict | <not_specific> | def serialize_dict(elements):
"""Serialize a list of BS4 tags to Python dict
Keyword Arguments:
elements : list
"""
return [
{
'name': el.name,
'attributes': el.attrs,
'content': el.string,
'source': str(el),
} for el in elements
] | Serialize a list of BS4 tags to Python dict
Keyword Arguments:
elements : list
| Serialize a list of BS4 tags to Python dict
Keyword Arguments:
elements : list | [
"Serialize",
"a",
"list",
"of",
"BS4",
"tags",
"to",
"Python",
"dict",
"Keyword",
"Arguments",
":",
"elements",
":",
"list"
] | def serialize_dict(elements):
return [
{
'name': el.name,
'attributes': el.attrs,
'content': el.string,
'source': str(el),
} for el in elements
] | [
"def",
"serialize_dict",
"(",
"elements",
")",
":",
"return",
"[",
"{",
"'name'",
":",
"el",
".",
"name",
",",
"'attributes'",
":",
"el",
".",
"attrs",
",",
"'content'",
":",
"el",
".",
"string",
",",
"'source'",
":",
"str",
"(",
"el",
")",
",",
"}... | Serialize a list of BS4 tags to Python dict
Keyword Arguments:
elements : list | [
"Serialize",
"a",
"list",
"of",
"BS4",
"tags",
"to",
"Python",
"dict",
"Keyword",
"Arguments",
":",
"elements",
":",
"list"
] | [
"\"\"\"Serialize a list of BS4 tags to Python dict\n Keyword Arguments:\n elements : list\n \"\"\""
] | [
{
"param": "elements",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "elements",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2d267ba6884d03547e59ecd3c93cd0799e6a77c0 | anned20/scrapman | serializer.py | [
"MIT"
] | Python | serialize_json | <not_specific> | def serialize_json(elements):
"""Serialize a list of BS4 tags to JSON
Keyword Arguments:
elements : list
"""
elements = serialize_dict(elements)
return json.dumps(elements) | Serialize a list of BS4 tags to JSON
Keyword Arguments:
elements : list
| Serialize a list of BS4 tags to JSON
Keyword Arguments:
elements : list | [
"Serialize",
"a",
"list",
"of",
"BS4",
"tags",
"to",
"JSON",
"Keyword",
"Arguments",
":",
"elements",
":",
"list"
] | def serialize_json(elements):
elements = serialize_dict(elements)
return json.dumps(elements) | [
"def",
"serialize_json",
"(",
"elements",
")",
":",
"elements",
"=",
"serialize_dict",
"(",
"elements",
")",
"return",
"json",
".",
"dumps",
"(",
"elements",
")"
] | Serialize a list of BS4 tags to JSON
Keyword Arguments:
elements : list | [
"Serialize",
"a",
"list",
"of",
"BS4",
"tags",
"to",
"JSON",
"Keyword",
"Arguments",
":",
"elements",
":",
"list"
] | [
"\"\"\"Serialize a list of BS4 tags to JSON\n Keyword Arguments:\n elements : list\n \"\"\""
] | [
{
"param": "elements",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "elements",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2d267ba6884d03547e59ecd3c93cd0799e6a77c0 | anned20/scrapman | serializer.py | [
"MIT"
] | Python | serialize_csv | <not_specific> | def serialize_csv(elements):
"""Serialize a list of BS 4 tags to CSV
Keyword Arguments:
elements : list
"""
elements = serialize_dict(elements)
output = io.StringIO()
keys = elements[0].keys()
dict_writer = csv.DictWriter(output, keys, quoting=csv.QUOTE_ALL)
dict_writer.writeheade... | Serialize a list of BS 4 tags to CSV
Keyword Arguments:
elements : list
| Serialize a list of BS 4 tags to CSV
Keyword Arguments:
elements : list | [
"Serialize",
"a",
"list",
"of",
"BS",
"4",
"tags",
"to",
"CSV",
"Keyword",
"Arguments",
":",
"elements",
":",
"list"
] | def serialize_csv(elements):
elements = serialize_dict(elements)
output = io.StringIO()
keys = elements[0].keys()
dict_writer = csv.DictWriter(output, keys, quoting=csv.QUOTE_ALL)
dict_writer.writeheader()
dict_writer.writerows(elements)
return output.getvalue() | [
"def",
"serialize_csv",
"(",
"elements",
")",
":",
"elements",
"=",
"serialize_dict",
"(",
"elements",
")",
"output",
"=",
"io",
".",
"StringIO",
"(",
")",
"keys",
"=",
"elements",
"[",
"0",
"]",
".",
"keys",
"(",
")",
"dict_writer",
"=",
"csv",
".",
... | Serialize a list of BS 4 tags to CSV
Keyword Arguments:
elements : list | [
"Serialize",
"a",
"list",
"of",
"BS",
"4",
"tags",
"to",
"CSV",
"Keyword",
"Arguments",
":",
"elements",
":",
"list"
] | [
"\"\"\"Serialize a list of BS 4 tags to CSV\n Keyword Arguments:\n elements : list\n \"\"\""
] | [
{
"param": "elements",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "elements",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b8de02ab55b4c8143bb98f3f2521b84a1718d937 | ncrocfer/similar | similar/similar.py | [
"MIT"
] | Python | best | <not_specific> | def best(self):
"""
Returns the best similar word.
"""
results = self.results()
return results[0][0] |
Returns the best similar word.
| Returns the best similar word. | [
"Returns",
"the",
"best",
"similar",
"word",
"."
] | def best(self):
results = self.results()
return results[0][0] | [
"def",
"best",
"(",
"self",
")",
":",
"results",
"=",
"self",
".",
"results",
"(",
")",
"return",
"results",
"[",
"0",
"]",
"[",
"0",
"]"
] | Returns the best similar word. | [
"Returns",
"the",
"best",
"similar",
"word",
"."
] | [
"\"\"\"\n Returns the best similar word.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b8de02ab55b4c8143bb98f3f2521b84a1718d937 | ncrocfer/similar | similar/similar.py | [
"MIT"
] | Python | results | <not_specific> | def results(self):
"""
Returns a list of tuple, ordered by similarity.
"""
d = dict()
words = [word.strip() for word in self.haystack]
if not words:
raise NoResultException('No similar word found.')
for w in words:
d[w] = Levenshtein.rati... |
Returns a list of tuple, ordered by similarity.
| Returns a list of tuple, ordered by similarity. | [
"Returns",
"a",
"list",
"of",
"tuple",
"ordered",
"by",
"similarity",
"."
] | def results(self):
d = dict()
words = [word.strip() for word in self.haystack]
if not words:
raise NoResultException('No similar word found.')
for w in words:
d[w] = Levenshtein.ratio(self.needle, w)
return sorted(d.items(), key=operator.itemgetter(1), rev... | [
"def",
"results",
"(",
"self",
")",
":",
"d",
"=",
"dict",
"(",
")",
"words",
"=",
"[",
"word",
".",
"strip",
"(",
")",
"for",
"word",
"in",
"self",
".",
"haystack",
"]",
"if",
"not",
"words",
":",
"raise",
"NoResultException",
"(",
"'No similar word... | Returns a list of tuple, ordered by similarity. | [
"Returns",
"a",
"list",
"of",
"tuple",
"ordered",
"by",
"similarity",
"."
] | [
"\"\"\"\n Returns a list of tuple, ordered by similarity.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b8de02ab55b4c8143bb98f3f2521b84a1718d937 | ncrocfer/similar | similar/similar.py | [
"MIT"
] | Python | best_match | <not_specific> | def best_match(needle, haystack):
"""
Constructs a Similar object and returns the best result found.
"""
p = Similar(needle, haystack)
return p.best() |
Constructs a Similar object and returns the best result found.
| Constructs a Similar object and returns the best result found. | [
"Constructs",
"a",
"Similar",
"object",
"and",
"returns",
"the",
"best",
"result",
"found",
"."
] | def best_match(needle, haystack):
p = Similar(needle, haystack)
return p.best() | [
"def",
"best_match",
"(",
"needle",
",",
"haystack",
")",
":",
"p",
"=",
"Similar",
"(",
"needle",
",",
"haystack",
")",
"return",
"p",
".",
"best",
"(",
")"
] | Constructs a Similar object and returns the best result found. | [
"Constructs",
"a",
"Similar",
"object",
"and",
"returns",
"the",
"best",
"result",
"found",
"."
] | [
"\"\"\"\n Constructs a Similar object and returns the best result found.\n \"\"\""
] | [
{
"param": "needle",
"type": null
},
{
"param": "haystack",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "needle",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "haystack",
"type": null,
"docstring": null,
"docstring_toke... |
e1f2bb337b4d88c123b7bac4613fb65b316a9b08 | CSAAtibaia/Listas | ERP/core/views.py | [
"MIT"
] | Python | save_data | null | def save_data(data):
'''
Salva os dados no banco.
'''
aux = []
for item in data:
produto = item.get('produto')
estoque = item.get('estoque')
obj = Produto(
produto=produto,
estoque=estoque,
)
aux.append(obj)
Produto.objects.bulk_cre... |
Salva os dados no banco.
| Salva os dados no banco. | [
"Salva",
"os",
"dados",
"no",
"banco",
"."
] | def save_data(data):
aux = []
for item in data:
produto = item.get('produto')
estoque = item.get('estoque')
obj = Produto(
produto=produto,
estoque=estoque,
)
aux.append(obj)
Produto.objects.bulk_create(aux) | [
"def",
"save_data",
"(",
"data",
")",
":",
"aux",
"=",
"[",
"]",
"for",
"item",
"in",
"data",
":",
"produto",
"=",
"item",
".",
"get",
"(",
"'produto'",
")",
"estoque",
"=",
"item",
".",
"get",
"(",
"'estoque'",
")",
"obj",
"=",
"Produto",
"(",
"... | Salva os dados no banco. | [
"Salva",
"os",
"dados",
"no",
"banco",
"."
] | [
"'''\n Salva os dados no banco.\n '''"
] | [
{
"param": "data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5bc3ea7ec565481cab133c8ff3751672b12b1bef | Suven-p/tl-cogs | recruitment/helper.py | [
"MIT"
] | Python | _is_member | <not_specific> | async def _is_member(member: discord.Member, guild: discord.Guild):
"""
Check if member already has any of roles
"""
"""
Credits: Gr8
"""
_membership_roles = [
discord.utils.get(guild.roles, name=r)
for r in [
"Membe... |
Check if member already has any of roles
| Check if member already has any of roles | [
"Check",
"if",
"member",
"already",
"has",
"any",
"of",
"roles"
] | async def _is_member(member: discord.Member, guild: discord.Guild):
_membership_roles = [
discord.utils.get(guild.roles, name=r)
for r in [
"Member",
"Co-Leader",
"Hub Officer",
"Hub Supervisor" "Clan Deputy",
... | [
"async",
"def",
"_is_member",
"(",
"member",
":",
"discord",
".",
"Member",
",",
"guild",
":",
"discord",
".",
"Guild",
")",
":",
"\"\"\"\n Credits: Gr8\n \"\"\"",
"_membership_roles",
"=",
"[",
"discord",
".",
"utils",
".",
"get",
"(",
"guild"... | Check if member already has any of roles | [
"Check",
"if",
"member",
"already",
"has",
"any",
"of",
"roles"
] | [
"\"\"\"\n Check if member already has any of roles\n \"\"\"",
"\"\"\"\n Credits: Gr8\n \"\"\""
] | [
{
"param": "member",
"type": "discord.Member"
},
{
"param": "guild",
"type": "discord.Guild"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "member",
"type": "discord.Member",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "guild",
"type": "discord.Guild",
"docstring": null,
... |
bc5228b2809b9dfb838cbfbdd14f0f602b3b2bba | Suven-p/tl-cogs | clashroyaleclans/clashroyaleclans.py | [
"MIT"
] | Python | _clan_server_setup | <not_specific> | async def _clan_server_setup(self, ctx, member: discord.Member):
"""
Setup nickname, and roles for a new member in a private clan server
"""
guild = ctx.guild
legend_servers = {
757553323602608128: ["RY9QJU2", "Rising"],
741928176779001948: ["9P2PQULQ"... |
Setup nickname, and roles for a new member in a private clan server
| Setup nickname, and roles for a new member in a private clan server | [
"Setup",
"nickname",
"and",
"roles",
"for",
"a",
"new",
"member",
"in",
"a",
"private",
"clan",
"server"
] | async def _clan_server_setup(self, ctx, member: discord.Member):
guild = ctx.guild
legend_servers = {
757553323602608128: ["RY9QJU2", "Rising"],
741928176779001948: ["9P2PQULQ", "Empire"],
424929926844776462: ["80CC8", "Squad"],
712090493399334913: ["PRCRJ... | [
"async",
"def",
"_clan_server_setup",
"(",
"self",
",",
"ctx",
",",
"member",
":",
"discord",
".",
"Member",
")",
":",
"guild",
"=",
"ctx",
".",
"guild",
"legend_servers",
"=",
"{",
"757553323602608128",
":",
"[",
"\"RY9QJU2\"",
",",
"\"Rising\"",
"]",
","... | Setup nickname, and roles for a new member in a private clan server | [
"Setup",
"nickname",
"and",
"roles",
"for",
"a",
"new",
"member",
"in",
"a",
"private",
"clan",
"server"
] | [
"\"\"\"\n Setup nickname, and roles for a new member in a private clan server\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
},
{
"param": "member",
"type": "discord.Member"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
18fd8be84b1e916908b546158c3c25e49eb8036b | Suven-p/tl-cogs | clashroyaleclansv2/clashroyaleclans.py | [
"MIT"
] | Python | clan_data | <not_specific> | async def clan_data(self, clankey: str, req_data: str = None):
"""Return clan info stored in config"""
all_clans = await self.config.clans()
key = self.get_static_clankey(clankey)
if key:
if req_data:
return all_clans[key][req_data]
else:
... | Return clan info stored in config | Return clan info stored in config | [
"Return",
"clan",
"info",
"stored",
"in",
"config"
] | async def clan_data(self, clankey: str, req_data: str = None):
all_clans = await self.config.clans()
key = self.get_static_clankey(clankey)
if key:
if req_data:
return all_clans[key][req_data]
else:
return all_clans[key]
return None | [
"async",
"def",
"clan_data",
"(",
"self",
",",
"clankey",
":",
"str",
",",
"req_data",
":",
"str",
"=",
"None",
")",
":",
"all_clans",
"=",
"await",
"self",
".",
"config",
".",
"clans",
"(",
")",
"key",
"=",
"self",
".",
"get_static_clankey",
"(",
"c... | Return clan info stored in config | [
"Return",
"clan",
"info",
"stored",
"in",
"config"
] | [
"\"\"\"Return clan info stored in config\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "clankey",
"type": "str"
},
{
"param": "req_data",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "clankey",
"type": "str",
"docstring": null,
"docstring_tokens... |
18fd8be84b1e916908b546158c3c25e49eb8036b | Suven-p/tl-cogs | clashroyaleclansv2/clashroyaleclans.py | [
"MIT"
] | Python | clan_member_data | <not_specific> | async def clan_member_data(
self, clankey: str, memberkey: str, req_data: str = None
):
"""Return clan member's dict"""
data = await self.clan_data(clankey, "member_list")
for member in data:
if member["tag"] == memberkey or member["name"] == memberkey:
... | Return clan member's dict | Return clan member's dict | [
"Return",
"clan",
"member",
"'",
"s",
"dict"
] | async def clan_member_data(
self, clankey: str, memberkey: str, req_data: str = None
):
data = await self.clan_data(clankey, "member_list")
for member in data:
if member["tag"] == memberkey or member["name"] == memberkey:
if req_data:
return me... | [
"async",
"def",
"clan_member_data",
"(",
"self",
",",
"clankey",
":",
"str",
",",
"memberkey",
":",
"str",
",",
"req_data",
":",
"str",
"=",
"None",
")",
":",
"data",
"=",
"await",
"self",
".",
"clan_data",
"(",
"clankey",
",",
"\"member_list\"",
")",
... | Return clan member's dict | [
"Return",
"clan",
"member",
"'",
"s",
"dict"
] | [
"\"\"\"Return clan member's dict\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "clankey",
"type": "str"
},
{
"param": "memberkey",
"type": "str"
},
{
"param": "req_data",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "clankey",
"type": "str",
"docstring": null,
"docstring_tokens... |
18fd8be84b1e916908b546158c3c25e49eb8036b | Suven-p/tl-cogs | clashroyaleclansv2/clashroyaleclans.py | [
"MIT"
] | Python | clan_roles | <not_specific> | def clan_roles(self):
"""Get roles of all the clans"""
roles = ["Member"]
roles.extend([clan["clanrole"] for clan in self.static_clandata.values()])
return roles | Get roles of all the clans | Get roles of all the clans | [
"Get",
"roles",
"of",
"all",
"the",
"clans"
] | def clan_roles(self):
roles = ["Member"]
roles.extend([clan["clanrole"] for clan in self.static_clandata.values()])
return roles | [
"def",
"clan_roles",
"(",
"self",
")",
":",
"roles",
"=",
"[",
"\"Member\"",
"]",
"roles",
".",
"extend",
"(",
"[",
"clan",
"[",
"\"clanrole\"",
"]",
"for",
"clan",
"in",
"self",
".",
"static_clandata",
".",
"values",
"(",
")",
"]",
")",
"return",
"r... | Get roles of all the clans | [
"Get",
"roles",
"of",
"all",
"the",
"clans"
] | [
"\"\"\"Get roles of all the clans\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
18fd8be84b1e916908b546158c3c25e49eb8036b | Suven-p/tl-cogs | clashroyaleclansv2/clashroyaleclans.py | [
"MIT"
] | Python | clan_key_from_tag | <not_specific> | def clan_key_from_tag(self, clantag):
"""Get a clan key from a clan tag."""
for key, data in self.static_clandata.items():
if data["tag"] == clantag:
return key
return None | Get a clan key from a clan tag. | Get a clan key from a clan tag. | [
"Get",
"a",
"clan",
"key",
"from",
"a",
"clan",
"tag",
"."
] | def clan_key_from_tag(self, clantag):
for key, data in self.static_clandata.items():
if data["tag"] == clantag:
return key
return None | [
"def",
"clan_key_from_tag",
"(",
"self",
",",
"clantag",
")",
":",
"for",
"key",
",",
"data",
"in",
"self",
".",
"static_clandata",
".",
"items",
"(",
")",
":",
"if",
"data",
"[",
"\"tag\"",
"]",
"==",
"clantag",
":",
"return",
"key",
"return",
"None"
... | Get a clan key from a clan tag. | [
"Get",
"a",
"clan",
"key",
"from",
"a",
"clan",
"tag",
"."
] | [
"\"\"\"Get a clan key from a clan tag.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "clantag",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "clantag",
"type": null,
"docstring": null,
"docstring_tokens"... |
18fd8be84b1e916908b546158c3c25e49eb8036b | Suven-p/tl-cogs | clashroyaleclansv2/clashroyaleclans.py | [
"MIT"
] | Python | clan_cwr | <not_specific> | async def clan_cwr(self, clankey, league):
"""Get a clan's CWR"""
for name, data in self.static_clandata.items():
if (
data["tag"] == clankey
or data["name"] == clankey
or data["nickname"] == clankey
):
retur... | Get a clan's CWR | Get a clan's CWR | [
"Get",
"a",
"clan",
"'",
"s",
"CWR"
] | async def clan_cwr(self, clankey, league):
for name, data in self.static_clandata.items():
if (
data["tag"] == clankey
or data["name"] == clankey
or data["nickname"] == clankey
):
return data["cwr"][league]
return 0 | [
"async",
"def",
"clan_cwr",
"(",
"self",
",",
"clankey",
",",
"league",
")",
":",
"for",
"name",
",",
"data",
"in",
"self",
".",
"static_clandata",
".",
"items",
"(",
")",
":",
"if",
"(",
"data",
"[",
"\"tag\"",
"]",
"==",
"clankey",
"or",
"data",
... | Get a clan's CWR | [
"Get",
"a",
"clan",
"'",
"s",
"CWR"
] | [
"\"\"\"Get a clan's CWR\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "clankey",
"type": null
},
{
"param": "league",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "clankey",
"type": null,
"docstring": null,
"docstring_tokens"... |
18fd8be84b1e916908b546158c3c25e49eb8036b | Suven-p/tl-cogs | clashroyaleclansv2/clashroyaleclans.py | [
"MIT"
] | Python | add_waiting_member | <not_specific> | async def add_waiting_member(self, clankey, memberID):
"""Add a user to a clan's waiting list"""
if memberID not in self.waiting(clankey):
clankey = self.get_static_clankey(clankey)
self.static_clandata[clankey]["waiting"].append(memberID)
await self.save_clan_da... | Add a user to a clan's waiting list | Add a user to a clan's waiting list | [
"Add",
"a",
"user",
"to",
"a",
"clan",
"'",
"s",
"waiting",
"list"
] | async def add_waiting_member(self, clankey, memberID):
if memberID not in self.waiting(clankey):
clankey = self.get_static_clankey(clankey)
self.static_clandata[clankey]["waiting"].append(memberID)
await self.save_clan_data()
return True
else:
... | [
"async",
"def",
"add_waiting_member",
"(",
"self",
",",
"clankey",
",",
"memberID",
")",
":",
"if",
"memberID",
"not",
"in",
"self",
".",
"waiting",
"(",
"clankey",
")",
":",
"clankey",
"=",
"self",
".",
"get_static_clankey",
"(",
"clankey",
")",
"self",
... | Add a user to a clan's waiting list | [
"Add",
"a",
"user",
"to",
"a",
"clan",
"'",
"s",
"waiting",
"list"
] | [
"\"\"\"Add a user to a clan's waiting list\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "clankey",
"type": null
},
{
"param": "memberID",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "clankey",
"type": null,
"docstring": null,
"docstring_tokens"... |
18fd8be84b1e916908b546158c3c25e49eb8036b | Suven-p/tl-cogs | clashroyaleclansv2/clashroyaleclans.py | [
"MIT"
] | Python | remove_waiting_member | <not_specific> | async def remove_waiting_member(self, clankey, memberID):
"""Remove a user to a clan's waiting list"""
if memberID in self.waiting(clankey):
clankey = self.get_static_clankey(clankey)
self.static_clandata[clankey]["waiting"].remove(memberID)
await self.save_clan_... | Remove a user to a clan's waiting list | Remove a user to a clan's waiting list | [
"Remove",
"a",
"user",
"to",
"a",
"clan",
"'",
"s",
"waiting",
"list"
] | async def remove_waiting_member(self, clankey, memberID):
if memberID in self.waiting(clankey):
clankey = self.get_static_clankey(clankey)
self.static_clandata[clankey]["waiting"].remove(memberID)
await self.save_clan_data()
return True
else:
r... | [
"async",
"def",
"remove_waiting_member",
"(",
"self",
",",
"clankey",
",",
"memberID",
")",
":",
"if",
"memberID",
"in",
"self",
".",
"waiting",
"(",
"clankey",
")",
":",
"clankey",
"=",
"self",
".",
"get_static_clankey",
"(",
"clankey",
")",
"self",
".",
... | Remove a user to a clan's waiting list | [
"Remove",
"a",
"user",
"to",
"a",
"clan",
"'",
"s",
"waiting",
"list"
] | [
"\"\"\"Remove a user to a clan's waiting list\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "clankey",
"type": null
},
{
"param": "memberID",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "clankey",
"type": null,
"docstring": null,
"docstring_tokens"... |
18fd8be84b1e916908b546158c3c25e49eb8036b | Suven-p/tl-cogs | clashroyaleclansv2/clashroyaleclans.py | [
"MIT"
] | Python | delClan | <not_specific> | async def delClan(self, clankey):
"""delete a clan from the family"""
if self.static_clandata.pop(clankey, None):
await self.save_clan_data()
return True
return False | delete a clan from the family | delete a clan from the family | [
"delete",
"a",
"clan",
"from",
"the",
"family"
] | async def delClan(self, clankey):
if self.static_clandata.pop(clankey, None):
await self.save_clan_data()
return True
return False | [
"async",
"def",
"delClan",
"(",
"self",
",",
"clankey",
")",
":",
"if",
"self",
".",
"static_clandata",
".",
"pop",
"(",
"clankey",
",",
"None",
")",
":",
"await",
"self",
".",
"save_clan_data",
"(",
")",
"return",
"True",
"return",
"False"
] | delete a clan from the family | [
"delete",
"a",
"clan",
"from",
"the",
"family"
] | [
"\"\"\"delete a clan from the family\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "clankey",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "clankey",
"type": null,
"docstring": null,
"docstring_tokens"... |
18fd8be84b1e916908b546158c3c25e49eb8036b | Suven-p/tl-cogs | clashroyaleclansv2/clashroyaleclans.py | [
"MIT"
] | Python | toggle_private | <not_specific> | async def toggle_private(self, clankey):
"""Toggle Private approval of new recruits"""
clankey = self.get_static_clankey(clankey)
self.static_clandata[clankey]["requirements"][
"approval"
] = not self.static_clandata[clankey]["requirements"]["approval"]
await se... | Toggle Private approval of new recruits | Toggle Private approval of new recruits | [
"Toggle",
"Private",
"approval",
"of",
"new",
"recruits"
] | async def toggle_private(self, clankey):
clankey = self.get_static_clankey(clankey)
self.static_clandata[clankey]["requirements"][
"approval"
] = not self.static_clandata[clankey]["requirements"]["approval"]
await self.save_clan_data()
return self.static_clandata[clan... | [
"async",
"def",
"toggle_private",
"(",
"self",
",",
"clankey",
")",
":",
"clankey",
"=",
"self",
".",
"get_static_clankey",
"(",
"clankey",
")",
"self",
".",
"static_clandata",
"[",
"clankey",
"]",
"[",
"\"requirements\"",
"]",
"[",
"\"approval\"",
"]",
"=",... | Toggle Private approval of new recruits | [
"Toggle",
"Private",
"approval",
"of",
"new",
"recruits"
] | [
"\"\"\"Toggle Private approval of new recruits\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "clankey",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "clankey",
"type": null,
"docstring": null,
"docstring_tokens"... |
20ac278c937abe2f751bc43f2834709c9df5924d | Suven-p/tl-cogs | recruitment/cr.py | [
"MIT"
] | Python | command_legend | <not_specific> | async def command_legend(
self,
ctx: commands.Context,
member: Optional[discord.Member] = None,
account: int = 1,
):
"""
Show Legend clans.
Can also show clans based on a member's stats
"""
async with ctx.channel.typing():
# Show al... |
Show Legend clans.
Can also show clans based on a member's stats
| Show Legend clans.
Can also show clans based on a member's stats | [
"Show",
"Legend",
"clans",
".",
"Can",
"also",
"show",
"clans",
"based",
"on",
"a",
"member",
"'",
"s",
"stats"
] | async def command_legend(
self,
ctx: commands.Context,
member: Optional[discord.Member] = None,
account: int = 1,
):
async with ctx.channel.typing():
player_trophies = 9999
player_pb = 9999
player_cwr = {
"legendary": {"perc... | [
"async",
"def",
"command_legend",
"(",
"self",
",",
"ctx",
":",
"commands",
".",
"Context",
",",
"member",
":",
"Optional",
"[",
"discord",
".",
"Member",
"]",
"=",
"None",
",",
"account",
":",
"int",
"=",
"1",
",",
")",
":",
"async",
"with",
"ctx",
... | Show Legend clans. | [
"Show",
"Legend",
"clans",
"."
] | [
"\"\"\"\n Show Legend clans.\n Can also show clans based on a member's stats\n \"\"\"",
"# Show all clans if member is None.",
"# REMINDER: Order is important. RequestError is base exception class.",
"# )"
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": "commands.Context"
},
{
"param": "member",
"type": "Optional[discord.Member]"
},
{
"param": "account",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": "commands.Context",
"docstring": null,
"docstri... |
20ac278c937abe2f751bc43f2834709c9df5924d | Suven-p/tl-cogs | recruitment/cr.py | [
"MIT"
] | Python | command_newmember | <not_specific> | async def command_newmember(self, ctx, member: discord.Member):
"""
Setup nickname, and roles for a new member
"""
guild = ctx.guild
# if not (await self.bot.is_mod(ctx.author)):
# return await ctx.send(
# "Sorry! You do not have enough permission... |
Setup nickname, and roles for a new member
| Setup nickname, and roles for a new member | [
"Setup",
"nickname",
"and",
"roles",
"for",
"a",
"new",
"member"
] | async def command_newmember(self, ctx, member: discord.Member):
guild = ctx.guild
"Error, " + member.mention + " is not a new member.")
is_clan_member = False
try:
player_tags = self.tags.getAllTags(member.id)
except AttributeError:
return await ctx.send("... | [
"async",
"def",
"command_newmember",
"(",
"self",
",",
"ctx",
",",
"member",
":",
"discord",
".",
"Member",
")",
":",
"guild",
"=",
"ctx",
".",
"guild",
"is_clan_member",
"=",
"False",
"try",
":",
"player_tags",
"=",
"self",
".",
"tags",
".",
"getAllTags... | Setup nickname, and roles for a new member | [
"Setup",
"nickname",
"and",
"roles",
"for",
"a",
"new",
"member"
] | [
"\"\"\"\n Setup nickname, and roles for a new member\n \"\"\"",
"# if not (await self.bot.is_mod(ctx.author)):",
"# return await ctx.send(",
"# \"Sorry! You do not have enough permissions to run this command.\"",
"# )",
"# Check if user already has any of member roles:",
... | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
},
{
"param": "member",
"type": "discord.Member"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
20ac278c937abe2f751bc43f2834709c9df5924d | Suven-p/tl-cogs | recruitment/cr.py | [
"MIT"
] | Python | _clan_server_setup | <not_specific> | async def _clan_server_setup(self, ctx, member: discord.Member):
"""
Setup nickname, and roles for a new member in a private clan server
"""
guild = ctx.guild
legend_servers = {
757553323602608128: ["RY9QJU2", "Rising"],
741928176779001948: ["9P2PQULQ"... |
Setup nickname, and roles for a new member in a private clan server
| Setup nickname, and roles for a new member in a private clan server | [
"Setup",
"nickname",
"and",
"roles",
"for",
"a",
"new",
"member",
"in",
"a",
"private",
"clan",
"server"
] | async def _clan_server_setup(self, ctx, member: discord.Member):
guild = ctx.guild
legend_servers = {
757553323602608128: ["RY9QJU2", "Rising"],
741928176779001948: ["9P2PQULQ", "Empire"],
424929926844776462: ["80CC8", "Squad"],
712090493399334913: ["PRCRJ... | [
"async",
"def",
"_clan_server_setup",
"(",
"self",
",",
"ctx",
",",
"member",
":",
"discord",
".",
"Member",
")",
":",
"guild",
"=",
"ctx",
".",
"guild",
"legend_servers",
"=",
"{",
"757553323602608128",
":",
"[",
"\"RY9QJU2\"",
",",
"\"Rising\"",
"]",
","... | Setup nickname, and roles for a new member in a private clan server | [
"Setup",
"nickname",
"and",
"roles",
"for",
"a",
"new",
"member",
"in",
"a",
"private",
"clan",
"server"
] | [
"\"\"\"\n Setup nickname, and roles for a new member in a private clan server\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
},
{
"param": "member",
"type": "discord.Member"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
20ac278c937abe2f751bc43f2834709c9df5924d | Suven-p/tl-cogs | recruitment/cr.py | [
"MIT"
] | Python | command_cwr | <not_specific> | async def command_cwr(
self, ctx, member: Optional[discord.Member] = None, account: int = 1
):
"""View yours or other's clash royale CWR"""
member = member or ctx.author
pages = list()
async with ctx.channel.typing():
try:
player_tag = self.tags.ge... | View yours or other's clash royale CWR | View yours or other's clash royale CWR | [
"View",
"yours",
"or",
"other",
"'",
"s",
"clash",
"royale",
"CWR"
] | async def command_cwr(
self, ctx, member: Optional[discord.Member] = None, account: int = 1
):
member = member or ctx.author
pages = list()
async with ctx.channel.typing():
try:
player_tag = self.tags.getTag(member.id, account)
if player_ta... | [
"async",
"def",
"command_cwr",
"(",
"self",
",",
"ctx",
",",
"member",
":",
"Optional",
"[",
"discord",
".",
"Member",
"]",
"=",
"None",
",",
"account",
":",
"int",
"=",
"1",
")",
":",
"member",
"=",
"member",
"or",
"ctx",
".",
"author",
"pages",
"... | View yours or other's clash royale CWR | [
"View",
"yours",
"or",
"other",
"'",
"s",
"clash",
"royale",
"CWR"
] | [
"\"\"\"View yours or other's clash royale CWR\"\"\"",
"# REMINDER: Order is important. RequestError is base exception class."
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
},
{
"param": "member",
"type": "Optional[discord.Member]"
},
{
"param": "account",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
20ac278c937abe2f751bc43f2834709c9df5924d | Suven-p/tl-cogs | recruitment/cr.py | [
"MIT"
] | Python | waiting_add | <not_specific> | async def waiting_add(
self, ctx: commands.Context, member: discord.Member, clan_name, account: int = 1
):
"""Add people to the waiting list for a clan"""
async with ctx.channel.typing():
clan_name = clan_name.lower()
valid_keys = [k["nickname"].lower() for k in self... | Add people to the waiting list for a clan | Add people to the waiting list for a clan | [
"Add",
"people",
"to",
"the",
"waiting",
"list",
"for",
"a",
"clan"
] | async def waiting_add(
self, ctx: commands.Context, member: discord.Member, clan_name, account: int = 1
):
async with ctx.channel.typing():
clan_name = clan_name.lower()
valid_keys = [k["nickname"].lower() for k in self.family_clans.values()]
if clan_name not in v... | [
"async",
"def",
"waiting_add",
"(",
"self",
",",
"ctx",
":",
"commands",
".",
"Context",
",",
"member",
":",
"discord",
".",
"Member",
",",
"clan_name",
",",
"account",
":",
"int",
"=",
"1",
")",
":",
"async",
"with",
"ctx",
".",
"channel",
".",
"typ... | Add people to the waiting list for a clan | [
"Add",
"people",
"to",
"the",
"waiting",
"list",
"for",
"a",
"clan"
] | [
"\"\"\"Add people to the waiting list for a clan\"\"\"",
"# Get requirements for clan to approve",
"# Clan data for clan to approve",
"# REMINDER: Order is important. RequestError is base exception class."
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": "commands.Context"
},
{
"param": "member",
"type": "discord.Member"
},
{
"param": "clan_name",
"type": null
},
{
"param": "account",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": "commands.Context",
"docstring": null,
"docstri... |
20ac278c937abe2f751bc43f2834709c9df5924d | Suven-p/tl-cogs | recruitment/cr.py | [
"MIT"
] | Python | waiting_list | <not_specific> | async def waiting_list(self, ctx: commands.Context):
"""Show status of the waiting list."""
message = ""
num_clans = 0
num_players = 0
async with ctx.channel.typing():
embed = discord.Embed(color=discord.Colour.blue())
for clan_name, clan_data in self.f... | Show status of the waiting list. | Show status of the waiting list. | [
"Show",
"status",
"of",
"the",
"waiting",
"list",
"."
] | async def waiting_list(self, ctx: commands.Context):
message = ""
num_clans = 0
num_players = 0
async with ctx.channel.typing():
embed = discord.Embed(color=discord.Colour.blue())
for clan_name, clan_data in self.family_clans.items():
if len(clan_d... | [
"async",
"def",
"waiting_list",
"(",
"self",
",",
"ctx",
":",
"commands",
".",
"Context",
")",
":",
"message",
"=",
"\"\"",
"num_clans",
"=",
"0",
"num_players",
"=",
"0",
"async",
"with",
"ctx",
".",
"channel",
".",
"typing",
"(",
")",
":",
"embed",
... | Show status of the waiting list. | [
"Show",
"status",
"of",
"the",
"waiting",
"list",
"."
] | [
"\"\"\"Show status of the waiting list.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": "commands.Context"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": "commands.Context",
"docstring": null,
"docstri... |
20ac278c937abe2f751bc43f2834709c9df5924d | Suven-p/tl-cogs | recruitment/cr.py | [
"MIT"
] | Python | waiting_remove | <not_specific> | async def waiting_remove(
self, ctx, member: discord.Member, clan_key, account: int = 1
):
"""Delete people from the waiting list for a clan"""
async with ctx.channel.typing():
clan_key = clan_key.lower()
valid_keys = [k["nickname"].lower() for k in self.family_clans.... | Delete people from the waiting list for a clan | Delete people from the waiting list for a clan | [
"Delete",
"people",
"from",
"the",
"waiting",
"list",
"for",
"a",
"clan"
] | async def waiting_remove(
self, ctx, member: discord.Member, clan_key, account: int = 1
):
async with ctx.channel.typing():
clan_key = clan_key.lower()
valid_keys = [k["nickname"].lower() for k in self.family_clans.values()]
if clan_key not in valid_keys:
... | [
"async",
"def",
"waiting_remove",
"(",
"self",
",",
"ctx",
",",
"member",
":",
"discord",
".",
"Member",
",",
"clan_key",
",",
"account",
":",
"int",
"=",
"1",
")",
":",
"async",
"with",
"ctx",
".",
"channel",
".",
"typing",
"(",
")",
":",
"clan_key"... | Delete people from the waiting list for a clan | [
"Delete",
"people",
"from",
"the",
"waiting",
"list",
"for",
"a",
"clan"
] | [
"\"\"\"Delete people from the waiting list for a clan\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
},
{
"param": "member",
"type": "discord.Member"
},
{
"param": "clan_key",
"type": null
},
{
"param": "account",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
20ac278c937abe2f751bc43f2834709c9df5924d | Suven-p/tl-cogs | recruitment/cr.py | [
"MIT"
] | Python | clans_cwr | <not_specific> | async def clans_cwr(self, ctx, clankey, league, percent: int):
""" Set cwr as requirement for clan """
clan_name = None
for name, data in self.family_clans.items():
if data["nickname"].lower() == clankey.lower():
clan_name = name
if not clan_name:
... | Set cwr as requirement for clan | Set cwr as requirement for clan | [
"Set",
"cwr",
"as",
"requirement",
"for",
"clan"
] | async def clans_cwr(self, ctx, clankey, league, percent: int):
clan_name = None
for name, data in self.family_clans.items():
if data["nickname"].lower() == clankey.lower():
clan_name = name
if not clan_name:
return await ctx.send(f"No clan named {clankey}.... | [
"async",
"def",
"clans_cwr",
"(",
"self",
",",
"ctx",
",",
"clankey",
",",
"league",
",",
"percent",
":",
"int",
")",
":",
"clan_name",
"=",
"None",
"for",
"name",
",",
"data",
"in",
"self",
".",
"family_clans",
".",
"items",
"(",
")",
":",
"if",
"... | Set cwr as requirement for clan | [
"Set",
"cwr",
"as",
"requirement",
"for",
"clan"
] | [
"\"\"\" Set cwr as requirement for clan \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
},
{
"param": "clankey",
"type": null
},
{
"param": "league",
"type": null
},
{
"param": "percent",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
20ac278c937abe2f751bc43f2834709c9df5924d | Suven-p/tl-cogs | recruitment/cr.py | [
"MIT"
] | Python | clans_bonus | <not_specific> | async def clans_bonus(self, ctx, clankey, value: str):
""" Set bonus requirements for clan. Note that these values must be checked manually by hub officers. """
clan_name = None
for name, data in self.family_clans.items():
if data["nickname"].lower() == clankey.lower():
... | Set bonus requirements for clan. Note that these values must be checked manually by hub officers. | Set bonus requirements for clan. Note that these values must be checked manually by hub officers. | [
"Set",
"bonus",
"requirements",
"for",
"clan",
".",
"Note",
"that",
"these",
"values",
"must",
"be",
"checked",
"manually",
"by",
"hub",
"officers",
"."
] | async def clans_bonus(self, ctx, clankey, value: str):
clan_name = None
for name, data in self.family_clans.items():
if data["nickname"].lower() == clankey.lower():
clan_name = name
if not clan_name:
return await ctx.send(f"No clan named {clankey}.")
... | [
"async",
"def",
"clans_bonus",
"(",
"self",
",",
"ctx",
",",
"clankey",
",",
"value",
":",
"str",
")",
":",
"clan_name",
"=",
"None",
"for",
"name",
",",
"data",
"in",
"self",
".",
"family_clans",
".",
"items",
"(",
")",
":",
"if",
"data",
"[",
"\"... | Set bonus requirements for clan. | [
"Set",
"bonus",
"requirements",
"for",
"clan",
"."
] | [
"\"\"\" Set bonus requirements for clan. Note that these values must be checked manually by hub officers. \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
},
{
"param": "clankey",
"type": null
},
{
"param": "value",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
20ac278c937abe2f751bc43f2834709c9df5924d | Suven-p/tl-cogs | recruitment/cr.py | [
"MIT"
] | Python | clans_wdwins | <not_specific> | async def clans_wdwins(self, ctx, clankey, value: int):
""" Set warday wins requirements for clan """
clan_name = None
for name, data in self.family_clans.items():
if data["nickname"].lower() == clankey.lower():
clan_name = name
if not clan_name:
r... | Set warday wins requirements for clan | Set warday wins requirements for clan | [
"Set",
"warday",
"wins",
"requirements",
"for",
"clan"
] | async def clans_wdwins(self, ctx, clankey, value: int):
clan_name = None
for name, data in self.family_clans.items():
if data["nickname"].lower() == clankey.lower():
clan_name = name
if not clan_name:
return await ctx.send(f"No clan named {clankey}.")
... | [
"async",
"def",
"clans_wdwins",
"(",
"self",
",",
"ctx",
",",
"clankey",
",",
"value",
":",
"int",
")",
":",
"clan_name",
"=",
"None",
"for",
"name",
",",
"data",
"in",
"self",
".",
"family_clans",
".",
"items",
"(",
")",
":",
"if",
"data",
"[",
"\... | Set warday wins requirements for clan | [
"Set",
"warday",
"wins",
"requirements",
"for",
"clan"
] | [
"\"\"\" Set warday wins requirements for clan \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
},
{
"param": "clankey",
"type": null
},
{
"param": "value",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
6c18e9ccafcef4be991aa379b941f2cba5eadb3f | richpsharp/raster_calculations | average_rasters.py | [
"Apache-2.0"
] | Python | count_op | <not_specific> | def count_op(*value_nodata_list):
"""Calculate count of valid pixels over each pixel stack."""
result = numpy.zeros(value_nodata_list[0].shape, dtype=numpy.int32)
valid_mask = numpy.zeros(result.shape, dtype=numpy.bool)
list_len = len(value_nodata_list)
for array, nodata in zip(
value_no... | Calculate count of valid pixels over each pixel stack. | Calculate count of valid pixels over each pixel stack. | [
"Calculate",
"count",
"of",
"valid",
"pixels",
"over",
"each",
"pixel",
"stack",
"."
] | def count_op(*value_nodata_list):
result = numpy.zeros(value_nodata_list[0].shape, dtype=numpy.int32)
valid_mask = numpy.zeros(result.shape, dtype=numpy.bool)
list_len = len(value_nodata_list)
for array, nodata in zip(
value_nodata_list[0:list_len//2],
value_nodata_list[list_len/... | [
"def",
"count_op",
"(",
"*",
"value_nodata_list",
")",
":",
"result",
"=",
"numpy",
".",
"zeros",
"(",
"value_nodata_list",
"[",
"0",
"]",
".",
"shape",
",",
"dtype",
"=",
"numpy",
".",
"int32",
")",
"valid_mask",
"=",
"numpy",
".",
"zeros",
"(",
"resu... | Calculate count of valid pixels over each pixel stack. | [
"Calculate",
"count",
"of",
"valid",
"pixels",
"over",
"each",
"pixel",
"stack",
"."
] | [
"\"\"\"Calculate count of valid pixels over each pixel stack.\"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
6c18e9ccafcef4be991aa379b941f2cba5eadb3f | richpsharp/raster_calculations | average_rasters.py | [
"Apache-2.0"
] | Python | average_op | <not_specific> | def average_op(*value_nodata_list):
"""Calculate count of valid pixels over each pixel stack."""
result = numpy.zeros(value_nodata_list[0].shape, dtype=numpy.float32)
count = numpy.zeros(value_nodata_list[0].shape, dtype=numpy.float32)
valid_mask = numpy.zeros(result.shape, dtype=numpy.bool)
list_le... | Calculate count of valid pixels over each pixel stack. | Calculate count of valid pixels over each pixel stack. | [
"Calculate",
"count",
"of",
"valid",
"pixels",
"over",
"each",
"pixel",
"stack",
"."
] | def average_op(*value_nodata_list):
result = numpy.zeros(value_nodata_list[0].shape, dtype=numpy.float32)
count = numpy.zeros(value_nodata_list[0].shape, dtype=numpy.float32)
valid_mask = numpy.zeros(result.shape, dtype=numpy.bool)
list_len = len(value_nodata_list)
for array, nodata in zip(
... | [
"def",
"average_op",
"(",
"*",
"value_nodata_list",
")",
":",
"result",
"=",
"numpy",
".",
"zeros",
"(",
"value_nodata_list",
"[",
"0",
"]",
".",
"shape",
",",
"dtype",
"=",
"numpy",
".",
"float32",
")",
"count",
"=",
"numpy",
".",
"zeros",
"(",
"value... | Calculate count of valid pixels over each pixel stack. | [
"Calculate",
"count",
"of",
"valid",
"pixels",
"over",
"each",
"pixel",
"stack",
"."
] | [
"\"\"\"Calculate count of valid pixels over each pixel stack.\"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
d71e6b20db36929667bb6905795d11a9d94db00a | richpsharp/raster_calculations | raster_stats/__main__.py | [
"Apache-2.0"
] | Python | _read_score_index_from_disk | null | def _read_score_index_from_disk(score_file_path, datatype_id):
"""Create generator of float/int value from the given filenames.
Reads a buffer of `buffer_size` big before to avoid keeping the
file open between generations.
score_file_path (string): a path to a file that has 32 bi... | Create generator of float/int value from the given filenames.
Reads a buffer of `buffer_size` big before to avoid keeping the
file open between generations.
score_file_path (string): a path to a file that has 32 bit data
packed consecutively
Yields:
ne... | Create generator of float/int value from the given filenames.
Reads a buffer of `buffer_size` big before to avoid keeping the
file open between generations.
score_file_path (string): a path to a file that has 32 bit data
packed consecutively | [
"Create",
"generator",
"of",
"float",
"/",
"int",
"value",
"from",
"the",
"given",
"filenames",
".",
"Reads",
"a",
"buffer",
"of",
"`",
"buffer_size",
"`",
"big",
"before",
"to",
"avoid",
"keeping",
"the",
"file",
"open",
"between",
"generations",
".",
"sc... | def _read_score_index_from_disk(score_file_path, datatype_id):
try:
score_buffer = ''
file_offset = 0
buffer_offset = 0
read_buffer_size = int(math.sqrt(_BLOCK_SIZE))
read_buffer_size = read_buffer_size - read_buffer_size % 4
while True:
... | [
"def",
"_read_score_index_from_disk",
"(",
"score_file_path",
",",
"datatype_id",
")",
":",
"try",
":",
"score_buffer",
"=",
"''",
"file_offset",
"=",
"0",
"buffer_offset",
"=",
"0",
"read_buffer_size",
"=",
"int",
"(",
"math",
".",
"sqrt",
"(",
"_BLOCK_SIZE",
... | Create generator of float/int value from the given filenames. | [
"Create",
"generator",
"of",
"float",
"/",
"int",
"value",
"from",
"the",
"given",
"filenames",
"."
] | [
"\"\"\"Create generator of float/int value from the given filenames.\r\n\r\n Reads a buffer of `buffer_size` big before to avoid keeping the\r\n file open between generations.\r\n\r\n score_file_path (string): a path to a file that has 32 bit data\r\n packed consecutively\r\n\r\n ... | [
{
"param": "score_file_path",
"type": null
},
{
"param": "datatype_id",
"type": null
}
] | {
"returns": [
{
"docstring": "next (score, index) tuple in the given score and index files.",
"docstring_tokens": [
"next",
"(",
"score",
"index",
")",
"tuple",
"in",
"the",
"given",
"score",
"and",
"index... |
d71e6b20db36929667bb6905795d11a9d94db00a | richpsharp/raster_calculations | raster_stats/__main__.py | [
"Apache-2.0"
] | Python | _make_logger_callback | <not_specific> | def _make_logger_callback(message):
"""Build a timed logger callback that prints ``message`` replaced.
Parameters:
message (string): a string that expects 2 placement %% variables,
first for % complete from ``df_complete``, second from
``p_progress_arg[0]``.
Returns... | Build a timed logger callback that prints ``message`` replaced.
Parameters:
message (string): a string that expects 2 placement %% variables,
first for % complete from ``df_complete``, second from
``p_progress_arg[0]``.
Returns:
Function with signature:
... | Build a timed logger callback that prints ``message`` replaced. | [
"Build",
"a",
"timed",
"logger",
"callback",
"that",
"prints",
"`",
"`",
"message",
"`",
"`",
"replaced",
"."
] | def _make_logger_callback(message):
def logger_callback(df_complete, _, p_progress_arg):
try:
current_time = time.time()
if ((current_time - logger_callback.last_time) > 5.0 or
(df_complete == 1.0 and
logger_callback.total_time >= 5.0)):
... | [
"def",
"_make_logger_callback",
"(",
"message",
")",
":",
"def",
"logger_callback",
"(",
"df_complete",
",",
"_",
",",
"p_progress_arg",
")",
":",
"\"\"\"Argument names come from the GDAL API for callbacks.\"\"\"",
"try",
":",
"current_time",
"=",
"time",
".",
"time",
... | Build a timed logger callback that prints ``message`` replaced. | [
"Build",
"a",
"timed",
"logger",
"callback",
"that",
"prints",
"`",
"`",
"message",
"`",
"`",
"replaced",
"."
] | [
"\"\"\"Build a timed logger callback that prints ``message`` replaced.\r\n\r\n Parameters:\r\n message (string): a string that expects 2 placement %% variables,\r\n first for % complete from ``df_complete``, second from\r\n ``p_progress_arg[0]``.\r\n\r\n Returns:\r\n Functi... | [
{
"param": "message",
"type": null
}
] | {
"returns": [
{
"docstring": "Function with signature:\nlogger_callback(df_complete, psz_message, p_progress_arg)",
"docstring_tokens": [
"Function",
"with",
"signature",
":",
"logger_callback",
"(",
"df_complete",
"psz_message",
... |
d71e6b20db36929667bb6905795d11a9d94db00a | richpsharp/raster_calculations | raster_stats/__main__.py | [
"Apache-2.0"
] | Python | logger_callback | null | def logger_callback(df_complete, _, p_progress_arg):
"""Argument names come from the GDAL API for callbacks."""
try:
current_time = time.time()
if ((current_time - logger_callback.last_time) > 5.0 or
(df_complete == 1.0 and
logger_ca... | Argument names come from the GDAL API for callbacks. | Argument names come from the GDAL API for callbacks. | [
"Argument",
"names",
"come",
"from",
"the",
"GDAL",
"API",
"for",
"callbacks",
"."
] | def logger_callback(df_complete, _, p_progress_arg):
try:
current_time = time.time()
if ((current_time - logger_callback.last_time) > 5.0 or
(df_complete == 1.0 and
logger_callback.total_time >= 5.0)):
if p_progress_arg:
... | [
"def",
"logger_callback",
"(",
"df_complete",
",",
"_",
",",
"p_progress_arg",
")",
":",
"try",
":",
"current_time",
"=",
"time",
".",
"time",
"(",
")",
"if",
"(",
"(",
"current_time",
"-",
"logger_callback",
".",
"last_time",
")",
">",
"5.0",
"or",
"(",... | Argument names come from the GDAL API for callbacks. | [
"Argument",
"names",
"come",
"from",
"the",
"GDAL",
"API",
"for",
"callbacks",
"."
] | [
"\"\"\"Argument names come from the GDAL API for callbacks.\"\"\"",
"# In some multiprocess applications I was encountering a\r",
"# ``p_progress_arg`` of None. This is unexpected and I suspect\r",
"# was an issue for some kind of GDAL race condition. So I'm\r",
"# guarding against it here and reporting an ... | [
{
"param": "df_complete",
"type": null
},
{
"param": "_",
"type": null
},
{
"param": "p_progress_arg",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df_complete",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "_",
"type": null,
"docstring": null,
"docstring_tokens... |
6717b139ab66b5aefd4b5a88d340da210970f885 | richpsharp/raster_calculations | cna_align_to_mask.py | [
"Apache-2.0"
] | Python | warp_raster | null | def warp_raster(base_raster_path, mask_raster_path, resample_mode, target_raster_path):
"""Warp raster to exemplar's bounding box, cell size, and projection."""
base_projection_wkt = pygeoprocessing.get_raster_info(
base_raster_path)['projection_wkt']
if base_projection_wkt is None:
# assume... | Warp raster to exemplar's bounding box, cell size, and projection. | Warp raster to exemplar's bounding box, cell size, and projection. | [
"Warp",
"raster",
"to",
"exemplar",
"'",
"s",
"bounding",
"box",
"cell",
"size",
"and",
"projection",
"."
] | def warp_raster(base_raster_path, mask_raster_path, resample_mode, target_raster_path):
base_projection_wkt = pygeoprocessing.get_raster_info(
base_raster_path)['projection_wkt']
if base_projection_wkt is None:
LOGGER.warn(
f'{base_raster_path} has undefined projection, assuming WGS8... | [
"def",
"warp_raster",
"(",
"base_raster_path",
",",
"mask_raster_path",
",",
"resample_mode",
",",
"target_raster_path",
")",
":",
"base_projection_wkt",
"=",
"pygeoprocessing",
".",
"get_raster_info",
"(",
"base_raster_path",
")",
"[",
"'projection_wkt'",
"]",
"if",
... | Warp raster to exemplar's bounding box, cell size, and projection. | [
"Warp",
"raster",
"to",
"exemplar",
"'",
"s",
"bounding",
"box",
"cell",
"size",
"and",
"projection",
"."
] | [
"\"\"\"Warp raster to exemplar's bounding box, cell size, and projection.\"\"\"",
"# assume its wgs84 if not defined"
] | [
{
"param": "base_raster_path",
"type": null
},
{
"param": "mask_raster_path",
"type": null
},
{
"param": "resample_mode",
"type": null
},
{
"param": "target_raster_path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "base_raster_path",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mask_raster_path",
"type": null,
"docstring": null,
... |
6717b139ab66b5aefd4b5a88d340da210970f885 | richpsharp/raster_calculations | cna_align_to_mask.py | [
"Apache-2.0"
] | Python | copy_and_rehash_final_file | null | def copy_and_rehash_final_file(base_raster_path, target_dir):
"""Copy base to target and replace hash with current hash."""
target_md5_free_path = os.path.join(
target_dir,
re.sub('(.*)md5_[0-9a-f]+_(.*)', r"\1\2", os.path.basename(
base_raster_path)))
shutil.copyfile(base_raster... | Copy base to target and replace hash with current hash. | Copy base to target and replace hash with current hash. | [
"Copy",
"base",
"to",
"target",
"and",
"replace",
"hash",
"with",
"current",
"hash",
"."
] | def copy_and_rehash_final_file(base_raster_path, target_dir):
target_md5_free_path = os.path.join(
target_dir,
re.sub('(.*)md5_[0-9a-f]+_(.*)', r"\1\2", os.path.basename(
base_raster_path)))
shutil.copyfile(base_raster_path, target_md5_free_path)
ecoshard.hash_file(target_md5_fre... | [
"def",
"copy_and_rehash_final_file",
"(",
"base_raster_path",
",",
"target_dir",
")",
":",
"target_md5_free_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"target_dir",
",",
"re",
".",
"sub",
"(",
"'(.*)md5_[0-9a-f]+_(.*)'",
",",
"r\"\\1\\2\"",
",",
"os",
".",... | Copy base to target and replace hash with current hash. | [
"Copy",
"base",
"to",
"target",
"and",
"replace",
"hash",
"with",
"current",
"hash",
"."
] | [
"\"\"\"Copy base to target and replace hash with current hash.\"\"\""
] | [
{
"param": "base_raster_path",
"type": null
},
{
"param": "target_dir",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "base_raster_path",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "target_dir",
"type": null,
"docstring": null,
"do... |
6717b139ab66b5aefd4b5a88d340da210970f885 | richpsharp/raster_calculations | cna_align_to_mask.py | [
"Apache-2.0"
] | Python | mask_raster | <not_specific> | def mask_raster(base_raster_path, mask_raster_path, target_raster_path):
"""Mask base by mask setting nodata to nodata otherwise passthrough."""
mask_nodata = pygeoprocessing.get_raster_info(
mask_raster_path)['nodata'][0]
base_raster_info = pygeoprocessing.get_raster_info(base_raster_path)
base... | Mask base by mask setting nodata to nodata otherwise passthrough. | Mask base by mask setting nodata to nodata otherwise passthrough. | [
"Mask",
"base",
"by",
"mask",
"setting",
"nodata",
"to",
"nodata",
"otherwise",
"passthrough",
"."
] | def mask_raster(base_raster_path, mask_raster_path, target_raster_path):
mask_nodata = pygeoprocessing.get_raster_info(
mask_raster_path)['nodata'][0]
base_raster_info = pygeoprocessing.get_raster_info(base_raster_path)
base_nodata = base_raster_info['nodata'][0]
def _mask_op(base_array, mask_ar... | [
"def",
"mask_raster",
"(",
"base_raster_path",
",",
"mask_raster_path",
",",
"target_raster_path",
")",
":",
"mask_nodata",
"=",
"pygeoprocessing",
".",
"get_raster_info",
"(",
"mask_raster_path",
")",
"[",
"'nodata'",
"]",
"[",
"0",
"]",
"base_raster_info",
"=",
... | Mask base by mask setting nodata to nodata otherwise passthrough. | [
"Mask",
"base",
"by",
"mask",
"setting",
"nodata",
"to",
"nodata",
"otherwise",
"passthrough",
"."
] | [
"\"\"\"Mask base by mask setting nodata to nodata otherwise passthrough.\"\"\""
] | [
{
"param": "base_raster_path",
"type": null
},
{
"param": "mask_raster_path",
"type": null
},
{
"param": "target_raster_path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "base_raster_path",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mask_raster_path",
"type": null,
"docstring": null,
... |
6717b139ab66b5aefd4b5a88d340da210970f885 | richpsharp/raster_calculations | cna_align_to_mask.py | [
"Apache-2.0"
] | Python | _convert_to_density | <not_specific> | def _convert_to_density(
base_wgs84_raster_path, target_wgs84_density_raster_path):
"""Convert base WGS84 raster path to a per density raster path."""
base_raster_info = pygeoprocessing.get_raster_info(
base_wgs84_raster_path)
# xmin, ymin, xmax, ymax
_, lat_min, _, lat_max = base_raster... | Convert base WGS84 raster path to a per density raster path. | Convert base WGS84 raster path to a per density raster path. | [
"Convert",
"base",
"WGS84",
"raster",
"path",
"to",
"a",
"per",
"density",
"raster",
"path",
"."
] | def _convert_to_density(
base_wgs84_raster_path, target_wgs84_density_raster_path):
base_raster_info = pygeoprocessing.get_raster_info(
base_wgs84_raster_path)
_, lat_min, _, lat_max = base_raster_info['bounding_box']
_, n_rows = base_raster_info['raster_size']
m2_area_col = _create_lati... | [
"def",
"_convert_to_density",
"(",
"base_wgs84_raster_path",
",",
"target_wgs84_density_raster_path",
")",
":",
"base_raster_info",
"=",
"pygeoprocessing",
".",
"get_raster_info",
"(",
"base_wgs84_raster_path",
")",
"_",
",",
"lat_min",
",",
"_",
",",
"lat_max",
"=",
... | Convert base WGS84 raster path to a per density raster path. | [
"Convert",
"base",
"WGS84",
"raster",
"path",
"to",
"a",
"per",
"density",
"raster",
"path",
"."
] | [
"\"\"\"Convert base WGS84 raster path to a per density raster path.\"\"\"",
"# xmin, ymin, xmax, ymax"
] | [
{
"param": "base_wgs84_raster_path",
"type": null
},
{
"param": "target_wgs84_density_raster_path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "base_wgs84_raster_path",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "target_wgs84_density_raster_path",
"type": null,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.