id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
2,200 | esheldon/fitsio | fitsio/header.py | FITSHDR.next | def next(self):
"""
for iteration over the header entries
"""
if self._current < len(self._record_list):
rec = self._record_list[self._current]
key = rec['name']
self._current += 1
return key
else:
raise StopIteration | python | def next(self):
"""
for iteration over the header entries
"""
if self._current < len(self._record_list):
rec = self._record_list[self._current]
key = rec['name']
self._current += 1
return key
else:
raise StopIteration | [
"def",
"next",
"(",
"self",
")",
":",
"if",
"self",
".",
"_current",
"<",
"len",
"(",
"self",
".",
"_record_list",
")",
":",
"rec",
"=",
"self",
".",
"_record_list",
"[",
"self",
".",
"_current",
"]",
"key",
"=",
"rec",
"[",
"'name'",
"]",
"self",
... | for iteration over the header entries | [
"for",
"iteration",
"over",
"the",
"header",
"entries"
] | a6f07919f457a282fe240adad9d2c30906b71a15 | https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/header.py#L359-L369 |
2,201 | esheldon/fitsio | fitsio/header.py | FITSRecord.set_record | def set_record(self, record, **kw):
"""
check the record is valid and set keys in the dict
parameters
----------
record: string
Dict representing a record or a string representing a FITS header
card
"""
if isstring(record):
ca... | python | def set_record(self, record, **kw):
"""
check the record is valid and set keys in the dict
parameters
----------
record: string
Dict representing a record or a string representing a FITS header
card
"""
if isstring(record):
ca... | [
"def",
"set_record",
"(",
"self",
",",
"record",
",",
"*",
"*",
"kw",
")",
":",
"if",
"isstring",
"(",
"record",
")",
":",
"card",
"=",
"FITSCard",
"(",
"record",
")",
"self",
".",
"update",
"(",
"card",
")",
"self",
".",
"verify",
"(",
")",
"els... | check the record is valid and set keys in the dict
parameters
----------
record: string
Dict representing a record or a string representing a FITS header
card | [
"check",
"the",
"record",
"is",
"valid",
"and",
"set",
"keys",
"in",
"the",
"dict"
] | a6f07919f457a282fe240adad9d2c30906b71a15 | https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/header.py#L477-L510 |
2,202 | esheldon/fitsio | fitsio/header.py | FITSCard._check_equals | def _check_equals(self):
"""
check for = in position 8, set attribute _has_equals
"""
card_string = self['card_string']
if len(card_string) < 9:
self._has_equals = False
elif card_string[8] == '=':
self._has_equals = True
else:
... | python | def _check_equals(self):
"""
check for = in position 8, set attribute _has_equals
"""
card_string = self['card_string']
if len(card_string) < 9:
self._has_equals = False
elif card_string[8] == '=':
self._has_equals = True
else:
... | [
"def",
"_check_equals",
"(",
"self",
")",
":",
"card_string",
"=",
"self",
"[",
"'card_string'",
"]",
"if",
"len",
"(",
"card_string",
")",
"<",
"9",
":",
"self",
".",
"_has_equals",
"=",
"False",
"elif",
"card_string",
"[",
"8",
"]",
"==",
"'='",
":",... | check for = in position 8, set attribute _has_equals | [
"check",
"for",
"=",
"in",
"position",
"8",
"set",
"attribute",
"_has_equals"
] | a6f07919f457a282fe240adad9d2c30906b71a15 | https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/header.py#L588-L598 |
2,203 | esheldon/fitsio | fitsio/header.py | FITSCard._convert_value | def _convert_value(self, value_orig):
"""
things like 6 and 1.25 are converted with ast.literal_value
Things like 'hello' are stripped of quotes
"""
import ast
if value_orig is None:
return value_orig
if value_orig.startswith("'") and value_orig.ends... | python | def _convert_value(self, value_orig):
"""
things like 6 and 1.25 are converted with ast.literal_value
Things like 'hello' are stripped of quotes
"""
import ast
if value_orig is None:
return value_orig
if value_orig.startswith("'") and value_orig.ends... | [
"def",
"_convert_value",
"(",
"self",
",",
"value_orig",
")",
":",
"import",
"ast",
"if",
"value_orig",
"is",
"None",
":",
"return",
"value_orig",
"if",
"value_orig",
".",
"startswith",
"(",
"\"'\"",
")",
"and",
"value_orig",
".",
"endswith",
"(",
"\"'\"",
... | things like 6 and 1.25 are converted with ast.literal_value
Things like 'hello' are stripped of quotes | [
"things",
"like",
"6",
"and",
"1",
".",
"25",
"are",
"converted",
"with",
"ast",
".",
"literal_value"
] | a6f07919f457a282fe240adad9d2c30906b71a15 | https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/header.py#L641-L669 |
2,204 | sanger-pathogens/ariba | ariba/cluster.py | Cluster._make_reads_for_assembly | def _make_reads_for_assembly(number_of_wanted_reads, total_reads, reads_in1, reads_in2, reads_out1, reads_out2, random_seed=None):
'''Makes fastq files that are random subset of input files. Returns total number of reads in output files.
If the number of wanted reads is >= total reads, then just make... | python | def _make_reads_for_assembly(number_of_wanted_reads, total_reads, reads_in1, reads_in2, reads_out1, reads_out2, random_seed=None):
'''Makes fastq files that are random subset of input files. Returns total number of reads in output files.
If the number of wanted reads is >= total reads, then just make... | [
"def",
"_make_reads_for_assembly",
"(",
"number_of_wanted_reads",
",",
"total_reads",
",",
"reads_in1",
",",
"reads_in2",
",",
"reads_out1",
",",
"reads_out2",
",",
"random_seed",
"=",
"None",
")",
":",
"random",
".",
"seed",
"(",
"random_seed",
")",
"if",
"numb... | Makes fastq files that are random subset of input files. Returns total number of reads in output files.
If the number of wanted reads is >= total reads, then just makes symlinks instead of making
new copies of the input files. | [
"Makes",
"fastq",
"files",
"that",
"are",
"random",
"subset",
"of",
"input",
"files",
".",
"Returns",
"total",
"number",
"of",
"reads",
"in",
"output",
"files",
".",
"If",
"the",
"number",
"of",
"wanted",
"reads",
"is",
">",
"=",
"total",
"reads",
"then"... | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/cluster.py#L262-L295 |
2,205 | sanger-pathogens/ariba | ariba/tb.py | load_mutations | def load_mutations(gene_coords, mutation_to_drug_json, variants_txt, upstream_before=100):
'''Load mutations from "mykrobe-style" files. mutation_to_drug_json is json file
of mutation -> list of drugs. variants_txt is text file of variants used my mykrobe's
make probes. gene_coords should be dict of gene co... | python | def load_mutations(gene_coords, mutation_to_drug_json, variants_txt, upstream_before=100):
'''Load mutations from "mykrobe-style" files. mutation_to_drug_json is json file
of mutation -> list of drugs. variants_txt is text file of variants used my mykrobe's
make probes. gene_coords should be dict of gene co... | [
"def",
"load_mutations",
"(",
"gene_coords",
",",
"mutation_to_drug_json",
",",
"variants_txt",
",",
"upstream_before",
"=",
"100",
")",
":",
"with",
"open",
"(",
"mutation_to_drug_json",
")",
"as",
"f",
":",
"drug_data",
"=",
"json",
".",
"load",
"(",
"f",
... | Load mutations from "mykrobe-style" files. mutation_to_drug_json is json file
of mutation -> list of drugs. variants_txt is text file of variants used my mykrobe's
make probes. gene_coords should be dict of gene coords made by the function
genbank_to_gene_coords | [
"Load",
"mutations",
"from",
"mykrobe",
"-",
"style",
"files",
".",
"mutation_to_drug_json",
"is",
"json",
"file",
"of",
"mutation",
"-",
">",
"list",
"of",
"drugs",
".",
"variants_txt",
"is",
"text",
"file",
"of",
"variants",
"used",
"my",
"mykrobe",
"s",
... | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/tb.py#L80-L142 |
2,206 | sanger-pathogens/ariba | ariba/tb.py | write_prepareref_fasta_file | def write_prepareref_fasta_file(outfile, gene_coords, genes_need_upstream, genes_non_upstream, upstream_before=100, upstream_after=100):
'''Writes fasta file to be used with -f option of prepareref'''
tmp_dict = {}
fasta_in = os.path.join(data_dir, 'NC_000962.3.fa.gz')
pyfastaq.tasks.file_to_dict(fasta_... | python | def write_prepareref_fasta_file(outfile, gene_coords, genes_need_upstream, genes_non_upstream, upstream_before=100, upstream_after=100):
'''Writes fasta file to be used with -f option of prepareref'''
tmp_dict = {}
fasta_in = os.path.join(data_dir, 'NC_000962.3.fa.gz')
pyfastaq.tasks.file_to_dict(fasta_... | [
"def",
"write_prepareref_fasta_file",
"(",
"outfile",
",",
"gene_coords",
",",
"genes_need_upstream",
",",
"genes_non_upstream",
",",
"upstream_before",
"=",
"100",
",",
"upstream_after",
"=",
"100",
")",
":",
"tmp_dict",
"=",
"{",
"}",
"fasta_in",
"=",
"os",
".... | Writes fasta file to be used with -f option of prepareref | [
"Writes",
"fasta",
"file",
"to",
"be",
"used",
"with",
"-",
"f",
"option",
"of",
"prepareref"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/tb.py#L145-L174 |
2,207 | sanger-pathogens/ariba | ariba/summary_cluster.py | SummaryCluster._get_known_noncoding_het_snp | def _get_known_noncoding_het_snp(data_dict):
'''If ref is coding, return None. If the data dict has a known snp, and
samtools made a call, then return the string ref_name_change and the
% of reads supporting the variant type. If noncoding, but no
samtools call, then return None'... | python | def _get_known_noncoding_het_snp(data_dict):
'''If ref is coding, return None. If the data dict has a known snp, and
samtools made a call, then return the string ref_name_change and the
% of reads supporting the variant type. If noncoding, but no
samtools call, then return None'... | [
"def",
"_get_known_noncoding_het_snp",
"(",
"data_dict",
")",
":",
"if",
"data_dict",
"[",
"'gene'",
"]",
"==",
"'1'",
":",
"return",
"None",
"if",
"data_dict",
"[",
"'known_var'",
"]",
"==",
"'1'",
"and",
"data_dict",
"[",
"'ref_ctg_effect'",
"]",
"==",
"'S... | If ref is coding, return None. If the data dict has a known snp, and
samtools made a call, then return the string ref_name_change and the
% of reads supporting the variant type. If noncoding, but no
samtools call, then return None | [
"If",
"ref",
"is",
"coding",
"return",
"None",
".",
"If",
"the",
"data",
"dict",
"has",
"a",
"known",
"snp",
"and",
"samtools",
"made",
"a",
"call",
"then",
"return",
"the",
"string",
"ref_name_change",
"and",
"the",
"%",
"of",
"reads",
"supporting",
"th... | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/summary_cluster.py#L236-L264 |
2,208 | sanger-pathogens/ariba | ariba/summary_cluster.py | SummaryCluster._has_match | def _has_match(self, assembled_summary):
'''assembled_summary should be output of _to_cluster_summary_assembled'''
if assembled_summary.startswith('yes'):
if self.data[0]['var_only'] == '0' or self._to_cluster_summary_has_known_nonsynonymous(assembled_summary) == 'yes':
retur... | python | def _has_match(self, assembled_summary):
'''assembled_summary should be output of _to_cluster_summary_assembled'''
if assembled_summary.startswith('yes'):
if self.data[0]['var_only'] == '0' or self._to_cluster_summary_has_known_nonsynonymous(assembled_summary) == 'yes':
retur... | [
"def",
"_has_match",
"(",
"self",
",",
"assembled_summary",
")",
":",
"if",
"assembled_summary",
".",
"startswith",
"(",
"'yes'",
")",
":",
"if",
"self",
".",
"data",
"[",
"0",
"]",
"[",
"'var_only'",
"]",
"==",
"'0'",
"or",
"self",
".",
"_to_cluster_sum... | assembled_summary should be output of _to_cluster_summary_assembled | [
"assembled_summary",
"should",
"be",
"output",
"of",
"_to_cluster_summary_assembled"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/summary_cluster.py#L298-L306 |
2,209 | sanger-pathogens/ariba | ariba/summary_cluster.py | SummaryCluster.has_var_groups | def has_var_groups(self):
'''Returns a set of the variant group ids that this cluster has'''
ids = set()
for d in self.data:
if self._has_known_variant(d) != 'no' and d['var_group'] != '.':
ids.add(d['var_group'])
return ids | python | def has_var_groups(self):
'''Returns a set of the variant group ids that this cluster has'''
ids = set()
for d in self.data:
if self._has_known_variant(d) != 'no' and d['var_group'] != '.':
ids.add(d['var_group'])
return ids | [
"def",
"has_var_groups",
"(",
"self",
")",
":",
"ids",
"=",
"set",
"(",
")",
"for",
"d",
"in",
"self",
".",
"data",
":",
"if",
"self",
".",
"_has_known_variant",
"(",
"d",
")",
"!=",
"'no'",
"and",
"d",
"[",
"'var_group'",
"]",
"!=",
"'.'",
":",
... | Returns a set of the variant group ids that this cluster has | [
"Returns",
"a",
"set",
"of",
"the",
"variant",
"group",
"ids",
"that",
"this",
"cluster",
"has"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/summary_cluster.py#L309-L315 |
2,210 | sanger-pathogens/ariba | ariba/summary_cluster.py | SummaryCluster.column_summary_data | def column_summary_data(self):
'''Returns a dictionary of column name -> value, for cluster-level results'''
assembled_summary = self._to_cluster_summary_assembled()
pct_id, read_depth = self._pc_id_and_read_depth_of_longest()
columns = {
'assembled': self._to_cluster_summar... | python | def column_summary_data(self):
'''Returns a dictionary of column name -> value, for cluster-level results'''
assembled_summary = self._to_cluster_summary_assembled()
pct_id, read_depth = self._pc_id_and_read_depth_of_longest()
columns = {
'assembled': self._to_cluster_summar... | [
"def",
"column_summary_data",
"(",
"self",
")",
":",
"assembled_summary",
"=",
"self",
".",
"_to_cluster_summary_assembled",
"(",
")",
"pct_id",
",",
"read_depth",
"=",
"self",
".",
"_pc_id_and_read_depth_of_longest",
"(",
")",
"columns",
"=",
"{",
"'assembled'",
... | Returns a dictionary of column name -> value, for cluster-level results | [
"Returns",
"a",
"dictionary",
"of",
"column",
"name",
"-",
">",
"value",
"for",
"cluster",
"-",
"level",
"results"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/summary_cluster.py#L318-L333 |
2,211 | sanger-pathogens/ariba | ariba/common.py | cat_files | def cat_files(infiles, outfile):
'''Cats all files in list infiles into outfile'''
f_out = pyfastaq.utils.open_file_write(outfile)
for filename in infiles:
if os.path.exists(filename):
f_in = pyfastaq.utils.open_file_read(filename)
for line in f_in:
print(lin... | python | def cat_files(infiles, outfile):
'''Cats all files in list infiles into outfile'''
f_out = pyfastaq.utils.open_file_write(outfile)
for filename in infiles:
if os.path.exists(filename):
f_in = pyfastaq.utils.open_file_read(filename)
for line in f_in:
print(lin... | [
"def",
"cat_files",
"(",
"infiles",
",",
"outfile",
")",
":",
"f_out",
"=",
"pyfastaq",
".",
"utils",
".",
"open_file_write",
"(",
"outfile",
")",
"for",
"filename",
"in",
"infiles",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":... | Cats all files in list infiles into outfile | [
"Cats",
"all",
"files",
"in",
"list",
"infiles",
"into",
"outfile"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/common.py#L45-L56 |
2,212 | sanger-pathogens/ariba | ariba/assembly.py | Assembly._check_spades_log_file | def _check_spades_log_file(logfile):
'''SPAdes can fail with a strange error. Stop everything if this happens'''
f = pyfastaq.utils.open_file_read(logfile)
for line in f:
if line.startswith('== Error == system call for:') and line.rstrip().endswith('finished abnormally, err code: -... | python | def _check_spades_log_file(logfile):
'''SPAdes can fail with a strange error. Stop everything if this happens'''
f = pyfastaq.utils.open_file_read(logfile)
for line in f:
if line.startswith('== Error == system call for:') and line.rstrip().endswith('finished abnormally, err code: -... | [
"def",
"_check_spades_log_file",
"(",
"logfile",
")",
":",
"f",
"=",
"pyfastaq",
".",
"utils",
".",
"open_file_read",
"(",
"logfile",
")",
"for",
"line",
"in",
"f",
":",
"if",
"line",
".",
"startswith",
"(",
"'== Error == system call for:'",
")",
"and",
"li... | SPAdes can fail with a strange error. Stop everything if this happens | [
"SPAdes",
"can",
"fail",
"with",
"a",
"strange",
"error",
".",
"Stop",
"everything",
"if",
"this",
"happens"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/assembly.py#L104-L116 |
2,213 | sanger-pathogens/ariba | ariba/assembly.py | Assembly._fix_contig_orientation | def _fix_contig_orientation(contigs_fa, ref_fa, outfile, min_id=90, min_length=20, breaklen=200):
'''Changes orientation of each contig to match the reference, when possible.
Returns a set of names of contigs that had hits in both orientations to the reference'''
if not os.path.exists(contigs... | python | def _fix_contig_orientation(contigs_fa, ref_fa, outfile, min_id=90, min_length=20, breaklen=200):
'''Changes orientation of each contig to match the reference, when possible.
Returns a set of names of contigs that had hits in both orientations to the reference'''
if not os.path.exists(contigs... | [
"def",
"_fix_contig_orientation",
"(",
"contigs_fa",
",",
"ref_fa",
",",
"outfile",
",",
"min_id",
"=",
"90",
",",
"min_length",
"=",
"20",
",",
"breaklen",
"=",
"200",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"contigs_fa",
")",
":... | Changes orientation of each contig to match the reference, when possible.
Returns a set of names of contigs that had hits in both orientations to the reference | [
"Changes",
"orientation",
"of",
"each",
"contig",
"to",
"match",
"the",
"reference",
"when",
"possible",
".",
"Returns",
"a",
"set",
"of",
"names",
"of",
"contigs",
"that",
"had",
"hits",
"in",
"both",
"orientations",
"to",
"the",
"reference"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/assembly.py#L205-L242 |
2,214 | sanger-pathogens/ariba | ariba/assembly_compare.py | AssemblyCompare._parse_nucmer_coords_file | def _parse_nucmer_coords_file(coords_file, ref_name):
'''Input is coords file made by self._run_nucmer. Reference should have one sequence only.
ref_name is name fo the reference sequence, to sanity check the coords file.
Returns dictionary. Key = assembly contig name. Value = list of nucm... | python | def _parse_nucmer_coords_file(coords_file, ref_name):
'''Input is coords file made by self._run_nucmer. Reference should have one sequence only.
ref_name is name fo the reference sequence, to sanity check the coords file.
Returns dictionary. Key = assembly contig name. Value = list of nucm... | [
"def",
"_parse_nucmer_coords_file",
"(",
"coords_file",
",",
"ref_name",
")",
":",
"file_reader",
"=",
"pymummer",
".",
"coords_file",
".",
"reader",
"(",
"coords_file",
")",
"nucmer_hits",
"=",
"{",
"}",
"for",
"hit",
"in",
"file_reader",
":",
"assert",
"hit"... | Input is coords file made by self._run_nucmer. Reference should have one sequence only.
ref_name is name fo the reference sequence, to sanity check the coords file.
Returns dictionary. Key = assembly contig name. Value = list of nucmer hits to that contig | [
"Input",
"is",
"coords",
"file",
"made",
"by",
"self",
".",
"_run_nucmer",
".",
"Reference",
"should",
"have",
"one",
"sequence",
"only",
".",
"ref_name",
"is",
"name",
"fo",
"the",
"reference",
"sequence",
"to",
"sanity",
"check",
"the",
"coords",
"file",
... | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/assembly_compare.py#L61-L74 |
2,215 | sanger-pathogens/ariba | ariba/assembly_compare.py | AssemblyCompare._nucmer_hits_to_percent_identity | def _nucmer_hits_to_percent_identity(nucmer_hits):
'''Input is hits made by self._parse_nucmer_coords_file.
Returns dictionary. key = contig name. Value = percent identity of hits to that contig'''
percent_identities = {}
max_lengths = {}
for contig in nucmer_hits:
... | python | def _nucmer_hits_to_percent_identity(nucmer_hits):
'''Input is hits made by self._parse_nucmer_coords_file.
Returns dictionary. key = contig name. Value = percent identity of hits to that contig'''
percent_identities = {}
max_lengths = {}
for contig in nucmer_hits:
... | [
"def",
"_nucmer_hits_to_percent_identity",
"(",
"nucmer_hits",
")",
":",
"percent_identities",
"=",
"{",
"}",
"max_lengths",
"=",
"{",
"}",
"for",
"contig",
"in",
"nucmer_hits",
":",
"max_length",
"=",
"-",
"1",
"percent_identity",
"=",
"0",
"for",
"hit",
"in"... | Input is hits made by self._parse_nucmer_coords_file.
Returns dictionary. key = contig name. Value = percent identity of hits to that contig | [
"Input",
"is",
"hits",
"made",
"by",
"self",
".",
"_parse_nucmer_coords_file",
".",
"Returns",
"dictionary",
".",
"key",
"=",
"contig",
"name",
".",
"Value",
"=",
"percent",
"identity",
"of",
"hits",
"to",
"that",
"contig"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/assembly_compare.py#L78-L93 |
2,216 | sanger-pathogens/ariba | ariba/assembly_compare.py | AssemblyCompare._nucmer_hits_to_assembly_coords | def _nucmer_hits_to_assembly_coords(nucmer_hits):
'''Input is hits made by self._parse_nucmer_coords_file.
Returns dictionary. key = contig name. Value = list of coords that match
to the reference gene'''
coords = {}
for l in nucmer_hits.values():
for hit in l:
... | python | def _nucmer_hits_to_assembly_coords(nucmer_hits):
'''Input is hits made by self._parse_nucmer_coords_file.
Returns dictionary. key = contig name. Value = list of coords that match
to the reference gene'''
coords = {}
for l in nucmer_hits.values():
for hit in l:
... | [
"def",
"_nucmer_hits_to_assembly_coords",
"(",
"nucmer_hits",
")",
":",
"coords",
"=",
"{",
"}",
"for",
"l",
"in",
"nucmer_hits",
".",
"values",
"(",
")",
":",
"for",
"hit",
"in",
"l",
":",
"if",
"hit",
".",
"qry_name",
"not",
"in",
"coords",
":",
"coo... | Input is hits made by self._parse_nucmer_coords_file.
Returns dictionary. key = contig name. Value = list of coords that match
to the reference gene | [
"Input",
"is",
"hits",
"made",
"by",
"self",
".",
"_parse_nucmer_coords_file",
".",
"Returns",
"dictionary",
".",
"key",
"=",
"contig",
"name",
".",
"Value",
"=",
"list",
"of",
"coords",
"that",
"match",
"to",
"the",
"reference",
"gene"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/assembly_compare.py#L97-L111 |
2,217 | sanger-pathogens/ariba | ariba/assembly_compare.py | AssemblyCompare.nucmer_hits_to_ref_coords | def nucmer_hits_to_ref_coords(cls, nucmer_hits, contig=None):
'''Input is hits made by self._parse_nucmer_coords_file.
Returns dictionary. Key = contig name. Value = list of coords in the
reference sequence for that contig.
if contig=contig_name, then just gets the ref coords fr... | python | def nucmer_hits_to_ref_coords(cls, nucmer_hits, contig=None):
'''Input is hits made by self._parse_nucmer_coords_file.
Returns dictionary. Key = contig name. Value = list of coords in the
reference sequence for that contig.
if contig=contig_name, then just gets the ref coords fr... | [
"def",
"nucmer_hits_to_ref_coords",
"(",
"cls",
",",
"nucmer_hits",
",",
"contig",
"=",
"None",
")",
":",
"coords",
"=",
"[",
"]",
"if",
"contig",
"is",
"None",
":",
"coords",
"=",
"{",
"key",
":",
"[",
"]",
"for",
"key",
"in",
"nucmer_hits",
".",
"k... | Input is hits made by self._parse_nucmer_coords_file.
Returns dictionary. Key = contig name. Value = list of coords in the
reference sequence for that contig.
if contig=contig_name, then just gets the ref coords from that contig,
instead of using all the contigs | [
"Input",
"is",
"hits",
"made",
"by",
"self",
".",
"_parse_nucmer_coords_file",
".",
"Returns",
"dictionary",
".",
"Key",
"=",
"contig",
"name",
".",
"Value",
"=",
"list",
"of",
"coords",
"in",
"the",
"reference",
"sequence",
"for",
"that",
"contig",
".",
"... | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/assembly_compare.py#L119-L135 |
2,218 | sanger-pathogens/ariba | ariba/assembly_compare.py | AssemblyCompare.nucmer_hits_to_ref_and_qry_coords | def nucmer_hits_to_ref_and_qry_coords(cls, nucmer_hits, contig=None):
'''Same as nucmer_hits_to_ref_coords, except removes containing hits first,
and returns ref and qry coords lists'''
if contig is None:
ctg_coords = {key: [] for key in nucmer_hits.keys()}
else:
... | python | def nucmer_hits_to_ref_and_qry_coords(cls, nucmer_hits, contig=None):
'''Same as nucmer_hits_to_ref_coords, except removes containing hits first,
and returns ref and qry coords lists'''
if contig is None:
ctg_coords = {key: [] for key in nucmer_hits.keys()}
else:
... | [
"def",
"nucmer_hits_to_ref_and_qry_coords",
"(",
"cls",
",",
"nucmer_hits",
",",
"contig",
"=",
"None",
")",
":",
"if",
"contig",
"is",
"None",
":",
"ctg_coords",
"=",
"{",
"key",
":",
"[",
"]",
"for",
"key",
"in",
"nucmer_hits",
".",
"keys",
"(",
")",
... | Same as nucmer_hits_to_ref_coords, except removes containing hits first,
and returns ref and qry coords lists | [
"Same",
"as",
"nucmer_hits_to_ref_coords",
"except",
"removes",
"containing",
"hits",
"first",
"and",
"returns",
"ref",
"and",
"qry",
"coords",
"lists"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/assembly_compare.py#L139-L168 |
2,219 | sanger-pathogens/ariba | ariba/assembly_compare.py | AssemblyCompare.ref_cov_per_contig | def ref_cov_per_contig(nucmer_hits):
'''Input is hits made by self._parse_nucmer_coords_file.
Returns dictionary. key = contig name. Value = number of bases that
match to the reference sequence.'''
coords = AssemblyCompare.nucmer_hits_to_ref_coords(nucmer_hits)
return {x: p... | python | def ref_cov_per_contig(nucmer_hits):
'''Input is hits made by self._parse_nucmer_coords_file.
Returns dictionary. key = contig name. Value = number of bases that
match to the reference sequence.'''
coords = AssemblyCompare.nucmer_hits_to_ref_coords(nucmer_hits)
return {x: p... | [
"def",
"ref_cov_per_contig",
"(",
"nucmer_hits",
")",
":",
"coords",
"=",
"AssemblyCompare",
".",
"nucmer_hits_to_ref_coords",
"(",
"nucmer_hits",
")",
"return",
"{",
"x",
":",
"pyfastaq",
".",
"intervals",
".",
"length_sum_from_list",
"(",
"coords",
"[",
"x",
"... | Input is hits made by self._parse_nucmer_coords_file.
Returns dictionary. key = contig name. Value = number of bases that
match to the reference sequence. | [
"Input",
"is",
"hits",
"made",
"by",
"self",
".",
"_parse_nucmer_coords_file",
".",
"Returns",
"dictionary",
".",
"key",
"=",
"contig",
"name",
".",
"Value",
"=",
"number",
"of",
"bases",
"that",
"match",
"to",
"the",
"reference",
"sequence",
"."
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/assembly_compare.py#L172-L177 |
2,220 | sanger-pathogens/ariba | ariba/assembly_compare.py | AssemblyCompare._ref_covered_by_at_least_one_full_length_contig | def _ref_covered_by_at_least_one_full_length_contig(nucmer_hits, percent_threshold, max_nt_extend):
'''Returns true iff there exists a contig that completely
covers the reference sequence
nucmer_hits = hits made by self._parse_nucmer_coords_file.'''
for l in nucmer_hits.values():
... | python | def _ref_covered_by_at_least_one_full_length_contig(nucmer_hits, percent_threshold, max_nt_extend):
'''Returns true iff there exists a contig that completely
covers the reference sequence
nucmer_hits = hits made by self._parse_nucmer_coords_file.'''
for l in nucmer_hits.values():
... | [
"def",
"_ref_covered_by_at_least_one_full_length_contig",
"(",
"nucmer_hits",
",",
"percent_threshold",
",",
"max_nt_extend",
")",
":",
"for",
"l",
"in",
"nucmer_hits",
".",
"values",
"(",
")",
":",
"for",
"hit",
"in",
"l",
":",
"if",
"(",
"(",
"2",
"*",
"ma... | Returns true iff there exists a contig that completely
covers the reference sequence
nucmer_hits = hits made by self._parse_nucmer_coords_file. | [
"Returns",
"true",
"iff",
"there",
"exists",
"a",
"contig",
"that",
"completely",
"covers",
"the",
"reference",
"sequence",
"nucmer_hits",
"=",
"hits",
"made",
"by",
"self",
".",
"_parse_nucmer_coords_file",
"."
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/assembly_compare.py#L352-L360 |
2,221 | sanger-pathogens/ariba | ariba/assembly_compare.py | AssemblyCompare.nucmer_hit_containing_reference_position | def nucmer_hit_containing_reference_position(nucmer_hits, ref_name, ref_position, qry_name=None):
'''Returns the first nucmer match found that contains the given
reference location. nucmer_hits = hits made by self._parse_nucmer_coords_file.
Returns None if no matching hit found'''
... | python | def nucmer_hit_containing_reference_position(nucmer_hits, ref_name, ref_position, qry_name=None):
'''Returns the first nucmer match found that contains the given
reference location. nucmer_hits = hits made by self._parse_nucmer_coords_file.
Returns None if no matching hit found'''
... | [
"def",
"nucmer_hit_containing_reference_position",
"(",
"nucmer_hits",
",",
"ref_name",
",",
"ref_position",
",",
"qry_name",
"=",
"None",
")",
":",
"for",
"contig_name",
"in",
"nucmer_hits",
":",
"for",
"hit",
"in",
"nucmer_hits",
"[",
"contig_name",
"]",
":",
... | Returns the first nucmer match found that contains the given
reference location. nucmer_hits = hits made by self._parse_nucmer_coords_file.
Returns None if no matching hit found | [
"Returns",
"the",
"first",
"nucmer",
"match",
"found",
"that",
"contains",
"the",
"given",
"reference",
"location",
".",
"nucmer_hits",
"=",
"hits",
"made",
"by",
"self",
".",
"_parse_nucmer_coords_file",
".",
"Returns",
"None",
"if",
"no",
"matching",
"hit",
... | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/assembly_compare.py#L384-L393 |
2,222 | sanger-pathogens/ariba | ariba/external_progs.py | ExternalProgs._get_exe | def _get_exe(prog):
'''Given a program name, return what we expect its exectuable to be called'''
if prog in prog_to_env_var:
env_var = prog_to_env_var[prog]
if env_var in os.environ:
return os.environ[env_var]
return prog_to_default[prog] | python | def _get_exe(prog):
'''Given a program name, return what we expect its exectuable to be called'''
if prog in prog_to_env_var:
env_var = prog_to_env_var[prog]
if env_var in os.environ:
return os.environ[env_var]
return prog_to_default[prog] | [
"def",
"_get_exe",
"(",
"prog",
")",
":",
"if",
"prog",
"in",
"prog_to_env_var",
":",
"env_var",
"=",
"prog_to_env_var",
"[",
"prog",
"]",
"if",
"env_var",
"in",
"os",
".",
"environ",
":",
"return",
"os",
".",
"environ",
"[",
"env_var",
"]",
"return",
... | Given a program name, return what we expect its exectuable to be called | [
"Given",
"a",
"program",
"name",
"return",
"what",
"we",
"expect",
"its",
"exectuable",
"to",
"be",
"called"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/external_progs.py#L131-L138 |
2,223 | sanger-pathogens/ariba | ariba/cdhit.py | Runner.fake_run | def fake_run(self):
'''Doesn't actually run cd-hit. Instead, puts each input sequence into its own cluster. So it's as if cdhit was run, but didn't cluster anything'''
clusters = {}
used_names = set()
seq_reader = pyfastaq.sequences.file_reader(self.infile)
for seq in seq_reader... | python | def fake_run(self):
'''Doesn't actually run cd-hit. Instead, puts each input sequence into its own cluster. So it's as if cdhit was run, but didn't cluster anything'''
clusters = {}
used_names = set()
seq_reader = pyfastaq.sequences.file_reader(self.infile)
for seq in seq_reader... | [
"def",
"fake_run",
"(",
"self",
")",
":",
"clusters",
"=",
"{",
"}",
"used_names",
"=",
"set",
"(",
")",
"seq_reader",
"=",
"pyfastaq",
".",
"sequences",
".",
"file_reader",
"(",
"self",
".",
"infile",
")",
"for",
"seq",
"in",
"seq_reader",
":",
"if",
... | Doesn't actually run cd-hit. Instead, puts each input sequence into its own cluster. So it's as if cdhit was run, but didn't cluster anything | [
"Doesn",
"t",
"actually",
"run",
"cd",
"-",
"hit",
".",
"Instead",
"puts",
"each",
"input",
"sequence",
"into",
"its",
"own",
"cluster",
".",
"So",
"it",
"s",
"as",
"if",
"cdhit",
"was",
"run",
"but",
"didn",
"t",
"cluster",
"anything"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/cdhit.py#L38-L51 |
2,224 | sanger-pathogens/ariba | ariba/cdhit.py | Runner.run_get_clusters_from_file | def run_get_clusters_from_file(self, clusters_infile, all_ref_seqs, rename_dict=None):
'''Instead of running cdhit, gets the clusters info from the input file.'''
if rename_dict is None:
rename_dict = {}
# check that every sequence in the clusters file can be
# found in the ... | python | def run_get_clusters_from_file(self, clusters_infile, all_ref_seqs, rename_dict=None):
'''Instead of running cdhit, gets the clusters info from the input file.'''
if rename_dict is None:
rename_dict = {}
# check that every sequence in the clusters file can be
# found in the ... | [
"def",
"run_get_clusters_from_file",
"(",
"self",
",",
"clusters_infile",
",",
"all_ref_seqs",
",",
"rename_dict",
"=",
"None",
")",
":",
"if",
"rename_dict",
"is",
"None",
":",
"rename_dict",
"=",
"{",
"}",
"# check that every sequence in the clusters file can be",
"... | Instead of running cdhit, gets the clusters info from the input file. | [
"Instead",
"of",
"running",
"cdhit",
"gets",
"the",
"clusters",
"info",
"from",
"the",
"input",
"file",
"."
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/cdhit.py#L86-L109 |
2,225 | sanger-pathogens/ariba | ariba/mapping.py | sam_pair_to_insert | def sam_pair_to_insert(s1, s2):
'''Returns insert size from pair of sam records, as long as their orientation is "innies".
Otherwise returns None.'''
if s1.is_unmapped or s2.is_unmapped or (s1.tid != s2.tid) or (s1.is_reverse == s2.is_reverse):
return None
# If here, reads are both mapped to... | python | def sam_pair_to_insert(s1, s2):
'''Returns insert size from pair of sam records, as long as their orientation is "innies".
Otherwise returns None.'''
if s1.is_unmapped or s2.is_unmapped or (s1.tid != s2.tid) or (s1.is_reverse == s2.is_reverse):
return None
# If here, reads are both mapped to... | [
"def",
"sam_pair_to_insert",
"(",
"s1",
",",
"s2",
")",
":",
"if",
"s1",
".",
"is_unmapped",
"or",
"s2",
".",
"is_unmapped",
"or",
"(",
"s1",
".",
"tid",
"!=",
"s2",
".",
"tid",
")",
"or",
"(",
"s1",
".",
"is_reverse",
"==",
"s2",
".",
"is_reverse"... | Returns insert size from pair of sam records, as long as their orientation is "innies".
Otherwise returns None. | [
"Returns",
"insert",
"size",
"from",
"pair",
"of",
"sam",
"records",
"as",
"long",
"as",
"their",
"orientation",
"is",
"innies",
".",
"Otherwise",
"returns",
"None",
"."
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/mapping.py#L153-L170 |
2,226 | sanger-pathogens/ariba | ariba/scaffold_graph.py | Graph.update_from_sam | def update_from_sam(self, sam, sam_reader):
'''Updates graph info from a pysam.AlignedSegment object'''
if sam.is_unmapped \
or sam.mate_is_unmapped \
or (sam.reference_id == sam.next_reference_id):
return
new_link = link.Link(sam, sam_reader, self.ref_lengths)
... | python | def update_from_sam(self, sam, sam_reader):
'''Updates graph info from a pysam.AlignedSegment object'''
if sam.is_unmapped \
or sam.mate_is_unmapped \
or (sam.reference_id == sam.next_reference_id):
return
new_link = link.Link(sam, sam_reader, self.ref_lengths)
... | [
"def",
"update_from_sam",
"(",
"self",
",",
"sam",
",",
"sam_reader",
")",
":",
"if",
"sam",
".",
"is_unmapped",
"or",
"sam",
".",
"mate_is_unmapped",
"or",
"(",
"sam",
".",
"reference_id",
"==",
"sam",
".",
"next_reference_id",
")",
":",
"return",
"new_li... | Updates graph info from a pysam.AlignedSegment object | [
"Updates",
"graph",
"info",
"from",
"a",
"pysam",
".",
"AlignedSegment",
"object"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/scaffold_graph.py#L13-L32 |
2,227 | sanger-pathogens/ariba | ariba/scaffold_graph.py | Graph._make_graph | def _make_graph(self, max_insert):
'''helper function to construct graph from current state of object'''
if len(self.partial_links) != 0:
raise Error('Error in _make_graph(). Cannot continue because there are partial links')
self.contig_links = {}
for key in self.lin... | python | def _make_graph(self, max_insert):
'''helper function to construct graph from current state of object'''
if len(self.partial_links) != 0:
raise Error('Error in _make_graph(). Cannot continue because there are partial links')
self.contig_links = {}
for key in self.lin... | [
"def",
"_make_graph",
"(",
"self",
",",
"max_insert",
")",
":",
"if",
"len",
"(",
"self",
".",
"partial_links",
")",
"!=",
"0",
":",
"raise",
"Error",
"(",
"'Error in _make_graph(). Cannot continue because there are partial links'",
")",
"self",
".",
"contig_links",... | helper function to construct graph from current state of object | [
"helper",
"function",
"to",
"construct",
"graph",
"from",
"current",
"state",
"of",
"object"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/scaffold_graph.py#L35-L48 |
2,228 | sanger-pathogens/ariba | ariba/bam_parse.py | Parser._sam_to_soft_clipped | def _sam_to_soft_clipped(self, sam):
'''Returns tuple of whether or not the left and right end of the mapped read in the sam record is soft-clipped'''
if sam.is_unmapped:
raise Error('Cannot get soft clip info from an unmapped read')
if sam.cigar is None or len(sam.cigar) == 0:
... | python | def _sam_to_soft_clipped(self, sam):
'''Returns tuple of whether or not the left and right end of the mapped read in the sam record is soft-clipped'''
if sam.is_unmapped:
raise Error('Cannot get soft clip info from an unmapped read')
if sam.cigar is None or len(sam.cigar) == 0:
... | [
"def",
"_sam_to_soft_clipped",
"(",
"self",
",",
"sam",
")",
":",
"if",
"sam",
".",
"is_unmapped",
":",
"raise",
"Error",
"(",
"'Cannot get soft clip info from an unmapped read'",
")",
"if",
"sam",
".",
"cigar",
"is",
"None",
"or",
"len",
"(",
"sam",
".",
"c... | Returns tuple of whether or not the left and right end of the mapped read in the sam record is soft-clipped | [
"Returns",
"tuple",
"of",
"whether",
"or",
"not",
"the",
"left",
"and",
"right",
"end",
"of",
"the",
"mapped",
"read",
"in",
"the",
"sam",
"record",
"is",
"soft",
"-",
"clipped"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/bam_parse.py#L21-L28 |
2,229 | sanger-pathogens/ariba | ariba/report_filter.py | ReportFilter._report_line_to_dict | def _report_line_to_dict(cls, line):
'''Takes report line string as input. Returns a dict of column name -> value in line'''
data = line.split('\t')
if len(data) != len(report.columns):
return None
d = dict(zip(report.columns, data))
for key in report.int_columns:
... | python | def _report_line_to_dict(cls, line):
'''Takes report line string as input. Returns a dict of column name -> value in line'''
data = line.split('\t')
if len(data) != len(report.columns):
return None
d = dict(zip(report.columns, data))
for key in report.int_columns:
... | [
"def",
"_report_line_to_dict",
"(",
"cls",
",",
"line",
")",
":",
"data",
"=",
"line",
".",
"split",
"(",
"'\\t'",
")",
"if",
"len",
"(",
"data",
")",
"!=",
"len",
"(",
"report",
".",
"columns",
")",
":",
"return",
"None",
"d",
"=",
"dict",
"(",
... | Takes report line string as input. Returns a dict of column name -> value in line | [
"Takes",
"report",
"line",
"string",
"as",
"input",
".",
"Returns",
"a",
"dict",
"of",
"column",
"name",
"-",
">",
"value",
"in",
"line"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/report_filter.py#L33-L53 |
2,230 | sanger-pathogens/ariba | ariba/report_filter.py | ReportFilter._dict_to_report_line | def _dict_to_report_line(cls, report_dict):
'''Takes a report_dict as input and returns a report line'''
return '\t'.join([str(report_dict[x]) for x in report.columns]) | python | def _dict_to_report_line(cls, report_dict):
'''Takes a report_dict as input and returns a report line'''
return '\t'.join([str(report_dict[x]) for x in report.columns]) | [
"def",
"_dict_to_report_line",
"(",
"cls",
",",
"report_dict",
")",
":",
"return",
"'\\t'",
".",
"join",
"(",
"[",
"str",
"(",
"report_dict",
"[",
"x",
"]",
")",
"for",
"x",
"in",
"report",
".",
"columns",
"]",
")"
] | Takes a report_dict as input and returns a report line | [
"Takes",
"a",
"report_dict",
"as",
"input",
"and",
"returns",
"a",
"report",
"line"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/report_filter.py#L57-L59 |
2,231 | sanger-pathogens/ariba | ariba/report_filter.py | ReportFilter._load_report | def _load_report(infile):
'''Loads report file into a dictionary. Key=reference name.
Value = list of report lines for that reference'''
report_dict = {}
f = pyfastaq.utils.open_file_read(infile)
first_line = True
for line in f:
line = line.rstrip()
... | python | def _load_report(infile):
'''Loads report file into a dictionary. Key=reference name.
Value = list of report lines for that reference'''
report_dict = {}
f = pyfastaq.utils.open_file_read(infile)
first_line = True
for line in f:
line = line.rstrip()
... | [
"def",
"_load_report",
"(",
"infile",
")",
":",
"report_dict",
"=",
"{",
"}",
"f",
"=",
"pyfastaq",
".",
"utils",
".",
"open_file_read",
"(",
"infile",
")",
"first_line",
"=",
"True",
"for",
"line",
"in",
"f",
":",
"line",
"=",
"line",
".",
"rstrip",
... | Loads report file into a dictionary. Key=reference name.
Value = list of report lines for that reference | [
"Loads",
"report",
"file",
"into",
"a",
"dictionary",
".",
"Key",
"=",
"reference",
"name",
".",
"Value",
"=",
"list",
"of",
"report",
"lines",
"for",
"that",
"reference"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/report_filter.py#L63-L94 |
2,232 | sanger-pathogens/ariba | ariba/report_filter.py | ReportFilter._filter_dicts | def _filter_dicts(self):
'''Filters out all the report_dicts that do not pass the cutoffs. If any ref sequence
loses all of its report_dicts, then it is completely removed.'''
keys_to_remove = set()
for ref_name in self.report:
for ctg_name in self.report[ref_name]:
... | python | def _filter_dicts(self):
'''Filters out all the report_dicts that do not pass the cutoffs. If any ref sequence
loses all of its report_dicts, then it is completely removed.'''
keys_to_remove = set()
for ref_name in self.report:
for ctg_name in self.report[ref_name]:
... | [
"def",
"_filter_dicts",
"(",
"self",
")",
":",
"keys_to_remove",
"=",
"set",
"(",
")",
"for",
"ref_name",
"in",
"self",
".",
"report",
":",
"for",
"ctg_name",
"in",
"self",
".",
"report",
"[",
"ref_name",
"]",
":",
"self",
".",
"report",
"[",
"ref_name... | Filters out all the report_dicts that do not pass the cutoffs. If any ref sequence
loses all of its report_dicts, then it is completely removed. | [
"Filters",
"out",
"all",
"the",
"report_dicts",
"that",
"do",
"not",
"pass",
"the",
"cutoffs",
".",
"If",
"any",
"ref",
"sequence",
"loses",
"all",
"of",
"its",
"report_dicts",
"then",
"it",
"is",
"completely",
"removed",
"."
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/report_filter.py#L167-L186 |
2,233 | sanger-pathogens/ariba | ariba/link.py | Link.merge | def merge(self, other):
'''Merge another link into this one. Expected that each link was created from each mate from a pair. We only know both distances to contig ends when we have read info from both mappings in a BAM file. All other info should be the same.'''
assert self.refnames == other.refnames
... | python | def merge(self, other):
'''Merge another link into this one. Expected that each link was created from each mate from a pair. We only know both distances to contig ends when we have read info from both mappings in a BAM file. All other info should be the same.'''
assert self.refnames == other.refnames
... | [
"def",
"merge",
"(",
"self",
",",
"other",
")",
":",
"assert",
"self",
".",
"refnames",
"==",
"other",
".",
"refnames",
"assert",
"self",
".",
"dirs",
"==",
"other",
".",
"dirs",
"assert",
"self",
".",
"lengths",
"==",
"other",
".",
"lengths",
"for",
... | Merge another link into this one. Expected that each link was created from each mate from a pair. We only know both distances to contig ends when we have read info from both mappings in a BAM file. All other info should be the same. | [
"Merge",
"another",
"link",
"into",
"this",
"one",
".",
"Expected",
"that",
"each",
"link",
"was",
"created",
"from",
"each",
"mate",
"from",
"a",
"pair",
".",
"We",
"only",
"know",
"both",
"distances",
"to",
"contig",
"ends",
"when",
"we",
"have",
"read... | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/link.py#L80-L93 |
2,234 | sanger-pathogens/ariba | ariba/summary.py | Summary._load_fofn | def _load_fofn(cls, fofn):
'''Returns dictionary of filename -> short name. Value is None
whenever short name is not provided'''
filenames = {}
f = pyfastaq.utils.open_file_read(fofn)
for line in f:
fields = line.rstrip().split()
if len(fields) == 1:
... | python | def _load_fofn(cls, fofn):
'''Returns dictionary of filename -> short name. Value is None
whenever short name is not provided'''
filenames = {}
f = pyfastaq.utils.open_file_read(fofn)
for line in f:
fields = line.rstrip().split()
if len(fields) == 1:
... | [
"def",
"_load_fofn",
"(",
"cls",
",",
"fofn",
")",
":",
"filenames",
"=",
"{",
"}",
"f",
"=",
"pyfastaq",
".",
"utils",
".",
"open_file_read",
"(",
"fofn",
")",
"for",
"line",
"in",
"f",
":",
"fields",
"=",
"line",
".",
"rstrip",
"(",
")",
".",
"... | Returns dictionary of filename -> short name. Value is None
whenever short name is not provided | [
"Returns",
"dictionary",
"of",
"filename",
"-",
">",
"short",
"name",
".",
"Value",
"is",
"None",
"whenever",
"short",
"name",
"is",
"not",
"provided"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/summary.py#L70-L85 |
2,235 | sanger-pathogens/ariba | ariba/summary.py | Summary._filter_matrix_rows | def _filter_matrix_rows(cls, matrix):
'''matrix = output from _to_matrix'''
indexes_to_keep = []
for i in range(len(matrix)):
keep_row = False
for element in matrix[i]:
if element not in {'NA', 'no'}:
keep_row = True
... | python | def _filter_matrix_rows(cls, matrix):
'''matrix = output from _to_matrix'''
indexes_to_keep = []
for i in range(len(matrix)):
keep_row = False
for element in matrix[i]:
if element not in {'NA', 'no'}:
keep_row = True
... | [
"def",
"_filter_matrix_rows",
"(",
"cls",
",",
"matrix",
")",
":",
"indexes_to_keep",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"matrix",
")",
")",
":",
"keep_row",
"=",
"False",
"for",
"element",
"in",
"matrix",
"[",
"i",
"]",
":",
... | matrix = output from _to_matrix | [
"matrix",
"=",
"output",
"from",
"_to_matrix"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/summary.py#L223-L236 |
2,236 | sanger-pathogens/ariba | ariba/summary.py | Summary._filter_matrix_columns | def _filter_matrix_columns(cls, matrix, phandango_header, csv_header):
'''phandango_header, csv_header, matrix = output from _to_matrix'''
indexes_to_keep = set()
for row in matrix:
for i in range(len(row)):
if row[i] not in {'NA', 'no'}:
indexes_... | python | def _filter_matrix_columns(cls, matrix, phandango_header, csv_header):
'''phandango_header, csv_header, matrix = output from _to_matrix'''
indexes_to_keep = set()
for row in matrix:
for i in range(len(row)):
if row[i] not in {'NA', 'no'}:
indexes_... | [
"def",
"_filter_matrix_columns",
"(",
"cls",
",",
"matrix",
",",
"phandango_header",
",",
"csv_header",
")",
":",
"indexes_to_keep",
"=",
"set",
"(",
")",
"for",
"row",
"in",
"matrix",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"row",
")",
")",
"... | phandango_header, csv_header, matrix = output from _to_matrix | [
"phandango_header",
"csv_header",
"matrix",
"=",
"output",
"from",
"_to_matrix"
] | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/summary.py#L240-L256 |
2,237 | sanger-pathogens/ariba | ariba/assembly_variants.py | AssemblyVariants._get_remaining_known_ref_variants | def _get_remaining_known_ref_variants(known_ref_variants, used_ref_variants, nucmer_coords):
'''Finds variants where ref has the variant and so does the contig. Which means
that there was no mummer call to flag it up so need to look through the known
ref variants. Also need to check that t... | python | def _get_remaining_known_ref_variants(known_ref_variants, used_ref_variants, nucmer_coords):
'''Finds variants where ref has the variant and so does the contig. Which means
that there was no mummer call to flag it up so need to look through the known
ref variants. Also need to check that t... | [
"def",
"_get_remaining_known_ref_variants",
"(",
"known_ref_variants",
",",
"used_ref_variants",
",",
"nucmer_coords",
")",
":",
"variants",
"=",
"[",
"]",
"for",
"ref_variant_pos",
",",
"ref_variants_set",
"in",
"sorted",
"(",
"known_ref_variants",
".",
"items",
"(",... | Finds variants where ref has the variant and so does the contig. Which means
that there was no mummer call to flag it up so need to look through the known
ref variants. Also need to check that the variant is in a nucmer match to an
assembly contig. | [
"Finds",
"variants",
"where",
"ref",
"has",
"the",
"variant",
"and",
"so",
"does",
"the",
"contig",
".",
"Which",
"means",
"that",
"there",
"was",
"no",
"mummer",
"call",
"to",
"flag",
"it",
"up",
"so",
"need",
"to",
"look",
"through",
"the",
"known",
... | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/assembly_variants.py#L232-L260 |
2,238 | sanger-pathogens/ariba | ariba/report.py | _samtools_depths_at_known_snps_all_wild | def _samtools_depths_at_known_snps_all_wild(sequence_meta, contig_name, cluster, variant_list):
'''Input is a known variants, as sequence_metadata object. The
assumption is that both the reference and the assembly have the
variant type, not wild type. The list variant_list should be a list
of p... | python | def _samtools_depths_at_known_snps_all_wild(sequence_meta, contig_name, cluster, variant_list):
'''Input is a known variants, as sequence_metadata object. The
assumption is that both the reference and the assembly have the
variant type, not wild type. The list variant_list should be a list
of p... | [
"def",
"_samtools_depths_at_known_snps_all_wild",
"(",
"sequence_meta",
",",
"contig_name",
",",
"cluster",
",",
"variant_list",
")",
":",
"ref_nuc_range",
"=",
"sequence_meta",
".",
"variant",
".",
"nucleotide_range",
"(",
")",
"if",
"ref_nuc_range",
"is",
"None",
... | Input is a known variants, as sequence_metadata object. The
assumption is that both the reference and the assembly have the
variant type, not wild type. The list variant_list should be a list
of pymummer.variant.Variant objects, only contaning variants to the
relevant query contig | [
"Input",
"is",
"a",
"known",
"variants",
"as",
"sequence_metadata",
"object",
".",
"The",
"assumption",
"is",
"that",
"both",
"the",
"reference",
"and",
"the",
"assembly",
"have",
"the",
"variant",
"type",
"not",
"wild",
"type",
".",
"The",
"list",
"variant_... | 16a0b1916ce0e886bd22550ba2d648542977001b | https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/report.py#L85-L136 |
2,239 | ethereum/eth-abi | eth_abi/utils/string.py | abbr | def abbr(value: Any, limit: int=20) -> str:
"""
Converts a value into its string representation and abbreviates that
representation based on the given length `limit` if necessary.
"""
rep = repr(value)
if len(rep) > limit:
if limit < 3:
raise ValueError('Abbreviation limit m... | python | def abbr(value: Any, limit: int=20) -> str:
"""
Converts a value into its string representation and abbreviates that
representation based on the given length `limit` if necessary.
"""
rep = repr(value)
if len(rep) > limit:
if limit < 3:
raise ValueError('Abbreviation limit m... | [
"def",
"abbr",
"(",
"value",
":",
"Any",
",",
"limit",
":",
"int",
"=",
"20",
")",
"->",
"str",
":",
"rep",
"=",
"repr",
"(",
"value",
")",
"if",
"len",
"(",
"rep",
")",
">",
"limit",
":",
"if",
"limit",
"<",
"3",
":",
"raise",
"ValueError",
... | Converts a value into its string representation and abbreviates that
representation based on the given length `limit` if necessary. | [
"Converts",
"a",
"value",
"into",
"its",
"string",
"representation",
"and",
"abbreviates",
"that",
"representation",
"based",
"on",
"the",
"given",
"length",
"limit",
"if",
"necessary",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/utils/string.py#L6-L19 |
2,240 | ethereum/eth-abi | eth_abi/encoding.py | BaseEncoder.invalidate_value | def invalidate_value(
cls,
value: Any,
exc: Type[Exception]=EncodingTypeError,
msg: Optional[str]=None,
) -> None:
"""
Throws a standard exception for when a value is not encodable by an
encoder.
"""
raise exc(
"Value `{rep}` of typ... | python | def invalidate_value(
cls,
value: Any,
exc: Type[Exception]=EncodingTypeError,
msg: Optional[str]=None,
) -> None:
"""
Throws a standard exception for when a value is not encodable by an
encoder.
"""
raise exc(
"Value `{rep}` of typ... | [
"def",
"invalidate_value",
"(",
"cls",
",",
"value",
":",
"Any",
",",
"exc",
":",
"Type",
"[",
"Exception",
"]",
"=",
"EncodingTypeError",
",",
"msg",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
")",
"->",
"None",
":",
"raise",
"exc",
"(",
... | Throws a standard exception for when a value is not encodable by an
encoder. | [
"Throws",
"a",
"standard",
"exception",
"for",
"when",
"a",
"value",
"is",
"not",
"encodable",
"by",
"an",
"encoder",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/encoding.py#L78-L95 |
2,241 | ethereum/eth-abi | eth_abi/base.py | parse_tuple_type_str | def parse_tuple_type_str(old_from_type_str):
"""
Used by BaseCoder subclasses as a convenience for implementing the
``from_type_str`` method required by ``ABIRegistry``. Useful if normalizing
then parsing a tuple type string is required in that method.
"""
@functools.wraps(old_from_type_str)
... | python | def parse_tuple_type_str(old_from_type_str):
"""
Used by BaseCoder subclasses as a convenience for implementing the
``from_type_str`` method required by ``ABIRegistry``. Useful if normalizing
then parsing a tuple type string is required in that method.
"""
@functools.wraps(old_from_type_str)
... | [
"def",
"parse_tuple_type_str",
"(",
"old_from_type_str",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"old_from_type_str",
")",
"def",
"new_from_type_str",
"(",
"cls",
",",
"type_str",
",",
"registry",
")",
":",
"normalized_type_str",
"=",
"normalize",
"(",
"t... | Used by BaseCoder subclasses as a convenience for implementing the
``from_type_str`` method required by ``ABIRegistry``. Useful if normalizing
then parsing a tuple type string is required in that method. | [
"Used",
"by",
"BaseCoder",
"subclasses",
"as",
"a",
"convenience",
"for",
"implementing",
"the",
"from_type_str",
"method",
"required",
"by",
"ABIRegistry",
".",
"Useful",
"if",
"normalizing",
"then",
"parsing",
"a",
"tuple",
"type",
"string",
"is",
"required",
... | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/base.py#L80-L110 |
2,242 | ethereum/eth-abi | eth_abi/decoding.py | ContextFramesBytesIO.seek_in_frame | def seek_in_frame(self, pos, *args, **kwargs):
"""
Seeks relative to the total offset of the current contextual frames.
"""
super().seek(self._total_offset + pos, *args, **kwargs) | python | def seek_in_frame(self, pos, *args, **kwargs):
"""
Seeks relative to the total offset of the current contextual frames.
"""
super().seek(self._total_offset + pos, *args, **kwargs) | [
"def",
"seek_in_frame",
"(",
"self",
",",
"pos",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
")",
".",
"seek",
"(",
"self",
".",
"_total_offset",
"+",
"pos",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Seeks relative to the total offset of the current contextual frames. | [
"Seeks",
"relative",
"to",
"the",
"total",
"offset",
"of",
"the",
"current",
"contextual",
"frames",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/decoding.py#L80-L84 |
2,243 | ethereum/eth-abi | eth_abi/decoding.py | ContextFramesBytesIO.push_frame | def push_frame(self, offset):
"""
Pushes a new contextual frame onto the stack with the given offset and a
return position at the current cursor position then seeks to the new
total offset.
"""
self._frames.append((offset, self.tell()))
self._total_offset += offse... | python | def push_frame(self, offset):
"""
Pushes a new contextual frame onto the stack with the given offset and a
return position at the current cursor position then seeks to the new
total offset.
"""
self._frames.append((offset, self.tell()))
self._total_offset += offse... | [
"def",
"push_frame",
"(",
"self",
",",
"offset",
")",
":",
"self",
".",
"_frames",
".",
"append",
"(",
"(",
"offset",
",",
"self",
".",
"tell",
"(",
")",
")",
")",
"self",
".",
"_total_offset",
"+=",
"offset",
"self",
".",
"seek_in_frame",
"(",
"0",
... | Pushes a new contextual frame onto the stack with the given offset and a
return position at the current cursor position then seeks to the new
total offset. | [
"Pushes",
"a",
"new",
"contextual",
"frame",
"onto",
"the",
"stack",
"with",
"the",
"given",
"offset",
"and",
"a",
"return",
"position",
"at",
"the",
"current",
"cursor",
"position",
"then",
"seeks",
"to",
"the",
"new",
"total",
"offset",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/decoding.py#L86-L95 |
2,244 | ethereum/eth-abi | eth_abi/decoding.py | ContextFramesBytesIO.pop_frame | def pop_frame(self):
"""
Pops the current contextual frame off of the stack and returns the
cursor to the frame's return position.
"""
try:
offset, return_pos = self._frames.pop()
except IndexError:
raise IndexError('no frames to pop')
self... | python | def pop_frame(self):
"""
Pops the current contextual frame off of the stack and returns the
cursor to the frame's return position.
"""
try:
offset, return_pos = self._frames.pop()
except IndexError:
raise IndexError('no frames to pop')
self... | [
"def",
"pop_frame",
"(",
"self",
")",
":",
"try",
":",
"offset",
",",
"return_pos",
"=",
"self",
".",
"_frames",
".",
"pop",
"(",
")",
"except",
"IndexError",
":",
"raise",
"IndexError",
"(",
"'no frames to pop'",
")",
"self",
".",
"_total_offset",
"-=",
... | Pops the current contextual frame off of the stack and returns the
cursor to the frame's return position. | [
"Pops",
"the",
"current",
"contextual",
"frame",
"off",
"of",
"the",
"stack",
"and",
"returns",
"the",
"cursor",
"to",
"the",
"frame",
"s",
"return",
"position",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/decoding.py#L97-L108 |
2,245 | ethereum/eth-abi | eth_abi/registry.py | has_arrlist | def has_arrlist(type_str):
"""
A predicate that matches a type string with an array dimension list.
"""
try:
abi_type = grammar.parse(type_str)
except exceptions.ParseError:
return False
return abi_type.arrlist is not None | python | def has_arrlist(type_str):
"""
A predicate that matches a type string with an array dimension list.
"""
try:
abi_type = grammar.parse(type_str)
except exceptions.ParseError:
return False
return abi_type.arrlist is not None | [
"def",
"has_arrlist",
"(",
"type_str",
")",
":",
"try",
":",
"abi_type",
"=",
"grammar",
".",
"parse",
"(",
"type_str",
")",
"except",
"exceptions",
".",
"ParseError",
":",
"return",
"False",
"return",
"abi_type",
".",
"arrlist",
"is",
"not",
"None"
] | A predicate that matches a type string with an array dimension list. | [
"A",
"predicate",
"that",
"matches",
"a",
"type",
"string",
"with",
"an",
"array",
"dimension",
"list",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/registry.py#L258-L267 |
2,246 | ethereum/eth-abi | eth_abi/registry.py | is_base_tuple | def is_base_tuple(type_str):
"""
A predicate that matches a tuple type with no array dimension list.
"""
try:
abi_type = grammar.parse(type_str)
except exceptions.ParseError:
return False
return isinstance(abi_type, grammar.TupleType) and abi_type.arrlist is None | python | def is_base_tuple(type_str):
"""
A predicate that matches a tuple type with no array dimension list.
"""
try:
abi_type = grammar.parse(type_str)
except exceptions.ParseError:
return False
return isinstance(abi_type, grammar.TupleType) and abi_type.arrlist is None | [
"def",
"is_base_tuple",
"(",
"type_str",
")",
":",
"try",
":",
"abi_type",
"=",
"grammar",
".",
"parse",
"(",
"type_str",
")",
"except",
"exceptions",
".",
"ParseError",
":",
"return",
"False",
"return",
"isinstance",
"(",
"abi_type",
",",
"grammar",
".",
... | A predicate that matches a tuple type with no array dimension list. | [
"A",
"predicate",
"that",
"matches",
"a",
"tuple",
"type",
"with",
"no",
"array",
"dimension",
"list",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/registry.py#L270-L279 |
2,247 | ethereum/eth-abi | eth_abi/registry.py | ABIRegistry.register | def register(self, lookup: Lookup, encoder: Encoder, decoder: Decoder, label: str=None) -> None:
"""
Registers the given ``encoder`` and ``decoder`` under the given
``lookup``. A unique string label may be optionally provided that can
be used to refer to the registration by name.
... | python | def register(self, lookup: Lookup, encoder: Encoder, decoder: Decoder, label: str=None) -> None:
"""
Registers the given ``encoder`` and ``decoder`` under the given
``lookup``. A unique string label may be optionally provided that can
be used to refer to the registration by name.
... | [
"def",
"register",
"(",
"self",
",",
"lookup",
":",
"Lookup",
",",
"encoder",
":",
"Encoder",
",",
"decoder",
":",
"Decoder",
",",
"label",
":",
"str",
"=",
"None",
")",
"->",
"None",
":",
"self",
".",
"register_encoder",
"(",
"lookup",
",",
"encoder",... | Registers the given ``encoder`` and ``decoder`` under the given
``lookup``. A unique string label may be optionally provided that can
be used to refer to the registration by name.
:param lookup: A type string or type string matcher function
(predicate). When the registry is querie... | [
"Registers",
"the",
"given",
"encoder",
"and",
"decoder",
"under",
"the",
"given",
"lookup",
".",
"A",
"unique",
"string",
"label",
"may",
"be",
"optionally",
"provided",
"that",
"can",
"be",
"used",
"to",
"refer",
"to",
"the",
"registration",
"by",
"name",
... | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/registry.py#L395-L431 |
2,248 | ethereum/eth-abi | eth_abi/registry.py | ABIRegistry.unregister | def unregister(self, label: str) -> None:
"""
Unregisters the entries in the encoder and decoder registries which
have the label ``label``.
"""
self.unregister_encoder(label)
self.unregister_decoder(label) | python | def unregister(self, label: str) -> None:
"""
Unregisters the entries in the encoder and decoder registries which
have the label ``label``.
"""
self.unregister_encoder(label)
self.unregister_decoder(label) | [
"def",
"unregister",
"(",
"self",
",",
"label",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"unregister_encoder",
"(",
"label",
")",
"self",
".",
"unregister_decoder",
"(",
"label",
")"
] | Unregisters the entries in the encoder and decoder registries which
have the label ``label``. | [
"Unregisters",
"the",
"entries",
"in",
"the",
"encoder",
"and",
"decoder",
"registries",
"which",
"have",
"the",
"label",
"label",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/registry.py#L433-L439 |
2,249 | ethereum/eth-abi | eth_abi/registry.py | ABIRegistry.copy | def copy(self):
"""
Copies a registry such that new registrations can be made or existing
registrations can be unregistered without affecting any instance from
which a copy was obtained. This is useful if an existing registry
fulfills most of a user's needs but requires one or t... | python | def copy(self):
"""
Copies a registry such that new registrations can be made or existing
registrations can be unregistered without affecting any instance from
which a copy was obtained. This is useful if an existing registry
fulfills most of a user's needs but requires one or t... | [
"def",
"copy",
"(",
"self",
")",
":",
"cpy",
"=",
"type",
"(",
"self",
")",
"(",
")",
"cpy",
".",
"_encoders",
"=",
"copy",
".",
"copy",
"(",
"self",
".",
"_encoders",
")",
"cpy",
".",
"_decoders",
"=",
"copy",
".",
"copy",
"(",
"self",
".",
"_... | Copies a registry such that new registrations can be made or existing
registrations can be unregistered without affecting any instance from
which a copy was obtained. This is useful if an existing registry
fulfills most of a user's needs but requires one or two modifications.
In that ca... | [
"Copies",
"a",
"registry",
"such",
"that",
"new",
"registrations",
"can",
"be",
"made",
"or",
"existing",
"registrations",
"can",
"be",
"unregistered",
"without",
"affecting",
"any",
"instance",
"from",
"which",
"a",
"copy",
"was",
"obtained",
".",
"This",
"is... | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/registry.py#L463-L477 |
2,250 | ethereum/eth-abi | eth_abi/codec.py | ABIEncoder.encode_single | def encode_single(self, typ: TypeStr, arg: Any) -> bytes:
"""
Encodes the python value ``arg`` as a binary value of the ABI type
``typ``.
:param typ: The string representation of the ABI type that will be used
for encoding e.g. ``'uint256'``, ``'bytes[]'``, ``'(int,int)'``,
... | python | def encode_single(self, typ: TypeStr, arg: Any) -> bytes:
"""
Encodes the python value ``arg`` as a binary value of the ABI type
``typ``.
:param typ: The string representation of the ABI type that will be used
for encoding e.g. ``'uint256'``, ``'bytes[]'``, ``'(int,int)'``,
... | [
"def",
"encode_single",
"(",
"self",
",",
"typ",
":",
"TypeStr",
",",
"arg",
":",
"Any",
")",
"->",
"bytes",
":",
"encoder",
"=",
"self",
".",
"_registry",
".",
"get_encoder",
"(",
"typ",
")",
"return",
"encoder",
"(",
"arg",
")"
] | Encodes the python value ``arg`` as a binary value of the ABI type
``typ``.
:param typ: The string representation of the ABI type that will be used
for encoding e.g. ``'uint256'``, ``'bytes[]'``, ``'(int,int)'``,
etc.
:param arg: The python value to be encoded.
... | [
"Encodes",
"the",
"python",
"value",
"arg",
"as",
"a",
"binary",
"value",
"of",
"the",
"ABI",
"type",
"typ",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/codec.py#L50-L65 |
2,251 | ethereum/eth-abi | eth_abi/codec.py | ABIEncoder.encode_abi | def encode_abi(self, types: Iterable[TypeStr], args: Iterable[Any]) -> bytes:
"""
Encodes the python values in ``args`` as a sequence of binary values of
the ABI types in ``types`` via the head-tail mechanism.
:param types: An iterable of string representations of the ABI types
... | python | def encode_abi(self, types: Iterable[TypeStr], args: Iterable[Any]) -> bytes:
"""
Encodes the python values in ``args`` as a sequence of binary values of
the ABI types in ``types`` via the head-tail mechanism.
:param types: An iterable of string representations of the ABI types
... | [
"def",
"encode_abi",
"(",
"self",
",",
"types",
":",
"Iterable",
"[",
"TypeStr",
"]",
",",
"args",
":",
"Iterable",
"[",
"Any",
"]",
")",
"->",
"bytes",
":",
"encoders",
"=",
"[",
"self",
".",
"_registry",
".",
"get_encoder",
"(",
"type_str",
")",
"f... | Encodes the python values in ``args`` as a sequence of binary values of
the ABI types in ``types`` via the head-tail mechanism.
:param types: An iterable of string representations of the ABI types
that will be used for encoding e.g. ``('uint256', 'bytes[]',
'(int,int)')``
... | [
"Encodes",
"the",
"python",
"values",
"in",
"args",
"as",
"a",
"sequence",
"of",
"binary",
"values",
"of",
"the",
"ABI",
"types",
"in",
"types",
"via",
"the",
"head",
"-",
"tail",
"mechanism",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/codec.py#L67-L87 |
2,252 | ethereum/eth-abi | eth_abi/codec.py | ABIEncoder.is_encodable | def is_encodable(self, typ: TypeStr, arg: Any) -> bool:
"""
Determines if the python value ``arg`` is encodable as a value of the
ABI type ``typ``.
:param typ: A string representation for the ABI type against which the
python value ``arg`` will be checked e.g. ``'uint256'``,... | python | def is_encodable(self, typ: TypeStr, arg: Any) -> bool:
"""
Determines if the python value ``arg`` is encodable as a value of the
ABI type ``typ``.
:param typ: A string representation for the ABI type against which the
python value ``arg`` will be checked e.g. ``'uint256'``,... | [
"def",
"is_encodable",
"(",
"self",
",",
"typ",
":",
"TypeStr",
",",
"arg",
":",
"Any",
")",
"->",
"bool",
":",
"encoder",
"=",
"self",
".",
"_registry",
".",
"get_encoder",
"(",
"typ",
")",
"try",
":",
"encoder",
".",
"validate_value",
"(",
"arg",
"... | Determines if the python value ``arg`` is encodable as a value of the
ABI type ``typ``.
:param typ: A string representation for the ABI type against which the
python value ``arg`` will be checked e.g. ``'uint256'``,
``'bytes[]'``, ``'(int,int)'``, etc.
:param arg: The py... | [
"Determines",
"if",
"the",
"python",
"value",
"arg",
"is",
"encodable",
"as",
"a",
"value",
"of",
"the",
"ABI",
"type",
"typ",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/codec.py#L89-L114 |
2,253 | ethereum/eth-abi | eth_abi/codec.py | ABIDecoder.decode_single | def decode_single(self, typ: TypeStr, data: Decodable) -> Any:
"""
Decodes the binary value ``data`` of the ABI type ``typ`` into its
equivalent python value.
:param typ: The string representation of the ABI type that will be used for
decoding e.g. ``'uint256'``, ``'bytes[]'... | python | def decode_single(self, typ: TypeStr, data: Decodable) -> Any:
"""
Decodes the binary value ``data`` of the ABI type ``typ`` into its
equivalent python value.
:param typ: The string representation of the ABI type that will be used for
decoding e.g. ``'uint256'``, ``'bytes[]'... | [
"def",
"decode_single",
"(",
"self",
",",
"typ",
":",
"TypeStr",
",",
"data",
":",
"Decodable",
")",
"->",
"Any",
":",
"if",
"not",
"is_bytes",
"(",
"data",
")",
":",
"raise",
"TypeError",
"(",
"\"The `data` value must be of bytes type. Got {0}\"",
".",
"form... | Decodes the binary value ``data`` of the ABI type ``typ`` into its
equivalent python value.
:param typ: The string representation of the ABI type that will be used for
decoding e.g. ``'uint256'``, ``'bytes[]'``, ``'(int,int)'``, etc.
:param data: The binary value to be decoded.
... | [
"Decodes",
"the",
"binary",
"value",
"data",
"of",
"the",
"ABI",
"type",
"typ",
"into",
"its",
"equivalent",
"python",
"value",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/codec.py#L135-L153 |
2,254 | ethereum/eth-abi | eth_abi/codec.py | ABIDecoder.decode_abi | def decode_abi(self, types: Iterable[TypeStr], data: Decodable) -> Tuple[Any, ...]:
"""
Decodes the binary value ``data`` as a sequence of values of the ABI types
in ``types`` via the head-tail mechanism into a tuple of equivalent python
values.
:param types: An iterable of stri... | python | def decode_abi(self, types: Iterable[TypeStr], data: Decodable) -> Tuple[Any, ...]:
"""
Decodes the binary value ``data`` as a sequence of values of the ABI types
in ``types`` via the head-tail mechanism into a tuple of equivalent python
values.
:param types: An iterable of stri... | [
"def",
"decode_abi",
"(",
"self",
",",
"types",
":",
"Iterable",
"[",
"TypeStr",
"]",
",",
"data",
":",
"Decodable",
")",
"->",
"Tuple",
"[",
"Any",
",",
"...",
"]",
":",
"if",
"not",
"is_bytes",
"(",
"data",
")",
":",
"raise",
"TypeError",
"(",
"\... | Decodes the binary value ``data`` as a sequence of values of the ABI types
in ``types`` via the head-tail mechanism into a tuple of equivalent python
values.
:param types: An iterable of string representations of the ABI types that
will be used for decoding e.g. ``('uint256', 'bytes... | [
"Decodes",
"the",
"binary",
"value",
"data",
"as",
"a",
"sequence",
"of",
"values",
"of",
"the",
"ABI",
"types",
"in",
"types",
"via",
"the",
"head",
"-",
"tail",
"mechanism",
"into",
"a",
"tuple",
"of",
"equivalent",
"python",
"values",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/codec.py#L155-L179 |
2,255 | aiortc/aioice | aioice/turn.py | create_turn_endpoint | async def create_turn_endpoint(protocol_factory, server_addr, username, password,
lifetime=600, ssl=False, transport='udp'):
"""
Create datagram connection relayed over TURN.
"""
loop = asyncio.get_event_loop()
if transport == 'tcp':
_, inner_protocol = await l... | python | async def create_turn_endpoint(protocol_factory, server_addr, username, password,
lifetime=600, ssl=False, transport='udp'):
"""
Create datagram connection relayed over TURN.
"""
loop = asyncio.get_event_loop()
if transport == 'tcp':
_, inner_protocol = await l... | [
"async",
"def",
"create_turn_endpoint",
"(",
"protocol_factory",
",",
"server_addr",
",",
"username",
",",
"password",
",",
"lifetime",
"=",
"600",
",",
"ssl",
"=",
"False",
",",
"transport",
"=",
"'udp'",
")",
":",
"loop",
"=",
"asyncio",
".",
"get_event_lo... | Create datagram connection relayed over TURN. | [
"Create",
"datagram",
"connection",
"relayed",
"over",
"TURN",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/turn.py#L276-L303 |
2,256 | aiortc/aioice | aioice/turn.py | TurnClientMixin.connect | async def connect(self):
"""
Create a TURN allocation.
"""
request = stun.Message(message_method=stun.Method.ALLOCATE,
message_class=stun.Class.REQUEST)
request.attributes['LIFETIME'] = self.lifetime
request.attributes['REQUESTED-TRANSPORT']... | python | async def connect(self):
"""
Create a TURN allocation.
"""
request = stun.Message(message_method=stun.Method.ALLOCATE,
message_class=stun.Class.REQUEST)
request.attributes['LIFETIME'] = self.lifetime
request.attributes['REQUESTED-TRANSPORT']... | [
"async",
"def",
"connect",
"(",
"self",
")",
":",
"request",
"=",
"stun",
".",
"Message",
"(",
"message_method",
"=",
"stun",
".",
"Method",
".",
"ALLOCATE",
",",
"message_class",
"=",
"stun",
".",
"Class",
".",
"REQUEST",
")",
"request",
".",
"attribute... | Create a TURN allocation. | [
"Create",
"a",
"TURN",
"allocation",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/turn.py#L70-L99 |
2,257 | aiortc/aioice | aioice/turn.py | TurnClientMixin.delete | async def delete(self):
"""
Delete the TURN allocation.
"""
if self.refresh_handle:
self.refresh_handle.cancel()
self.refresh_handle = None
request = stun.Message(message_method=stun.Method.REFRESH,
message_class=stun.Class.... | python | async def delete(self):
"""
Delete the TURN allocation.
"""
if self.refresh_handle:
self.refresh_handle.cancel()
self.refresh_handle = None
request = stun.Message(message_method=stun.Method.REFRESH,
message_class=stun.Class.... | [
"async",
"def",
"delete",
"(",
"self",
")",
":",
"if",
"self",
".",
"refresh_handle",
":",
"self",
".",
"refresh_handle",
".",
"cancel",
"(",
")",
"self",
".",
"refresh_handle",
"=",
"None",
"request",
"=",
"stun",
".",
"Message",
"(",
"message_method",
... | Delete the TURN allocation. | [
"Delete",
"the",
"TURN",
"allocation",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/turn.py#L130-L145 |
2,258 | aiortc/aioice | aioice/turn.py | TurnClientMixin.refresh | async def refresh(self):
"""
Periodically refresh the TURN allocation.
"""
while True:
await asyncio.sleep(5/6 * self.lifetime)
request = stun.Message(message_method=stun.Method.REFRESH,
message_class=stun.Class.REQUEST)
... | python | async def refresh(self):
"""
Periodically refresh the TURN allocation.
"""
while True:
await asyncio.sleep(5/6 * self.lifetime)
request = stun.Message(message_method=stun.Method.REFRESH,
message_class=stun.Class.REQUEST)
... | [
"async",
"def",
"refresh",
"(",
"self",
")",
":",
"while",
"True",
":",
"await",
"asyncio",
".",
"sleep",
"(",
"5",
"/",
"6",
"*",
"self",
".",
"lifetime",
")",
"request",
"=",
"stun",
".",
"Message",
"(",
"message_method",
"=",
"stun",
".",
"Method"... | Periodically refresh the TURN allocation. | [
"Periodically",
"refresh",
"the",
"TURN",
"allocation",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/turn.py#L147-L159 |
2,259 | aiortc/aioice | aioice/turn.py | TurnClientMixin.send_data | async def send_data(self, data, addr):
"""
Send data to a remote host via the TURN server.
"""
channel = self.peer_to_channel.get(addr)
if channel is None:
channel = self.channel_number
self.channel_number += 1
self.channel_to_peer[channel] = a... | python | async def send_data(self, data, addr):
"""
Send data to a remote host via the TURN server.
"""
channel = self.peer_to_channel.get(addr)
if channel is None:
channel = self.channel_number
self.channel_number += 1
self.channel_to_peer[channel] = a... | [
"async",
"def",
"send_data",
"(",
"self",
",",
"data",
",",
"addr",
")",
":",
"channel",
"=",
"self",
".",
"peer_to_channel",
".",
"get",
"(",
"addr",
")",
"if",
"channel",
"is",
"None",
":",
"channel",
"=",
"self",
".",
"channel_number",
"self",
".",
... | Send data to a remote host via the TURN server. | [
"Send",
"data",
"to",
"a",
"remote",
"host",
"via",
"the",
"TURN",
"server",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/turn.py#L177-L192 |
2,260 | aiortc/aioice | aioice/turn.py | TurnClientMixin.send_stun | def send_stun(self, message, addr):
"""
Send a STUN message to the TURN server.
"""
logger.debug('%s > %s %s', self, addr, message)
self._send(bytes(message)) | python | def send_stun(self, message, addr):
"""
Send a STUN message to the TURN server.
"""
logger.debug('%s > %s %s', self, addr, message)
self._send(bytes(message)) | [
"def",
"send_stun",
"(",
"self",
",",
"message",
",",
"addr",
")",
":",
"logger",
".",
"debug",
"(",
"'%s > %s %s'",
",",
"self",
",",
"addr",
",",
"message",
")",
"self",
".",
"_send",
"(",
"bytes",
"(",
"message",
")",
")"
] | Send a STUN message to the TURN server. | [
"Send",
"a",
"STUN",
"message",
"to",
"the",
"TURN",
"server",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/turn.py#L194-L199 |
2,261 | aiortc/aioice | aioice/turn.py | TurnTransport.get_extra_info | def get_extra_info(self, name, default=None):
"""
Return optional transport information.
- `'related_address'`: the related address
- `'sockname'`: the relayed address
"""
if name == 'related_address':
return self.__inner_protocol.transport.get_extra_info('so... | python | def get_extra_info(self, name, default=None):
"""
Return optional transport information.
- `'related_address'`: the related address
- `'sockname'`: the relayed address
"""
if name == 'related_address':
return self.__inner_protocol.transport.get_extra_info('so... | [
"def",
"get_extra_info",
"(",
"self",
",",
"name",
",",
"default",
"=",
"None",
")",
":",
"if",
"name",
"==",
"'related_address'",
":",
"return",
"self",
".",
"__inner_protocol",
".",
"transport",
".",
"get_extra_info",
"(",
"'sockname'",
")",
"elif",
"name"... | Return optional transport information.
- `'related_address'`: the related address
- `'sockname'`: the relayed address | [
"Return",
"optional",
"transport",
"information",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/turn.py#L250-L261 |
2,262 | aiortc/aioice | aioice/turn.py | TurnTransport.sendto | def sendto(self, data, addr):
"""
Sends the `data` bytes to the remote peer given `addr`.
This will bind a TURN channel as necessary.
"""
asyncio.ensure_future(self.__inner_protocol.send_data(data, addr)) | python | def sendto(self, data, addr):
"""
Sends the `data` bytes to the remote peer given `addr`.
This will bind a TURN channel as necessary.
"""
asyncio.ensure_future(self.__inner_protocol.send_data(data, addr)) | [
"def",
"sendto",
"(",
"self",
",",
"data",
",",
"addr",
")",
":",
"asyncio",
".",
"ensure_future",
"(",
"self",
".",
"__inner_protocol",
".",
"send_data",
"(",
"data",
",",
"addr",
")",
")"
] | Sends the `data` bytes to the remote peer given `addr`.
This will bind a TURN channel as necessary. | [
"Sends",
"the",
"data",
"bytes",
"to",
"the",
"remote",
"peer",
"given",
"addr",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/turn.py#L263-L269 |
2,263 | aiortc/aioice | aioice/candidate.py | candidate_foundation | def candidate_foundation(candidate_type, candidate_transport, base_address):
"""
See RFC 5245 - 4.1.1.3. Computing Foundations
"""
key = '%s|%s|%s' % (candidate_type, candidate_transport, base_address)
return hashlib.md5(key.encode('ascii')).hexdigest() | python | def candidate_foundation(candidate_type, candidate_transport, base_address):
"""
See RFC 5245 - 4.1.1.3. Computing Foundations
"""
key = '%s|%s|%s' % (candidate_type, candidate_transport, base_address)
return hashlib.md5(key.encode('ascii')).hexdigest() | [
"def",
"candidate_foundation",
"(",
"candidate_type",
",",
"candidate_transport",
",",
"base_address",
")",
":",
"key",
"=",
"'%s|%s|%s'",
"%",
"(",
"candidate_type",
",",
"candidate_transport",
",",
"base_address",
")",
"return",
"hashlib",
".",
"md5",
"(",
"key"... | See RFC 5245 - 4.1.1.3. Computing Foundations | [
"See",
"RFC",
"5245",
"-",
"4",
".",
"1",
".",
"1",
".",
"3",
".",
"Computing",
"Foundations"
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/candidate.py#L5-L10 |
2,264 | aiortc/aioice | aioice/candidate.py | candidate_priority | def candidate_priority(candidate_component, candidate_type, local_pref=65535):
"""
See RFC 5245 - 4.1.2.1. Recommended Formula
"""
if candidate_type == 'host':
type_pref = 126
elif candidate_type == 'prflx':
type_pref = 110
elif candidate_type == 'srflx':
type_pref = 100
... | python | def candidate_priority(candidate_component, candidate_type, local_pref=65535):
"""
See RFC 5245 - 4.1.2.1. Recommended Formula
"""
if candidate_type == 'host':
type_pref = 126
elif candidate_type == 'prflx':
type_pref = 110
elif candidate_type == 'srflx':
type_pref = 100
... | [
"def",
"candidate_priority",
"(",
"candidate_component",
",",
"candidate_type",
",",
"local_pref",
"=",
"65535",
")",
":",
"if",
"candidate_type",
"==",
"'host'",
":",
"type_pref",
"=",
"126",
"elif",
"candidate_type",
"==",
"'prflx'",
":",
"type_pref",
"=",
"11... | See RFC 5245 - 4.1.2.1. Recommended Formula | [
"See",
"RFC",
"5245",
"-",
"4",
".",
"1",
".",
"2",
".",
"1",
".",
"Recommended",
"Formula"
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/candidate.py#L13-L28 |
2,265 | aiortc/aioice | aioice/candidate.py | Candidate.to_sdp | def to_sdp(self):
"""
Return a string representation suitable for SDP.
"""
sdp = '%s %d %s %d %s %d typ %s' % (
self.foundation,
self.component,
self.transport,
self.priority,
self.host,
self.port,
self.t... | python | def to_sdp(self):
"""
Return a string representation suitable for SDP.
"""
sdp = '%s %d %s %d %s %d typ %s' % (
self.foundation,
self.component,
self.transport,
self.priority,
self.host,
self.port,
self.t... | [
"def",
"to_sdp",
"(",
"self",
")",
":",
"sdp",
"=",
"'%s %d %s %d %s %d typ %s'",
"%",
"(",
"self",
".",
"foundation",
",",
"self",
".",
"component",
",",
"self",
".",
"transport",
",",
"self",
".",
"priority",
",",
"self",
".",
"host",
",",
"self",
".... | Return a string representation suitable for SDP. | [
"Return",
"a",
"string",
"representation",
"suitable",
"for",
"SDP",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/candidate.py#L85-L105 |
2,266 | aiortc/aioice | aioice/candidate.py | Candidate.can_pair_with | def can_pair_with(self, other):
"""
A local candidate is paired with a remote candidate if and only if
the two candidates have the same component ID and have the same IP
address version.
"""
a = ipaddress.ip_address(self.host)
b = ipaddress.ip_address(other.host)
... | python | def can_pair_with(self, other):
"""
A local candidate is paired with a remote candidate if and only if
the two candidates have the same component ID and have the same IP
address version.
"""
a = ipaddress.ip_address(self.host)
b = ipaddress.ip_address(other.host)
... | [
"def",
"can_pair_with",
"(",
"self",
",",
"other",
")",
":",
"a",
"=",
"ipaddress",
".",
"ip_address",
"(",
"self",
".",
"host",
")",
"b",
"=",
"ipaddress",
".",
"ip_address",
"(",
"other",
".",
"host",
")",
"return",
"(",
"self",
".",
"component",
"... | A local candidate is paired with a remote candidate if and only if
the two candidates have the same component ID and have the same IP
address version. | [
"A",
"local",
"candidate",
"is",
"paired",
"with",
"a",
"remote",
"candidate",
"if",
"and",
"only",
"if",
"the",
"two",
"candidates",
"have",
"the",
"same",
"component",
"ID",
"and",
"have",
"the",
"same",
"IP",
"address",
"version",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/candidate.py#L107-L119 |
2,267 | aiortc/aioice | aioice/ice.py | candidate_pair_priority | def candidate_pair_priority(local, remote, ice_controlling):
"""
See RFC 5245 - 5.7.2. Computing Pair Priority and Ordering Pairs
"""
G = ice_controlling and local.priority or remote.priority
D = ice_controlling and remote.priority or local.priority
return (1 << 32) * min(G, D) + 2 * max(G, D) +... | python | def candidate_pair_priority(local, remote, ice_controlling):
"""
See RFC 5245 - 5.7.2. Computing Pair Priority and Ordering Pairs
"""
G = ice_controlling and local.priority or remote.priority
D = ice_controlling and remote.priority or local.priority
return (1 << 32) * min(G, D) + 2 * max(G, D) +... | [
"def",
"candidate_pair_priority",
"(",
"local",
",",
"remote",
",",
"ice_controlling",
")",
":",
"G",
"=",
"ice_controlling",
"and",
"local",
".",
"priority",
"or",
"remote",
".",
"priority",
"D",
"=",
"ice_controlling",
"and",
"remote",
".",
"priority",
"or",... | See RFC 5245 - 5.7.2. Computing Pair Priority and Ordering Pairs | [
"See",
"RFC",
"5245",
"-",
"5",
".",
"7",
".",
"2",
".",
"Computing",
"Pair",
"Priority",
"and",
"Ordering",
"Pairs"
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L24-L30 |
2,268 | aiortc/aioice | aioice/ice.py | get_host_addresses | def get_host_addresses(use_ipv4, use_ipv6):
"""
Get local IP addresses.
"""
addresses = []
for interface in netifaces.interfaces():
ifaddresses = netifaces.ifaddresses(interface)
for address in ifaddresses.get(socket.AF_INET, []):
if use_ipv4 and address['addr'] != '127.0... | python | def get_host_addresses(use_ipv4, use_ipv6):
"""
Get local IP addresses.
"""
addresses = []
for interface in netifaces.interfaces():
ifaddresses = netifaces.ifaddresses(interface)
for address in ifaddresses.get(socket.AF_INET, []):
if use_ipv4 and address['addr'] != '127.0... | [
"def",
"get_host_addresses",
"(",
"use_ipv4",
",",
"use_ipv6",
")",
":",
"addresses",
"=",
"[",
"]",
"for",
"interface",
"in",
"netifaces",
".",
"interfaces",
"(",
")",
":",
"ifaddresses",
"=",
"netifaces",
".",
"ifaddresses",
"(",
"interface",
")",
"for",
... | Get local IP addresses. | [
"Get",
"local",
"IP",
"addresses",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L33-L46 |
2,269 | aiortc/aioice | aioice/ice.py | server_reflexive_candidate | async def server_reflexive_candidate(protocol, stun_server):
"""
Query STUN server to obtain a server-reflexive candidate.
"""
# lookup address
loop = asyncio.get_event_loop()
stun_server = (
await loop.run_in_executor(None, socket.gethostbyname, stun_server[0]),
stun_server[1])
... | python | async def server_reflexive_candidate(protocol, stun_server):
"""
Query STUN server to obtain a server-reflexive candidate.
"""
# lookup address
loop = asyncio.get_event_loop()
stun_server = (
await loop.run_in_executor(None, socket.gethostbyname, stun_server[0]),
stun_server[1])
... | [
"async",
"def",
"server_reflexive_candidate",
"(",
"protocol",
",",
"stun_server",
")",
":",
"# lookup address",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"stun_server",
"=",
"(",
"await",
"loop",
".",
"run_in_executor",
"(",
"None",
",",
"socket"... | Query STUN server to obtain a server-reflexive candidate. | [
"Query",
"STUN",
"server",
"to",
"obtain",
"a",
"server",
"-",
"reflexive",
"candidate",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L49-L74 |
2,270 | aiortc/aioice | aioice/ice.py | sort_candidate_pairs | def sort_candidate_pairs(pairs, ice_controlling):
"""
Sort a list of candidate pairs.
"""
def pair_priority(pair):
return -candidate_pair_priority(pair.local_candidate,
pair.remote_candidate,
ice_controlling)
pa... | python | def sort_candidate_pairs(pairs, ice_controlling):
"""
Sort a list of candidate pairs.
"""
def pair_priority(pair):
return -candidate_pair_priority(pair.local_candidate,
pair.remote_candidate,
ice_controlling)
pa... | [
"def",
"sort_candidate_pairs",
"(",
"pairs",
",",
"ice_controlling",
")",
":",
"def",
"pair_priority",
"(",
"pair",
")",
":",
"return",
"-",
"candidate_pair_priority",
"(",
"pair",
".",
"local_candidate",
",",
"pair",
".",
"remote_candidate",
",",
"ice_controlling... | Sort a list of candidate pairs. | [
"Sort",
"a",
"list",
"of",
"candidate",
"pairs",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L77-L86 |
2,271 | aiortc/aioice | aioice/ice.py | StunProtocol.send_stun | def send_stun(self, message, addr):
"""
Send a STUN message.
"""
self.__log_debug('> %s %s', addr, message)
self.transport.sendto(bytes(message), addr) | python | def send_stun(self, message, addr):
"""
Send a STUN message.
"""
self.__log_debug('> %s %s', addr, message)
self.transport.sendto(bytes(message), addr) | [
"def",
"send_stun",
"(",
"self",
",",
"message",
",",
"addr",
")",
":",
"self",
".",
"__log_debug",
"(",
"'> %s %s'",
",",
"addr",
",",
"message",
")",
"self",
".",
"transport",
".",
"sendto",
"(",
"bytes",
"(",
"message",
")",
",",
"addr",
")"
] | Send a STUN message. | [
"Send",
"a",
"STUN",
"message",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L200-L205 |
2,272 | aiortc/aioice | aioice/ice.py | Connection.add_remote_candidate | def add_remote_candidate(self, remote_candidate):
"""
Add a remote candidate or signal end-of-candidates.
To signal end-of-candidates, pass `None`.
"""
if self._remote_candidates_end:
raise ValueError('Cannot add remote candidate after end-of-candidates.')
i... | python | def add_remote_candidate(self, remote_candidate):
"""
Add a remote candidate or signal end-of-candidates.
To signal end-of-candidates, pass `None`.
"""
if self._remote_candidates_end:
raise ValueError('Cannot add remote candidate after end-of-candidates.')
i... | [
"def",
"add_remote_candidate",
"(",
"self",
",",
"remote_candidate",
")",
":",
"if",
"self",
".",
"_remote_candidates_end",
":",
"raise",
"ValueError",
"(",
"'Cannot add remote candidate after end-of-candidates.'",
")",
"if",
"remote_candidate",
"is",
"None",
":",
"self... | Add a remote candidate or signal end-of-candidates.
To signal end-of-candidates, pass `None`. | [
"Add",
"a",
"remote",
"candidate",
"or",
"signal",
"end",
"-",
"of",
"-",
"candidates",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L299-L319 |
2,273 | aiortc/aioice | aioice/ice.py | Connection.gather_candidates | async def gather_candidates(self):
"""
Gather local candidates.
You **must** call this coroutine before calling :meth:`connect`.
"""
if not self._local_candidates_start:
self._local_candidates_start = True
addresses = get_host_addresses(use_ipv4=self._use... | python | async def gather_candidates(self):
"""
Gather local candidates.
You **must** call this coroutine before calling :meth:`connect`.
"""
if not self._local_candidates_start:
self._local_candidates_start = True
addresses = get_host_addresses(use_ipv4=self._use... | [
"async",
"def",
"gather_candidates",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_local_candidates_start",
":",
"self",
".",
"_local_candidates_start",
"=",
"True",
"addresses",
"=",
"get_host_addresses",
"(",
"use_ipv4",
"=",
"self",
".",
"_use_ipv4",
","... | Gather local candidates.
You **must** call this coroutine before calling :meth:`connect`. | [
"Gather",
"local",
"candidates",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L321-L334 |
2,274 | aiortc/aioice | aioice/ice.py | Connection.get_default_candidate | def get_default_candidate(self, component):
"""
Gets the default local candidate for the specified component.
"""
for candidate in sorted(self._local_candidates, key=lambda x: x.priority):
if candidate.component == component:
return candidate | python | def get_default_candidate(self, component):
"""
Gets the default local candidate for the specified component.
"""
for candidate in sorted(self._local_candidates, key=lambda x: x.priority):
if candidate.component == component:
return candidate | [
"def",
"get_default_candidate",
"(",
"self",
",",
"component",
")",
":",
"for",
"candidate",
"in",
"sorted",
"(",
"self",
".",
"_local_candidates",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
".",
"priority",
")",
":",
"if",
"candidate",
".",
"component",
... | Gets the default local candidate for the specified component. | [
"Gets",
"the",
"default",
"local",
"candidate",
"for",
"the",
"specified",
"component",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L336-L342 |
2,275 | aiortc/aioice | aioice/ice.py | Connection.connect | async def connect(self):
"""
Perform ICE handshake.
This coroutine returns if a candidate pair was successfuly nominated
and raises an exception otherwise.
"""
if not self._local_candidates_end:
raise ConnectionError('Local candidates gathering was not perfor... | python | async def connect(self):
"""
Perform ICE handshake.
This coroutine returns if a candidate pair was successfuly nominated
and raises an exception otherwise.
"""
if not self._local_candidates_end:
raise ConnectionError('Local candidates gathering was not perfor... | [
"async",
"def",
"connect",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_local_candidates_end",
":",
"raise",
"ConnectionError",
"(",
"'Local candidates gathering was not performed'",
")",
"if",
"(",
"self",
".",
"remote_username",
"is",
"None",
"or",
"self",... | Perform ICE handshake.
This coroutine returns if a candidate pair was successfuly nominated
and raises an exception otherwise. | [
"Perform",
"ICE",
"handshake",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L344-L395 |
2,276 | aiortc/aioice | aioice/ice.py | Connection.recvfrom | async def recvfrom(self):
"""
Receive the next datagram.
The return value is a `(bytes, component)` tuple where `bytes` is a
bytes object representing the data received and `component` is the
component on which the data was received.
If the connection is not established... | python | async def recvfrom(self):
"""
Receive the next datagram.
The return value is a `(bytes, component)` tuple where `bytes` is a
bytes object representing the data received and `component` is the
component on which the data was received.
If the connection is not established... | [
"async",
"def",
"recvfrom",
"(",
"self",
")",
":",
"if",
"not",
"len",
"(",
"self",
".",
"_nominated",
")",
":",
"raise",
"ConnectionError",
"(",
"'Cannot receive data, not connected'",
")",
"result",
"=",
"await",
"self",
".",
"_queue",
".",
"get",
"(",
"... | Receive the next datagram.
The return value is a `(bytes, component)` tuple where `bytes` is a
bytes object representing the data received and `component` is the
component on which the data was received.
If the connection is not established, a `ConnectionError` is raised. | [
"Receive",
"the",
"next",
"datagram",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L430-L446 |
2,277 | aiortc/aioice | aioice/ice.py | Connection.sendto | async def sendto(self, data, component):
"""
Send a datagram on the specified component.
If the connection is not established, a `ConnectionError` is raised.
"""
active_pair = self._nominated.get(component)
if active_pair:
await active_pair.protocol.send_data... | python | async def sendto(self, data, component):
"""
Send a datagram on the specified component.
If the connection is not established, a `ConnectionError` is raised.
"""
active_pair = self._nominated.get(component)
if active_pair:
await active_pair.protocol.send_data... | [
"async",
"def",
"sendto",
"(",
"self",
",",
"data",
",",
"component",
")",
":",
"active_pair",
"=",
"self",
".",
"_nominated",
".",
"get",
"(",
"component",
")",
"if",
"active_pair",
":",
"await",
"active_pair",
".",
"protocol",
".",
"send_data",
"(",
"d... | Send a datagram on the specified component.
If the connection is not established, a `ConnectionError` is raised. | [
"Send",
"a",
"datagram",
"on",
"the",
"specified",
"component",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L456-L466 |
2,278 | aiortc/aioice | aioice/ice.py | Connection.set_selected_pair | def set_selected_pair(self, component, local_foundation, remote_foundation):
"""
Force the selected candidate pair.
If the remote party does not support ICE, you should using this
instead of calling :meth:`connect`.
"""
# find local candidate
protocol = None
... | python | def set_selected_pair(self, component, local_foundation, remote_foundation):
"""
Force the selected candidate pair.
If the remote party does not support ICE, you should using this
instead of calling :meth:`connect`.
"""
# find local candidate
protocol = None
... | [
"def",
"set_selected_pair",
"(",
"self",
",",
"component",
",",
"local_foundation",
",",
"remote_foundation",
")",
":",
"# find local candidate",
"protocol",
"=",
"None",
"for",
"p",
"in",
"self",
".",
"_protocols",
":",
"if",
"(",
"p",
".",
"local_candidate",
... | Force the selected candidate pair.
If the remote party does not support ICE, you should using this
instead of calling :meth:`connect`. | [
"Force",
"the",
"selected",
"candidate",
"pair",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L468-L490 |
2,279 | aiortc/aioice | aioice/ice.py | Connection.check_incoming | def check_incoming(self, message, addr, protocol):
"""
Handle a succesful incoming check.
"""
component = protocol.local_candidate.component
# find remote candidate
remote_candidate = None
for c in self._remote_candidates:
if c.host == addr[0] and c.p... | python | def check_incoming(self, message, addr, protocol):
"""
Handle a succesful incoming check.
"""
component = protocol.local_candidate.component
# find remote candidate
remote_candidate = None
for c in self._remote_candidates:
if c.host == addr[0] and c.p... | [
"def",
"check_incoming",
"(",
"self",
",",
"message",
",",
"addr",
",",
"protocol",
")",
":",
"component",
"=",
"protocol",
".",
"local_candidate",
".",
"component",
"# find remote candidate",
"remote_candidate",
"=",
"None",
"for",
"c",
"in",
"self",
".",
"_r... | Handle a succesful incoming check. | [
"Handle",
"a",
"succesful",
"incoming",
"check",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L554-L598 |
2,280 | aiortc/aioice | aioice/ice.py | Connection.check_start | async def check_start(self, pair):
"""
Starts a check.
"""
self.check_state(pair, CandidatePair.State.IN_PROGRESS)
request = self.build_request(pair)
try:
response, addr = await pair.protocol.request(
request, pair.remote_addr,
... | python | async def check_start(self, pair):
"""
Starts a check.
"""
self.check_state(pair, CandidatePair.State.IN_PROGRESS)
request = self.build_request(pair)
try:
response, addr = await pair.protocol.request(
request, pair.remote_addr,
... | [
"async",
"def",
"check_start",
"(",
"self",
",",
"pair",
")",
":",
"self",
".",
"check_state",
"(",
"pair",
",",
"CandidatePair",
".",
"State",
".",
"IN_PROGRESS",
")",
"request",
"=",
"self",
".",
"build_request",
"(",
"pair",
")",
"try",
":",
"response... | Starts a check. | [
"Starts",
"a",
"check",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L619-L654 |
2,281 | aiortc/aioice | aioice/ice.py | Connection.check_state | def check_state(self, pair, state):
"""
Updates the state of a check.
"""
self.__log_info('Check %s %s -> %s', pair, pair.state, state)
pair.state = state | python | def check_state(self, pair, state):
"""
Updates the state of a check.
"""
self.__log_info('Check %s %s -> %s', pair, pair.state, state)
pair.state = state | [
"def",
"check_state",
"(",
"self",
",",
"pair",
",",
"state",
")",
":",
"self",
".",
"__log_info",
"(",
"'Check %s %s -> %s'",
",",
"pair",
",",
"pair",
".",
"state",
",",
"state",
")",
"pair",
".",
"state",
"=",
"state"
] | Updates the state of a check. | [
"Updates",
"the",
"state",
"of",
"a",
"check",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L656-L661 |
2,282 | aiortc/aioice | aioice/ice.py | Connection._find_pair | def _find_pair(self, protocol, remote_candidate):
"""
Find a candidate pair in the check list.
"""
for pair in self._check_list:
if (pair.protocol == protocol and pair.remote_candidate == remote_candidate):
return pair
return None | python | def _find_pair(self, protocol, remote_candidate):
"""
Find a candidate pair in the check list.
"""
for pair in self._check_list:
if (pair.protocol == protocol and pair.remote_candidate == remote_candidate):
return pair
return None | [
"def",
"_find_pair",
"(",
"self",
",",
"protocol",
",",
"remote_candidate",
")",
":",
"for",
"pair",
"in",
"self",
".",
"_check_list",
":",
"if",
"(",
"pair",
".",
"protocol",
"==",
"protocol",
"and",
"pair",
".",
"remote_candidate",
"==",
"remote_candidate"... | Find a candidate pair in the check list. | [
"Find",
"a",
"candidate",
"pair",
"in",
"the",
"check",
"list",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L663-L670 |
2,283 | aiortc/aioice | aioice/ice.py | Connection._prune_components | def _prune_components(self):
"""
Remove components for which the remote party did not provide any candidates.
This can only be determined after end-of-candidates.
"""
seen_components = set(map(lambda x: x.component, self._remote_candidates))
missing_components = self._co... | python | def _prune_components(self):
"""
Remove components for which the remote party did not provide any candidates.
This can only be determined after end-of-candidates.
"""
seen_components = set(map(lambda x: x.component, self._remote_candidates))
missing_components = self._co... | [
"def",
"_prune_components",
"(",
"self",
")",
":",
"seen_components",
"=",
"set",
"(",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"component",
",",
"self",
".",
"_remote_candidates",
")",
")",
"missing_components",
"=",
"self",
".",
"_components",
"-",
"see... | Remove components for which the remote party did not provide any candidates.
This can only be determined after end-of-candidates. | [
"Remove",
"components",
"for",
"which",
"the",
"remote",
"party",
"did",
"not",
"provide",
"any",
"candidates",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L740-L750 |
2,284 | aiortc/aioice | aioice/stun.py | parse_message | def parse_message(data, integrity_key=None):
"""
Parses a STUN message.
If the ``integrity_key`` parameter is given, the message's HMAC will be verified.
"""
if len(data) < HEADER_LENGTH:
raise ValueError('STUN message length is less than 20 bytes')
message_type, length, cookie, transac... | python | def parse_message(data, integrity_key=None):
"""
Parses a STUN message.
If the ``integrity_key`` parameter is given, the message's HMAC will be verified.
"""
if len(data) < HEADER_LENGTH:
raise ValueError('STUN message length is less than 20 bytes')
message_type, length, cookie, transac... | [
"def",
"parse_message",
"(",
"data",
",",
"integrity_key",
"=",
"None",
")",
":",
"if",
"len",
"(",
"data",
")",
"<",
"HEADER_LENGTH",
":",
"raise",
"ValueError",
"(",
"'STUN message length is less than 20 bytes'",
")",
"message_type",
",",
"length",
",",
"cooki... | Parses a STUN message.
If the ``integrity_key`` parameter is given, the message's HMAC will be verified. | [
"Parses",
"a",
"STUN",
"message",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/stun.py#L268-L306 |
2,285 | cole/aiosmtplib | src/aiosmtplib/protocol.py | SMTPProtocol.connection_made | def connection_made(self, transport: asyncio.BaseTransport) -> None:
"""
Modified ``connection_made`` that supports upgrading our transport in
place using STARTTLS.
We set the _transport directly on the StreamReader, rather than calling
set_transport (which will raise an Asserti... | python | def connection_made(self, transport: asyncio.BaseTransport) -> None:
"""
Modified ``connection_made`` that supports upgrading our transport in
place using STARTTLS.
We set the _transport directly on the StreamReader, rather than calling
set_transport (which will raise an Asserti... | [
"def",
"connection_made",
"(",
"self",
",",
"transport",
":",
"asyncio",
".",
"BaseTransport",
")",
"->",
"None",
":",
"if",
"self",
".",
"_stream_reader",
"is",
"None",
":",
"raise",
"SMTPServerDisconnected",
"(",
"\"Client not connected\"",
")",
"self",
".",
... | Modified ``connection_made`` that supports upgrading our transport in
place using STARTTLS.
We set the _transport directly on the StreamReader, rather than calling
set_transport (which will raise an AssertionError on upgrade). | [
"Modified",
"connection_made",
"that",
"supports",
"upgrading",
"our",
"transport",
"in",
"place",
"using",
"STARTTLS",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L50-L68 |
2,286 | cole/aiosmtplib | src/aiosmtplib/protocol.py | SMTPProtocol.upgrade_transport | def upgrade_transport(
self,
context: ssl.SSLContext,
server_hostname: str = None,
waiter: Awaitable = None,
) -> SSLProtocol:
"""
Upgrade our transport to TLS in place.
"""
if self._over_ssl:
raise RuntimeError("Already using TLS.")
... | python | def upgrade_transport(
self,
context: ssl.SSLContext,
server_hostname: str = None,
waiter: Awaitable = None,
) -> SSLProtocol:
"""
Upgrade our transport to TLS in place.
"""
if self._over_ssl:
raise RuntimeError("Already using TLS.")
... | [
"def",
"upgrade_transport",
"(",
"self",
",",
"context",
":",
"ssl",
".",
"SSLContext",
",",
"server_hostname",
":",
"str",
"=",
"None",
",",
"waiter",
":",
"Awaitable",
"=",
"None",
",",
")",
"->",
"SSLProtocol",
":",
"if",
"self",
".",
"_over_ssl",
":"... | Upgrade our transport to TLS in place. | [
"Upgrade",
"our",
"transport",
"to",
"TLS",
"in",
"place",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L70-L109 |
2,287 | cole/aiosmtplib | src/aiosmtplib/protocol.py | SMTPProtocol.read_response | async def read_response(self, timeout: NumType = None) -> SMTPResponse:
"""
Get a status reponse from the server.
Returns an SMTPResponse namedtuple consisting of:
- server response code (e.g. 250, or such, if all goes well)
- server response string corresponding to response... | python | async def read_response(self, timeout: NumType = None) -> SMTPResponse:
"""
Get a status reponse from the server.
Returns an SMTPResponse namedtuple consisting of:
- server response code (e.g. 250, or such, if all goes well)
- server response string corresponding to response... | [
"async",
"def",
"read_response",
"(",
"self",
",",
"timeout",
":",
"NumType",
"=",
"None",
")",
"->",
"SMTPResponse",
":",
"if",
"self",
".",
"_stream_reader",
"is",
"None",
":",
"raise",
"SMTPServerDisconnected",
"(",
"\"Client not connected\"",
")",
"code",
... | Get a status reponse from the server.
Returns an SMTPResponse namedtuple consisting of:
- server response code (e.g. 250, or such, if all goes well)
- server response string corresponding to response code (multiline
responses are converted to a single, multiline string). | [
"Get",
"a",
"status",
"reponse",
"from",
"the",
"server",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L111-L148 |
2,288 | cole/aiosmtplib | src/aiosmtplib/protocol.py | SMTPProtocol.write_and_drain | async def write_and_drain(self, data: bytes, timeout: NumType = None) -> None:
"""
Format a command and send it to the server.
"""
if self._stream_writer is None:
raise SMTPServerDisconnected("Client not connected")
self._stream_writer.write(data)
async with... | python | async def write_and_drain(self, data: bytes, timeout: NumType = None) -> None:
"""
Format a command and send it to the server.
"""
if self._stream_writer is None:
raise SMTPServerDisconnected("Client not connected")
self._stream_writer.write(data)
async with... | [
"async",
"def",
"write_and_drain",
"(",
"self",
",",
"data",
":",
"bytes",
",",
"timeout",
":",
"NumType",
"=",
"None",
")",
"->",
"None",
":",
"if",
"self",
".",
"_stream_writer",
"is",
"None",
":",
"raise",
"SMTPServerDisconnected",
"(",
"\"Client not conn... | Format a command and send it to the server. | [
"Format",
"a",
"command",
"and",
"send",
"it",
"to",
"the",
"server",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L150-L160 |
2,289 | cole/aiosmtplib | src/aiosmtplib/protocol.py | SMTPProtocol.write_message_data | async def write_message_data(self, data: bytes, timeout: NumType = None) -> None:
"""
Encode and write email message data.
Automatically quotes lines beginning with a period per RFC821.
Lone \\\\r and \\\\n characters are converted to \\\\r\\\\n
characters.
"""
d... | python | async def write_message_data(self, data: bytes, timeout: NumType = None) -> None:
"""
Encode and write email message data.
Automatically quotes lines beginning with a period per RFC821.
Lone \\\\r and \\\\n characters are converted to \\\\r\\\\n
characters.
"""
d... | [
"async",
"def",
"write_message_data",
"(",
"self",
",",
"data",
":",
"bytes",
",",
"timeout",
":",
"NumType",
"=",
"None",
")",
"->",
"None",
":",
"data",
"=",
"LINE_ENDINGS_REGEX",
".",
"sub",
"(",
"b\"\\r\\n\"",
",",
"data",
")",
"data",
"=",
"PERIOD_R... | Encode and write email message data.
Automatically quotes lines beginning with a period per RFC821.
Lone \\\\r and \\\\n characters are converted to \\\\r\\\\n
characters. | [
"Encode",
"and",
"write",
"email",
"message",
"data",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L162-L176 |
2,290 | cole/aiosmtplib | src/aiosmtplib/protocol.py | SMTPProtocol.execute_command | async def execute_command(
self, *args: bytes, timeout: NumType = None
) -> SMTPResponse:
"""
Sends an SMTP command along with any args to the server, and returns
a response.
"""
command = b" ".join(args) + b"\r\n"
await self.write_and_drain(command, timeout=... | python | async def execute_command(
self, *args: bytes, timeout: NumType = None
) -> SMTPResponse:
"""
Sends an SMTP command along with any args to the server, and returns
a response.
"""
command = b" ".join(args) + b"\r\n"
await self.write_and_drain(command, timeout=... | [
"async",
"def",
"execute_command",
"(",
"self",
",",
"*",
"args",
":",
"bytes",
",",
"timeout",
":",
"NumType",
"=",
"None",
")",
"->",
"SMTPResponse",
":",
"command",
"=",
"b\" \"",
".",
"join",
"(",
"args",
")",
"+",
"b\"\\r\\n\"",
"await",
"self",
"... | Sends an SMTP command along with any args to the server, and returns
a response. | [
"Sends",
"an",
"SMTP",
"command",
"along",
"with",
"any",
"args",
"to",
"the",
"server",
"and",
"returns",
"a",
"response",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L178-L190 |
2,291 | cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP.last_ehlo_response | def last_ehlo_response(self, response: SMTPResponse) -> None:
"""
When setting the last EHLO response, parse the message for supported
extensions and auth methods.
"""
extensions, auth_methods = parse_esmtp_extensions(response.message)
self._last_ehlo_response = response
... | python | def last_ehlo_response(self, response: SMTPResponse) -> None:
"""
When setting the last EHLO response, parse the message for supported
extensions and auth methods.
"""
extensions, auth_methods = parse_esmtp_extensions(response.message)
self._last_ehlo_response = response
... | [
"def",
"last_ehlo_response",
"(",
"self",
",",
"response",
":",
"SMTPResponse",
")",
"->",
"None",
":",
"extensions",
",",
"auth_methods",
"=",
"parse_esmtp_extensions",
"(",
"response",
".",
"message",
")",
"self",
".",
"_last_ehlo_response",
"=",
"response",
"... | When setting the last EHLO response, parse the message for supported
extensions and auth methods. | [
"When",
"setting",
"the",
"last",
"EHLO",
"response",
"parse",
"the",
"message",
"for",
"supported",
"extensions",
"and",
"auth",
"methods",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L59-L68 |
2,292 | cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP.helo | async def helo(
self, hostname: str = None, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Send the SMTP HELO command.
Hostname to send for this command defaults to the FQDN of the local
host.
:raises SMTPHeloError: on unexpected server response code
... | python | async def helo(
self, hostname: str = None, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Send the SMTP HELO command.
Hostname to send for this command defaults to the FQDN of the local
host.
:raises SMTPHeloError: on unexpected server response code
... | [
"async",
"def",
"helo",
"(",
"self",
",",
"hostname",
":",
"str",
"=",
"None",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"if",
"hostname",
"is",
"None",
":",
"hostname",
"=",
"self",
".",
"source_address",
"a... | Send the SMTP HELO command.
Hostname to send for this command defaults to the FQDN of the local
host.
:raises SMTPHeloError: on unexpected server response code | [
"Send",
"the",
"SMTP",
"HELO",
"command",
".",
"Hostname",
"to",
"send",
"for",
"this",
"command",
"defaults",
"to",
"the",
"FQDN",
"of",
"the",
"local",
"host",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L86-L107 |
2,293 | cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP.help | async def help(self, timeout: DefaultNumType = _default) -> str:
"""
Send the SMTP HELP command, which responds with help text.
:raises SMTPResponseException: on unexpected server response code
"""
await self._ehlo_or_helo_if_needed()
async with self._command_lock:
... | python | async def help(self, timeout: DefaultNumType = _default) -> str:
"""
Send the SMTP HELP command, which responds with help text.
:raises SMTPResponseException: on unexpected server response code
"""
await self._ehlo_or_helo_if_needed()
async with self._command_lock:
... | [
"async",
"def",
"help",
"(",
"self",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"str",
":",
"await",
"self",
".",
"_ehlo_or_helo_if_needed",
"(",
")",
"async",
"with",
"self",
".",
"_command_lock",
":",
"response",
"=",
"await",
"se... | Send the SMTP HELP command, which responds with help text.
:raises SMTPResponseException: on unexpected server response code | [
"Send",
"the",
"SMTP",
"HELP",
"command",
"which",
"responds",
"with",
"help",
"text",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L109-L127 |
2,294 | cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP.noop | async def noop(self, timeout: DefaultNumType = _default) -> SMTPResponse:
"""
Send an SMTP NOOP command, which does nothing.
:raises SMTPResponseException: on unexpected server response code
"""
await self._ehlo_or_helo_if_needed()
async with self._command_lock:
... | python | async def noop(self, timeout: DefaultNumType = _default) -> SMTPResponse:
"""
Send an SMTP NOOP command, which does nothing.
:raises SMTPResponseException: on unexpected server response code
"""
await self._ehlo_or_helo_if_needed()
async with self._command_lock:
... | [
"async",
"def",
"noop",
"(",
"self",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"await",
"self",
".",
"_ehlo_or_helo_if_needed",
"(",
")",
"async",
"with",
"self",
".",
"_command_lock",
":",
"response",
"=",
"awai... | Send an SMTP NOOP command, which does nothing.
:raises SMTPResponseException: on unexpected server response code | [
"Send",
"an",
"SMTP",
"NOOP",
"command",
"which",
"does",
"nothing",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L145-L158 |
2,295 | cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP.vrfy | async def vrfy(
self, address: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Send an SMTP VRFY command, which tests an address for validity.
Not many servers support this command.
:raises SMTPResponseException: on unexpected server response code
"""
... | python | async def vrfy(
self, address: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Send an SMTP VRFY command, which tests an address for validity.
Not many servers support this command.
:raises SMTPResponseException: on unexpected server response code
"""
... | [
"async",
"def",
"vrfy",
"(",
"self",
",",
"address",
":",
"str",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"await",
"self",
".",
"_ehlo_or_helo_if_needed",
"(",
")",
"parsed_address",
"=",
"parse_address",
"(",
"... | Send an SMTP VRFY command, which tests an address for validity.
Not many servers support this command.
:raises SMTPResponseException: on unexpected server response code | [
"Send",
"an",
"SMTP",
"VRFY",
"command",
"which",
"tests",
"an",
"address",
"for",
"validity",
".",
"Not",
"many",
"servers",
"support",
"this",
"command",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L160-L187 |
2,296 | cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP.expn | async def expn(
self, address: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Send an SMTP EXPN command, which expands a mailing list.
Not many servers support this command.
:raises SMTPResponseException: on unexpected server response code
"""
... | python | async def expn(
self, address: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Send an SMTP EXPN command, which expands a mailing list.
Not many servers support this command.
:raises SMTPResponseException: on unexpected server response code
"""
... | [
"async",
"def",
"expn",
"(",
"self",
",",
"address",
":",
"str",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"await",
"self",
".",
"_ehlo_or_helo_if_needed",
"(",
")",
"parsed_address",
"=",
"parse_address",
"(",
"... | Send an SMTP EXPN command, which expands a mailing list.
Not many servers support this command.
:raises SMTPResponseException: on unexpected server response code | [
"Send",
"an",
"SMTP",
"EXPN",
"command",
"which",
"expands",
"a",
"mailing",
"list",
".",
"Not",
"many",
"servers",
"support",
"this",
"command",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L189-L210 |
2,297 | cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP.quit | async def quit(self, timeout: DefaultNumType = _default) -> SMTPResponse:
"""
Send the SMTP QUIT command, which closes the connection.
Also closes the connection from our side after a response is received.
:raises SMTPResponseException: on unexpected server response code
"""
... | python | async def quit(self, timeout: DefaultNumType = _default) -> SMTPResponse:
"""
Send the SMTP QUIT command, which closes the connection.
Also closes the connection from our side after a response is received.
:raises SMTPResponseException: on unexpected server response code
"""
... | [
"async",
"def",
"quit",
"(",
"self",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"# Can't quit without HELO/EHLO",
"await",
"self",
".",
"_ehlo_or_helo_if_needed",
"(",
")",
"async",
"with",
"self",
".",
"_command_lock",... | Send the SMTP QUIT command, which closes the connection.
Also closes the connection from our side after a response is received.
:raises SMTPResponseException: on unexpected server response code | [
"Send",
"the",
"SMTP",
"QUIT",
"command",
"which",
"closes",
"the",
"connection",
".",
"Also",
"closes",
"the",
"connection",
"from",
"our",
"side",
"after",
"a",
"response",
"is",
"received",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L212-L229 |
2,298 | cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP.rcpt | async def rcpt(
self,
recipient: str,
options: Iterable[str] = None,
timeout: DefaultNumType = _default,
) -> SMTPResponse:
"""
Send an SMTP RCPT command, which specifies a single recipient for
the message. This command is sent once per recipient and must be
... | python | async def rcpt(
self,
recipient: str,
options: Iterable[str] = None,
timeout: DefaultNumType = _default,
) -> SMTPResponse:
"""
Send an SMTP RCPT command, which specifies a single recipient for
the message. This command is sent once per recipient and must be
... | [
"async",
"def",
"rcpt",
"(",
"self",
",",
"recipient",
":",
"str",
",",
"options",
":",
"Iterable",
"[",
"str",
"]",
"=",
"None",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
",",
")",
"->",
"SMTPResponse",
":",
"await",
"self",
".",
"_ehlo_... | Send an SMTP RCPT command, which specifies a single recipient for
the message. This command is sent once per recipient and must be
preceded by 'MAIL'.
:raises SMTPRecipientRefused: on unexpected server response code | [
"Send",
"an",
"SMTP",
"RCPT",
"command",
"which",
"specifies",
"a",
"single",
"recipient",
"for",
"the",
"message",
".",
"This",
"command",
"is",
"sent",
"once",
"per",
"recipient",
"and",
"must",
"be",
"preceded",
"by",
"MAIL",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L261-L291 |
2,299 | cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP.data | async def data(
self, message: Union[str, bytes], timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Send an SMTP DATA command, followed by the message given.
This method transfers the actual email content to the server.
:raises SMTPDataError: on unexpected server res... | python | async def data(
self, message: Union[str, bytes], timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Send an SMTP DATA command, followed by the message given.
This method transfers the actual email content to the server.
:raises SMTPDataError: on unexpected server res... | [
"async",
"def",
"data",
"(",
"self",
",",
"message",
":",
"Union",
"[",
"str",
",",
"bytes",
"]",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"await",
"self",
".",
"_ehlo_or_helo_if_needed",
"(",
")",
"# As data ... | Send an SMTP DATA command, followed by the message given.
This method transfers the actual email content to the server.
:raises SMTPDataError: on unexpected server response code
:raises SMTPServerDisconnected: connection lost | [
"Send",
"an",
"SMTP",
"DATA",
"command",
"followed",
"by",
"the",
"message",
"given",
".",
"This",
"method",
"transfers",
"the",
"actual",
"email",
"content",
"to",
"the",
"server",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L293-L333 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.