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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6ebd7b7e6fc97086c6322adff65374929b60b816 | EdinburghGenomics/EGCG-Data-Deletion | project_report/project_report_latex.py | [
"MIT"
] | Python | _limit_cell_width | <not_specific> | def _limit_cell_width(rows, cell_widths):
"""
Limit the size of the text in the cells of specific columns.
When a cell has more characters than the limit, insert a new line.
It can only insert one new line.
:param rows: all rows of the table.
:param cell_widths: a dict wh... |
Limit the size of the text in the cells of specific columns.
When a cell has more characters than the limit, insert a new line.
It can only insert one new line.
:param rows: all rows of the table.
:param cell_widths: a dict where the key is the column number (starting from 0) an... | Limit the size of the text in the cells of specific columns.
When a cell has more characters than the limit, insert a new line.
It can only insert one new line. | [
"Limit",
"the",
"size",
"of",
"the",
"text",
"in",
"the",
"cells",
"of",
"specific",
"columns",
".",
"When",
"a",
"cell",
"has",
"more",
"characters",
"than",
"the",
"limit",
"insert",
"a",
"new",
"line",
".",
"It",
"can",
"only",
"insert",
"one",
"new... | def _limit_cell_width(rows, cell_widths):
new_rows = []
for row in rows:
new_row = []
new_rows.append(new_row)
for i, cell in enumerate(row):
if i in cell_widths and len(str(cell)) > cell_widths.get(i):
new_row.append(
... | [
"def",
"_limit_cell_width",
"(",
"rows",
",",
"cell_widths",
")",
":",
"new_rows",
"=",
"[",
"]",
"for",
"row",
"in",
"rows",
":",
"new_row",
"=",
"[",
"]",
"new_rows",
".",
"append",
"(",
"new_row",
")",
"for",
"i",
",",
"cell",
"in",
"enumerate",
"... | Limit the size of the text in the cells of specific columns. | [
"Limit",
"the",
"size",
"of",
"the",
"text",
"in",
"the",
"cells",
"of",
"specific",
"columns",
"."
] | [
"\"\"\"\n Limit the size of the text in the cells of specific columns.\n When a cell has more characters than the limit, insert a new line.\n It can only insert one new line.\n :param rows: all rows of the table.\n :param cell_widths: a dict where the key is the column number (sta... | [
{
"param": "rows",
"type": null
},
{
"param": "cell_widths",
"type": null
}
] | {
"returns": [
{
"docstring": "new rows modified if the character limit was reached.",
"docstring_tokens": [
"new",
"rows",
"modified",
"if",
"the",
"character",
"limit",
"was",
"reached",
"."
],
"type": null
... |
6ebd7b7e6fc97086c6322adff65374929b60b816 | EdinburghGenomics/EGCG-Data-Deletion | project_report/project_report_latex.py | [
"MIT"
] | Python | create_vertical_table | null | def create_vertical_table(container, header, rows, column_def=None, footer=None):
"""
Create a table with the specified header at the top in the provided container.
The table is created using the tabu package. http://mirrors.ibiblio.org/CTAN/macros/latex/contrib/tabu/tabu.pdf
The header ... |
Create a table with the specified header at the top in the provided container.
The table is created using the tabu package. http://mirrors.ibiblio.org/CTAN/macros/latex/contrib/tabu/tabu.pdf
The header will be formatted as bold.
:param container: The container where the table will be ad... | Create a table with the specified header at the top in the provided container.
The table is created using the tabu package. | [
"Create",
"a",
"table",
"with",
"the",
"specified",
"header",
"at",
"the",
"top",
"in",
"the",
"provided",
"container",
".",
"The",
"table",
"is",
"created",
"using",
"the",
"tabu",
"package",
"."
] | def create_vertical_table(container, header, rows, column_def=None, footer=None):
def add_footer_rows(foot):
if not isinstance(foot, list):
foot = [foot]
for f in foot:
data_table.add_row((MultiColumn(ncol - 1, align='l', data=f), ''))
ncol = len(h... | [
"def",
"create_vertical_table",
"(",
"container",
",",
"header",
",",
"rows",
",",
"column_def",
"=",
"None",
",",
"footer",
"=",
"None",
")",
":",
"def",
"add_footer_rows",
"(",
"foot",
")",
":",
"if",
"not",
"isinstance",
"(",
"foot",
",",
"list",
")",... | Create a table with the specified header at the top in the provided container. | [
"Create",
"a",
"table",
"with",
"the",
"specified",
"header",
"at",
"the",
"top",
"in",
"the",
"provided",
"container",
"."
] | [
"\"\"\"\n Create a table with the specified header at the top in the provided container.\n The table is created using the tabu package. http://mirrors.ibiblio.org/CTAN/macros/latex/contrib/tabu/tabu.pdf\n The header will be formatted as bold.\n :param container: The container where the t... | [
{
"param": "container",
"type": null
},
{
"param": "header",
"type": null
},
{
"param": "rows",
"type": null
},
{
"param": "column_def",
"type": null
},
{
"param": "footer",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "container",
"type": null,
"docstring": "The container where the table will be added.",
"docstring_tokens": [
"The",
"container",
"where",
"the",
"table",
"will",
"be",
... |
6ebd7b7e6fc97086c6322adff65374929b60b816 | EdinburghGenomics/EGCG-Data-Deletion | project_report/project_report_latex.py | [
"MIT"
] | Python | create_horizontal_table | null | def create_horizontal_table(container, rows):
""" Meant to be used for only two columns where the header is the first column"""
# Convert cell containing lists into multilines cells
converted_rows = []
for row in rows:
converted_row = []
for cell in row:
... | Meant to be used for only two columns where the header is the first column | Meant to be used for only two columns where the header is the first column | [
"Meant",
"to",
"be",
"used",
"for",
"only",
"two",
"columns",
"where",
"the",
"header",
"is",
"the",
"first",
"column"
] | def create_horizontal_table(container, rows):
converted_rows = []
for row in rows:
converted_row = []
for cell in row:
if isinstance(cell, list):
converted_row.append('\n'.join(cell))
else:
converted_row.appe... | [
"def",
"create_horizontal_table",
"(",
"container",
",",
"rows",
")",
":",
"converted_rows",
"=",
"[",
"]",
"for",
"row",
"in",
"rows",
":",
"converted_row",
"=",
"[",
"]",
"for",
"cell",
"in",
"row",
":",
"if",
"isinstance",
"(",
"cell",
",",
"list",
... | Meant to be used for only two columns where the header is the first column | [
"Meant",
"to",
"be",
"used",
"for",
"only",
"two",
"columns",
"where",
"the",
"header",
"is",
"the",
"first",
"column"
] | [
"\"\"\" Meant to be used for only two columns where the header is the first column\"\"\"",
"# Convert cell containing lists into multilines cells"
] | [
{
"param": "container",
"type": null
},
{
"param": "rows",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "container",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rows",
"type": null,
"docstring": null,
"docstring_token... |
6ebd7b7e6fc97086c6322adff65374929b60b816 | EdinburghGenomics/EGCG-Data-Deletion | project_report/project_report_latex.py | [
"MIT"
] | Python | format_table_footer_line | <not_specific> | def format_table_footer_line(definitions, superscript):
"""
Take a footer rows as list of tuples. The tuple have two elements.
The first element will be formatted as bold.
:param superscript: superscripted text that appear at the beginning of the line
:param definitions: lists o... |
Take a footer rows as list of tuples. The tuple have two elements.
The first element will be formatted as bold.
:param superscript: superscripted text that appear at the beginning of the line
:param definitions: lists of tuples containing the definitions to be added on that line
... | Take a footer rows as list of tuples. The tuple have two elements.
The first element will be formatted as bold. | [
"Take",
"a",
"footer",
"rows",
"as",
"list",
"of",
"tuples",
".",
"The",
"tuple",
"have",
"two",
"elements",
".",
"The",
"first",
"element",
"will",
"be",
"formatted",
"as",
"bold",
"."
] | def format_table_footer_line(definitions, superscript):
formatted_latex = []
if superscript:
formatted_latex.append(NoEscape(r'\textsuperscript{%s}' % superscript))
for def_element in definitions:
formatted_latex.append(bold(def_element[0]))
formatted_latex.ap... | [
"def",
"format_table_footer_line",
"(",
"definitions",
",",
"superscript",
")",
":",
"formatted_latex",
"=",
"[",
"]",
"if",
"superscript",
":",
"formatted_latex",
".",
"append",
"(",
"NoEscape",
"(",
"r'\\textsuperscript{%s}'",
"%",
"superscript",
")",
")",
"for"... | Take a footer rows as list of tuples. | [
"Take",
"a",
"footer",
"rows",
"as",
"list",
"of",
"tuples",
"."
] | [
"\"\"\"\n Take a footer rows as list of tuples. The tuple have two elements.\n The first element will be formatted as bold.\n\n :param superscript: superscripted text that appear at the beginning of the line\n :param definitions: lists of tuples containing the definitions to be added on ... | [
{
"param": "definitions",
"type": null
},
{
"param": "superscript",
"type": null
}
] | {
"returns": [
{
"docstring": "list of latex formatted rows",
"docstring_tokens": [
"list",
"of",
"latex",
"formatted",
"rows"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "definitions",
"type": null,
... |
63f0c93b7a8b8b111ab8fe01b7e54df605aee70f | EdinburghGenomics/EGCG-Data-Deletion | project_report/pylatex_ext.py | [
"MIT"
] | Python | add_text | <not_specific> | def add_text(doc, t):
"""
Generic function to add text to a pylatex document.
Split the provided text to escape latex commands and then add to the container.
"""
current_pos = 0
for m in re.finditer(r'latex::(.+?)::', t):
doc.append(t[current_pos: m.start()])
doc.append(NoEscape(... |
Generic function to add text to a pylatex document.
Split the provided text to escape latex commands and then add to the container.
| Generic function to add text to a pylatex document.
Split the provided text to escape latex commands and then add to the container. | [
"Generic",
"function",
"to",
"add",
"text",
"to",
"a",
"pylatex",
"document",
".",
"Split",
"the",
"provided",
"text",
"to",
"escape",
"latex",
"commands",
"and",
"then",
"add",
"to",
"the",
"container",
"."
] | def add_text(doc, t):
current_pos = 0
for m in re.finditer(r'latex::(.+?)::', t):
doc.append(t[current_pos: m.start()])
doc.append(NoEscape(' ' + m.group(1) + ' '))
current_pos = m.end()
doc.append(t[current_pos:])
return doc | [
"def",
"add_text",
"(",
"doc",
",",
"t",
")",
":",
"current_pos",
"=",
"0",
"for",
"m",
"in",
"re",
".",
"finditer",
"(",
"r'latex::(.+?)::'",
",",
"t",
")",
":",
"doc",
".",
"append",
"(",
"t",
"[",
"current_pos",
":",
"m",
".",
"start",
"(",
")... | Generic function to add text to a pylatex document. | [
"Generic",
"function",
"to",
"add",
"text",
"to",
"a",
"pylatex",
"document",
"."
] | [
"\"\"\"\n Generic function to add text to a pylatex document.\n Split the provided text to escape latex commands and then add to the container.\n \"\"\""
] | [
{
"param": "doc",
"type": null
},
{
"param": "t",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "doc",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "t",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
601e9995c33dd418340313c2b5c75332999a7d70 | EdinburghGenomics/EGCG-Data-Deletion | bin/reference_data.py | [
"MIT"
] | Python | download_data | null | def download_data(self):
"""
Download data retrieve the reference fasta file and the vcf file.
It should provide the fasta file uncompressed but the vcf file compressed with gzip.
"""
raise NotImplementedError |
Download data retrieve the reference fasta file and the vcf file.
It should provide the fasta file uncompressed but the vcf file compressed with gzip.
| Download data retrieve the reference fasta file and the vcf file.
It should provide the fasta file uncompressed but the vcf file compressed with gzip. | [
"Download",
"data",
"retrieve",
"the",
"reference",
"fasta",
"file",
"and",
"the",
"vcf",
"file",
".",
"It",
"should",
"provide",
"the",
"fasta",
"file",
"uncompressed",
"but",
"the",
"vcf",
"file",
"compressed",
"with",
"gzip",
"."
] | def download_data(self):
raise NotImplementedError | [
"def",
"download_data",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | Download data retrieve the reference fasta file and the vcf file. | [
"Download",
"data",
"retrieve",
"the",
"reference",
"fasta",
"file",
"and",
"the",
"vcf",
"file",
"."
] | [
"\"\"\"\n Download data retrieve the reference fasta file and the vcf file.\n It should provide the fasta file uncompressed but the vcf file compressed with gzip.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
601e9995c33dd418340313c2b5c75332999a7d70 | EdinburghGenomics/EGCG-Data-Deletion | bin/reference_data.py | [
"MIT"
] | Python | prepare_data | null | def prepare_data(self):
"""Prepare the reference data by indexing the fasta and vcf files"""
self.info('Indexing reference genome data')
if not util.find_file(self.reference_fasta + '.fai'):
if os.path.isfile(self.reference_fasta + '.gz.fai'):
os.rename(self.referenc... | Prepare the reference data by indexing the fasta and vcf files | Prepare the reference data by indexing the fasta and vcf files | [
"Prepare",
"the",
"reference",
"data",
"by",
"indexing",
"the",
"fasta",
"and",
"vcf",
"files"
] | def prepare_data(self):
self.info('Indexing reference genome data')
if not util.find_file(self.reference_fasta + '.fai'):
if os.path.isfile(self.reference_fasta + '.gz.fai'):
os.rename(self.reference_fasta + '.gz.fai', self.reference_fasta + '.fai')
else:
... | [
"def",
"prepare_data",
"(",
"self",
")",
":",
"self",
".",
"info",
"(",
"'Indexing reference genome data'",
")",
"if",
"not",
"util",
".",
"find_file",
"(",
"self",
".",
"reference_fasta",
"+",
"'.fai'",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
... | Prepare the reference data by indexing the fasta and vcf files | [
"Prepare",
"the",
"reference",
"data",
"by",
"indexing",
"the",
"fasta",
"and",
"vcf",
"files"
] | [
"\"\"\"Prepare the reference data by indexing the fasta and vcf files\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
601e9995c33dd418340313c2b5c75332999a7d70 | EdinburghGenomics/EGCG-Data-Deletion | bin/reference_data.py | [
"MIT"
] | Python | validate_data | null | def validate_data(self):
"""
Validate that the reference data conforms to some expectations such as:
- The vcf file ran through GATK ValidateVariants without error.
"""
if self.reference_variation:
if 'faidx' in self.procs:
self.procs['faidx'].wait()... |
Validate that the reference data conforms to some expectations such as:
- The vcf file ran through GATK ValidateVariants without error.
| Validate that the reference data conforms to some expectations such as:
The vcf file ran through GATK ValidateVariants without error. | [
"Validate",
"that",
"the",
"reference",
"data",
"conforms",
"to",
"some",
"expectations",
"such",
"as",
":",
"The",
"vcf",
"file",
"ran",
"through",
"GATK",
"ValidateVariants",
"without",
"error",
"."
] | def validate_data(self):
if self.reference_variation:
if 'faidx' in self.procs:
self.procs['faidx'].wait()
self.procs['CreateSequenceDictionary'].wait()
self.procs['ValidateVariants'] = self.run_background(
'java -Xmx20G -jar %s -T ValidateVari... | [
"def",
"validate_data",
"(",
"self",
")",
":",
"if",
"self",
".",
"reference_variation",
":",
"if",
"'faidx'",
"in",
"self",
".",
"procs",
":",
"self",
".",
"procs",
"[",
"'faidx'",
"]",
".",
"wait",
"(",
")",
"self",
".",
"procs",
"[",
"'CreateSequenc... | Validate that the reference data conforms to some expectations such as:
The vcf file ran through GATK ValidateVariants without error. | [
"Validate",
"that",
"the",
"reference",
"data",
"conforms",
"to",
"some",
"expectations",
"such",
"as",
":",
"The",
"vcf",
"file",
"ran",
"through",
"GATK",
"ValidateVariants",
"without",
"error",
"."
] | [
"\"\"\"\n Validate that the reference data conforms to some expectations such as:\n - The vcf file ran through GATK ValidateVariants without error.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
601e9995c33dd418340313c2b5c75332999a7d70 | EdinburghGenomics/EGCG-Data-Deletion | bin/reference_data.py | [
"MIT"
] | Python | prepare_metadata | null | def prepare_metadata(self):
"""Initial preparation of the genome metadata that will be uploaded to the REST API."""
self.payload.update({
'tools_used': {
'picard': self.check_stderr([self.tools['picard'], 'CreateSequenceDictionary', '--version']),
'tabix': sel... | Initial preparation of the genome metadata that will be uploaded to the REST API. | Initial preparation of the genome metadata that will be uploaded to the REST API. | [
"Initial",
"preparation",
"of",
"the",
"genome",
"metadata",
"that",
"will",
"be",
"uploaded",
"to",
"the",
"REST",
"API",
"."
] | def prepare_metadata(self):
self.payload.update({
'tools_used': {
'picard': self.check_stderr([self.tools['picard'], 'CreateSequenceDictionary', '--version']),
'tabix': self.check_stderr([self.tools['tabix']]).split('\n')[0].split(' ')[1],
'bwa': self.... | [
"def",
"prepare_metadata",
"(",
"self",
")",
":",
"self",
".",
"payload",
".",
"update",
"(",
"{",
"'tools_used'",
":",
"{",
"'picard'",
":",
"self",
".",
"check_stderr",
"(",
"[",
"self",
".",
"tools",
"[",
"'picard'",
"]",
",",
"'CreateSequenceDictionary... | Initial preparation of the genome metadata that will be uploaded to the REST API. | [
"Initial",
"preparation",
"of",
"the",
"genome",
"metadata",
"that",
"will",
"be",
"uploaded",
"to",
"the",
"REST",
"API",
"."
] | [
"\"\"\"Initial preparation of the genome metadata that will be uploaded to the REST API.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
601e9995c33dd418340313c2b5c75332999a7d70 | EdinburghGenomics/EGCG-Data-Deletion | bin/reference_data.py | [
"MIT"
] | Python | finish_metadata | null | def finish_metadata(self):
"""Finalise the genome metadata that will be uploaded to the REST API."""
self.payload.update(
assembly_name=self.genome_version,
species=self.species,
date_added=self.now()
)
project_whitelist = input('Enter a comma-separat... | Finalise the genome metadata that will be uploaded to the REST API. | Finalise the genome metadata that will be uploaded to the REST API. | [
"Finalise",
"the",
"genome",
"metadata",
"that",
"will",
"be",
"uploaded",
"to",
"the",
"REST",
"API",
"."
] | def finish_metadata(self):
self.payload.update(
assembly_name=self.genome_version,
species=self.species,
date_added=self.now()
)
project_whitelist = input('Enter a comma-separated list of projects to whitelist for this genome. ')
if project_whitelist:
... | [
"def",
"finish_metadata",
"(",
"self",
")",
":",
"self",
".",
"payload",
".",
"update",
"(",
"assembly_name",
"=",
"self",
".",
"genome_version",
",",
"species",
"=",
"self",
".",
"species",
",",
"date_added",
"=",
"self",
".",
"now",
"(",
")",
")",
"p... | Finalise the genome metadata that will be uploaded to the REST API. | [
"Finalise",
"the",
"genome",
"metadata",
"that",
"will",
"be",
"uploaded",
"to",
"the",
"REST",
"API",
"."
] | [
"\"\"\"Finalise the genome metadata that will be uploaded to the REST API.\"\"\"",
"# human"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
601e9995c33dd418340313c2b5c75332999a7d70 | EdinburghGenomics/EGCG-Data-Deletion | bin/reference_data.py | [
"MIT"
] | Python | upload_to_rest_api | <not_specific> | def upload_to_rest_api(self):
"""Upload the genome and optionally the species metadata."""
if not self.upload:
print(self.payload)
return
rest_communication.post_or_patch('genomes', [self.payload], id_field='assembly_name')
species = rest_communication.get_docum... | Upload the genome and optionally the species metadata. | Upload the genome and optionally the species metadata. | [
"Upload",
"the",
"genome",
"and",
"optionally",
"the",
"species",
"metadata",
"."
] | def upload_to_rest_api(self):
if not self.upload:
print(self.payload)
return
rest_communication.post_or_patch('genomes', [self.payload], id_field='assembly_name')
species = rest_communication.get_document('species', where={'name': self.species})
if species:
... | [
"def",
"upload_to_rest_api",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"upload",
":",
"print",
"(",
"self",
".",
"payload",
")",
"return",
"rest_communication",
".",
"post_or_patch",
"(",
"'genomes'",
",",
"[",
"self",
".",
"payload",
"]",
",",
"i... | Upload the genome and optionally the species metadata. | [
"Upload",
"the",
"genome",
"and",
"optionally",
"the",
"species",
"metadata",
"."
] | [
"\"\"\"Upload the genome and optionally the species metadata.\"\"\"",
"# FIXME: Probably should expose the taxid in EGCG-Core so we do not have to access the private methods"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
601e9995c33dd418340313c2b5c75332999a7d70 | EdinburghGenomics/EGCG-Data-Deletion | bin/reference_data.py | [
"MIT"
] | Python | check_stderr | <not_specific> | def check_stderr(argv):
"""Capture output from tabix and picard --version commands, which print to stderr and exit with status 1."""
p = subprocess.Popen(argv, stderr=subprocess.PIPE)
out, err = p.communicate()
return err.decode().strip() | Capture output from tabix and picard --version commands, which print to stderr and exit with status 1. | Capture output from tabix and picard --version commands, which print to stderr and exit with status 1. | [
"Capture",
"output",
"from",
"tabix",
"and",
"picard",
"--",
"version",
"commands",
"which",
"print",
"to",
"stderr",
"and",
"exit",
"with",
"status",
"1",
"."
] | def check_stderr(argv):
p = subprocess.Popen(argv, stderr=subprocess.PIPE)
out, err = p.communicate()
return err.decode().strip() | [
"def",
"check_stderr",
"(",
"argv",
")",
":",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"argv",
",",
"stderr",
"=",
"subprocess",
".",
"PIPE",
")",
"out",
",",
"err",
"=",
"p",
".",
"communicate",
"(",
")",
"return",
"err",
".",
"decode",
"(",
")"... | Capture output from tabix and picard --version commands, which print to stderr and exit with status 1. | [
"Capture",
"output",
"from",
"tabix",
"and",
"picard",
"--",
"version",
"commands",
"which",
"print",
"to",
"stderr",
"and",
"exit",
"with",
"status",
"1",
"."
] | [
"\"\"\"Capture output from tabix and picard --version commands, which print to stderr and exit with status 1.\"\"\""
] | [
{
"param": "argv",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "argv",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
601e9995c33dd418340313c2b5c75332999a7d70 | EdinburghGenomics/EGCG-Data-Deletion | bin/reference_data.py | [
"MIT"
] | Python | download_data | null | def download_data(self):
"""
Download reference and variation file from Ensembl and decompress if necessary.
"""
self.info('Downloading reference genome')
base_dir = '%s/fasta/%s' % (self.ensembl_base_url, self.ftp_species)
ls = self.ftp.nlst(base_dir)
if os.path... |
Download reference and variation file from Ensembl and decompress if necessary.
| Download reference and variation file from Ensembl and decompress if necessary. | [
"Download",
"reference",
"and",
"variation",
"file",
"from",
"Ensembl",
"and",
"decompress",
"if",
"necessary",
"."
] | def download_data(self):
self.info('Downloading reference genome')
base_dir = '%s/fasta/%s' % (self.ensembl_base_url, self.ftp_species)
ls = self.ftp.nlst(base_dir)
if os.path.join(base_dir, 'dna_index') in ls:
ls = self.ftp.nlst(os.path.join(base_dir, 'dna_index'))
e... | [
"def",
"download_data",
"(",
"self",
")",
":",
"self",
".",
"info",
"(",
"'Downloading reference genome'",
")",
"base_dir",
"=",
"'%s/fasta/%s'",
"%",
"(",
"self",
".",
"ensembl_base_url",
",",
"self",
".",
"ftp_species",
")",
"ls",
"=",
"self",
".",
"ftp",
... | Download reference and variation file from Ensembl and decompress if necessary. | [
"Download",
"reference",
"and",
"variation",
"file",
"from",
"Ensembl",
"and",
"decompress",
"if",
"necessary",
"."
] | [
"\"\"\"\n Download reference and variation file from Ensembl and decompress if necessary.\n \"\"\"",
"# TODO: Add support multiple chromosome files if toplevel does not exist",
"# this should include the index file"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
601e9995c33dd418340313c2b5c75332999a7d70 | EdinburghGenomics/EGCG-Data-Deletion | bin/reference_data.py | [
"MIT"
] | Python | upload_species_without_genome | null | def upload_species_without_genome(species_name):
"""
This function only adds a new species without the need for a new genome.
An existing genome will be associated with the new species.
"""
scientific_name = ncbi.get_species_name(species_name)
if not scientific_name:
raise EGCGError('Spe... |
This function only adds a new species without the need for a new genome.
An existing genome will be associated with the new species.
| This function only adds a new species without the need for a new genome.
An existing genome will be associated with the new species. | [
"This",
"function",
"only",
"adds",
"a",
"new",
"species",
"without",
"the",
"need",
"for",
"a",
"new",
"genome",
".",
"An",
"existing",
"genome",
"will",
"be",
"associated",
"with",
"the",
"new",
"species",
"."
] | def upload_species_without_genome(species_name):
scientific_name = ncbi.get_species_name(species_name)
if not scientific_name:
raise EGCGError('Species %s could not be resolved in NCBI please check the spelling.', species_name)
species = rest_communication.get_document('species', where={'name': scie... | [
"def",
"upload_species_without_genome",
"(",
"species_name",
")",
":",
"scientific_name",
"=",
"ncbi",
".",
"get_species_name",
"(",
"species_name",
")",
"if",
"not",
"scientific_name",
":",
"raise",
"EGCGError",
"(",
"'Species %s could not be resolved in NCBI please check ... | This function only adds a new species without the need for a new genome. | [
"This",
"function",
"only",
"adds",
"a",
"new",
"species",
"without",
"the",
"need",
"for",
"a",
"new",
"genome",
"."
] | [
"\"\"\"\n This function only adds a new species without the need for a new genome.\n An existing genome will be associated with the new species.\n \"\"\""
] | [
{
"param": "species_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "species_name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6042e814504bc390262217b2bea73468ccbb2d3b | fortifyadmin/fortifyapi | fortifyapi/fortify.py | [
"MIT"
] | Python | bulk_create_new_application_version_request | <not_specific> | def bulk_create_new_application_version_request(self, version_id, development_phase, development_strategy,
accessibility, business_risk_ranking, custom_attributes=[]):
"""
Creates a new Application Version by using the Bulk Request API. 'create_new_pro... |
Creates a new Application Version by using the Bulk Request API. 'create_new_project_version' must be used
before calling this method.
:param version_id: Version ID
:param development_phase: Development Phase GUID of Version
:param development_strategy: Development Strategy GUID... | Creates a new Application Version by using the Bulk Request API. 'create_new_project_version' must be used
before calling this method. | [
"Creates",
"a",
"new",
"Application",
"Version",
"by",
"using",
"the",
"Bulk",
"Request",
"API",
".",
"'",
"create_new_project_version",
"'",
"must",
"be",
"used",
"before",
"calling",
"this",
"method",
"."
] | def bulk_create_new_application_version_request(self, version_id, development_phase, development_strategy,
accessibility, business_risk_ranking, custom_attributes=[]):
data = self._bulk_format_new_application_version_payload(version_id=version_id,
... | [
"def",
"bulk_create_new_application_version_request",
"(",
"self",
",",
"version_id",
",",
"development_phase",
",",
"development_strategy",
",",
"accessibility",
",",
"business_risk_ranking",
",",
"custom_attributes",
"=",
"[",
"]",
")",
":",
"data",
"=",
"self",
"."... | Creates a new Application Version by using the Bulk Request API. | [
"Creates",
"a",
"new",
"Application",
"Version",
"by",
"using",
"the",
"Bulk",
"Request",
"API",
"."
] | [
"\"\"\"\n Creates a new Application Version by using the Bulk Request API. 'create_new_project_version' must be used\n before calling this method.\n :param version_id: Version ID\n :param development_phase: Development Phase GUID of Version\n :param development_strategy: Developme... | [
{
"param": "self",
"type": null
},
{
"param": "version_id",
"type": null
},
{
"param": "development_phase",
"type": null
},
{
"param": "development_strategy",
"type": null
},
{
"param": "accessibility",
"type": null
},
{
"param": "business_risk_ranking... | {
"returns": [
{
"docstring": "A response object containing the newly created project and project version",
"docstring_tokens": [
"A",
"response",
"object",
"containing",
"the",
"newly",
"created",
"project",
"and",
"proje... |
6042e814504bc390262217b2bea73468ccbb2d3b | fortifyadmin/fortifyapi | fortifyapi/fortify.py | [
"MIT"
] | Python | delete_application_version | <not_specific> | def delete_application_version(self, id):
"""
Delete a given application or project version from SSC
:param id: Project Version ID
:return:
"""
url = "/api/v1/projectVersions/" + str(id)
return self._request('DELETE', url) |
Delete a given application or project version from SSC
:param id: Project Version ID
:return:
| Delete a given application or project version from SSC | [
"Delete",
"a",
"given",
"application",
"or",
"project",
"version",
"from",
"SSC"
] | def delete_application_version(self, id):
url = "/api/v1/projectVersions/" + str(id)
return self._request('DELETE', url) | [
"def",
"delete_application_version",
"(",
"self",
",",
"id",
")",
":",
"url",
"=",
"\"/api/v1/projectVersions/\"",
"+",
"str",
"(",
"id",
")",
"return",
"self",
".",
"_request",
"(",
"'DELETE'",
",",
"url",
")"
] | Delete a given application or project version from SSC | [
"Delete",
"a",
"given",
"application",
"or",
"project",
"version",
"from",
"SSC"
] | [
"\"\"\"\n Delete a given application or project version from SSC\n :param id: Project Version ID\n :return:\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "id",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
6042e814504bc390262217b2bea73468ccbb2d3b | fortifyadmin/fortifyapi | fortifyapi/fortify.py | [
"MIT"
] | Python | download_artifact | <not_specific> | def download_artifact(self, artifact_id):
"""
You might use this method like this, for example
api = FortifyApi("https://my-fortify-server:my-port", token=get_token())
response, file_name = api.download_artifact_scan("my-id")
if response.success:
file_... |
You might use this method like this, for example
api = FortifyApi("https://my-fortify-server:my-port", token=get_token())
response, file_name = api.download_artifact_scan("my-id")
if response.success:
file_content = response.data
with open('/p... |
We've coded this for the entire file to load into memory. A future change may be to permit
streaming/chunking of the file and handing back a stream instead of content. | [
"We",
"'",
"ve",
"coded",
"this",
"for",
"the",
"entire",
"file",
"to",
"load",
"into",
"memory",
".",
"A",
"future",
"change",
"may",
"be",
"to",
"permit",
"streaming",
"/",
"chunking",
"of",
"the",
"file",
"and",
"handing",
"back",
"a",
"stream",
"in... | def download_artifact(self, artifact_id):
file_token = self.get_file_token('DOWNLOAD').data['data']['token']
url = "/download/artifactDownload.html?mat=" + file_token + "&id=" + str(
artifact_id) + "&clientVersion=" + self.client_version
headers = {
'Accept': 'text/html,a... | [
"def",
"download_artifact",
"(",
"self",
",",
"artifact_id",
")",
":",
"file_token",
"=",
"self",
".",
"get_file_token",
"(",
"'DOWNLOAD'",
")",
".",
"data",
"[",
"'data'",
"]",
"[",
"'token'",
"]",
"url",
"=",
"\"/download/artifactDownload.html?mat=\"",
"+",
... | You might use this method like this, for example
api = FortifyApi("https://my-fortify-server:my-port", token=get_token())
response, file_name = api.download_artifact_scan("my-id")
if response.success:
file_content = response.data
with open('/path/to/some/folder/' + file_name, 'wb') as f:
f.write(file_content)
else:
pri... | [
"You",
"might",
"use",
"this",
"method",
"like",
"this",
"for",
"example",
"api",
"=",
"FortifyApi",
"(",
"\"",
"https",
":",
"//",
"my",
"-",
"fortify",
"-",
"server",
":",
"my",
"-",
"port",
"\"",
"token",
"=",
"get_token",
"()",
")",
"response",
"... | [
"\"\"\"\n You might use this method like this, for example\n api = FortifyApi(\"https://my-fortify-server:my-port\", token=get_token())\n response, file_name = api.download_artifact_scan(\"my-id\")\n if response.success:\n file_content = response.data\n ... | [
{
"param": "self",
"type": null
},
{
"param": "artifact_id",
"type": null
}
] | {
"returns": [
{
"docstring": "binary file data and file name",
"docstring_tokens": [
"binary",
"file",
"data",
"and",
"file",
"name"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": nul... |
6042e814504bc390262217b2bea73468ccbb2d3b | fortifyadmin/fortifyapi | fortifyapi/fortify.py | [
"MIT"
] | Python | download_artifact_scan | <not_specific> | def download_artifact_scan(self, artifact_id):
"""
You might use this method like this, for example
api = FortifyApi("https://my-fortify-server:my-port", token=get_token())
response, file_name = api.download_artifact_scan("my-id")
if response.success:
... |
You might use this method like this, for example
api = FortifyApi("https://my-fortify-server:my-port", token=get_token())
response, file_name = api.download_artifact_scan("my-id")
if response.success:
file_content = response.data
with open('/p... |
We've coded this for the entire file to load into memory. A future change may be to permit
streaming/chunking of the file and handing back a stream instead of content. | [
"We",
"'",
"ve",
"coded",
"this",
"for",
"the",
"entire",
"file",
"to",
"load",
"into",
"memory",
".",
"A",
"future",
"change",
"may",
"be",
"to",
"permit",
"streaming",
"/",
"chunking",
"of",
"the",
"file",
"and",
"handing",
"back",
"a",
"stream",
"in... | def download_artifact_scan(self, artifact_id):
file_token = self.get_file_token('DOWNLOAD').data['data']['token']
url = "/download/currentStateFprDownload.html?mat=" + file_token + "&id=" + str(
artifact_id) + "&clientVersion=" + self.client_version + "&includeSource=true"
headers = ... | [
"def",
"download_artifact_scan",
"(",
"self",
",",
"artifact_id",
")",
":",
"file_token",
"=",
"self",
".",
"get_file_token",
"(",
"'DOWNLOAD'",
")",
".",
"data",
"[",
"'data'",
"]",
"[",
"'token'",
"]",
"url",
"=",
"\"/download/currentStateFprDownload.html?mat=\"... | You might use this method like this, for example
api = FortifyApi("https://my-fortify-server:my-port", token=get_token())
response, file_name = api.download_artifact_scan("my-id")
if response.success:
file_content = response.data
with open('/path/to/some/folder/' + file_name, 'wb') as f:
f.write(file_content)
else:
pri... | [
"You",
"might",
"use",
"this",
"method",
"like",
"this",
"for",
"example",
"api",
"=",
"FortifyApi",
"(",
"\"",
"https",
":",
"//",
"my",
"-",
"fortify",
"-",
"server",
":",
"my",
"-",
"port",
"\"",
"token",
"=",
"get_token",
"()",
")",
"response",
"... | [
"\"\"\"\n You might use this method like this, for example\n api = FortifyApi(\"https://my-fortify-server:my-port\", token=get_token())\n response, file_name = api.download_artifact_scan(\"my-id\")\n if response.success:\n file_content = response.data\n ... | [
{
"param": "self",
"type": null
},
{
"param": "artifact_id",
"type": null
}
] | {
"returns": [
{
"docstring": "binary file data and file name",
"docstring_tokens": [
"binary",
"file",
"data",
"and",
"file",
"name"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": nul... |
6042e814504bc390262217b2bea73468ccbb2d3b | fortifyadmin/fortifyapi | fortifyapi/fortify.py | [
"MIT"
] | Python | delete_token | <not_specific> | def delete_token(self, token_id):
"""
Delete a token by ID from the auth-token-controller
:param id:
:return:
"""
url = "/api/v1/tokens/" + str(token_id)
return self._request('DELETE', url) |
Delete a token by ID from the auth-token-controller
:param id:
:return:
| Delete a token by ID from the auth-token-controller | [
"Delete",
"a",
"token",
"by",
"ID",
"from",
"the",
"auth",
"-",
"token",
"-",
"controller"
] | def delete_token(self, token_id):
url = "/api/v1/tokens/" + str(token_id)
return self._request('DELETE', url) | [
"def",
"delete_token",
"(",
"self",
",",
"token_id",
")",
":",
"url",
"=",
"\"/api/v1/tokens/\"",
"+",
"str",
"(",
"token_id",
")",
"return",
"self",
".",
"_request",
"(",
"'DELETE'",
",",
"url",
")"
] | Delete a token by ID from the auth-token-controller | [
"Delete",
"a",
"token",
"by",
"ID",
"from",
"the",
"auth",
"-",
"token",
"-",
"controller"
] | [
"\"\"\"\n Delete a token by ID from the auth-token-controller\n :param id:\n :return:\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "token_id",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
6042e814504bc390262217b2bea73468ccbb2d3b | fortifyadmin/fortifyapi | fortifyapi/fortify.py | [
"MIT"
] | Python | delete_all_user_tokens | <not_specific> | def delete_all_user_tokens(self):
"""
Delete all tokens by user from the auth-token-controller
:return:
"""
url = '/api/v1/tokens' + '?all=true'
return self._request('DELETE', url) |
Delete all tokens by user from the auth-token-controller
:return:
| Delete all tokens by user from the auth-token-controller | [
"Delete",
"all",
"tokens",
"by",
"user",
"from",
"the",
"auth",
"-",
"token",
"-",
"controller"
] | def delete_all_user_tokens(self):
url = '/api/v1/tokens' + '?all=true'
return self._request('DELETE', url) | [
"def",
"delete_all_user_tokens",
"(",
"self",
")",
":",
"url",
"=",
"'/api/v1/tokens'",
"+",
"'?all=true'",
"return",
"self",
".",
"_request",
"(",
"'DELETE'",
",",
"url",
")"
] | Delete all tokens by user from the auth-token-controller | [
"Delete",
"all",
"tokens",
"by",
"user",
"from",
"the",
"auth",
"-",
"token",
"-",
"controller"
] | [
"\"\"\"\n Delete all tokens by user from the auth-token-controller\n :return:\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
6042e814504bc390262217b2bea73468ccbb2d3b | fortifyadmin/fortifyapi | fortifyapi/fortify.py | [
"MIT"
] | Python | delete_rulepack | <not_specific> | def delete_rulepack(self, rulepack_id):
"""
Delete a given rulepack by ID
:param rulepack_id:
:return:
"""
url = "/api/v1/coreRulepacks/" + str(rulepack_id)
return self._request('DELETE', url) |
Delete a given rulepack by ID
:param rulepack_id:
:return:
| Delete a given rulepack by ID | [
"Delete",
"a",
"given",
"rulepack",
"by",
"ID"
] | def delete_rulepack(self, rulepack_id):
url = "/api/v1/coreRulepacks/" + str(rulepack_id)
return self._request('DELETE', url) | [
"def",
"delete_rulepack",
"(",
"self",
",",
"rulepack_id",
")",
":",
"url",
"=",
"\"/api/v1/coreRulepacks/\"",
"+",
"str",
"(",
"rulepack_id",
")",
"return",
"self",
".",
"_request",
"(",
"'DELETE'",
",",
"url",
")"
] | Delete a given rulepack by ID | [
"Delete",
"a",
"given",
"rulepack",
"by",
"ID"
] | [
"\"\"\"\n Delete a given rulepack by ID\n :param rulepack_id:\n :return:\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "rulepack_id",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
6042e814504bc390262217b2bea73468ccbb2d3b | fortifyadmin/fortifyapi | fortifyapi/fortify.py | [
"MIT"
] | Python | update_rulepacks | <not_specific> | def update_rulepacks(self):
"""
Described as a Dolimport, update rulepacks from the public fortify server and return status with rulepacks
updated.
Update Fortify Stock Rulepacks
:return:
"""
url = "/api/v1/updateRulepacks"
return self._request('GET', url) |
Described as a Dolimport, update rulepacks from the public fortify server and return status with rulepacks
updated.
Update Fortify Stock Rulepacks
:return:
| Described as a Dolimport, update rulepacks from the public fortify server and return status with rulepacks
updated.
Update Fortify Stock Rulepacks | [
"Described",
"as",
"a",
"Dolimport",
"update",
"rulepacks",
"from",
"the",
"public",
"fortify",
"server",
"and",
"return",
"status",
"with",
"rulepacks",
"updated",
".",
"Update",
"Fortify",
"Stock",
"Rulepacks"
] | def update_rulepacks(self):
url = "/api/v1/updateRulepacks"
return self._request('GET', url) | [
"def",
"update_rulepacks",
"(",
"self",
")",
":",
"url",
"=",
"\"/api/v1/updateRulepacks\"",
"return",
"self",
".",
"_request",
"(",
"'GET'",
",",
"url",
")"
] | Described as a Dolimport, update rulepacks from the public fortify server and return status with rulepacks
updated. | [
"Described",
"as",
"a",
"Dolimport",
"update",
"rulepacks",
"from",
"the",
"public",
"fortify",
"server",
"and",
"return",
"status",
"with",
"rulepacks",
"updated",
"."
] | [
"\"\"\"\n Described as a Dolimport, update rulepacks from the public fortify server and return status with rulepacks\n updated.\n Update Fortify Stock Rulepacks\n :return:\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
6042e814504bc390262217b2bea73468ccbb2d3b | fortifyadmin/fortifyapi | fortifyapi/fortify.py | [
"MIT"
] | Python | _request | <not_specific> | def _request(self, method, url, params=None, files=None, json=None, data=None, headers=None, stream=False):
"""Common handler for all HTTP requests."""
if not params:
params = {}
if not headers:
headers = {
'Accept': 'application/json'
}
... | Common handler for all HTTP requests. | Common handler for all HTTP requests. | [
"Common",
"handler",
"for",
"all",
"HTTP",
"requests",
"."
] | def _request(self, method, url, params=None, files=None, json=None, data=None, headers=None, stream=False):
if not params:
params = {}
if not headers:
headers = {
'Accept': 'application/json'
}
if method == 'GET' or method == 'POST' or meth... | [
"def",
"_request",
"(",
"self",
",",
"method",
",",
"url",
",",
"params",
"=",
"None",
",",
"files",
"=",
"None",
",",
"json",
"=",
"None",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"stream",
"=",
"False",
")",
":",
"if",
"not",... | Common handler for all HTTP requests. | [
"Common",
"handler",
"for",
"all",
"HTTP",
"requests",
"."
] | [
"\"\"\"Common handler for all HTTP requests.\"\"\"",
"# two flavors of response are successful, GETs return 200, PUTs return 204 with empty response text",
"# Sometimes the returned data isn't JSON, so return raw"
] | [
{
"param": "self",
"type": null
},
{
"param": "method",
"type": null
},
{
"param": "url",
"type": null
},
{
"param": "params",
"type": null
},
{
"param": "files",
"type": null
},
{
"param": "json",
"type": null
},
{
"param": "data",
"ty... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "method",
"type": null,
"docstring": null,
"docstring_tokens":... |
6042e814504bc390262217b2bea73468ccbb2d3b | fortifyadmin/fortifyapi | fortifyapi/fortify.py | [
"MIT"
] | Python | data_json | <not_specific> | def data_json(self, pretty=False):
"""Returns the data as a valid JSON string."""
if pretty:
return json.dumps(self.data, sort_keys=True, indent=4, separators=(',', ': '))
else:
return json.dumps(self.data) | Returns the data as a valid JSON string. | Returns the data as a valid JSON string. | [
"Returns",
"the",
"data",
"as",
"a",
"valid",
"JSON",
"string",
"."
] | def data_json(self, pretty=False):
if pretty:
return json.dumps(self.data, sort_keys=True, indent=4, separators=(',', ': '))
else:
return json.dumps(self.data) | [
"def",
"data_json",
"(",
"self",
",",
"pretty",
"=",
"False",
")",
":",
"if",
"pretty",
":",
"return",
"json",
".",
"dumps",
"(",
"self",
".",
"data",
",",
"sort_keys",
"=",
"True",
",",
"indent",
"=",
"4",
",",
"separators",
"=",
"(",
"','",
",",
... | Returns the data as a valid JSON string. | [
"Returns",
"the",
"data",
"as",
"a",
"valid",
"JSON",
"string",
"."
] | [
"\"\"\"Returns the data as a valid JSON string.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "pretty",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pretty",
"type": null,
"docstring": null,
"docstring_tokens":... |
59625851c55f3e36c5fb28cddbce2ca933bd52e4 | fortifyadmin/fortifyapi | fortifyapi/client.py | [
"MIT"
] | Python | initialize | <not_specific> | def initialize(self, template=DefaultVersionTemplate):
"""
Called automatically when Version.create is called.
:return:
"""
with self._api as api:
if not isinstance(template, DefaultVersionTemplate):
template = template()
data = template.g... |
Called automatically when Version.create is called.
:return:
| Called automatically when Version.create is called. | [
"Called",
"automatically",
"when",
"Version",
".",
"create",
"is",
"called",
"."
] | def initialize(self, template=DefaultVersionTemplate):
with self._api as api:
if not isinstance(template, DefaultVersionTemplate):
template = template()
data = template.generate(api=api, project_version_id=self['id'])
return api.bulk_request(data) | [
"def",
"initialize",
"(",
"self",
",",
"template",
"=",
"DefaultVersionTemplate",
")",
":",
"with",
"self",
".",
"_api",
"as",
"api",
":",
"if",
"not",
"isinstance",
"(",
"template",
",",
"DefaultVersionTemplate",
")",
":",
"template",
"=",
"template",
"(",
... | Called automatically when Version.create is called. | [
"Called",
"automatically",
"when",
"Version",
".",
"create",
"is",
"called",
"."
] | [
"\"\"\"\n Called automatically when Version.create is called.\n\n :return:\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "template",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
59625851c55f3e36c5fb28cddbce2ca933bd52e4 | fortifyadmin/fortifyapi | fortifyapi/client.py | [
"MIT"
] | Python | create | <not_specific> | def create(self, version_name, description="", active=True, committed=False, template=DefaultVersionTemplate):
""" Creates a version for the CURRENT project """
self.assert_is_instance("Cannot create version for empty project - consider using `create_project_version`")
assert self.parent['name']... | Creates a version for the CURRENT project | Creates a version for the CURRENT project | [
"Creates",
"a",
"version",
"for",
"the",
"CURRENT",
"project"
] | def create(self, version_name, description="", active=True, committed=False, template=DefaultVersionTemplate):
self.assert_is_instance("Cannot create version for empty project - consider using `create_project_version`")
assert self.parent['name'] is not None, "how is the parent name None?"
retur... | [
"def",
"create",
"(",
"self",
",",
"version_name",
",",
"description",
"=",
"\"\"",
",",
"active",
"=",
"True",
",",
"committed",
"=",
"False",
",",
"template",
"=",
"DefaultVersionTemplate",
")",
":",
"self",
".",
"assert_is_instance",
"(",
"\"Cannot create v... | Creates a version for the CURRENT project | [
"Creates",
"a",
"version",
"for",
"the",
"CURRENT",
"project"
] | [
"\"\"\" Creates a version for the CURRENT project \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "version_name",
"type": null
},
{
"param": "description",
"type": null
},
{
"param": "active",
"type": null
},
{
"param": "committed",
"type": null
},
{
"param": "template",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "version_name",
"type": null,
"docstring": null,
"docstring_to... |
59625851c55f3e36c5fb28cddbce2ca933bd52e4 | fortifyadmin/fortifyapi | fortifyapi/client.py | [
"MIT"
] | Python | copy | <not_specific> | def copy(self, new_name: str, new_description: str = ""):
"""
Copy THIS project version including findings and finding state.
Useful for some operations, e.g. pull requests
"""
self.assert_is_instance()
return self.create(new_name, new_description, active=self['active'], ... |
Copy THIS project version including findings and finding state.
Useful for some operations, e.g. pull requests
| Copy THIS project version including findings and finding state.
Useful for some operations, e.g. pull requests | [
"Copy",
"THIS",
"project",
"version",
"including",
"findings",
"and",
"finding",
"state",
".",
"Useful",
"for",
"some",
"operations",
"e",
".",
"g",
".",
"pull",
"requests"
] | def copy(self, new_name: str, new_description: str = ""):
self.assert_is_instance()
return self.create(new_name, new_description, active=self['active'], committed=self['committed'],
template=CloneVersionTemplate(self['id'])) | [
"def",
"copy",
"(",
"self",
",",
"new_name",
":",
"str",
",",
"new_description",
":",
"str",
"=",
"\"\"",
")",
":",
"self",
".",
"assert_is_instance",
"(",
")",
"return",
"self",
".",
"create",
"(",
"new_name",
",",
"new_description",
",",
"active",
"=",... | Copy THIS project version including findings and finding state. | [
"Copy",
"THIS",
"project",
"version",
"including",
"findings",
"and",
"finding",
"state",
"."
] | [
"\"\"\"\n Copy THIS project version including findings and finding state.\n Useful for some operations, e.g. pull requests\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "new_name",
"type": "str"
},
{
"param": "new_description",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "new_name",
"type": "str",
"docstring": null,
"docstring_token... |
59625851c55f3e36c5fb28cddbce2ca933bd52e4 | fortifyadmin/fortifyapi | fortifyapi/client.py | [
"MIT"
] | Python | test | bool | def test(self, application_name: str) -> bool:
"""
Check whether the specified application name is already defined in the system
:returns: If the application_name was found
"""
with self._api as api:
return api.post(f"/api/v1/projects/action/test", applicationName=app... |
Check whether the specified application name is already defined in the system
:returns: If the application_name was found
| Check whether the specified application name is already defined in the system | [
"Check",
"whether",
"the",
"specified",
"application",
"name",
"is",
"already",
"defined",
"in",
"the",
"system"
] | def test(self, application_name: str) -> bool:
with self._api as api:
return api.post(f"/api/v1/projects/action/test", applicationName=application_name)['data']['found'] | [
"def",
"test",
"(",
"self",
",",
"application_name",
":",
"str",
")",
"->",
"bool",
":",
"with",
"self",
".",
"_api",
"as",
"api",
":",
"return",
"api",
".",
"post",
"(",
"f\"/api/v1/projects/action/test\"",
",",
"applicationName",
"=",
"application_name",
"... | Check whether the specified application name is already defined in the system | [
"Check",
"whether",
"the",
"specified",
"application",
"name",
"is",
"already",
"defined",
"in",
"the",
"system"
] | [
"\"\"\"\n Check whether the specified application name is already defined in the system\n :returns: If the application_name was found\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "application_name",
"type": "str"
}
] | {
"returns": [
{
"docstring": "If the application_name was found",
"docstring_tokens": [
"If",
"the",
"application_name",
"was",
"found"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
... |
59625851c55f3e36c5fb28cddbce2ca933bd52e4 | fortifyadmin/fortifyapi | fortifyapi/client.py | [
"MIT"
] | Python | upsert | Version | def upsert(self, project_name, version_name, description="", active=True,
committed=False, issue_template_id='Prioritized-HighRisk-Project-Template',
template=DefaultVersionTemplate) -> Version:
""" same as create but uses existing project and version"""
# see if the projec... | same as create but uses existing project and version | same as create but uses existing project and version | [
"same",
"as",
"create",
"but",
"uses",
"existing",
"project",
"and",
"version"
] | def upsert(self, project_name, version_name, description="", active=True,
committed=False, issue_template_id='Prioritized-HighRisk-Project-Template',
template=DefaultVersionTemplate) -> Version:
q = Query().query("name", project_name)
projects = list(self.list(q=q))
... | [
"def",
"upsert",
"(",
"self",
",",
"project_name",
",",
"version_name",
",",
"description",
"=",
"\"\"",
",",
"active",
"=",
"True",
",",
"committed",
"=",
"False",
",",
"issue_template_id",
"=",
"'Prioritized-HighRisk-Project-Template'",
",",
"template",
"=",
"... | same as create but uses existing project and version | [
"same",
"as",
"create",
"but",
"uses",
"existing",
"project",
"and",
"version"
] | [
"\"\"\" same as create but uses existing project and version\"\"\"",
"# see if the project exists",
"# TODO: change this to /projectVersions/action/test with {projectName:x, projectVersionName: y}",
"# should be the first one",
"# but check if the version is there..."
] | [
{
"param": "self",
"type": null
},
{
"param": "project_name",
"type": null
},
{
"param": "version_name",
"type": null
},
{
"param": "description",
"type": null
},
{
"param": "active",
"type": null
},
{
"param": "committed",
"type": null
},
{
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "project_name",
"type": null,
"docstring": null,
"docstring_to... |
59625851c55f3e36c5fb28cddbce2ca933bd52e4 | fortifyadmin/fortifyapi | fortifyapi/client.py | [
"MIT"
] | Python | list_all | null | def list_all(self, **kwargs):
""" Helper function to just disable paging and get them all """
kwargs['limit'] = -1
for e in self.list(**kwargs):
yield e | Helper function to just disable paging and get them all | Helper function to just disable paging and get them all | [
"Helper",
"function",
"to",
"just",
"disable",
"paging",
"and",
"get",
"them",
"all"
] | def list_all(self, **kwargs):
kwargs['limit'] = -1
for e in self.list(**kwargs):
yield e | [
"def",
"list_all",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"kwargs",
"[",
"'limit'",
"]",
"=",
"-",
"1",
"for",
"e",
"in",
"self",
".",
"list",
"(",
"**",
"kwargs",
")",
":",
"yield",
"e"
] | Helper function to just disable paging and get them all | [
"Helper",
"function",
"to",
"just",
"disable",
"paging",
"and",
"get",
"them",
"all"
] | [
"\"\"\" Helper function to just disable paging and get them all \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e6be87d17d350d911ea98e2af5bd1b9b8e579e74 | moonboy13/brew-journal | brew_journal/recipies/serializers.py | [
"Apache-2.0"
] | Python | create | <not_specific> | def create(self, validated_data):
"""Create the recipe and all related data"""
# As hops and malt will be handled separately, remove them from the current data.
hops = validated_data.pop("recipe_hops")
malts = validated_data.pop('recipe_malts')
user = validated_data.pop('u... | Create the recipe and all related data | Create the recipe and all related data | [
"Create",
"the",
"recipe",
"and",
"all",
"related",
"data"
] | def create(self, validated_data):
hops = validated_data.pop("recipe_hops")
malts = validated_data.pop('recipe_malts')
user = validated_data.pop('user')
return Recipe.objects.create_recipe(user, validated_data, malts, hops) | [
"def",
"create",
"(",
"self",
",",
"validated_data",
")",
":",
"hops",
"=",
"validated_data",
".",
"pop",
"(",
"\"recipe_hops\"",
")",
"malts",
"=",
"validated_data",
".",
"pop",
"(",
"'recipe_malts'",
")",
"user",
"=",
"validated_data",
".",
"pop",
"(",
"... | Create the recipe and all related data | [
"Create",
"the",
"recipe",
"and",
"all",
"related",
"data"
] | [
"\"\"\"Create the recipe and all related data\"\"\"",
"# As hops and malt will be handled separately, remove them from the current data.\r"
] | [
{
"param": "self",
"type": null
},
{
"param": "validated_data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "validated_data",
"type": null,
"docstring": null,
"docstring_... |
e6be87d17d350d911ea98e2af5bd1b9b8e579e74 | moonboy13/brew-journal | brew_journal/recipies/serializers.py | [
"Apache-2.0"
] | Python | update | <not_specific> | def update(self, instance, validated_data):
"""Update a recipe. This will clear all previous malts/hops and replace them with a new list"""
instance.recipe_name = validated_data.get('recipe_name', instance.recipe_name)
instance.recipe_style = validated_data.get('recipe_style', ins... | Update a recipe. This will clear all previous malts/hops and replace them with a new list | Update a recipe. This will clear all previous malts/hops and replace them with a new list | [
"Update",
"a",
"recipe",
".",
"This",
"will",
"clear",
"all",
"previous",
"malts",
"/",
"hops",
"and",
"replace",
"them",
"with",
"a",
"new",
"list"
] | def update(self, instance, validated_data):
instance.recipe_name = validated_data.get('recipe_name', instance.recipe_name)
instance.recipe_style = validated_data.get('recipe_style', instance.recipe_style)
instance.recipe_notes = validated_data.get('recipe_notes', instance.recipe_no... | [
"def",
"update",
"(",
"self",
",",
"instance",
",",
"validated_data",
")",
":",
"instance",
".",
"recipe_name",
"=",
"validated_data",
".",
"get",
"(",
"'recipe_name'",
",",
"instance",
".",
"recipe_name",
")",
"instance",
".",
"recipe_style",
"=",
"validated_... | Update a recipe. | [
"Update",
"a",
"recipe",
"."
] | [
"\"\"\"Update a recipe. This will clear all previous malts/hops and replace them with a new list\"\"\"",
"# Delete all of the hops and then resave them\r",
"# Throw an exception if invalid\r",
"# Do the same for malts\r"
] | [
{
"param": "self",
"type": null
},
{
"param": "instance",
"type": null
},
{
"param": "validated_data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "instance",
"type": null,
"docstring": null,
"docstring_tokens... |
3d232819807011c2d8da3b61495d816cc4ffc68b | moonboy13/brew-journal | brew_journal/recipies/views.py | [
"Apache-2.0"
] | Python | list | <not_specific> | def list(self, request):
"""
List all of a user's recipes. Only return the ID and the name.
While this may seem initially uneeded, as the number of recipes
grows limiting data will be important.
"""
if not request.user.is_active:
return Response({
... |
List all of a user's recipes. Only return the ID and the name.
While this may seem initially uneeded, as the number of recipes
grows limiting data will be important.
| List all of a user's recipes. Only return the ID and the name.
While this may seem initially uneeded, as the number of recipes
grows limiting data will be important. | [
"List",
"all",
"of",
"a",
"user",
"'",
"s",
"recipes",
".",
"Only",
"return",
"the",
"ID",
"and",
"the",
"name",
".",
"While",
"this",
"may",
"seem",
"initially",
"uneeded",
"as",
"the",
"number",
"of",
"recipes",
"grows",
"limiting",
"data",
"will",
"... | def list(self, request):
if not request.user.is_active:
return Response({
'status' : 'UNAUTHORIZED',
'message' : 'Requesting user is no longer active.',
}, status=status.HTTP_401_UNAUTHORIZED);
queryset = Recipe.objects.filter(account=request.user... | [
"def",
"list",
"(",
"self",
",",
"request",
")",
":",
"if",
"not",
"request",
".",
"user",
".",
"is_active",
":",
"return",
"Response",
"(",
"{",
"'status'",
":",
"'UNAUTHORIZED'",
",",
"'message'",
":",
"'Requesting user is no longer active.'",
",",
"}",
",... | List all of a user's recipes. | [
"List",
"all",
"of",
"a",
"user",
"'",
"s",
"recipes",
"."
] | [
"\"\"\"\n List all of a user's recipes. Only return the ID and the name.\n While this may seem initially uneeded, as the number of recipes\n grows limiting data will be important.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
3d232819807011c2d8da3b61495d816cc4ffc68b | moonboy13/brew-journal | brew_journal/recipies/views.py | [
"Apache-2.0"
] | Python | retrieve | <not_specific> | def retrieve(self, request, pk):
"""Get all the specifics of a recipe."""
recipe = get_object_or_404(Recipe, pk=pk)
serializer = RecipeSerializer(recipe)
return Response(serializer.data) | Get all the specifics of a recipe. | Get all the specifics of a recipe. | [
"Get",
"all",
"the",
"specifics",
"of",
"a",
"recipe",
"."
] | def retrieve(self, request, pk):
recipe = get_object_or_404(Recipe, pk=pk)
serializer = RecipeSerializer(recipe)
return Response(serializer.data) | [
"def",
"retrieve",
"(",
"self",
",",
"request",
",",
"pk",
")",
":",
"recipe",
"=",
"get_object_or_404",
"(",
"Recipe",
",",
"pk",
"=",
"pk",
")",
"serializer",
"=",
"RecipeSerializer",
"(",
"recipe",
")",
"return",
"Response",
"(",
"serializer",
".",
"d... | Get all the specifics of a recipe. | [
"Get",
"all",
"the",
"specifics",
"of",
"a",
"recipe",
"."
] | [
"\"\"\"Get all the specifics of a recipe.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "pk",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
3d232819807011c2d8da3b61495d816cc4ffc68b | moonboy13/brew-journal | brew_journal/recipies/views.py | [
"Apache-2.0"
] | Python | destroy | <not_specific> | def destroy(self, request, pk=None):
"""Get rid of a recipe."""
recipe = get_object_or_404(Recipe, pk=pk)
recipe.delete()
return Response({},status=status.HTTP_204_NO_CONTENT) | Get rid of a recipe. | Get rid of a recipe. | [
"Get",
"rid",
"of",
"a",
"recipe",
"."
] | def destroy(self, request, pk=None):
recipe = get_object_or_404(Recipe, pk=pk)
recipe.delete()
return Response({},status=status.HTTP_204_NO_CONTENT) | [
"def",
"destroy",
"(",
"self",
",",
"request",
",",
"pk",
"=",
"None",
")",
":",
"recipe",
"=",
"get_object_or_404",
"(",
"Recipe",
",",
"pk",
"=",
"pk",
")",
"recipe",
".",
"delete",
"(",
")",
"return",
"Response",
"(",
"{",
"}",
",",
"status",
"=... | Get rid of a recipe. | [
"Get",
"rid",
"of",
"a",
"recipe",
"."
] | [
"\"\"\"Get rid of a recipe.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "pk",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
eb5bb03c9089383b1032363ba2ccfeb1ac5cf3c7 | moonboy13/brew-journal | brew_journal/recipies/tests.py | [
"Apache-2.0"
] | Python | checkElement | null | def checkElement(test_instance, model, data):
"""Helper Function. Either check two values against on another or call correct helper function"""
# IF the type is a list or dict, call the correct function to check its elements. ELSE directly
# compare the elements
if type(model) is list:
... | Helper Function. Either check two values against on another or call correct helper function | Helper Function. Either check two values against on another or call correct helper function | [
"Helper",
"Function",
".",
"Either",
"check",
"two",
"values",
"against",
"on",
"another",
"or",
"call",
"correct",
"helper",
"function"
] | def checkElement(test_instance, model, data):
if type(model) is list:
Utility.checkArrayModel(test_instance, model, data)
elif type(model) is dict:
Utility.checkDictModel(test_instance, model, data)
else:
test_instance.assertEqual(model, data) | [
"def",
"checkElement",
"(",
"test_instance",
",",
"model",
",",
"data",
")",
":",
"if",
"type",
"(",
"model",
")",
"is",
"list",
":",
"Utility",
".",
"checkArrayModel",
"(",
"test_instance",
",",
"model",
",",
"data",
")",
"elif",
"type",
"(",
"model",
... | Helper Function. | [
"Helper",
"Function",
"."
] | [
"\"\"\"Helper Function. Either check two values against on another or call correct helper function\"\"\"",
"# IF the type is a list or dict, call the correct function to check its elements. ELSE directly",
"# compare the elements"
] | [
{
"param": "test_instance",
"type": null
},
{
"param": "model",
"type": null
},
{
"param": "data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "test_instance",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "model",
"type": null,
"docstring": null,
"docstring_... |
eb5bb03c9089383b1032363ba2ccfeb1ac5cf3c7 | moonboy13/brew-journal | brew_journal/recipies/tests.py | [
"Apache-2.0"
] | Python | checkArrayModel | null | def checkArrayModel(test_instance, model, data):
"""Helper function. Check an array to see if the model data is present in the data array"""
for i in range(len(model)):
Utility.checkElement(test_instance, model[i], data[i]) | Helper function. Check an array to see if the model data is present in the data array | Helper function. Check an array to see if the model data is present in the data array | [
"Helper",
"function",
".",
"Check",
"an",
"array",
"to",
"see",
"if",
"the",
"model",
"data",
"is",
"present",
"in",
"the",
"data",
"array"
] | def checkArrayModel(test_instance, model, data):
for i in range(len(model)):
Utility.checkElement(test_instance, model[i], data[i]) | [
"def",
"checkArrayModel",
"(",
"test_instance",
",",
"model",
",",
"data",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"model",
")",
")",
":",
"Utility",
".",
"checkElement",
"(",
"test_instance",
",",
"model",
"[",
"i",
"]",
",",
"data",
"... | Helper function. | [
"Helper",
"function",
"."
] | [
"\"\"\"Helper function. Check an array to see if the model data is present in the data array\"\"\""
] | [
{
"param": "test_instance",
"type": null
},
{
"param": "model",
"type": null
},
{
"param": "data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "test_instance",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "model",
"type": null,
"docstring": null,
"docstring_... |
eb5bb03c9089383b1032363ba2ccfeb1ac5cf3c7 | moonboy13/brew-journal | brew_journal/recipies/tests.py | [
"Apache-2.0"
] | Python | createRecipe | <not_specific> | def createRecipe(self, user, data):
"""Create a recipe for use with the update unit test"""
hops = data.pop("recipe_hops")
malts = data.pop("recipe_malts")
return Recipe.objects.create_recipe(user, data, malts, hops) | Create a recipe for use with the update unit test | Create a recipe for use with the update unit test | [
"Create",
"a",
"recipe",
"for",
"use",
"with",
"the",
"update",
"unit",
"test"
] | def createRecipe(self, user, data):
hops = data.pop("recipe_hops")
malts = data.pop("recipe_malts")
return Recipe.objects.create_recipe(user, data, malts, hops) | [
"def",
"createRecipe",
"(",
"self",
",",
"user",
",",
"data",
")",
":",
"hops",
"=",
"data",
".",
"pop",
"(",
"\"recipe_hops\"",
")",
"malts",
"=",
"data",
".",
"pop",
"(",
"\"recipe_malts\"",
")",
"return",
"Recipe",
".",
"objects",
".",
"create_recipe"... | Create a recipe for use with the update unit test | [
"Create",
"a",
"recipe",
"for",
"use",
"with",
"the",
"update",
"unit",
"test"
] | [
"\"\"\"Create a recipe for use with the update unit test\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "user",
"type": null
},
{
"param": "data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "user",
"type": null,
"docstring": null,
"docstring_tokens": [... |
55b8ed109739a1afcb641e457d418bdde51c8e4e | binhnhu1409/flaskFarm | flaskFarm/db.py | [
"MIT"
] | Python | init_db | null | def init_db():
"""Clear existing data and create new tables."""
# check if the database file is exist
if not os.path.isfile(current_app.config["DATABASE"]):
db = get_db()
with current_app.open_resource("schema.sql") as f:
db.executescript(f.read().decode("utf8")) | Clear existing data and create new tables. | Clear existing data and create new tables. | [
"Clear",
"existing",
"data",
"and",
"create",
"new",
"tables",
"."
] | def init_db():
if not os.path.isfile(current_app.config["DATABASE"]):
db = get_db()
with current_app.open_resource("schema.sql") as f:
db.executescript(f.read().decode("utf8")) | [
"def",
"init_db",
"(",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"current_app",
".",
"config",
"[",
"\"DATABASE\"",
"]",
")",
":",
"db",
"=",
"get_db",
"(",
")",
"with",
"current_app",
".",
"open_resource",
"(",
"\"schema.sql\"",
")... | Clear existing data and create new tables. | [
"Clear",
"existing",
"data",
"and",
"create",
"new",
"tables",
"."
] | [
"\"\"\"Clear existing data and create new tables.\"\"\"",
"# check if the database file is exist"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
be79a29764aacec92f4eafeb7b57d943a2dbb032 | RSNA-QIBA-US-SWS/QIBA-DigitalPhantoms | results/c_ve_3param.py | [
"MIT"
] | Python | calc | <not_specific> | def calc(f, G0, GI, Beta):
""" calculate SWS as a function of frequency
:param f: vector of frequency (Hz)
:param G0: G_o (Pa)
:param GI: G_inf (Pa)
:param Beta: exponential relaxation constant (s^-1)
:returms: c_omega (SWS in m/s as a function of omega (rad/s)
"""
import numpy as np
... | calculate SWS as a function of frequency
:param f: vector of frequency (Hz)
:param G0: G_o (Pa)
:param GI: G_inf (Pa)
:param Beta: exponential relaxation constant (s^-1)
:returms: c_omega (SWS in m/s as a function of omega (rad/s)
| calculate SWS as a function of frequency | [
"calculate",
"SWS",
"as",
"a",
"function",
"of",
"frequency"
] | def calc(f, G0, GI, Beta):
import numpy as np
omega = 2*np.pi*np.array(f);
rho = 1000;
mu1 = GI;
mu2 = G0-GI;
eta = (G0-GI)/Beta;
muprime = mu1 + (mu2 * omega**2 * eta**2) / (mu2**2 + omega**2 * eta**2)
muprime2 = -(mu2**2 * omega * eta) / (mu2**2 +omega**2 * eta**2)
alpha = np.sqrt... | [
"def",
"calc",
"(",
"f",
",",
"G0",
",",
"GI",
",",
"Beta",
")",
":",
"import",
"numpy",
"as",
"np",
"omega",
"=",
"2",
"*",
"np",
".",
"pi",
"*",
"np",
".",
"array",
"(",
"f",
")",
";",
"rho",
"=",
"1000",
";",
"mu1",
"=",
"GI",
";",
"mu... | calculate SWS as a function of frequency | [
"calculate",
"SWS",
"as",
"a",
"function",
"of",
"frequency"
] | [
"\"\"\" calculate SWS as a function of frequency\n\n :param f: vector of frequency (Hz)\n :param G0: G_o (Pa)\n :param GI: G_inf (Pa)\n :param Beta: exponential relaxation constant (s^-1)\n :returms: c_omega (SWS in m/s as a function of omega (rad/s)\n \"\"\"",
"# kg / m^3"
] | [
{
"param": "f",
"type": null
},
{
"param": "G0",
"type": null
},
{
"param": "GI",
"type": null
},
{
"param": "Beta",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "f",
"type": null,
"docstring": "vector of frequency (Hz)",
"docstring_tokens": [
"vector",
"of",
"frequency",
"(",
"Hz",
")"
],
"default": null,
"is_optional": ... |
134ba54ba453e1aeffb2d6da939c9dc540ec6135 | s-fifteen-instruments/QKDServer | S15qkd/splicer.py | [
"MIT"
] | Python | start_splicer | null | def start_splicer(qkd_protocol: int = QKDProtocol.BBM92):
'''
Starts the splicer process and attaches a thread digesting
the splice pipe and the genlog.
'''
global data_root, cwd, proc_splicer
initialize()
args = f'-d {FoldersQKD.T3FILES} \
-D {FoldersQKD.RECEIVEFILES} \
... |
Starts the splicer process and attaches a thread digesting
the splice pipe and the genlog.
| Starts the splicer process and attaches a thread digesting
the splice pipe and the genlog. | [
"Starts",
"the",
"splicer",
"process",
"and",
"attaches",
"a",
"thread",
"digesting",
"the",
"splice",
"pipe",
"and",
"the",
"genlog",
"."
] | def start_splicer(qkd_protocol: int = QKDProtocol.BBM92):
global data_root, cwd, proc_splicer
initialize()
args = f'-d {FoldersQKD.T3FILES} \
-D {FoldersQKD.RECEIVEFILES} \
-f {FoldersQKD.RAWKEYS} \
-E {PipesQKD.SPLICER} \
{kill_option} \
-p {... | [
"def",
"start_splicer",
"(",
"qkd_protocol",
":",
"int",
"=",
"QKDProtocol",
".",
"BBM92",
")",
":",
"global",
"data_root",
",",
"cwd",
",",
"proc_splicer",
"initialize",
"(",
")",
"args",
"=",
"f'-d {FoldersQKD.T3FILES} \\\n -D {FoldersQKD.RECEIVEFILES} \\\... | Starts the splicer process and attaches a thread digesting
the splice pipe and the genlog. | [
"Starts",
"the",
"splicer",
"process",
"and",
"attaches",
"a",
"thread",
"digesting",
"the",
"splice",
"pipe",
"and",
"the",
"genlog",
"."
] | [
"'''\n Starts the splicer process and attaches a thread digesting \n the splice pipe and the genlog.\n '''"
] | [
{
"param": "qkd_protocol",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "qkd_protocol",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
134ba54ba453e1aeffb2d6da939c9dc540ec6135 | s-fifteen-instruments/QKDServer | S15qkd/splicer.py | [
"MIT"
] | Python | _splice_pipe_digest | null | def _splice_pipe_digest(qkd_protocol, config_file_name: str = qkd_globals.config_file):
'''
Digests the text written into splicepipe and genlog.
Runs until the splicer process closes.
'''
logger.info(f'Starting _splice_pipe_digest thread.')
fd_genlog = os.open(PipesQKD.GENLOG, os.O_RDONLY |
... |
Digests the text written into splicepipe and genlog.
Runs until the splicer process closes.
| Digests the text written into splicepipe and genlog.
Runs until the splicer process closes. | [
"Digests",
"the",
"text",
"written",
"into",
"splicepipe",
"and",
"genlog",
".",
"Runs",
"until",
"the",
"splicer",
"process",
"closes",
"."
] | def _splice_pipe_digest(qkd_protocol, config_file_name: str = qkd_globals.config_file):
logger.info(f'Starting _splice_pipe_digest thread.')
fd_genlog = os.open(PipesQKD.GENLOG, os.O_RDONLY |
os.O_NONBLOCK)
f_genlog = os.fdopen(fd_genlog, 'rb', 0)
logger.info(f'Thread started... | [
"def",
"_splice_pipe_digest",
"(",
"qkd_protocol",
",",
"config_file_name",
":",
"str",
"=",
"qkd_globals",
".",
"config_file",
")",
":",
"logger",
".",
"info",
"(",
"f'Starting _splice_pipe_digest thread.'",
")",
"fd_genlog",
"=",
"os",
".",
"open",
"(",
"PipesQK... | Digests the text written into splicepipe and genlog. | [
"Digests",
"the",
"text",
"written",
"into",
"splicepipe",
"and",
"genlog",
"."
] | [
"'''\n Digests the text written into splicepipe and genlog.\n Runs until the splicer process closes.\n '''",
"# non-blocking",
"# non-blocking",
"# sleep time before next read file attempt"
] | [
{
"param": "qkd_protocol",
"type": null
},
{
"param": "config_file_name",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "qkd_protocol",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "config_file_name",
"type": "str",
"docstring": null,
... |
0d7fbd8c4a1362184f123ee61b94df1b136d451f | s-fifteen-instruments/QKDServer | S15qkd/timestampsimulator/readevents_simulator.py | [
"MIT"
] | Python | _data_extractor | <not_specific> | def _data_extractor(filename, highres_tscard=False):
"""Reads raw timestamp into time and patterns vectors
:param filename: a python file object open in binary mode
:param highres_tscard: Flag for the 4ps time resolution card
:type filename: _io.BufferedReader
:returns: Two vectors: timestamps, co... | Reads raw timestamp into time and patterns vectors
:param filename: a python file object open in binary mode
:param highres_tscard: Flag for the 4ps time resolution card
:type filename: _io.BufferedReader
:returns: Two vectors: timestamps, corresponding pattern
:rtype: {numpy.ndarray(float), numpy... | Reads raw timestamp into time and patterns vectors | [
"Reads",
"raw",
"timestamp",
"into",
"time",
"and",
"patterns",
"vectors"
] | def _data_extractor(filename, highres_tscard=False):
with open(filename, 'rb') as f:
data = np.fromfile(file=f, dtype='=I').reshape(-1, 2)
if highres_tscard:
t = ((np.uint64(data[:, 0]) << 22) + (data[:, 1] >> 10)) / 256.
else:
t = ((np.uint64(data[:, 0]) << 17) + (da... | [
"def",
"_data_extractor",
"(",
"filename",
",",
"highres_tscard",
"=",
"False",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"f",
":",
"data",
"=",
"np",
".",
"fromfile",
"(",
"file",
"=",
"f",
",",
"dtype",
"=",
"'=I'",
")",
... | Reads raw timestamp into time and patterns vectors | [
"Reads",
"raw",
"timestamp",
"into",
"time",
"and",
"patterns",
"vectors"
] | [
"\"\"\"Reads raw timestamp into time and patterns vectors\n\n :param filename: a python file object open in binary mode\n :param highres_tscard: Flag for the 4ps time resolution card \n :type filename: _io.BufferedReader\n :returns: Two vectors: timestamps, corresponding pattern\n :rtype: {numpy.ndar... | [
{
"param": "filename",
"type": null
},
{
"param": "highres_tscard",
"type": null
}
] | {
"returns": [
{
"docstring": "Two vectors: timestamps, corresponding pattern",
"docstring_tokens": [
"Two",
"vectors",
":",
"timestamps",
"corresponding",
"pattern"
],
"type": "{numpy.ndarray(float), numpy.ndarray(uint32)}"
}
],
"rai... |
5b42dcc1c63164b5802fffa94406ce282e529a09 | s-fifteen-instruments/QKDServer | S15qkd/chopper2.py | [
"MIT"
] | Python | _t1logpipe_digest | null | def _t1logpipe_digest():
'''
Digest the t1log pipe written by chopper2.
Chopper2 runs on the high-count side.
Also counts the number of epochs recorded by chopper2.
'''
global t1logpipe_digest_thread_flag, t1_epoch_count, first_epoch
t1_epoch_count = 0
t1logpipe_digest_thread_flag = True... |
Digest the t1log pipe written by chopper2.
Chopper2 runs on the high-count side.
Also counts the number of epochs recorded by chopper2.
| Digest the t1log pipe written by chopper2.
Chopper2 runs on the high-count side.
Also counts the number of epochs recorded by chopper2. | [
"Digest",
"the",
"t1log",
"pipe",
"written",
"by",
"chopper2",
".",
"Chopper2",
"runs",
"on",
"the",
"high",
"-",
"count",
"side",
".",
"Also",
"counts",
"the",
"number",
"of",
"epochs",
"recorded",
"by",
"chopper2",
"."
] | def _t1logpipe_digest():
global t1logpipe_digest_thread_flag, t1_epoch_count, first_epoch
t1_epoch_count = 0
t1logpipe_digest_thread_flag = True
while t1logpipe_digest_thread_flag is True:
for message in _reader(PipesQKD.T1LOG):
logger.debug(f'[read msg] {message}')
if t1... | [
"def",
"_t1logpipe_digest",
"(",
")",
":",
"global",
"t1logpipe_digest_thread_flag",
",",
"t1_epoch_count",
",",
"first_epoch",
"t1_epoch_count",
"=",
"0",
"t1logpipe_digest_thread_flag",
"=",
"True",
"while",
"t1logpipe_digest_thread_flag",
"is",
"True",
":",
"for",
"m... | Digest the t1log pipe written by chopper2. | [
"Digest",
"the",
"t1log",
"pipe",
"written",
"by",
"chopper2",
"."
] | [
"'''\n Digest the t1log pipe written by chopper2.\n Chopper2 runs on the high-count side.\n Also counts the number of epochs recorded by chopper2.\n '''"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
47477aff124b74d3759b724e661c670f13af8aa1 | s-fifteen-instruments/QKDServer | S15qkd/timestampsimulator/timestamp_simulator.py | [
"MIT"
] | Python | simulate_pair_source_timestamps_write_into_two_files | null | def simulate_pair_source_timestamps_write_into_two_files(file_name_ph1, file_name_ph2,
rate_photon_1, rate_photon_2,
rate_pairs, tot_time, pattern_photon_1=int(
... | Generates two timestamp streams which contain photon pairs and coherent light statistics.
The streams are written into two files.
| Generates two timestamp streams which contain photon pairs and coherent light statistics.
The streams are written into two files. | [
"Generates",
"two",
"timestamp",
"streams",
"which",
"contain",
"photon",
"pairs",
"and",
"coherent",
"light",
"statistics",
".",
"The",
"streams",
"are",
"written",
"into",
"two",
"files",
"."
] | def simulate_pair_source_timestamps_write_into_two_files(file_name_ph1, file_name_ph2,
rate_photon_1, rate_photon_2,
rate_pairs, tot_time, pattern_photon_1=int(
... | [
"def",
"simulate_pair_source_timestamps_write_into_two_files",
"(",
"file_name_ph1",
",",
"file_name_ph2",
",",
"rate_photon_1",
",",
"rate_photon_2",
",",
"rate_pairs",
",",
"tot_time",
",",
"pattern_photon_1",
"=",
"int",
"(",
"'0001'",
",",
"2",
")",
",",
"pattern_... | Generates two timestamp streams which contain photon pairs and coherent light statistics. | [
"Generates",
"two",
"timestamp",
"streams",
"which",
"contain",
"photon",
"pairs",
"and",
"coherent",
"light",
"statistics",
"."
] | [
"'''Generates two timestamp streams which contain photon pairs and coherent light statistics.\n\n The streams are written into two files.\n '''",
"# create photon waiting times from an exponential distribution",
"# simulates exponential distribution for waiting times",
"# simulates exponential distribut... | [
{
"param": "file_name_ph1",
"type": null
},
{
"param": "file_name_ph2",
"type": null
},
{
"param": "rate_photon_1",
"type": null
},
{
"param": "rate_photon_2",
"type": null
},
{
"param": "rate_pairs",
"type": null
},
{
"param": "tot_time",
"type": ... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file_name_ph1",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file_name_ph2",
"type": null,
"docstring": null,
"do... |
a33c46ce3359ac5c4d5598197accee6e175509b7 | s-fifteen-instruments/QKDServer | S15qkd/error_correction.py | [
"MIT"
] | Python | start_error_correction | null | def start_error_correction(cmd_pipe: str = PipesQKD.ECCMD, send_pipe: str = PipesQKD.ECS,
receive_pipe: str = PipesQKD.ECR, raw_keys_folder: str = FoldersQKD.RAWKEYS,
final_keys_folder: str = FoldersQKD.FINALKEYS, notification_pipe: str = PipesQKD.ECNOTE,
... | Starts the error correction process.
| Starts the error correction process. | [
"Starts",
"the",
"error",
"correction",
"process",
"."
] | def start_error_correction(cmd_pipe: str = PipesQKD.ECCMD, send_pipe: str = PipesQKD.ECS,
receive_pipe: str = PipesQKD.ECR, raw_keys_folder: str = FoldersQKD.RAWKEYS,
final_keys_folder: str = FoldersQKD.FINALKEYS, notification_pipe: str = PipesQKD.ECNOTE,
... | [
"def",
"start_error_correction",
"(",
"cmd_pipe",
":",
"str",
"=",
"PipesQKD",
".",
"ECCMD",
",",
"send_pipe",
":",
"str",
"=",
"PipesQKD",
".",
"ECS",
",",
"receive_pipe",
":",
"str",
"=",
"PipesQKD",
".",
"ECR",
",",
"raw_keys_folder",
":",
"str",
"=",
... | Starts the error correction process. | [
"Starts",
"the",
"error",
"correction",
"process",
"."
] | [
"'''Starts the error correction process.\n '''",
"# create erroroptions from settings",
"# start pipe digests"
] | [
{
"param": "cmd_pipe",
"type": "str"
},
{
"param": "send_pipe",
"type": "str"
},
{
"param": "receive_pipe",
"type": "str"
},
{
"param": "raw_keys_folder",
"type": "str"
},
{
"param": "final_keys_folder",
"type": "str"
},
{
"param": "notification_pipe",... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cmd_pipe",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "send_pipe",
"type": "str",
"docstring": null,
"docstring... |
a33c46ce3359ac5c4d5598197accee6e175509b7 | s-fifteen-instruments/QKDServer | S15qkd/error_correction.py | [
"MIT"
] | Python | _ecnotepipe_digest | null | def _ecnotepipe_digest(ec_note_pipe: str = PipesQKD.ECNOTE):
'''
Digests error correction activities indicated by the 'ecnotepipe' pipe.
This is getting input from the ec_note_pipe which is updated after an error correction run.
'''
global proc_error_correction, total_ec_key_bits, servoed_QBER
g... |
Digests error correction activities indicated by the 'ecnotepipe' pipe.
This is getting input from the ec_note_pipe which is updated after an error correction run.
| Digests error correction activities indicated by the 'ecnotepipe' pipe.
This is getting input from the ec_note_pipe which is updated after an error correction run. | [
"Digests",
"error",
"correction",
"activities",
"indicated",
"by",
"the",
"'",
"ecnotepipe",
"'",
"pipe",
".",
"This",
"is",
"getting",
"input",
"from",
"the",
"ec_note_pipe",
"which",
"is",
"updated",
"after",
"an",
"error",
"correction",
"run",
"."
] | def _ecnotepipe_digest(ec_note_pipe: str = PipesQKD.ECNOTE):
global proc_error_correction, total_ec_key_bits, servoed_QBER
global ec_epoch, ec_raw_bits, ec_final_bits, ec_err_fraction
global ec_err_fraction_history, ec_err_key_length_history, ec_key_gen_rate
fd = os.open(ec_note_pipe, os.O_RDONLY | os.O... | [
"def",
"_ecnotepipe_digest",
"(",
"ec_note_pipe",
":",
"str",
"=",
"PipesQKD",
".",
"ECNOTE",
")",
":",
"global",
"proc_error_correction",
",",
"total_ec_key_bits",
",",
"servoed_QBER",
"global",
"ec_epoch",
",",
"ec_raw_bits",
",",
"ec_final_bits",
",",
"ec_err_fra... | Digests error correction activities indicated by the 'ecnotepipe' pipe. | [
"Digests",
"error",
"correction",
"activities",
"indicated",
"by",
"the",
"'",
"ecnotepipe",
"'",
"pipe",
"."
] | [
"'''\n Digests error correction activities indicated by the 'ecnotepipe' pipe.\n This is getting input from the ec_note_pipe which is updated after an error correction run.\n '''",
"# non-blocking",
"# servoing QBER"
] | [
{
"param": "ec_note_pipe",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ec_note_pipe",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a33c46ce3359ac5c4d5598197accee6e175509b7 | s-fifteen-instruments/QKDServer | S15qkd/error_correction.py | [
"MIT"
] | Python | _do_error_correction | null | def _do_error_correction():
'''
Executes error correction based on the files in the ec_queue.
The queue consists of raw key file names generated by costream or splicer.
This function usually runs as a thread waiting for pipe input.
This function checks each file for the number of bits and once enou... |
Executes error correction based on the files in the ec_queue.
The queue consists of raw key file names generated by costream or splicer.
This function usually runs as a thread waiting for pipe input.
This function checks each file for the number of bits and once enough bits are available
it notifi... | Executes error correction based on the files in the ec_queue.
The queue consists of raw key file names generated by costream or splicer.
This function usually runs as a thread waiting for pipe input.
This function checks each file for the number of bits and once enough bits are available
it notifies the error correcti... | [
"Executes",
"error",
"correction",
"based",
"on",
"the",
"files",
"in",
"the",
"ec_queue",
".",
"The",
"queue",
"consists",
"of",
"raw",
"key",
"file",
"names",
"generated",
"by",
"costream",
"or",
"splicer",
".",
"This",
"function",
"usually",
"runs",
"as",... | def _do_error_correction():
global ec_queue, minimal_block_size, first_epoch_info, undigested_epochs_info, init_QBER_info
undigested_raw_bits = 0
first_epoch = ''
undigested_epochs = 0
while proc_error_correction is not None and proc_error_correction.poll() is None:
try:
file_nam... | [
"def",
"_do_error_correction",
"(",
")",
":",
"global",
"ec_queue",
",",
"minimal_block_size",
",",
"first_epoch_info",
",",
"undigested_epochs_info",
",",
"init_QBER_info",
"undigested_raw_bits",
"=",
"0",
"first_epoch",
"=",
"''",
"undigested_epochs",
"=",
"0",
"whi... | Executes error correction based on the files in the ec_queue. | [
"Executes",
"error",
"correction",
"based",
"on",
"the",
"files",
"in",
"the",
"ec_queue",
"."
] | [
"'''\n Executes error correction based on the files in the ec_queue.\n The queue consists of raw key file names generated by costream or splicer.\n This function usually runs as a thread waiting for pipe input.\n\n This function checks each file for the number of bits and once enough bits are available\... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
6b65b1dbb5a2a765ee34f5a86470ffe0df9d5f0a | s-fifteen-instruments/QKDServer | S15qkd/chopper.py | [
"MIT"
] | Python | _t2logpipe_digest | null | def _t2logpipe_digest():
'''Digests chopper activities.
Watches t2logpipe for new epoch files and writes the epoch name into the transferd cmdpipe.
Transferd copies the corresponding epoch file to the partnering computer.
'''
global t2logpipe_digest_thread_flag
t2logpipe_digest_thread_flag = Tr... | Digests chopper activities.
Watches t2logpipe for new epoch files and writes the epoch name into the transferd cmdpipe.
Transferd copies the corresponding epoch file to the partnering computer.
| Digests chopper activities.
Watches t2logpipe for new epoch files and writes the epoch name into the transferd cmdpipe.
Transferd copies the corresponding epoch file to the partnering computer. | [
"Digests",
"chopper",
"activities",
".",
"Watches",
"t2logpipe",
"for",
"new",
"epoch",
"files",
"and",
"writes",
"the",
"epoch",
"name",
"into",
"the",
"transferd",
"cmdpipe",
".",
"Transferd",
"copies",
"the",
"corresponding",
"epoch",
"file",
"to",
"the",
"... | def _t2logpipe_digest():
global t2logpipe_digest_thread_flag
t2logpipe_digest_thread_flag = True
fd = os.open(PipesQKD.T2LOG, os.O_RDONLY | os.O_NONBLOCK)
f = os.fdopen(fd, 'rb', 0)
while t2logpipe_digest_thread_flag is True:
time.sleep(0.1)
try:
message = (f.readline()... | [
"def",
"_t2logpipe_digest",
"(",
")",
":",
"global",
"t2logpipe_digest_thread_flag",
"t2logpipe_digest_thread_flag",
"=",
"True",
"fd",
"=",
"os",
".",
"open",
"(",
"PipesQKD",
".",
"T2LOG",
",",
"os",
".",
"O_RDONLY",
"|",
"os",
".",
"O_NONBLOCK",
")",
"f",
... | Digests chopper activities. | [
"Digests",
"chopper",
"activities",
"."
] | [
"'''Digests chopper activities.\n\n Watches t2logpipe for new epoch files and writes the epoch name into the transferd cmdpipe.\n Transferd copies the corresponding epoch file to the partnering computer.\n '''",
"# non-blocking"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
ea0e70d4e50d7aefde2618a58503eefaa3882846 | s-fifteen-instruments/QKDServer | S15qkd/transferd.py | [
"MIT"
] | Python | _local_callback | null | def _local_callback(msg: str):
'''
The transferd process has a msgout pipe which contains received messages.
Usually we let another script manage the response to these messages,
however when no response function is defined this function is used as a default response.
Arguments:
msg {str} ... |
The transferd process has a msgout pipe which contains received messages.
Usually we let another script manage the response to these messages,
however when no response function is defined this function is used as a default response.
Arguments:
msg {str} -- Contains the messages received in t... | The transferd process has a msgout pipe which contains received messages.
Usually we let another script manage the response to these messages,
however when no response function is defined this function is used as a default response.
msg {str} -- Contains the messages received in the msgout pipe. | [
"The",
"transferd",
"process",
"has",
"a",
"msgout",
"pipe",
"which",
"contains",
"received",
"messages",
".",
"Usually",
"we",
"let",
"another",
"script",
"manage",
"the",
"response",
"to",
"these",
"messages",
"however",
"when",
"no",
"response",
"function",
... | def _local_callback(msg: str):
logger.info(f'The msgout pipe is printed locally by the transferd modul.\n\
Define a callback function in start_communication to digest the msgout output in your custom function.')
logger.info(msg) | [
"def",
"_local_callback",
"(",
"msg",
":",
"str",
")",
":",
"logger",
".",
"info",
"(",
"f'The msgout pipe is printed locally by the transferd modul.\\n\\\n Define a callback function in start_communication to digest the msgout output in your custom function.'",
")",
"logger",
... | The transferd process has a msgout pipe which contains received messages. | [
"The",
"transferd",
"process",
"has",
"a",
"msgout",
"pipe",
"which",
"contains",
"received",
"messages",
"."
] | [
"'''\n The transferd process has a msgout pipe which contains received messages.\n Usually we let another script manage the response to these messages, \n however when no response function is defined this function is used as a default response.\n\n\n Arguments:\n msg {str} -- Contains the message... | [
{
"param": "msg",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "msg",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ea0e70d4e50d7aefde2618a58503eefaa3882846 | s-fifteen-instruments/QKDServer | S15qkd/transferd.py | [
"MIT"
] | Python | _transferlog_digest | null | def _transferlog_digest():
'''
Digests the transferlog which is written by the transferd process.
This function usually runs as a thread and watches the transferlog file.
If this is the low count side this function notifies the splicer about file arrival.
'''
global first_received_epoch, low_c... |
Digests the transferlog which is written by the transferd process.
This function usually runs as a thread and watches the transferlog file.
If this is the low count side this function notifies the splicer about file arrival.
| Digests the transferlog which is written by the transferd process.
This function usually runs as a thread and watches the transferlog file.
If this is the low count side this function notifies the splicer about file arrival. | [
"Digests",
"the",
"transferlog",
"which",
"is",
"written",
"by",
"the",
"transferd",
"process",
".",
"This",
"function",
"usually",
"runs",
"as",
"a",
"thread",
"and",
"watches",
"the",
"transferlog",
"file",
".",
"If",
"this",
"is",
"the",
"low",
"count",
... | def _transferlog_digest():
global first_received_epoch, low_count_side, last_received_epoch
fd = os.open(PipesQKD.TRANSFERLOG, os.O_RDONLY | os.O_NONBLOCK)
f = os.fdopen(fd, 'rb', 0)
logger.info('Thread started.')
while is_running():
time.sleep(0.1)
try:
message = f.rea... | [
"def",
"_transferlog_digest",
"(",
")",
":",
"global",
"first_received_epoch",
",",
"low_count_side",
",",
"last_received_epoch",
"fd",
"=",
"os",
".",
"open",
"(",
"PipesQKD",
".",
"TRANSFERLOG",
",",
"os",
".",
"O_RDONLY",
"|",
"os",
".",
"O_NONBLOCK",
")",
... | Digests the transferlog which is written by the transferd process. | [
"Digests",
"the",
"transferlog",
"which",
"is",
"written",
"by",
"the",
"transferd",
"process",
"."
] | [
"'''\n Digests the transferlog which is written by the transferd process.\n\n This function usually runs as a thread and watches the transferlog file. \n If this is the low count side this function notifies the splicer about file arrival.\n '''",
"# non-blocking"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
ea0e70d4e50d7aefde2618a58503eefaa3882846 | s-fifteen-instruments/QKDServer | S15qkd/transferd.py | [
"MIT"
] | Python | measure_local_count_rate | <not_specific> | def measure_local_count_rate(config_file_name: str = qkd_globals.config_file):
'''
Measure local photon count rate.
'''
global localcountrate
with open(config_file_name, 'r') as f:
config = json.load(f, object_hook=lambda d: SimpleNamespace(**d))
localcountrate = -1
cmd = prog_readev... |
Measure local photon count rate.
| Measure local photon count rate. | [
"Measure",
"local",
"photon",
"count",
"rate",
"."
] | def measure_local_count_rate(config_file_name: str = qkd_globals.config_file):
global localcountrate
with open(config_file_name, 'r') as f:
config = json.load(f, object_hook=lambda d: SimpleNamespace(**d))
localcountrate = -1
cmd = prog_readevents
args = f'-a 1 -F -u {config.clock_source} -S... | [
"def",
"measure_local_count_rate",
"(",
"config_file_name",
":",
"str",
"=",
"qkd_globals",
".",
"config_file",
")",
":",
"global",
"localcountrate",
"with",
"open",
"(",
"config_file_name",
",",
"'r'",
")",
"as",
"f",
":",
"config",
"=",
"json",
".",
"load",
... | Measure local photon count rate. | [
"Measure",
"local",
"photon",
"count",
"rate",
"."
] | [
"'''\n Measure local photon count rate.\n '''"
] | [
{
"param": "config_file_name",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "config_file_name",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dd26aa1a2cec849ed6868c3736efc01de1eb41a4 | s-fifteen-instruments/QKDServer | S15qkd/controller.py | [
"MIT"
] | Python | time_difference_find | <not_specific> | def time_difference_find():
'''
Starts pfind and searches for the detection coincidence peak in combined timestamp files.
'''
global periode_count, fft_buffer_order
global prog_pfind, first_epoch
first_epoch, epoch_diff = wait_for_epoch_files(periode_count)
if epoch_diff > 0:
use_p... |
Starts pfind and searches for the detection coincidence peak in combined timestamp files.
| Starts pfind and searches for the detection coincidence peak in combined timestamp files. | [
"Starts",
"pfind",
"and",
"searches",
"for",
"the",
"detection",
"coincidence",
"peak",
"in",
"combined",
"timestamp",
"files",
"."
] | def time_difference_find():
global periode_count, fft_buffer_order
global prog_pfind, first_epoch
first_epoch, epoch_diff = wait_for_epoch_files(periode_count)
if epoch_diff > 0:
use_periods = periode_count - epoch_diff
else:
use_periods = periode_count - 2
args = f'-d {cwd}/{d... | [
"def",
"time_difference_find",
"(",
")",
":",
"global",
"periode_count",
",",
"fft_buffer_order",
"global",
"prog_pfind",
",",
"first_epoch",
"first_epoch",
",",
"epoch_diff",
"=",
"wait_for_epoch_files",
"(",
"periode_count",
")",
"if",
"epoch_diff",
">",
"0",
":",... | Starts pfind and searches for the detection coincidence peak in combined timestamp files. | [
"Starts",
"pfind",
"and",
"searches",
"for",
"the",
"detection",
"coincidence",
"peak",
"in",
"combined",
"timestamp",
"files",
"."
] | [
"'''\n Starts pfind and searches for the detection coincidence peak in combined timestamp files.\n '''",
"# less periodes are available",
"# Not sure why minus 2, but I'm following what was done in crgui_ec."
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
dd26aa1a2cec849ed6868c3736efc01de1eb41a4 | s-fifteen-instruments/QKDServer | S15qkd/controller.py | [
"MIT"
] | Python | start_communication | null | def start_communication():
'''Establishes classical communication, based on sockets, between computers.
'''
if not transferd.is_running():
qkd_globals.FoldersQKD.prepare_folders()
qkd_globals.PipesQKD.prepare_pipes()
transferd.start_communication(msg_response) | Establishes classical communication, based on sockets, between computers.
| Establishes classical communication, based on sockets, between computers. | [
"Establishes",
"classical",
"communication",
"based",
"on",
"sockets",
"between",
"computers",
"."
] | def start_communication():
if not transferd.is_running():
qkd_globals.FoldersQKD.prepare_folders()
qkd_globals.PipesQKD.prepare_pipes()
transferd.start_communication(msg_response) | [
"def",
"start_communication",
"(",
")",
":",
"if",
"not",
"transferd",
".",
"is_running",
"(",
")",
":",
"qkd_globals",
".",
"FoldersQKD",
".",
"prepare_folders",
"(",
")",
"qkd_globals",
".",
"PipesQKD",
".",
"prepare_pipes",
"(",
")",
"transferd",
".",
"st... | Establishes classical communication, based on sockets, between computers. | [
"Establishes",
"classical",
"communication",
"based",
"on",
"sockets",
"between",
"computers",
"."
] | [
"'''Establishes classical communication, based on sockets, between computers.\n '''"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
dd26aa1a2cec849ed6868c3736efc01de1eb41a4 | s-fifteen-instruments/QKDServer | S15qkd/controller.py | [
"MIT"
] | Python | crash_detection_and_restart | <not_specific> | def crash_detection_and_restart(self, process_states):
'''
Checks if processes are running and restarts if any abnormalities are detected.
'''
if qkd_engine_state in [QKDEngineState.SERVICE_MODE, QKDEngineState.KEY_GENERATION]:
if process_states['transferd'] is False:
... |
Checks if processes are running and restarts if any abnormalities are detected.
| Checks if processes are running and restarts if any abnormalities are detected. | [
"Checks",
"if",
"processes",
"are",
"running",
"and",
"restarts",
"if",
"any",
"abnormalities",
"are",
"detected",
"."
] | def crash_detection_and_restart(self, process_states):
if qkd_engine_state in [QKDEngineState.SERVICE_MODE, QKDEngineState.KEY_GENERATION]:
if process_states['transferd'] is False:
self._logger.error(f'Transferd crashed. Trying to restart communication and key generation.')
... | [
"def",
"crash_detection_and_restart",
"(",
"self",
",",
"process_states",
")",
":",
"if",
"qkd_engine_state",
"in",
"[",
"QKDEngineState",
".",
"SERVICE_MODE",
",",
"QKDEngineState",
".",
"KEY_GENERATION",
"]",
":",
"if",
"process_states",
"[",
"'transferd'",
"]",
... | Checks if processes are running and restarts if any abnormalities are detected. | [
"Checks",
"if",
"processes",
"are",
"running",
"and",
"restarts",
"if",
"any",
"abnormalities",
"are",
"detected",
"."
] | [
"'''\n Checks if processes are running and restarts if any abnormalities are detected.\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "process_states",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "process_states",
"type": null,
"docstring": null,
"docstring_... |
907df9e5fdc054e70aab789c74762a06f7c4447d | s-fifteen-instruments/QKDServer | S15qkd/costream.py | [
"MIT"
] | Python | _genlog_digest | null | def _genlog_digest(qkd_protocol, config_file_name: str = qkd_globals.config_file):
'''
Digests the genlog pipe written by costream.
'''
global latest_coincidences, latest_accidentals, latest_deltat, latest_sentevents
global latest_compress, latest_rawevents, latest_outepoch
fd = os.open(PipesQKD... |
Digests the genlog pipe written by costream.
| Digests the genlog pipe written by costream. | [
"Digests",
"the",
"genlog",
"pipe",
"written",
"by",
"costream",
"."
] | def _genlog_digest(qkd_protocol, config_file_name: str = qkd_globals.config_file):
global latest_coincidences, latest_accidentals, latest_deltat, latest_sentevents
global latest_compress, latest_rawevents, latest_outepoch
fd = os.open(PipesQKD.GENLOG, os.O_RDONLY | os.O_NONBLOCK)
f = os.fdopen(fd, 'rb',... | [
"def",
"_genlog_digest",
"(",
"qkd_protocol",
",",
"config_file_name",
":",
"str",
"=",
"qkd_globals",
".",
"config_file",
")",
":",
"global",
"latest_coincidences",
",",
"latest_accidentals",
",",
"latest_deltat",
",",
"latest_sentevents",
"global",
"latest_compress",
... | Digests the genlog pipe written by costream. | [
"Digests",
"the",
"genlog",
"pipe",
"written",
"by",
"costream",
"."
] | [
"'''\n Digests the genlog pipe written by costream.\n '''",
"# non-blocking",
"# restart time difference finder if pairs to accidentals is too low"
] | [
{
"param": "qkd_protocol",
"type": null
},
{
"param": "config_file_name",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "qkd_protocol",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "config_file_name",
"type": "str",
"docstring": null,
... |
b6e3ac0b7bdd49714583145e2bae31ad2c166113 | s-fifteen-instruments/QKDServer | S15qkd/qkd_globals.py | [
"MIT"
] | Python | kill_process_by_name | <not_specific> | def kill_process_by_name(process_name: str):
'''
Searches processes by name and kills them.
'''
list_of_process_objects = []
# Iterate over the all the running process
for proc in psutil.process_iter():
try:
pinfo = proc.as_dict(attrs=['pid', 'name', 'create_time'])
... |
Searches processes by name and kills them.
| Searches processes by name and kills them. | [
"Searches",
"processes",
"by",
"name",
"and",
"kills",
"them",
"."
] | def kill_process_by_name(process_name: str):
list_of_process_objects = []
for proc in psutil.process_iter():
try:
pinfo = proc.as_dict(attrs=['pid', 'name', 'create_time'])
if process_name.lower() in pinfo['name'].lower():
list_of_process_objects.append(pinfo)
... | [
"def",
"kill_process_by_name",
"(",
"process_name",
":",
"str",
")",
":",
"list_of_process_objects",
"=",
"[",
"]",
"for",
"proc",
"in",
"psutil",
".",
"process_iter",
"(",
")",
":",
"try",
":",
"pinfo",
"=",
"proc",
".",
"as_dict",
"(",
"attrs",
"=",
"[... | Searches processes by name and kills them. | [
"Searches",
"processes",
"by",
"name",
"and",
"kills",
"them",
"."
] | [
"'''\n Searches processes by name and kills them.\n '''",
"# Iterate over the all the running process",
"# Check if process name contains the given name string."
] | [
{
"param": "process_name",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "process_name",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
bcfdfcfb669b194647488f08b26156e054a21f3a | Fatalerr/logparser | logparser/utils.py | [
"Apache-2.0"
] | Python | read_logfile | null | def read_logfile(self, filename):
"""read the log lines from log file.
NOTICE: large file should be considered.
"""
try:
with open(filename) as fp:
self._lines = fp.readlines()
except Exception as err:
print(f"Can't open logfile: {filename}... | read the log lines from log file.
NOTICE: large file should be considered.
| read the log lines from log file.
NOTICE: large file should be considered. | [
"read",
"the",
"log",
"lines",
"from",
"log",
"file",
".",
"NOTICE",
":",
"large",
"file",
"should",
"be",
"considered",
"."
] | def read_logfile(self, filename):
try:
with open(filename) as fp:
self._lines = fp.readlines()
except Exception as err:
print(f"Can't open logfile: {filename}. msg:{err}") | [
"def",
"read_logfile",
"(",
"self",
",",
"filename",
")",
":",
"try",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"fp",
":",
"self",
".",
"_lines",
"=",
"fp",
".",
"readlines",
"(",
")",
"except",
"Exception",
"as",
"err",
":",
"print",
"(",
"... | read the log lines from log file. | [
"read",
"the",
"log",
"lines",
"from",
"log",
"file",
"."
] | [
"\"\"\"read the log lines from log file.\n NOTICE: large file should be considered.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "filename",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename",
"type": null,
"docstring": null,
"docstring_tokens... |
bcfdfcfb669b194647488f08b26156e054a21f3a | Fatalerr/logparser | logparser/utils.py | [
"Apache-2.0"
] | Python | _select_lines | <not_specific> | def _select_lines(self, selector):
"""select the lines which filtered by selector.
selector is a class of `BlockFilter`
"""
selected = []
for line in self._lines:
start, end = selector.check(line)
#logger.debug(f"line:{[line]}, {start}, {end}")
... | select the lines which filtered by selector.
selector is a class of `BlockFilter`
| select the lines which filtered by selector.
selector is a class of `BlockFilter` | [
"select",
"the",
"lines",
"which",
"filtered",
"by",
"selector",
".",
"selector",
"is",
"a",
"class",
"of",
"`",
"BlockFilter",
"`"
] | def _select_lines(self, selector):
selected = []
for line in self._lines:
start, end = selector.check(line)
if start:
selected.append(line)
continue
if end and not self.multi_match:
selected.append(line)
... | [
"def",
"_select_lines",
"(",
"self",
",",
"selector",
")",
":",
"selected",
"=",
"[",
"]",
"for",
"line",
"in",
"self",
".",
"_lines",
":",
"start",
",",
"end",
"=",
"selector",
".",
"check",
"(",
"line",
")",
"if",
"start",
":",
"selected",
".",
"... | select the lines which filtered by selector. | [
"select",
"the",
"lines",
"which",
"filtered",
"by",
"selector",
"."
] | [
"\"\"\"select the lines which filtered by selector.\n selector is a class of `BlockFilter`\n \n \"\"\"",
"#logger.debug(f\"line:{[line]}, {start}, {end}\")"
] | [
{
"param": "self",
"type": null
},
{
"param": "selector",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "selector",
"type": null,
"docstring": null,
"docstring_tokens... |
bcfdfcfb669b194647488f08b26156e054a21f3a | Fatalerr/logparser | logparser/utils.py | [
"Apache-2.0"
] | Python | filter_blocks | <not_specific> | def filter_blocks(self, selector):
"""filtering multi blocks which have same structure selected by selector.
selector is a class of `BlockFilter`
"""
blocks = []
selected = []
for line in self._lines:
start, end = selector.check(line)
#log... | filtering multi blocks which have same structure selected by selector.
selector is a class of `BlockFilter`
| filtering multi blocks which have same structure selected by selector.
selector is a class of `BlockFilter` | [
"filtering",
"multi",
"blocks",
"which",
"have",
"same",
"structure",
"selected",
"by",
"selector",
".",
"selector",
"is",
"a",
"class",
"of",
"`",
"BlockFilter",
"`"
] | def filter_blocks(self, selector):
blocks = []
selected = []
for line in self._lines:
start, end = selector.check(line)
if start:
selected.append(line)
continue
if end:
selected.append(line)
block... | [
"def",
"filter_blocks",
"(",
"self",
",",
"selector",
")",
":",
"blocks",
"=",
"[",
"]",
"selected",
"=",
"[",
"]",
"for",
"line",
"in",
"self",
".",
"_lines",
":",
"start",
",",
"end",
"=",
"selector",
".",
"check",
"(",
"line",
")",
"if",
"start"... | filtering multi blocks which have same structure selected by selector. | [
"filtering",
"multi",
"blocks",
"which",
"have",
"same",
"structure",
"selected",
"by",
"selector",
"."
] | [
"\"\"\"filtering multi blocks which have same structure selected by selector.\n selector is a class of `BlockFilter`\n \n \"\"\"",
"#logger.debug(f\"line:{[line]}, {start}, {end}\")"
] | [
{
"param": "self",
"type": null
},
{
"param": "selector",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "selector",
"type": null,
"docstring": null,
"docstring_tokens... |
bcfdfcfb669b194647488f08b26156e054a21f3a | Fatalerr/logparser | logparser/utils.py | [
"Apache-2.0"
] | Python | _filter_block | <not_specific> | def _filter_block(self, filter_list):
"""filter the log blocks using the 'ilter_list`
params:
filter_list, a list including some `BlockFilter` classes
return:
a list including some log lines blocks.
"""
blocks = []
for blk_filt... | filter the log blocks using the 'ilter_list`
params:
filter_list, a list including some `BlockFilter` classes
return:
a list including some log lines blocks.
| filter the log blocks using the 'ilter_list`
params:
filter_list, a list including some `BlockFilter` classes
a list including some log lines blocks. | [
"filter",
"the",
"log",
"blocks",
"using",
"the",
"'",
"ilter_list",
"`",
"params",
":",
"filter_list",
"a",
"list",
"including",
"some",
"`",
"BlockFilter",
"`",
"classes",
"a",
"list",
"including",
"some",
"log",
"lines",
"blocks",
"."
] | def _filter_block(self, filter_list):
blocks = []
for blk_filter in filter_list:
blocks.append(self._select_lines(blk_filter))
self.blocks = blocks
return blocks | [
"def",
"_filter_block",
"(",
"self",
",",
"filter_list",
")",
":",
"blocks",
"=",
"[",
"]",
"for",
"blk_filter",
"in",
"filter_list",
":",
"blocks",
".",
"append",
"(",
"self",
".",
"_select_lines",
"(",
"blk_filter",
")",
")",
"self",
".",
"blocks",
"="... | filter the log blocks using the 'ilter_list`
params:
filter_list, a list including some `BlockFilter` classes | [
"filter",
"the",
"log",
"blocks",
"using",
"the",
"'",
"ilter_list",
"`",
"params",
":",
"filter_list",
"a",
"list",
"including",
"some",
"`",
"BlockFilter",
"`",
"classes"
] | [
"\"\"\"filter the log blocks using the 'ilter_list` \n \n params: \n filter_list, a list including some `BlockFilter` classes\n \n return:\n a list including some log lines blocks.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "filter_list",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filter_list",
"type": null,
"docstring": null,
"docstring_tok... |
25d9a481cd9755dc6e53ce6e271a59d77e338b36 | Fatalerr/logparser | logparser/logparser.py | [
"Apache-2.0"
] | Python | load_from_file | null | def load_from_file(self, filename=None):
"""load log content from file.
"""
try:
with open(filename) as fp:
self.lines = fp.readlines()
except IOError as err:
print(f"Can't open config file: {filename}\n{err}")
exit(1) | load log content from file.
| load log content from file. | [
"load",
"log",
"content",
"from",
"file",
"."
] | def load_from_file(self, filename=None):
try:
with open(filename) as fp:
self.lines = fp.readlines()
except IOError as err:
print(f"Can't open config file: {filename}\n{err}")
exit(1) | [
"def",
"load_from_file",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"try",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"fp",
":",
"self",
".",
"lines",
"=",
"fp",
".",
"readlines",
"(",
")",
"except",
"IOError",
"as",
"err",
":",
"pr... | load log content from file. | [
"load",
"log",
"content",
"from",
"file",
"."
] | [
"\"\"\"load log content from file.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "filename",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename",
"type": null,
"docstring": null,
"docstring_tokens... |
25d9a481cd9755dc6e53ce6e271a59d77e338b36 | Fatalerr/logparser | logparser/logparser.py | [
"Apache-2.0"
] | Python | parse | <not_specific> | def parse(self, lines):
"""parse the lines with the loaded/preset rules
"""
self._data = {}
for rule in self._rules:
#print(rule.name, rule.re_pattern)
data = rule.parse(lines)
self._data[rule.name] = data
return self._data | parse the lines with the loaded/preset rules
| parse the lines with the loaded/preset rules | [
"parse",
"the",
"lines",
"with",
"the",
"loaded",
"/",
"preset",
"rules"
] | def parse(self, lines):
self._data = {}
for rule in self._rules:
data = rule.parse(lines)
self._data[rule.name] = data
return self._data | [
"def",
"parse",
"(",
"self",
",",
"lines",
")",
":",
"self",
".",
"_data",
"=",
"{",
"}",
"for",
"rule",
"in",
"self",
".",
"_rules",
":",
"data",
"=",
"rule",
".",
"parse",
"(",
"lines",
")",
"self",
".",
"_data",
"[",
"rule",
".",
"name",
"]"... | parse the lines with the loaded/preset rules | [
"parse",
"the",
"lines",
"with",
"the",
"loaded",
"/",
"preset",
"rules"
] | [
"\"\"\"parse the lines with the loaded/preset rules\n \"\"\"",
"#print(rule.name, rule.re_pattern)"
] | [
{
"param": "self",
"type": null
},
{
"param": "lines",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lines",
"type": null,
"docstring": null,
"docstring_tokens": ... |
04beffc759c47dc3e97227887132afe00fd5ba60 | TSchweikert/BalancingControl | world.py | [
"MIT"
] | Python | simulate_experiment | null | def simulate_experiment(self, curr_trials=None):
"""This methods evolves all the states of the world by iterating
through all the trials and time steps of each trial.
"""
if curr_trials is not None:
trials = curr_trials
else:
trials = range(self.trials)
... | This methods evolves all the states of the world by iterating
through all the trials and time steps of each trial.
| This methods evolves all the states of the world by iterating
through all the trials and time steps of each trial. | [
"This",
"methods",
"evolves",
"all",
"the",
"states",
"of",
"the",
"world",
"by",
"iterating",
"through",
"all",
"the",
"trials",
"and",
"time",
"steps",
"of",
"each",
"trial",
"."
] | def simulate_experiment(self, curr_trials=None):
if curr_trials is not None:
trials = curr_trials
else:
trials = range(self.trials)
for tau in trials:
for t in range(self.T):
self.__update_world(tau, t) | [
"def",
"simulate_experiment",
"(",
"self",
",",
"curr_trials",
"=",
"None",
")",
":",
"if",
"curr_trials",
"is",
"not",
"None",
":",
"trials",
"=",
"curr_trials",
"else",
":",
"trials",
"=",
"range",
"(",
"self",
".",
"trials",
")",
"for",
"tau",
"in",
... | This methods evolves all the states of the world by iterating
through all the trials and time steps of each trial. | [
"This",
"methods",
"evolves",
"all",
"the",
"states",
"of",
"the",
"world",
"by",
"iterating",
"through",
"all",
"the",
"trials",
"and",
"time",
"steps",
"of",
"each",
"trial",
"."
] | [
"\"\"\"This methods evolves all the states of the world by iterating\n through all the trials and time steps of each trial.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "curr_trials",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "curr_trials",
"type": null,
"docstring": null,
"docstring_tok... |
04beffc759c47dc3e97227887132afe00fd5ba60 | TSchweikert/BalancingControl | world.py | [
"MIT"
] | Python | fit_model | <not_specific> | def fit_model(self, bounds, n_pars, method='MLE'):
"""This method uses the existing observation and response data to
determine the set of parameter values that are most likely to cause
the meassured behavior.
"""
inference = Inference(ftol = 1e-4, xtol = 1e-8, bounds = bounds,
... | This method uses the existing observation and response data to
determine the set of parameter values that are most likely to cause
the meassured behavior.
| This method uses the existing observation and response data to
determine the set of parameter values that are most likely to cause
the meassured behavior. | [
"This",
"method",
"uses",
"the",
"existing",
"observation",
"and",
"response",
"data",
"to",
"determine",
"the",
"set",
"of",
"parameter",
"values",
"that",
"are",
"most",
"likely",
"to",
"cause",
"the",
"meassured",
"behavior",
"."
] | def fit_model(self, bounds, n_pars, method='MLE'):
inference = Inference(ftol = 1e-4, xtol = 1e-8, bounds = bounds,
opts = {'np': n_pars})
if method == 'MLE':
return inference.infer_posterior(self.__get_log_likelihood)
else:
return inference.inf... | [
"def",
"fit_model",
"(",
"self",
",",
"bounds",
",",
"n_pars",
",",
"method",
"=",
"'MLE'",
")",
":",
"inference",
"=",
"Inference",
"(",
"ftol",
"=",
"1e-4",
",",
"xtol",
"=",
"1e-8",
",",
"bounds",
"=",
"bounds",
",",
"opts",
"=",
"{",
"'np'",
":... | This method uses the existing observation and response data to
determine the set of parameter values that are most likely to cause
the meassured behavior. | [
"This",
"method",
"uses",
"the",
"existing",
"observation",
"and",
"response",
"data",
"to",
"determine",
"the",
"set",
"of",
"parameter",
"values",
"that",
"are",
"most",
"likely",
"to",
"cause",
"the",
"meassured",
"behavior",
"."
] | [
"\"\"\"This method uses the existing observation and response data to\n determine the set of parameter values that are most likely to cause\n the meassured behavior.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "bounds",
"type": null
},
{
"param": "n_pars",
"type": null
},
{
"param": "method",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bounds",
"type": null,
"docstring": null,
"docstring_tokens":... |
04beffc759c47dc3e97227887132afe00fd5ba60 | TSchweikert/BalancingControl | world.py | [
"MIT"
] | Python | __update_model | null | def __update_model(self):
"""This private method updates the internal states of the behavioral
model given the avalible set of observations and actions.
"""
for tau in range(self.trials):
for t in range(self.T):
if t == 0:
response = None
... | This private method updates the internal states of the behavioral
model given the avalible set of observations and actions.
| This private method updates the internal states of the behavioral
model given the avalible set of observations and actions. | [
"This",
"private",
"method",
"updates",
"the",
"internal",
"states",
"of",
"the",
"behavioral",
"model",
"given",
"the",
"avalible",
"set",
"of",
"observations",
"and",
"actions",
"."
] | def __update_model(self):
for tau in range(self.trials):
for t in range(self.T):
if t == 0:
response = None
else:
response = self.actions[tau, t-1]
observation = self.observations[tau,t]
self.agen... | [
"def",
"__update_model",
"(",
"self",
")",
":",
"for",
"tau",
"in",
"range",
"(",
"self",
".",
"trials",
")",
":",
"for",
"t",
"in",
"range",
"(",
"self",
".",
"T",
")",
":",
"if",
"t",
"==",
"0",
":",
"response",
"=",
"None",
"else",
":",
"res... | This private method updates the internal states of the behavioral
model given the avalible set of observations and actions. | [
"This",
"private",
"method",
"updates",
"the",
"internal",
"states",
"of",
"the",
"behavioral",
"model",
"given",
"the",
"avalible",
"set",
"of",
"observations",
"and",
"actions",
"."
] | [
"\"\"\"This private method updates the internal states of the behavioral\n model given the avalible set of observations and actions.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
04beffc759c47dc3e97227887132afe00fd5ba60 | TSchweikert/BalancingControl | world.py | [
"MIT"
] | Python | __update_world | null | def __update_world(self, tau, t):
"""This private method performs a signel time step update of the
whole world. Here we update the hidden state(s) of the environment,
the perceptual and planning states of the agent, and in parallel we
generate observations and actions.
"""
... | This private method performs a signel time step update of the
whole world. Here we update the hidden state(s) of the environment,
the perceptual and planning states of the agent, and in parallel we
generate observations and actions.
| This private method performs a signel time step update of the
whole world. Here we update the hidden state(s) of the environment,
the perceptual and planning states of the agent, and in parallel we
generate observations and actions. | [
"This",
"private",
"method",
"performs",
"a",
"signel",
"time",
"step",
"update",
"of",
"the",
"whole",
"world",
".",
"Here",
"we",
"update",
"the",
"hidden",
"state",
"(",
"s",
")",
"of",
"the",
"environment",
"the",
"perceptual",
"and",
"planning",
"stat... | def __update_world(self, tau, t):
if t==0:
self.environment.set_initial_states(tau)
response = None
if hasattr(self.environment, 'Chi'):
context = self.environment.generate_context_obs(tau)
else:
context = None
else:
... | [
"def",
"__update_world",
"(",
"self",
",",
"tau",
",",
"t",
")",
":",
"if",
"t",
"==",
"0",
":",
"self",
".",
"environment",
".",
"set_initial_states",
"(",
"tau",
")",
"response",
"=",
"None",
"if",
"hasattr",
"(",
"self",
".",
"environment",
",",
"... | This private method performs a signel time step update of the
whole world. | [
"This",
"private",
"method",
"performs",
"a",
"signel",
"time",
"step",
"update",
"of",
"the",
"whole",
"world",
"."
] | [
"\"\"\"This private method performs a signel time step update of the\n whole world. Here we update the hidden state(s) of the environment,\n the perceptual and planning states of the agent, and in parallel we\n generate observations and actions.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "tau",
"type": null
},
{
"param": "t",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tau",
"type": null,
"docstring": null,
"docstring_tokens": []... |
04beffc759c47dc3e97227887132afe00fd5ba60 | TSchweikert/BalancingControl | world.py | [
"MIT"
] | Python | __update_world | null | def __update_world(self, tau, t):
"""This private method performs a signel time step update of the
whole world. Here we update the hidden state(s) of the environment,
the perceptual and planning states of the agent, and in parallel we
generate observations and actions.
"""
... | This private method performs a signel time step update of the
whole world. Here we update the hidden state(s) of the environment,
the perceptual and planning states of the agent, and in parallel we
generate observations and actions.
| This private method performs a signel time step update of the
whole world. Here we update the hidden state(s) of the environment,
the perceptual and planning states of the agent, and in parallel we
generate observations and actions. | [
"This",
"private",
"method",
"performs",
"a",
"signel",
"time",
"step",
"update",
"of",
"the",
"whole",
"world",
".",
"Here",
"we",
"update",
"the",
"hidden",
"state",
"(",
"s",
")",
"of",
"the",
"environment",
"the",
"perceptual",
"and",
"planning",
"stat... | def __update_world(self, tau, t):
if t==0:
self.environment.set_initial_states(tau)
response = None
else:
response = self.actions[tau, t-1]
self.environment.update_hidden_states(tau, t, response)
self.observations[tau, t] = \
self.envir... | [
"def",
"__update_world",
"(",
"self",
",",
"tau",
",",
"t",
")",
":",
"if",
"t",
"==",
"0",
":",
"self",
".",
"environment",
".",
"set_initial_states",
"(",
"tau",
")",
"response",
"=",
"None",
"else",
":",
"response",
"=",
"self",
".",
"actions",
"[... | This private method performs a signel time step update of the
whole world. | [
"This",
"private",
"method",
"performs",
"a",
"signel",
"time",
"step",
"update",
"of",
"the",
"whole",
"world",
"."
] | [
"\"\"\"This private method performs a signel time step update of the\n whole world. Here we update the hidden state(s) of the environment,\n the perceptual and planning states of the agent, and in parallel we\n generate observations and actions.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "tau",
"type": null
},
{
"param": "t",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tau",
"type": null,
"docstring": null,
"docstring_tokens": []... |
04beffc759c47dc3e97227887132afe00fd5ba60 | TSchweikert/BalancingControl | world.py | [
"MIT"
] | Python | __simulate_agent | null | def __simulate_agent(self):
"""This methods evolves all the states of the world by iterating
through all the trials and time steps of each trial.
"""
for tau in range(self.trials):
for t in range(self.T):
self.__update_model(tau, t) | This methods evolves all the states of the world by iterating
through all the trials and time steps of each trial.
| This methods evolves all the states of the world by iterating
through all the trials and time steps of each trial. | [
"This",
"methods",
"evolves",
"all",
"the",
"states",
"of",
"the",
"world",
"by",
"iterating",
"through",
"all",
"the",
"trials",
"and",
"time",
"steps",
"of",
"each",
"trial",
"."
] | def __simulate_agent(self):
for tau in range(self.trials):
for t in range(self.T):
self.__update_model(tau, t) | [
"def",
"__simulate_agent",
"(",
"self",
")",
":",
"for",
"tau",
"in",
"range",
"(",
"self",
".",
"trials",
")",
":",
"for",
"t",
"in",
"range",
"(",
"self",
".",
"T",
")",
":",
"self",
".",
"__update_model",
"(",
"tau",
",",
"t",
")"
] | This methods evolves all the states of the world by iterating
through all the trials and time steps of each trial. | [
"This",
"methods",
"evolves",
"all",
"the",
"states",
"of",
"the",
"world",
"by",
"iterating",
"through",
"all",
"the",
"trials",
"and",
"time",
"steps",
"of",
"each",
"trial",
"."
] | [
"\"\"\"This methods evolves all the states of the world by iterating\n through all the trials and time steps of each trial.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
04beffc759c47dc3e97227887132afe00fd5ba60 | TSchweikert/BalancingControl | world.py | [
"MIT"
] | Python | __update_model | null | def __update_model(self, tau, t):
"""This private method updates the internal states of the behavioral
model given the avalible set of observations and actions.
"""
if t==0:
response = None
else:
response = self.actions[tau, t-1]
self.like_act... | This private method updates the internal states of the behavioral
model given the avalible set of observations and actions.
| This private method updates the internal states of the behavioral
model given the avalible set of observations and actions. | [
"This",
"private",
"method",
"updates",
"the",
"internal",
"states",
"of",
"the",
"behavioral",
"model",
"given",
"the",
"avalible",
"set",
"of",
"observations",
"and",
"actions",
"."
] | def __update_model(self, tau, t):
if t==0:
response = None
else:
response = self.actions[tau, t-1]
self.like_actions[tau,t-1] = self.agent.posterior_actions[tau, t-1, response]
observation = self.observations[tau, t]
reward = self.rewards[tau, t]
... | [
"def",
"__update_model",
"(",
"self",
",",
"tau",
",",
"t",
")",
":",
"if",
"t",
"==",
"0",
":",
"response",
"=",
"None",
"else",
":",
"response",
"=",
"self",
".",
"actions",
"[",
"tau",
",",
"t",
"-",
"1",
"]",
"self",
".",
"like_actions",
"[",... | This private method updates the internal states of the behavioral
model given the avalible set of observations and actions. | [
"This",
"private",
"method",
"updates",
"the",
"internal",
"states",
"of",
"the",
"behavioral",
"model",
"given",
"the",
"avalible",
"set",
"of",
"observations",
"and",
"actions",
"."
] | [
"\"\"\"This private method updates the internal states of the behavioral\n model given the avalible set of observations and actions.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "tau",
"type": null
},
{
"param": "t",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tau",
"type": null,
"docstring": null,
"docstring_tokens": []... |
e05fe3a57c7da3432cfb77d393b2e3bbf1fcec2e | TSchweikert/BalancingControl | inference_twostage.py | [
"MIT"
] | Python | infer_posterior | <not_specific> | def infer_posterior(self,
iter_steps=1000,
num_particles=10,
optim_kwargs={'lr': .01}):
"""Perform SVI over free model parameters.
"""
pyro.clear_param_store()
svi = pyro.infer.SVI(model=self.model,
... | Perform SVI over free model parameters.
| Perform SVI over free model parameters. | [
"Perform",
"SVI",
"over",
"free",
"model",
"parameters",
"."
] | def infer_posterior(self,
iter_steps=1000,
num_particles=10,
optim_kwargs={'lr': .01}):
pyro.clear_param_store()
svi = pyro.infer.SVI(model=self.model,
guide=self.guide,
optim=pyro.optim.Adam(opti... | [
"def",
"infer_posterior",
"(",
"self",
",",
"iter_steps",
"=",
"1000",
",",
"num_particles",
"=",
"10",
",",
"optim_kwargs",
"=",
"{",
"'lr'",
":",
".01",
"}",
")",
":",
"pyro",
".",
"clear_param_store",
"(",
")",
"svi",
"=",
"pyro",
".",
"infer",
".",... | Perform SVI over free model parameters. | [
"Perform",
"SVI",
"over",
"free",
"model",
"parameters",
"."
] | [
"\"\"\"Perform SVI over free model parameters.\n \"\"\"",
"#set below to true once code is vectorized"
] | [
{
"param": "self",
"type": null
},
{
"param": "iter_steps",
"type": null
},
{
"param": "num_particles",
"type": null
},
{
"param": "optim_kwargs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "iter_steps",
"type": null,
"docstring": null,
"docstring_toke... |
fc496b4a1a2cd806ab458dec48b0b7e6db42cd9d | marrow/contentment | web/contentment/taxonomy.py | [
"MIT"
] | Python | _find_references | <not_specific> | def _find_references(self, items, depth=0, finded_ids=None):
"""
Recursively finds all db references to be dereferenced
:param items: The iterable (dict, list, queryset)
:param depth: The current depth of recursion
"""
# if items and isinstance(items, list) and getattr(items[0], 'name', '') == 'child2':
... |
Recursively finds all db references to be dereferenced
:param items: The iterable (dict, list, queryset)
:param depth: The current depth of recursion
| Recursively finds all db references to be dereferenced | [
"Recursively",
"finds",
"all",
"db",
"references",
"to",
"be",
"dereferenced"
] | def _find_references(self, items, depth=0, finded_ids=None):
reference_map = {}
if not items or depth >= self.max_depth:
return reference_map
if not hasattr(items, 'items'):
iterator = enumerate(items)
else:
iterator = iter(items.items())
depth += 1
processed_ids = finded_ids if finded_ids is not N... | [
"def",
"_find_references",
"(",
"self",
",",
"items",
",",
"depth",
"=",
"0",
",",
"finded_ids",
"=",
"None",
")",
":",
"reference_map",
"=",
"{",
"}",
"if",
"not",
"items",
"or",
"depth",
">=",
"self",
".",
"max_depth",
":",
"return",
"reference_map",
... | Recursively finds all db references to be dereferenced | [
"Recursively",
"finds",
"all",
"db",
"references",
"to",
"be",
"dereferenced"
] | [
"\"\"\"\n\t\tRecursively finds all db references to be dereferenced\n\n\t\t:param items: The iterable (dict, list, queryset)\n\t\t:param depth: The current depth of recursion\n\t\t\"\"\"",
"# if items and isinstance(items, list) and getattr(items[0], 'name', '') == 'child2':",
"# \timport pudb; pudb.set_trace()... | [
{
"param": "self",
"type": null
},
{
"param": "items",
"type": null
},
{
"param": "depth",
"type": null
},
{
"param": "finded_ids",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "items",
"type": null,
"docstring": "The iterable (dict, list, query... |
fc496b4a1a2cd806ab458dec48b0b7e6db42cd9d | marrow/contentment | web/contentment/taxonomy.py | [
"MIT"
] | Python | empty | <not_specific> | def empty(self, *q_objs, **query):
"""Delete all descendants of the currently selected assets.
Warning: If run on all assets this will only leave the root element intact. It would also be expensive.
"""
# import ipdb; ipdb.set_trace()
parents = self.clone().filter(*q_objs, **query)
# Optimization note: ... | Delete all descendants of the currently selected assets.
Warning: If run on all assets this will only leave the root element intact. It would also be expensive.
| Delete all descendants of the currently selected assets.
Warning: If run on all assets this will only leave the root element intact. It would also be expensive. | [
"Delete",
"all",
"descendants",
"of",
"the",
"currently",
"selected",
"assets",
".",
"Warning",
":",
"If",
"run",
"on",
"all",
"assets",
"this",
"will",
"only",
"leave",
"the",
"root",
"element",
"intact",
".",
"It",
"would",
"also",
"be",
"expensive",
"."... | def empty(self, *q_objs, **query):
parents = self.clone().filter(*q_objs, **query)
self.base_query(parents__in=parents).delete(write_concern=None, _from_doc_delete=True)
return self | [
"def",
"empty",
"(",
"self",
",",
"*",
"q_objs",
",",
"**",
"query",
")",
":",
"parents",
"=",
"self",
".",
"clone",
"(",
")",
".",
"filter",
"(",
"*",
"q_objs",
",",
"**",
"query",
")",
"self",
".",
"base_query",
"(",
"parents__in",
"=",
"parents"... | Delete all descendants of the currently selected assets. | [
"Delete",
"all",
"descendants",
"of",
"the",
"currently",
"selected",
"assets",
"."
] | [
"\"\"\"Delete all descendants of the currently selected assets.\n\n\t\tWarning: If run on all assets this will only leave the root element intact. It would also be expensive.\n\t\t\"\"\"",
"# import ipdb; ipdb.set_trace()",
"# Optimization note: this doesn't need to worry about normalizing paths, thus the _from... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fc496b4a1a2cd806ab458dec48b0b7e6db42cd9d | marrow/contentment | web/contentment/taxonomy.py | [
"MIT"
] | Python | insert | <not_specific> | def insert(self, index, child):
"""Add an asset, specified by the parameter, as a child of this asset."""
parent = self.clone().first()
log.info("Inserting asset.", extra=dict(asset=parent.id, index=index, child=getattr(child, 'id', child)))
# Detach the new child (and thus it's own child nodes).
chi... | Add an asset, specified by the parameter, as a child of this asset. | Add an asset, specified by the parameter, as a child of this asset. | [
"Add",
"an",
"asset",
"specified",
"by",
"the",
"parameter",
"as",
"a",
"child",
"of",
"this",
"asset",
"."
] | def insert(self, index, child):
parent = self.clone().first()
log.info("Inserting asset.", extra=dict(asset=parent.id, index=index, child=getattr(child, 'id', child)))
child = (self.base_query.get(id=child) if isinstance(child, ObjectId) else child).detach(False)
if index < 0:
_max = self.base_query(parent=p... | [
"def",
"insert",
"(",
"self",
",",
"index",
",",
"child",
")",
":",
"parent",
"=",
"self",
".",
"clone",
"(",
")",
".",
"first",
"(",
")",
"log",
".",
"info",
"(",
"\"Inserting asset.\"",
",",
"extra",
"=",
"dict",
"(",
"asset",
"=",
"parent",
".",... | Add an asset, specified by the parameter, as a child of this asset. | [
"Add",
"an",
"asset",
"specified",
"by",
"the",
"parameter",
"as",
"a",
"child",
"of",
"this",
"asset",
"."
] | [
"\"\"\"Add an asset, specified by the parameter, as a child of this asset.\"\"\"",
"# Detach the new child (and thus it's own child nodes)."
] | [
{
"param": "self",
"type": null
},
{
"param": "index",
"type": null
},
{
"param": "child",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "index",
"type": null,
"docstring": null,
"docstring_tokens": ... |
fc496b4a1a2cd806ab458dec48b0b7e6db42cd9d | marrow/contentment | web/contentment/taxonomy.py | [
"MIT"
] | Python | detach | <not_specific> | def detach(self, path=True):
"""Detach this asset from its current taxonomy."""
obj = self.clone().first()
if obj.path in (None, '', obj.name):
return obj
log.warn("Detaching from taxonomy.", extra=dict(asset=repr(obj), path=path))
self.nextAll.update(inc__order=-1)
self.contents.update(pull_... | Detach this asset from its current taxonomy. | Detach this asset from its current taxonomy. | [
"Detach",
"this",
"asset",
"from",
"its",
"current",
"taxonomy",
"."
] | def detach(self, path=True):
obj = self.clone().first()
if obj.path in (None, '', obj.name):
return obj
log.warn("Detaching from taxonomy.", extra=dict(asset=repr(obj), path=path))
self.nextAll.update(inc__order=-1)
self.contents.update(pull_all__parents=obj.parents)
obj.order = None
obj.path = obj.nam... | [
"def",
"detach",
"(",
"self",
",",
"path",
"=",
"True",
")",
":",
"obj",
"=",
"self",
".",
"clone",
"(",
")",
".",
"first",
"(",
")",
"if",
"obj",
".",
"path",
"in",
"(",
"None",
",",
"''",
",",
"obj",
".",
"name",
")",
":",
"return",
"obj",
... | Detach this asset from its current taxonomy. | [
"Detach",
"this",
"asset",
"from",
"its",
"current",
"taxonomy",
"."
] | [
"\"\"\"Detach this asset from its current taxonomy.\"\"\"",
"# We can't use `del obj.parents[:]` because MongoEngine detects that."
] | [
{
"param": "self",
"type": null
},
{
"param": "path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "path",
"type": null,
"docstring": null,
"docstring_tokens": [... |
fc496b4a1a2cd806ab458dec48b0b7e6db42cd9d | marrow/contentment | web/contentment/taxonomy.py | [
"MIT"
] | Python | after | <not_specific> | def after(self, sibling):
"""Insert an asset, specified by the parameter, after this asset."""
obj = self.clone().first()
obj.parent.insert(obj.order + 1, sibling)
return self | Insert an asset, specified by the parameter, after this asset. | Insert an asset, specified by the parameter, after this asset. | [
"Insert",
"an",
"asset",
"specified",
"by",
"the",
"parameter",
"after",
"this",
"asset",
"."
] | def after(self, sibling):
obj = self.clone().first()
obj.parent.insert(obj.order + 1, sibling)
return self | [
"def",
"after",
"(",
"self",
",",
"sibling",
")",
":",
"obj",
"=",
"self",
".",
"clone",
"(",
")",
".",
"first",
"(",
")",
"obj",
".",
"parent",
".",
"insert",
"(",
"obj",
".",
"order",
"+",
"1",
",",
"sibling",
")",
"return",
"self"
] | Insert an asset, specified by the parameter, after this asset. | [
"Insert",
"an",
"asset",
"specified",
"by",
"the",
"parameter",
"after",
"this",
"asset",
"."
] | [
"\"\"\"Insert an asset, specified by the parameter, after this asset.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "sibling",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sibling",
"type": null,
"docstring": null,
"docstring_tokens"... |
fc496b4a1a2cd806ab458dec48b0b7e6db42cd9d | marrow/contentment | web/contentment/taxonomy.py | [
"MIT"
] | Python | before | <not_specific> | def before(self, sibling):
"""Insert an asset, specified by the parameter, before this asset."""
obj = self.clone().first()
obj.parent.insert(obj.order, sibling)
return self | Insert an asset, specified by the parameter, before this asset. | Insert an asset, specified by the parameter, before this asset. | [
"Insert",
"an",
"asset",
"specified",
"by",
"the",
"parameter",
"before",
"this",
"asset",
"."
] | def before(self, sibling):
obj = self.clone().first()
obj.parent.insert(obj.order, sibling)
return self | [
"def",
"before",
"(",
"self",
",",
"sibling",
")",
":",
"obj",
"=",
"self",
".",
"clone",
"(",
")",
".",
"first",
"(",
")",
"obj",
".",
"parent",
".",
"insert",
"(",
"obj",
".",
"order",
",",
"sibling",
")",
"return",
"self"
] | Insert an asset, specified by the parameter, before this asset. | [
"Insert",
"an",
"asset",
"specified",
"by",
"the",
"parameter",
"before",
"this",
"asset",
"."
] | [
"\"\"\"Insert an asset, specified by the parameter, before this asset.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "sibling",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sibling",
"type": null,
"docstring": null,
"docstring_tokens"... |
fc496b4a1a2cd806ab458dec48b0b7e6db42cd9d | marrow/contentment | web/contentment/taxonomy.py | [
"MIT"
] | Python | replace | <not_specific> | def replace(self, target):
"""Replace an asset, specified by the parameter, with this asset."""
target = self.clone().get(id=target) if isinstance(target, ObjectId) else target
obj = self.clone().first()
obj.name = target.name
obj.parent = target.parent
obj.parents = target.parents
obj.path = target... | Replace an asset, specified by the parameter, with this asset. | Replace an asset, specified by the parameter, with this asset. | [
"Replace",
"an",
"asset",
"specified",
"by",
"the",
"parameter",
"with",
"this",
"asset",
"."
] | def replace(self, target):
target = self.clone().get(id=target) if isinstance(target, ObjectId) else target
obj = self.clone().first()
obj.name = target.name
obj.parent = target.parent
obj.parents = target.parents
obj.path = target.path
obj.order = target.order
target.delete()
obj.save()
return self | [
"def",
"replace",
"(",
"self",
",",
"target",
")",
":",
"target",
"=",
"self",
".",
"clone",
"(",
")",
".",
"get",
"(",
"id",
"=",
"target",
")",
"if",
"isinstance",
"(",
"target",
",",
"ObjectId",
")",
"else",
"target",
"obj",
"=",
"self",
".",
... | Replace an asset, specified by the parameter, with this asset. | [
"Replace",
"an",
"asset",
"specified",
"by",
"the",
"parameter",
"with",
"this",
"asset",
"."
] | [
"\"\"\"Replace an asset, specified by the parameter, with this asset.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "target",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "target",
"type": null,
"docstring": null,
"docstring_tokens":... |
fc496b4a1a2cd806ab458dec48b0b7e6db42cd9d | marrow/contentment | web/contentment/taxonomy.py | [
"MIT"
] | Python | replaceWith | <not_specific> | def replaceWith(self, source):
"""Replace this asset with an asset specified by the parameter."""
source = self.clone().get(id=source) if isinstance(source, ObjectId) else source
obj = self.clone().first()
source.name = obj.name
source.parent = obj.parent
source.parents = obj.parents
source.path = o... | Replace this asset with an asset specified by the parameter. | Replace this asset with an asset specified by the parameter. | [
"Replace",
"this",
"asset",
"with",
"an",
"asset",
"specified",
"by",
"the",
"parameter",
"."
] | def replaceWith(self, source):
source = self.clone().get(id=source) if isinstance(source, ObjectId) else source
obj = self.clone().first()
source.name = obj.name
source.parent = obj.parent
source.parents = obj.parents
source.path = obj.path
source.order = obj.order
obj.delete()
source.save()
return ... | [
"def",
"replaceWith",
"(",
"self",
",",
"source",
")",
":",
"source",
"=",
"self",
".",
"clone",
"(",
")",
".",
"get",
"(",
"id",
"=",
"source",
")",
"if",
"isinstance",
"(",
"source",
",",
"ObjectId",
")",
"else",
"source",
"obj",
"=",
"self",
"."... | Replace this asset with an asset specified by the parameter. | [
"Replace",
"this",
"asset",
"with",
"an",
"asset",
"specified",
"by",
"the",
"parameter",
"."
] | [
"\"\"\"Replace this asset with an asset specified by the parameter.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "source",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "source",
"type": null,
"docstring": null,
"docstring_tokens":... |
fc496b4a1a2cd806ab458dec48b0b7e6db42cd9d | marrow/contentment | web/contentment/taxonomy.py | [
"MIT"
] | Python | siblings | <not_specific> | def siblings(self):
"""All siblings of the currently selected assets, not including these assets."""
query = []
for id, parent in self.clone().scalar('id', 'parent'):#.no_dereference():
query.append(Q(parent=parent, id__ne=id))
if not query: # TODO: Armour everywhere.
return None
return sel... | All siblings of the currently selected assets, not including these assets. | All siblings of the currently selected assets, not including these assets. | [
"All",
"siblings",
"of",
"the",
"currently",
"selected",
"assets",
"not",
"including",
"these",
"assets",
"."
] | def siblings(self):
query = []
for id, parent in self.clone().scalar('id', 'parent'):
query.append(Q(parent=parent, id__ne=id))
if not query:
return None
return self.base_query(reduce(__or__, query)).order_by('parent', 'order') | [
"def",
"siblings",
"(",
"self",
")",
":",
"query",
"=",
"[",
"]",
"for",
"id",
",",
"parent",
"in",
"self",
".",
"clone",
"(",
")",
".",
"scalar",
"(",
"'id'",
",",
"'parent'",
")",
":",
"query",
".",
"append",
"(",
"Q",
"(",
"parent",
"=",
"pa... | All siblings of the currently selected assets, not including these assets. | [
"All",
"siblings",
"of",
"the",
"currently",
"selected",
"assets",
"not",
"including",
"these",
"assets",
"."
] | [
"\"\"\"All siblings of the currently selected assets, not including these assets.\"\"\"",
"#.no_dereference():",
"# TODO: Armour everywhere."
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fc496b4a1a2cd806ab458dec48b0b7e6db42cd9d | marrow/contentment | web/contentment/taxonomy.py | [
"MIT"
] | Python | next | <not_specific> | def next(self):
"""The sibling immediately following this asset."""
from operator import __or__
from functools import reduce
query = []
for parent, order in self.clone().scalar('parent', 'order'):#.no_dereference():
query.append(Q(parent=parent, order=order + 1))
if not query:
return None
... | The sibling immediately following this asset. | The sibling immediately following this asset. | [
"The",
"sibling",
"immediately",
"following",
"this",
"asset",
"."
] | def next(self):
from operator import __or__
from functools import reduce
query = []
for parent, order in self.clone().scalar('parent', 'order'):
query.append(Q(parent=parent, order=order + 1))
if not query:
return None
return self.base_query(reduce(__or__, query)).order_by('path').first() | [
"def",
"next",
"(",
"self",
")",
":",
"from",
"operator",
"import",
"__or__",
"from",
"functools",
"import",
"reduce",
"query",
"=",
"[",
"]",
"for",
"parent",
",",
"order",
"in",
"self",
".",
"clone",
"(",
")",
".",
"scalar",
"(",
"'parent'",
",",
"... | The sibling immediately following this asset. | [
"The",
"sibling",
"immediately",
"following",
"this",
"asset",
"."
] | [
"\"\"\"The sibling immediately following this asset.\"\"\"",
"#.no_dereference():"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fc496b4a1a2cd806ab458dec48b0b7e6db42cd9d | marrow/contentment | web/contentment/taxonomy.py | [
"MIT"
] | Python | nextAll | <not_specific> | def nextAll(self):
"""All siblings following this asset."""
from operator import __or__
from functools import reduce
query = []
# Indexing note: (parent, order, id) for covered query and optimal re-use.
# Including id here to prevent an edge case (assets being shuffled) from including non-siblings.
for ... | All siblings following this asset. | All siblings following this asset. | [
"All",
"siblings",
"following",
"this",
"asset",
"."
] | def nextAll(self):
from operator import __or__
from functools import reduce
query = []
for id, parent, order in self.clone().scalar('id', 'parent', 'order'):
query.append(Q(parent=parent, order__gt=order, id__ne=id))
if not query:
return None
return self.base_query(reduce(__or__, query)).order_by('par... | [
"def",
"nextAll",
"(",
"self",
")",
":",
"from",
"operator",
"import",
"__or__",
"from",
"functools",
"import",
"reduce",
"query",
"=",
"[",
"]",
"for",
"id",
",",
"parent",
",",
"order",
"in",
"self",
".",
"clone",
"(",
")",
".",
"scalar",
"(",
"'id... | All siblings following this asset. | [
"All",
"siblings",
"following",
"this",
"asset",
"."
] | [
"\"\"\"All siblings following this asset.\"\"\"",
"# Indexing note: (parent, order, id) for covered query and optimal re-use.",
"# Including id here to prevent an edge case (assets being shuffled) from including non-siblings.",
"#.no_dereference():"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fc496b4a1a2cd806ab458dec48b0b7e6db42cd9d | marrow/contentment | web/contentment/taxonomy.py | [
"MIT"
] | Python | prev | <not_specific> | def prev(self):
"""The sibling immediately preceeding this asset."""
from operator import __or__
from functools import reduce
query = []
for parent, order in self.clone().scalar('parent', 'order'):#.no_dereference():
query.append(Q(parent=parent, order=order - 1))
if not query:
return None
retur... | The sibling immediately preceeding this asset. | The sibling immediately preceeding this asset. | [
"The",
"sibling",
"immediately",
"preceeding",
"this",
"asset",
"."
] | def prev(self):
from operator import __or__
from functools import reduce
query = []
for parent, order in self.clone().scalar('parent', 'order'):
query.append(Q(parent=parent, order=order - 1))
if not query:
return None
return self.base_query(reduce(__or__, query)).order_by('parent').first() | [
"def",
"prev",
"(",
"self",
")",
":",
"from",
"operator",
"import",
"__or__",
"from",
"functools",
"import",
"reduce",
"query",
"=",
"[",
"]",
"for",
"parent",
",",
"order",
"in",
"self",
".",
"clone",
"(",
")",
".",
"scalar",
"(",
"'parent'",
",",
"... | The sibling immediately preceeding this asset. | [
"The",
"sibling",
"immediately",
"preceeding",
"this",
"asset",
"."
] | [
"\"\"\"The sibling immediately preceeding this asset.\"\"\"",
"#.no_dereference():"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fc496b4a1a2cd806ab458dec48b0b7e6db42cd9d | marrow/contentment | web/contentment/taxonomy.py | [
"MIT"
] | Python | prevAll | <not_specific> | def prevAll(self):
"""All siblings preceeding the selected assets."""
from operator import __or__
from functools import reduce
query = []
for parent, order in self.clone().scalar('parent', 'order'):#.no_dereference():
query.append(Q(parent=parent, order__lt=order))
if not query:
return None
ret... | All siblings preceeding the selected assets. | All siblings preceeding the selected assets. | [
"All",
"siblings",
"preceeding",
"the",
"selected",
"assets",
"."
] | def prevAll(self):
from operator import __or__
from functools import reduce
query = []
for parent, order in self.clone().scalar('parent', 'order'):
query.append(Q(parent=parent, order__lt=order))
if not query:
return None
return self.base_query(reduce(__or__, query)).order_by('parent', 'order') | [
"def",
"prevAll",
"(",
"self",
")",
":",
"from",
"operator",
"import",
"__or__",
"from",
"functools",
"import",
"reduce",
"query",
"=",
"[",
"]",
"for",
"parent",
",",
"order",
"in",
"self",
".",
"clone",
"(",
")",
".",
"scalar",
"(",
"'parent'",
",",
... | All siblings preceeding the selected assets. | [
"All",
"siblings",
"preceeding",
"the",
"selected",
"assets",
"."
] | [
"\"\"\"All siblings preceeding the selected assets.\"\"\"",
"#.no_dereference():"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fc496b4a1a2cd806ab458dec48b0b7e6db42cd9d | marrow/contentment | web/contentment/taxonomy.py | [
"MIT"
] | Python | contains | <not_specific> | def contains(self, other):
"""The asset, specified by the parameter, is a descendant of any of the selected assets."""
if __debug__: # Can be optimized away (-O) in production.
from web.component.asset import Asset
assert isinstance(other, Asset) or isinstance(other, ObjectId), "Argument must be Asset or Ob... | The asset, specified by the parameter, is a descendant of any of the selected assets. | The asset, specified by the parameter, is a descendant of any of the selected assets. | [
"The",
"asset",
"specified",
"by",
"the",
"parameter",
"is",
"a",
"descendant",
"of",
"any",
"of",
"the",
"selected",
"assets",
"."
] | def contains(self, other):
if __debug__:
from web.component.asset import Asset
assert isinstance(other, Asset) or isinstance(other, ObjectId), "Argument must be Asset or ObjectId instance."
parents = self.clone().scalar('id').no_dereference()
return bool(self.base_query(pk=getattr(other, 'pk', other), par... | [
"def",
"contains",
"(",
"self",
",",
"other",
")",
":",
"if",
"__debug__",
":",
"from",
"web",
".",
"component",
".",
"asset",
"import",
"Asset",
"assert",
"isinstance",
"(",
"other",
",",
"Asset",
")",
"or",
"isinstance",
"(",
"other",
",",
"ObjectId",
... | The asset, specified by the parameter, is a descendant of any of the selected assets. | [
"The",
"asset",
"specified",
"by",
"the",
"parameter",
"is",
"a",
"descendant",
"of",
"any",
"of",
"the",
"selected",
"assets",
"."
] | [
"\"\"\"The asset, specified by the parameter, is a descendant of any of the selected assets.\"\"\"",
"# Can be optimized away (-O) in production."
] | [
{
"param": "self",
"type": null
},
{
"param": "other",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "other",
"type": null,
"docstring": null,
"docstring_tokens": ... |
fc496b4a1a2cd806ab458dec48b0b7e6db42cd9d | marrow/contentment | web/contentment/taxonomy.py | [
"MIT"
] | Python | extend | <not_specific> | def extend(self, *others):
"""Merge the contents of another asset or assets, specified by positional parameters, with this one."""
obj = self.clone().first()
for other in others:
for child in other.children:
obj.insert(-1, child)
return self | Merge the contents of another asset or assets, specified by positional parameters, with this one. | Merge the contents of another asset or assets, specified by positional parameters, with this one. | [
"Merge",
"the",
"contents",
"of",
"another",
"asset",
"or",
"assets",
"specified",
"by",
"positional",
"parameters",
"with",
"this",
"one",
"."
] | def extend(self, *others):
obj = self.clone().first()
for other in others:
for child in other.children:
obj.insert(-1, child)
return self | [
"def",
"extend",
"(",
"self",
",",
"*",
"others",
")",
":",
"obj",
"=",
"self",
".",
"clone",
"(",
")",
".",
"first",
"(",
")",
"for",
"other",
"in",
"others",
":",
"for",
"child",
"in",
"other",
".",
"children",
":",
"obj",
".",
"insert",
"(",
... | Merge the contents of another asset or assets, specified by positional parameters, with this one. | [
"Merge",
"the",
"contents",
"of",
"another",
"asset",
"or",
"assets",
"specified",
"by",
"positional",
"parameters",
"with",
"this",
"one",
"."
] | [
"\"\"\"Merge the contents of another asset or assets, specified by positional parameters, with this one.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fc496b4a1a2cd806ab458dec48b0b7e6db42cd9d | marrow/contentment | web/contentment/taxonomy.py | [
"MIT"
] | Python | _qs | <not_specific> | def _qs(self):
"""Return the queryset for updating, reloading, and deletions."""
if not hasattr(self, '__objects'):
self.__objects = self.tqs
return self.__objects | Return the queryset for updating, reloading, and deletions. | Return the queryset for updating, reloading, and deletions. | [
"Return",
"the",
"queryset",
"for",
"updating",
"reloading",
"and",
"deletions",
"."
] | def _qs(self):
if not hasattr(self, '__objects'):
self.__objects = self.tqs
return self.__objects | [
"def",
"_qs",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'__objects'",
")",
":",
"self",
".",
"__objects",
"=",
"self",
".",
"tqs",
"return",
"self",
".",
"__objects"
] | Return the queryset for updating, reloading, and deletions. | [
"Return",
"the",
"queryset",
"for",
"updating",
"reloading",
"and",
"deletions",
"."
] | [
"\"\"\"Return the queryset for updating, reloading, and deletions.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fc496b4a1a2cd806ab458dec48b0b7e6db42cd9d | marrow/contentment | web/contentment/taxonomy.py | [
"MIT"
] | Python | tree | null | def tree(self, indent=''):
"""Visualization of the Asset tree."""
print(indent, repr(self), sep="")
for child in self.children:
child.tree(indent + "\t") | Visualization of the Asset tree. | Visualization of the Asset tree. | [
"Visualization",
"of",
"the",
"Asset",
"tree",
"."
] | def tree(self, indent=''):
print(indent, repr(self), sep="")
for child in self.children:
child.tree(indent + "\t") | [
"def",
"tree",
"(",
"self",
",",
"indent",
"=",
"''",
")",
":",
"print",
"(",
"indent",
",",
"repr",
"(",
"self",
")",
",",
"sep",
"=",
"\"\"",
")",
"for",
"child",
"in",
"self",
".",
"children",
":",
"child",
".",
"tree",
"(",
"indent",
"+",
"... | Visualization of the Asset tree. | [
"Visualization",
"of",
"the",
"Asset",
"tree",
"."
] | [
"\"\"\"Visualization of the Asset tree.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "indent",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "indent",
"type": null,
"docstring": null,
"docstring_tokens":... |
fc496b4a1a2cd806ab458dec48b0b7e6db42cd9d | marrow/contentment | web/contentment/taxonomy.py | [
"MIT"
] | Python | _normpath | <not_specific> | def _normpath(self):
"""Recalculate the paths for all descendants of this asset."""
cache = {}
descendants = self.contents.order_by('path').no_dereference().only('parent', 'name')
i = -1
for i, child in enumerate(descendants):
pid = str(child.parent._id)
if pid not in cache:
cache[pi... | Recalculate the paths for all descendants of this asset. | Recalculate the paths for all descendants of this asset. | [
"Recalculate",
"the",
"paths",
"for",
"all",
"descendants",
"of",
"this",
"asset",
"."
] | def _normpath(self):
cache = {}
descendants = self.contents.order_by('path').no_dereference().only('parent', 'name')
i = -1
for i, child in enumerate(descendants):
pid = str(child.parent._id)
if pid not in cache:
cache[pid] = self.tqs(id=child.parent._id).scalar('path')
parent_path = cache[child.pa... | [
"def",
"_normpath",
"(",
"self",
")",
":",
"cache",
"=",
"{",
"}",
"descendants",
"=",
"self",
".",
"contents",
".",
"order_by",
"(",
"'path'",
")",
".",
"no_dereference",
"(",
")",
".",
"only",
"(",
"'parent'",
",",
"'name'",
")",
"i",
"=",
"-",
"... | Recalculate the paths for all descendants of this asset. | [
"Recalculate",
"the",
"paths",
"for",
"all",
"descendants",
"of",
"this",
"asset",
"."
] | [
"\"\"\"Recalculate the paths for all descendants of this asset.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d37273b589bc5c36fec70f1a48cc54b6e3fd09ce | marrow/contentment | web/contentment/util/logging.py | [
"MIT"
] | Python | format | <not_specific> | def format(self, record):
"""Formats LogRecord into a MongoEngine Log instance."""
document = Log(
service = record.name,
level = record.levelno,
message = record.getMessage(), # TODO: Raw w/ positional if possible.
time = datetime.fromtimestamp(record.created),
process = LogRuntime(ide... | Formats LogRecord into a MongoEngine Log instance. | Formats LogRecord into a MongoEngine Log instance. | [
"Formats",
"LogRecord",
"into",
"a",
"MongoEngine",
"Log",
"instance",
"."
] | def format(self, record):
document = Log(
service = record.name,
level = record.levelno,
message = record.getMessage(),
time = datetime.fromtimestamp(record.created),
process = LogRuntime(identifier=record.process, name=record.processName),
thread = LogRuntime(identifier=record.thread, name=... | [
"def",
"format",
"(",
"self",
",",
"record",
")",
":",
"document",
"=",
"Log",
"(",
"service",
"=",
"record",
".",
"name",
",",
"level",
"=",
"record",
".",
"levelno",
",",
"message",
"=",
"record",
".",
"getMessage",
"(",
")",
",",
"time",
"=",
"d... | Formats LogRecord into a MongoEngine Log instance. | [
"Formats",
"LogRecord",
"into",
"a",
"MongoEngine",
"Log",
"instance",
"."
] | [
"\"\"\"Formats LogRecord into a MongoEngine Log instance.\"\"\"",
"# TODO: Raw w/ positional if possible.",
"# Standard document decorated with extra contextual information"
] | [
{
"param": "self",
"type": null
},
{
"param": "record",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "record",
"type": null,
"docstring": null,
"docstring_tokens":... |
d37273b589bc5c36fec70f1a48cc54b6e3fd09ce | marrow/contentment | web/contentment/util/logging.py | [
"MIT"
] | Python | emit | null | def emit(self, record):
"""Inserting new logging record to mongo database."""
try:
document = self.format(record)
except:
self.handleError(record)
try:
document.save(force_insert=True, validate=False, write_concern=self.concern)
if self.buffer:
Log.objects.insert(self.buffer, load_bulk... | Inserting new logging record to mongo database. | Inserting new logging record to mongo database. | [
"Inserting",
"new",
"logging",
"record",
"to",
"mongo",
"database",
"."
] | def emit(self, record):
try:
document = self.format(record)
except:
self.handleError(record)
try:
document.save(force_insert=True, validate=False, write_concern=self.concern)
if self.buffer:
Log.objects.insert(self.buffer, load_bulk=False, write_concern=self.concern)
self.buffer = None
exc... | [
"def",
"emit",
"(",
"self",
",",
"record",
")",
":",
"try",
":",
"document",
"=",
"self",
".",
"format",
"(",
"record",
")",
"except",
":",
"self",
".",
"handleError",
"(",
"record",
")",
"try",
":",
"document",
".",
"save",
"(",
"force_insert",
"=",... | Inserting new logging record to mongo database. | [
"Inserting",
"new",
"logging",
"record",
"to",
"mongo",
"database",
"."
] | [
"\"\"\"Inserting new logging record to mongo database.\"\"\"",
"# Disable buffering of messages after startup.",
"# Buffering is disabled.",
"# During startup there might not be a DB connection yet, so we buffer messages until at least one can be",
"# written, then we dump the buffer."
] | [
{
"param": "self",
"type": null
},
{
"param": "record",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "record",
"type": null,
"docstring": null,
"docstring_tokens":... |
e0a3293b7c20b6cf9bb67ff874a852471c291fdd | sadok-f/okta-awscli | oktaawscli/okta_auth_config.py | [
"Apache-2.0"
] | Python | duration_for | <not_specific> | def duration_for(self, okta_profile):
""" Gets requested duration from config, ignore it on failure """
if self._value.has_option(okta_profile, 'duration'):
duration = self._value.get(okta_profile, 'duration')
self.logger.debug(
"Requesting a duration of %s second... | Gets requested duration from config, ignore it on failure | Gets requested duration from config, ignore it on failure | [
"Gets",
"requested",
"duration",
"from",
"config",
"ignore",
"it",
"on",
"failure"
] | def duration_for(self, okta_profile):
if self._value.has_option(okta_profile, 'duration'):
duration = self._value.get(okta_profile, 'duration')
self.logger.debug(
"Requesting a duration of %s seconds" % duration
)
try:
return int(du... | [
"def",
"duration_for",
"(",
"self",
",",
"okta_profile",
")",
":",
"if",
"self",
".",
"_value",
".",
"has_option",
"(",
"okta_profile",
",",
"'duration'",
")",
":",
"duration",
"=",
"self",
".",
"_value",
".",
"get",
"(",
"okta_profile",
",",
"'duration'",... | Gets requested duration from config, ignore it on failure | [
"Gets",
"requested",
"duration",
"from",
"config",
"ignore",
"it",
"on",
"failure"
] | [
"\"\"\" Gets requested duration from config, ignore it on failure \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "okta_profile",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "okta_profile",
"type": null,
"docstring": null,
"docstring_to... |
e0a3293b7c20b6cf9bb67ff874a852471c291fdd | sadok-f/okta-awscli | oktaawscli/okta_auth_config.py | [
"Apache-2.0"
] | Python | write_role_to_profile | null | def write_role_to_profile(self, okta_profile, role_arn):
""" Saves role to profile in config """
if not self._value.has_section(okta_profile):
self._value.add_section(okta_profile)
base_url = self.base_url_for(okta_profile)
self._value.set(okta_profile, 'base-url', base_url)... | Saves role to profile in config | Saves role to profile in config | [
"Saves",
"role",
"to",
"profile",
"in",
"config"
] | def write_role_to_profile(self, okta_profile, role_arn):
if not self._value.has_section(okta_profile):
self._value.add_section(okta_profile)
base_url = self.base_url_for(okta_profile)
self._value.set(okta_profile, 'base-url', base_url)
self._value.set(okta_profile, 'role', ro... | [
"def",
"write_role_to_profile",
"(",
"self",
",",
"okta_profile",
",",
"role_arn",
")",
":",
"if",
"not",
"self",
".",
"_value",
".",
"has_section",
"(",
"okta_profile",
")",
":",
"self",
".",
"_value",
".",
"add_section",
"(",
"okta_profile",
")",
"base_url... | Saves role to profile in config | [
"Saves",
"role",
"to",
"profile",
"in",
"config"
] | [
"\"\"\" Saves role to profile in config \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "okta_profile",
"type": null
},
{
"param": "role_arn",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "okta_profile",
"type": null,
"docstring": null,
"docstring_to... |
e0a3293b7c20b6cf9bb67ff874a852471c291fdd | sadok-f/okta-awscli | oktaawscli/okta_auth_config.py | [
"Apache-2.0"
] | Python | write_applink_to_profile | null | def write_applink_to_profile(self, okta_profile, app_link):
""" Saves app link to profile in config """
if not self._value.has_section(okta_profile):
self._value.add_section(okta_profile)
base_url = self.base_url_for(okta_profile)
self._value.set(okta_profile, 'base-url', ba... | Saves app link to profile in config | Saves app link to profile in config | [
"Saves",
"app",
"link",
"to",
"profile",
"in",
"config"
] | def write_applink_to_profile(self, okta_profile, app_link):
if not self._value.has_section(okta_profile):
self._value.add_section(okta_profile)
base_url = self.base_url_for(okta_profile)
self._value.set(okta_profile, 'base-url', base_url)
self._value.set(okta_profile, 'app-li... | [
"def",
"write_applink_to_profile",
"(",
"self",
",",
"okta_profile",
",",
"app_link",
")",
":",
"if",
"not",
"self",
".",
"_value",
".",
"has_section",
"(",
"okta_profile",
")",
":",
"self",
".",
"_value",
".",
"add_section",
"(",
"okta_profile",
")",
"base_... | Saves app link to profile in config | [
"Saves",
"app",
"link",
"to",
"profile",
"in",
"config"
] | [
"\"\"\" Saves app link to profile in config \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "okta_profile",
"type": null
},
{
"param": "app_link",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "okta_profile",
"type": null,
"docstring": null,
"docstring_to... |
0b968568c00ab687413a864e1933e38850145a1f | sadok-f/okta-awscli | oktaawscli/aws_auth.py | [
"Apache-2.0"
] | Python | choose_aws_role | <not_specific> | def choose_aws_role(self, assertion, refresh_role):
""" Choose AWS role from SAML assertion """
roles = self.__extract_available_roles_from(assertion)
if self.role:
predefined_role = self.__find_predefined_role_from(roles)
if predefined_role and not refresh_role:
... | Choose AWS role from SAML assertion | Choose AWS role from SAML assertion | [
"Choose",
"AWS",
"role",
"from",
"SAML",
"assertion"
] | def choose_aws_role(self, assertion, refresh_role):
roles = self.__extract_available_roles_from(assertion)
if self.role:
predefined_role = self.__find_predefined_role_from(roles)
if predefined_role and not refresh_role:
self.logger.info("Using predefined role: %s"... | [
"def",
"choose_aws_role",
"(",
"self",
",",
"assertion",
",",
"refresh_role",
")",
":",
"roles",
"=",
"self",
".",
"__extract_available_roles_from",
"(",
"assertion",
")",
"if",
"self",
".",
"role",
":",
"predefined_role",
"=",
"self",
".",
"__find_predefined_ro... | Choose AWS role from SAML assertion | [
"Choose",
"AWS",
"role",
"from",
"SAML",
"assertion"
] | [
"\"\"\" Choose AWS role from SAML assertion \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "assertion",
"type": null
},
{
"param": "refresh_role",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "assertion",
"type": null,
"docstring": null,
"docstring_token... |
0b968568c00ab687413a864e1933e38850145a1f | sadok-f/okta-awscli | oktaawscli/aws_auth.py | [
"Apache-2.0"
] | Python | check_sts_token | <not_specific> | def check_sts_token(self, profile):
""" Verifies that STS credentials are valid """
# Don't check for creds if profile is blank
if not self.profile:
return False
parser = RawConfigParser()
parser.read(self.creds_file)
if not os.path.exists(self.creds_dir):
... | Verifies that STS credentials are valid | Verifies that STS credentials are valid | [
"Verifies",
"that",
"STS",
"credentials",
"are",
"valid"
] | def check_sts_token(self, profile):
if not self.profile:
return False
parser = RawConfigParser()
parser.read(self.creds_file)
if not os.path.exists(self.creds_dir):
self.logger.info("AWS credentials path does not exist. Not checking.")
return False
... | [
"def",
"check_sts_token",
"(",
"self",
",",
"profile",
")",
":",
"if",
"not",
"self",
".",
"profile",
":",
"return",
"False",
"parser",
"=",
"RawConfigParser",
"(",
")",
"parser",
".",
"read",
"(",
"self",
".",
"creds_file",
")",
"if",
"not",
"os",
"."... | Verifies that STS credentials are valid | [
"Verifies",
"that",
"STS",
"credentials",
"are",
"valid"
] | [
"\"\"\" Verifies that STS credentials are valid \"\"\"",
"# Don't check for creds if profile is blank",
"# See https://docs.aws.amazon.com/STS/latest/APIReference/CommonErrors.html"
] | [
{
"param": "self",
"type": null
},
{
"param": "profile",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "profile",
"type": null,
"docstring": null,
"docstring_tokens"... |
0b968568c00ab687413a864e1933e38850145a1f | sadok-f/okta-awscli | oktaawscli/aws_auth.py | [
"Apache-2.0"
] | Python | write_sts_token | null | def write_sts_token(self, access_key_id, secret_access_key, session_token):
""" Writes STS auth information to credentials file """
if not os.path.exists(self.creds_dir):
os.makedirs(self.creds_dir)
config = RawConfigParser()
if os.path.isfile(self.creds_file):
c... | Writes STS auth information to credentials file | Writes STS auth information to credentials file | [
"Writes",
"STS",
"auth",
"information",
"to",
"credentials",
"file"
] | def write_sts_token(self, access_key_id, secret_access_key, session_token):
if not os.path.exists(self.creds_dir):
os.makedirs(self.creds_dir)
config = RawConfigParser()
if os.path.isfile(self.creds_file):
config.read(self.creds_file)
if not config.has_section(sel... | [
"def",
"write_sts_token",
"(",
"self",
",",
"access_key_id",
",",
"secret_access_key",
",",
"session_token",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"creds_dir",
")",
":",
"os",
".",
"makedirs",
"(",
"self",
".",
"creds... | Writes STS auth information to credentials file | [
"Writes",
"STS",
"auth",
"information",
"to",
"credentials",
"file"
] | [
"\"\"\" Writes STS auth information to credentials file \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "access_key_id",
"type": null
},
{
"param": "secret_access_key",
"type": null
},
{
"param": "session_token",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "access_key_id",
"type": null,
"docstring": null,
"docstring_t... |
fc1c3a9bc5326d5c9bcfb66f82352021a5f89e8f | RJsingh7/secretBot | db_actions.py | [
"MIT"
] | Python | update_users_followers | null | def update_users_followers(username, follower_id, table, remove=False):
'''
Find all the users that %username% follows and
update their "followers" list and "followers_count" amount
'''
item = table.get_item(Key={'username': username}).get('Item', False)
item['followers'].remove(follower_id) i... |
Find all the users that %username% follows and
update their "followers" list and "followers_count" amount
| Find all the users that %username% follows and
update their "followers" list and "followers_count" amount | [
"Find",
"all",
"the",
"users",
"that",
"%username%",
"follows",
"and",
"update",
"their",
"\"",
"followers",
"\"",
"list",
"and",
"\"",
"followers_count",
"\"",
"amount"
] | def update_users_followers(username, follower_id, table, remove=False):
item = table.get_item(Key={'username': username}).get('Item', False)
item['followers'].remove(follower_id) if remove else item['followers'].append(follower_id)
table.update_item(
Key={
'username': username
},... | [
"def",
"update_users_followers",
"(",
"username",
",",
"follower_id",
",",
"table",
",",
"remove",
"=",
"False",
")",
":",
"item",
"=",
"table",
".",
"get_item",
"(",
"Key",
"=",
"{",
"'username'",
":",
"username",
"}",
")",
".",
"get",
"(",
"'Item'",
... | Find all the users that %username% follows and
update their "followers" list and "followers_count" amount | [
"Find",
"all",
"the",
"users",
"that",
"%username%",
"follows",
"and",
"update",
"their",
"\"",
"followers",
"\"",
"list",
"and",
"\"",
"followers_count",
"\"",
"amount"
] | [
"'''\n Find all the users that %username% follows and \n update their \"followers\" list and \"followers_count\" amount\n '''"
] | [
{
"param": "username",
"type": null
},
{
"param": "follower_id",
"type": null
},
{
"param": "table",
"type": null
},
{
"param": "remove",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "username",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "follower_id",
"type": null,
"docstring": null,
"docstring... |
c7045759634b4f9e4aa99c10314da8d8ec103ded | RJsingh7/secretBot | handler.py | [
"MIT"
] | Python | contact_handler | <not_specific> | def contact_handler(bot, update):
'''
Handler for the messages with contacts
'''
username = str(update['message']['chat']['id'])
user_to_follow = str(update['message']['contact']['user_id'])
if not update['message']['contact']['user_id']:
bot.send_message(username, RESPONSES['empty_cont... |
Handler for the messages with contacts
| Handler for the messages with contacts | [
"Handler",
"for",
"the",
"messages",
"with",
"contacts"
] | def contact_handler(bot, update):
username = str(update['message']['chat']['id'])
user_to_follow = str(update['message']['contact']['user_id'])
if not update['message']['contact']['user_id']:
bot.send_message(username, RESPONSES['empty_contact'])
return
new_follower = follow_user(userna... | [
"def",
"contact_handler",
"(",
"bot",
",",
"update",
")",
":",
"username",
"=",
"str",
"(",
"update",
"[",
"'message'",
"]",
"[",
"'chat'",
"]",
"[",
"'id'",
"]",
")",
"user_to_follow",
"=",
"str",
"(",
"update",
"[",
"'message'",
"]",
"[",
"'contact'"... | Handler for the messages with contacts | [
"Handler",
"for",
"the",
"messages",
"with",
"contacts"
] | [
"'''\n Handler for the messages with contacts\n '''"
] | [
{
"param": "bot",
"type": null
},
{
"param": "update",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bot",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "update",
"type": null,
"docstring": null,
"docstring_tokens": ... |
c7045759634b4f9e4aa99c10314da8d8ec103ded | RJsingh7/secretBot | handler.py | [
"MIT"
] | Python | start_command_handler | null | def start_command_handler(bot, update):
'''
Handler for the "start" command.
Add current user to the Users table
'''
# Avoid duplication of the existing users
username = str(update['message']['chat']['id'])
create_user(update, table)
photo = bot.getUserProfilePhotos(update.message.from... |
Handler for the "start" command.
Add current user to the Users table
| Handler for the "start" command.
Add current user to the Users table | [
"Handler",
"for",
"the",
"\"",
"start",
"\"",
"command",
".",
"Add",
"current",
"user",
"to",
"the",
"Users",
"table"
] | def start_command_handler(bot, update):
username = str(update['message']['chat']['id'])
create_user(update, table)
photo = bot.getUserProfilePhotos(update.message.from_user.id)['photos'][0]
update_user_photo(photo, username, table)
logger.info('start_command_handler') | [
"def",
"start_command_handler",
"(",
"bot",
",",
"update",
")",
":",
"username",
"=",
"str",
"(",
"update",
"[",
"'message'",
"]",
"[",
"'chat'",
"]",
"[",
"'id'",
"]",
")",
"create_user",
"(",
"update",
",",
"table",
")",
"photo",
"=",
"bot",
".",
"... | Handler for the "start" command. | [
"Handler",
"for",
"the",
"\"",
"start",
"\"",
"command",
"."
] | [
"'''\n Handler for the \"start\" command.\n Add current user to the Users table\n '''",
"# Avoid duplication of the existing users"
] | [
{
"param": "bot",
"type": null
},
{
"param": "update",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bot",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "update",
"type": null,
"docstring": null,
"docstring_tokens": ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.