repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
brentp/cruzdb
cruzdb/models.py
Interval.overlaps
def overlaps(self, other): """ check for overlap with the other interval """ if self.chrom != other.chrom: return False if self.start >= other.end: return False if other.start >= self.end: return False return True
python
def overlaps(self, other): """ check for overlap with the other interval """ if self.chrom != other.chrom: return False if self.start >= other.end: return False if other.start >= self.end: return False return True
[ "def", "overlaps", "(", "self", ",", "other", ")", ":", "if", "self", ".", "chrom", "!=", "other", ".", "chrom", ":", "return", "False", "if", "self", ".", "start", ">=", "other", ".", "end", ":", "return", "False", "if", "other", ".", "start", ">=...
check for overlap with the other interval
[ "check", "for", "overlap", "with", "the", "other", "interval" ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L81-L88
brentp/cruzdb
cruzdb/models.py
Interval.is_upstream_of
def is_upstream_of(self, other): """ check if this is upstream of the `other` interval taking the strand of the other interval into account """ if self.chrom != other.chrom: return None if getattr(other, "strand", None) == "+": return self.end <= other.start ...
python
def is_upstream_of(self, other): """ check if this is upstream of the `other` interval taking the strand of the other interval into account """ if self.chrom != other.chrom: return None if getattr(other, "strand", None) == "+": return self.end <= other.start ...
[ "def", "is_upstream_of", "(", "self", ",", "other", ")", ":", "if", "self", ".", "chrom", "!=", "other", ".", "chrom", ":", "return", "None", "if", "getattr", "(", "other", ",", "\"strand\"", ",", "None", ")", "==", "\"+\"", ":", "return", "self", "....
check if this is upstream of the `other` interval taking the strand of the other interval into account
[ "check", "if", "this", "is", "upstream", "of", "the", "other", "interval", "taking", "the", "strand", "of", "the", "other", "interval", "into", "account" ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L90-L99
brentp/cruzdb
cruzdb/models.py
Interval.distance
def distance(self, other_or_start=None, end=None, features=False): """ check the distance between this an another interval Parameters ---------- other_or_start : Interval or int either an integer or an Interval with a start attribute indicating the start ...
python
def distance(self, other_or_start=None, end=None, features=False): """ check the distance between this an another interval Parameters ---------- other_or_start : Interval or int either an integer or an Interval with a start attribute indicating the start ...
[ "def", "distance", "(", "self", ",", "other_or_start", "=", "None", ",", "end", "=", "None", ",", "features", "=", "False", ")", ":", "if", "end", "is", "None", ":", "assert", "other_or_start", ".", "chrom", "==", "self", ".", "chrom", "other_start", "...
check the distance between this an another interval Parameters ---------- other_or_start : Interval or int either an integer or an Interval with a start attribute indicating the start of the interval end : int if `other_or_start` is an integer, this ...
[ "check", "the", "distance", "between", "this", "an", "another", "interval", "Parameters", "----------" ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L101-L128
brentp/cruzdb
cruzdb/models.py
ABase.exons
def exons(self): """ return a list of exons [(start, stop)] for this object if appropriate """ # drop the trailing comma if not self.is_gene_pred: return [] if hasattr(self, "exonStarts"): try: starts = (long(s) for s in self.exonStarts[:-1].sp...
python
def exons(self): """ return a list of exons [(start, stop)] for this object if appropriate """ # drop the trailing comma if not self.is_gene_pred: return [] if hasattr(self, "exonStarts"): try: starts = (long(s) for s in self.exonStarts[:-1].sp...
[ "def", "exons", "(", "self", ")", ":", "# drop the trailing comma", "if", "not", "self", ".", "is_gene_pred", ":", "return", "[", "]", "if", "hasattr", "(", "self", ",", "\"exonStarts\"", ")", ":", "try", ":", "starts", "=", "(", "long", "(", "s", ")",...
return a list of exons [(start, stop)] for this object if appropriate
[ "return", "a", "list", "of", "exons", "[", "(", "start", "stop", ")", "]", "for", "this", "object", "if", "appropriate" ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L160-L180
brentp/cruzdb
cruzdb/models.py
ABase.gene_features
def gene_features(self): """ return a list of features for the gene features of this object. This would include exons, introns, utrs, etc. """ nm, strand = self.gene_name, self.strand feats = [(self.chrom, self.start, self.end, nm, strand, 'gene')] for feat in ('i...
python
def gene_features(self): """ return a list of features for the gene features of this object. This would include exons, introns, utrs, etc. """ nm, strand = self.gene_name, self.strand feats = [(self.chrom, self.start, self.end, nm, strand, 'gene')] for feat in ('i...
[ "def", "gene_features", "(", "self", ")", ":", "nm", ",", "strand", "=", "self", ".", "gene_name", ",", "self", ".", "strand", "feats", "=", "[", "(", "self", ".", "chrom", ",", "self", ".", "start", ",", "self", ".", "end", ",", "nm", ",", "stra...
return a list of features for the gene features of this object. This would include exons, introns, utrs, etc.
[ "return", "a", "list", "of", "features", "for", "the", "gene", "features", "of", "this", "object", ".", "This", "would", "include", "exons", "introns", "utrs", "etc", "." ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L183-L203
brentp/cruzdb
cruzdb/models.py
ABase.tss
def tss(self, up=0, down=0): """ Return a start, end tuple of positions around the transcription-start site Parameters ---------- up : int if greature than 0, the strand is used to add this many upstream bases in the appropriate direction ...
python
def tss(self, up=0, down=0): """ Return a start, end tuple of positions around the transcription-start site Parameters ---------- up : int if greature than 0, the strand is used to add this many upstream bases in the appropriate direction ...
[ "def", "tss", "(", "self", ",", "up", "=", "0", ",", "down", "=", "0", ")", ":", "if", "not", "self", ".", "is_gene_pred", ":", "return", "None", "tss", "=", "self", ".", "txEnd", "if", "self", ".", "strand", "==", "'-'", "else", "self", ".", "...
Return a start, end tuple of positions around the transcription-start site Parameters ---------- up : int if greature than 0, the strand is used to add this many upstream bases in the appropriate direction down : int if greature than 0, the str...
[ "Return", "a", "start", "end", "tuple", "of", "positions", "around", "the", "transcription", "-", "start", "site" ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L205-L231
brentp/cruzdb
cruzdb/models.py
ABase.promoter
def promoter(self, up=2000, down=0): """ Return a start, end tuple of positions for the promoter region of this gene Parameters ---------- up : int this distance upstream that is considered the promoter down : int the strand is used to add...
python
def promoter(self, up=2000, down=0): """ Return a start, end tuple of positions for the promoter region of this gene Parameters ---------- up : int this distance upstream that is considered the promoter down : int the strand is used to add...
[ "def", "promoter", "(", "self", ",", "up", "=", "2000", ",", "down", "=", "0", ")", ":", "if", "not", "self", ".", "is_gene_pred", ":", "return", "None", "return", "self", ".", "tss", "(", "up", "=", "up", ",", "down", "=", "down", ")" ]
Return a start, end tuple of positions for the promoter region of this gene Parameters ---------- up : int this distance upstream that is considered the promoter down : int the strand is used to add this many downstream bases into the gene.
[ "Return", "a", "start", "end", "tuple", "of", "positions", "for", "the", "promoter", "region", "of", "this", "gene" ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L233-L248
brentp/cruzdb
cruzdb/models.py
ABase.coding_exons
def coding_exons(self): """ includes the entire exon as long as any of it is > cdsStart and < cdsEnd """ # drop the trailing comma starts = (long(s) for s in self.exonStarts[:-1].split(",")) ends = (long(s) for s in self.exonEnds[:-1].split(",")) return [(...
python
def coding_exons(self): """ includes the entire exon as long as any of it is > cdsStart and < cdsEnd """ # drop the trailing comma starts = (long(s) for s in self.exonStarts[:-1].split(",")) ends = (long(s) for s in self.exonEnds[:-1].split(",")) return [(...
[ "def", "coding_exons", "(", "self", ")", ":", "# drop the trailing comma", "starts", "=", "(", "long", "(", "s", ")", "for", "s", "in", "self", ".", "exonStarts", "[", ":", "-", "1", "]", ".", "split", "(", "\",\"", ")", ")", "ends", "=", "(", "lon...
includes the entire exon as long as any of it is > cdsStart and < cdsEnd
[ "includes", "the", "entire", "exon", "as", "long", "as", "any", "of", "it", "is", ">", "cdsStart", "and", "<", "cdsEnd" ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L251-L261
brentp/cruzdb
cruzdb/models.py
ABase.cds
def cds(self): """just the parts of the exons that are translated""" ces = self.coding_exons if len(ces) < 1: return ces ces[0] = (self.cdsStart, ces[0][1]) ces[-1] = (ces[-1][0], self.cdsEnd) assert all((s < e for s, e in ces)) return ces
python
def cds(self): """just the parts of the exons that are translated""" ces = self.coding_exons if len(ces) < 1: return ces ces[0] = (self.cdsStart, ces[0][1]) ces[-1] = (ces[-1][0], self.cdsEnd) assert all((s < e for s, e in ces)) return ces
[ "def", "cds", "(", "self", ")", ":", "ces", "=", "self", ".", "coding_exons", "if", "len", "(", "ces", ")", "<", "1", ":", "return", "ces", "ces", "[", "0", "]", "=", "(", "self", ".", "cdsStart", ",", "ces", "[", "0", "]", "[", "1", "]", "...
just the parts of the exons that are translated
[ "just", "the", "parts", "of", "the", "exons", "that", "are", "translated" ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L264-L271
brentp/cruzdb
cruzdb/models.py
ABase.is_downstream_of
def is_downstream_of(self, other): """ return a boolean indicating whether this feature is downstream of `other` taking the strand of other into account """ if self.chrom != other.chrom: return None if getattr(other, "strand", None) == "-": # other feature is ...
python
def is_downstream_of(self, other): """ return a boolean indicating whether this feature is downstream of `other` taking the strand of other into account """ if self.chrom != other.chrom: return None if getattr(other, "strand", None) == "-": # other feature is ...
[ "def", "is_downstream_of", "(", "self", ",", "other", ")", ":", "if", "self", ".", "chrom", "!=", "other", ".", "chrom", ":", "return", "None", "if", "getattr", "(", "other", ",", "\"strand\"", ",", "None", ")", "==", "\"-\"", ":", "# other feature is on...
return a boolean indicating whether this feature is downstream of `other` taking the strand of other into account
[ "return", "a", "boolean", "indicating", "whether", "this", "feature", "is", "downstream", "of", "other", "taking", "the", "strand", "of", "other", "into", "account" ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L348-L357
brentp/cruzdb
cruzdb/models.py
ABase.features
def features(self, other_start, other_end): """ return e.g. "intron;exon" if the other_start, end overlap introns and exons """ # completely encases gene. if other_start <= self.start and other_end >= self.end: return ['gene' if self.cdsStart != self.cdsEnd el...
python
def features(self, other_start, other_end): """ return e.g. "intron;exon" if the other_start, end overlap introns and exons """ # completely encases gene. if other_start <= self.start and other_end >= self.end: return ['gene' if self.cdsStart != self.cdsEnd el...
[ "def", "features", "(", "self", ",", "other_start", ",", "other_end", ")", ":", "# completely encases gene.", "if", "other_start", "<=", "self", ".", "start", "and", "other_end", ">=", "self", ".", "end", ":", "return", "[", "'gene'", "if", "self", ".", "c...
return e.g. "intron;exon" if the other_start, end overlap introns and exons
[ "return", "e", ".", "g", ".", "intron", ";", "exon", "if", "the", "other_start", "end", "overlap", "introns", "and", "exons" ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L359-L382
brentp/cruzdb
cruzdb/models.py
ABase.upstream
def upstream(self, distance): """ return the (start, end) of the region before the geneStart """ if getattr(self, "strand", None) == "+": e = self.start s = e - distance else: s = self.end e = s + distance return self._xstre...
python
def upstream(self, distance): """ return the (start, end) of the region before the geneStart """ if getattr(self, "strand", None) == "+": e = self.start s = e - distance else: s = self.end e = s + distance return self._xstre...
[ "def", "upstream", "(", "self", ",", "distance", ")", ":", "if", "getattr", "(", "self", ",", "\"strand\"", ",", "None", ")", "==", "\"+\"", ":", "e", "=", "self", ".", "start", "s", "=", "e", "-", "distance", "else", ":", "s", "=", "self", ".", ...
return the (start, end) of the region before the geneStart
[ "return", "the", "(", "start", "end", ")", "of", "the", "region", "before", "the", "geneStart" ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L414-L424
brentp/cruzdb
cruzdb/models.py
ABase.utr5
def utr5(self): """ return the 5' UTR if appropriate """ if not self.is_coding or len(self.exons) < 2: return (None, None) if self.strand == "+": s, e = (self.txStart, self.cdsStart) else: s, e = (self.cdsEnd, self.txEnd) if s == e: return ...
python
def utr5(self): """ return the 5' UTR if appropriate """ if not self.is_coding or len(self.exons) < 2: return (None, None) if self.strand == "+": s, e = (self.txStart, self.cdsStart) else: s, e = (self.cdsEnd, self.txEnd) if s == e: return ...
[ "def", "utr5", "(", "self", ")", ":", "if", "not", "self", ".", "is_coding", "or", "len", "(", "self", ".", "exons", ")", "<", "2", ":", "return", "(", "None", ",", "None", ")", "if", "self", ".", "strand", "==", "\"+\"", ":", "s", ",", "e", ...
return the 5' UTR if appropriate
[ "return", "the", "5", "UTR", "if", "appropriate" ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L439-L449
brentp/cruzdb
cruzdb/models.py
ABase.sequence
def sequence(self, per_exon=False): """ Return the sequence for this feature. if per-exon is True, return an array of exon sequences This sequence is never reverse complemented """ db = self.db if not per_exon: start = self.txStart + 1 retu...
python
def sequence(self, per_exon=False): """ Return the sequence for this feature. if per-exon is True, return an array of exon sequences This sequence is never reverse complemented """ db = self.db if not per_exon: start = self.txStart + 1 retu...
[ "def", "sequence", "(", "self", ",", "per_exon", "=", "False", ")", ":", "db", "=", "self", ".", "db", "if", "not", "per_exon", ":", "start", "=", "self", ".", "txStart", "+", "1", "return", "_sequence", "(", "db", ",", "self", ".", "chrom", ",", ...
Return the sequence for this feature. if per-exon is True, return an array of exon sequences This sequence is never reverse complemented
[ "Return", "the", "sequence", "for", "this", "feature", ".", "if", "per", "-", "exon", "is", "True", "return", "an", "array", "of", "exon", "sequences", "This", "sequence", "is", "never", "reverse", "complemented" ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L527-L542
brentp/cruzdb
cruzdb/models.py
ABase.ncbi_blast
def ncbi_blast(self, db="nr", megablast=True, sequence=None): """ perform an NCBI blast against the sequence of this feature """ import requests requests.defaults.max_retries = 4 assert sequence in (None, "cds", "mrna") seq = self.sequence() if sequence is None el...
python
def ncbi_blast(self, db="nr", megablast=True, sequence=None): """ perform an NCBI blast against the sequence of this feature """ import requests requests.defaults.max_retries = 4 assert sequence in (None, "cds", "mrna") seq = self.sequence() if sequence is None el...
[ "def", "ncbi_blast", "(", "self", ",", "db", "=", "\"nr\"", ",", "megablast", "=", "True", ",", "sequence", "=", "None", ")", ":", "import", "requests", "requests", ".", "defaults", ".", "max_retries", "=", "4", "assert", "sequence", "in", "(", "None", ...
perform an NCBI blast against the sequence of this feature
[ "perform", "an", "NCBI", "blast", "against", "the", "sequence", "of", "this", "feature" ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L548-L591
brentp/cruzdb
cruzdb/models.py
ABase.blat
def blat(self, db=None, sequence=None, seq_type="DNA"): """ make a request to the genome-browsers BLAT interface sequence is one of None, "mrna", "cds" returns a list of features that are hits to this sequence. """ from . blat_blast import blat, blat_all assert se...
python
def blat(self, db=None, sequence=None, seq_type="DNA"): """ make a request to the genome-browsers BLAT interface sequence is one of None, "mrna", "cds" returns a list of features that are hits to this sequence. """ from . blat_blast import blat, blat_all assert se...
[ "def", "blat", "(", "self", ",", "db", "=", "None", ",", "sequence", "=", "None", ",", "seq_type", "=", "\"DNA\"", ")", ":", "from", ".", "blat_blast", "import", "blat", ",", "blat_all", "assert", "sequence", "in", "(", "None", ",", "\"cds\"", ",", "...
make a request to the genome-browsers BLAT interface sequence is one of None, "mrna", "cds" returns a list of features that are hits to this sequence.
[ "make", "a", "request", "to", "the", "genome", "-", "browsers", "BLAT", "interface", "sequence", "is", "one", "of", "None", "mrna", "cds", "returns", "a", "list", "of", "features", "that", "are", "hits", "to", "this", "sequence", "." ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L593-L605
brentp/cruzdb
cruzdb/models.py
ABase.bed
def bed(self, *attrs, **kwargs): """ return a bed formatted string of this feature """ exclude = ("chrom", "start", "end", "txStart", "txEnd", "chromStart", "chromEnd") if self.is_gene_pred: return self.bed12(**kwargs) return "\t".join(map(str,...
python
def bed(self, *attrs, **kwargs): """ return a bed formatted string of this feature """ exclude = ("chrom", "start", "end", "txStart", "txEnd", "chromStart", "chromEnd") if self.is_gene_pred: return self.bed12(**kwargs) return "\t".join(map(str,...
[ "def", "bed", "(", "self", ",", "*", "attrs", ",", "*", "*", "kwargs", ")", ":", "exclude", "=", "(", "\"chrom\"", ",", "\"start\"", ",", "\"end\"", ",", "\"txStart\"", ",", "\"txEnd\"", ",", "\"chromStart\"", ",", "\"chromEnd\"", ")", "if", "self", "....
return a bed formatted string of this feature
[ "return", "a", "bed", "formatted", "string", "of", "this", "feature" ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L614-L625
brentp/cruzdb
cruzdb/models.py
ABase.bed12
def bed12(self, score="0", rgb="."): """ return a bed12 (http://genome.ucsc.edu/FAQ/FAQformat.html#format1) representation of this interval """ if not self.is_gene_pred: raise CruzException("can't create bed12 from non genepred feature") exons = list(self.exon...
python
def bed12(self, score="0", rgb="."): """ return a bed12 (http://genome.ucsc.edu/FAQ/FAQformat.html#format1) representation of this interval """ if not self.is_gene_pred: raise CruzException("can't create bed12 from non genepred feature") exons = list(self.exon...
[ "def", "bed12", "(", "self", ",", "score", "=", "\"0\"", ",", "rgb", "=", "\".\"", ")", ":", "if", "not", "self", ".", "is_gene_pred", ":", "raise", "CruzException", "(", "\"can't create bed12 from non genepred feature\"", ")", "exons", "=", "list", "(", "se...
return a bed12 (http://genome.ucsc.edu/FAQ/FAQformat.html#format1) representation of this interval
[ "return", "a", "bed12", "(", "http", ":", "//", "genome", ".", "ucsc", ".", "edu", "/", "FAQ", "/", "FAQformat", ".", "html#format1", ")", "representation", "of", "this", "interval" ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L628-L644
brentp/cruzdb
cruzdb/models.py
ABase.localize
def localize(self, *positions, **kwargs): """ convert global coordinate(s) to local taking introns into account and cds/tx-Start depending on cdna=True kwarg """ cdna = kwargs.get('cdna', False) # TODO: account for strand ?? add kwarg ?? # if it's to the CDNA, the...
python
def localize(self, *positions, **kwargs): """ convert global coordinate(s) to local taking introns into account and cds/tx-Start depending on cdna=True kwarg """ cdna = kwargs.get('cdna', False) # TODO: account for strand ?? add kwarg ?? # if it's to the CDNA, the...
[ "def", "localize", "(", "self", ",", "*", "positions", ",", "*", "*", "kwargs", ")", ":", "cdna", "=", "kwargs", ".", "get", "(", "'cdna'", ",", "False", ")", "# TODO: account for strand ?? add kwarg ??", "# if it's to the CDNA, then it's based on the cdsStart", "st...
convert global coordinate(s) to local taking introns into account and cds/tx-Start depending on cdna=True kwarg
[ "convert", "global", "coordinate", "(", "s", ")", "to", "local", "taking", "introns", "into", "account", "and", "cds", "/", "tx", "-", "Start", "depending", "on", "cdna", "=", "True", "kwarg" ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L665-L709
brentp/cruzdb
cruzdb/models.py
cpgIslandExt.distance
def distance(self, other_or_start=None, end=None, features="unused", shore_dist=3000): """ check the distance between this an another interval Parameters ---------- other_or_start : Interval or int either an integer or an Interval with a start attribute i...
python
def distance(self, other_or_start=None, end=None, features="unused", shore_dist=3000): """ check the distance between this an another interval Parameters ---------- other_or_start : Interval or int either an integer or an Interval with a start attribute i...
[ "def", "distance", "(", "self", ",", "other_or_start", "=", "None", ",", "end", "=", "None", ",", "features", "=", "\"unused\"", ",", "shore_dist", "=", "3000", ")", ":", "# leave features kwarg to match signature from Feature.distance", "if", "end", "is", "None",...
check the distance between this an another interval Parameters ---------- other_or_start : Interval or int either an integer or an Interval with a start attribute indicating the start of the interval end : int if `other_or_start` is an integer, this ...
[ "check", "the", "distance", "between", "this", "an", "another", "interval", "Parameters", "----------" ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L725-L758
brentp/cruzdb
cruzdb/annotate.py
annotate
def annotate(g, fname, tables, feature_strand=False, in_memory=False, header=None, out=sys.stdout, _chrom=None, parallel=False): """ annotate bed file in fname with tables. distances are integers for distance. and intron/exon/utr5 etc for gene-pred tables. if the annotation features have a stran...
python
def annotate(g, fname, tables, feature_strand=False, in_memory=False, header=None, out=sys.stdout, _chrom=None, parallel=False): """ annotate bed file in fname with tables. distances are integers for distance. and intron/exon/utr5 etc for gene-pred tables. if the annotation features have a stran...
[ "def", "annotate", "(", "g", ",", "fname", ",", "tables", ",", "feature_strand", "=", "False", ",", "in_memory", "=", "False", ",", "header", "=", "None", ",", "out", "=", "sys", ".", "stdout", ",", "_chrom", "=", "None", ",", "parallel", "=", "False...
annotate bed file in fname with tables. distances are integers for distance. and intron/exon/utr5 etc for gene-pred tables. if the annotation features have a strand, the distance reported is negative if the annotation feature is upstream of the feature in question if feature_strand is True, then the dis...
[ "annotate", "bed", "file", "in", "fname", "with", "tables", ".", "distances", "are", "integers", "for", "distance", ".", "and", "intron", "/", "exon", "/", "utr5", "etc", "for", "gene", "-", "pred", "tables", ".", "if", "the", "annotation", "features", "...
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/annotate.py#L28-L171
ome/omego
omego/main.py
entry_point
def entry_point(): """ External entry point which calls main() and if Stop is raised, calls sys.exit() """ try: main("omego", items=[ (InstallCommand.NAME, InstallCommand), (UpgradeCommand.NAME, UpgradeCommand), (ConvertCommand.NAME, ConvertCommand), ...
python
def entry_point(): """ External entry point which calls main() and if Stop is raised, calls sys.exit() """ try: main("omego", items=[ (InstallCommand.NAME, InstallCommand), (UpgradeCommand.NAME, UpgradeCommand), (ConvertCommand.NAME, ConvertCommand), ...
[ "def", "entry_point", "(", ")", ":", "try", ":", "main", "(", "\"omego\"", ",", "items", "=", "[", "(", "InstallCommand", ".", "NAME", ",", "InstallCommand", ")", ",", "(", "UpgradeCommand", ".", "NAME", ",", "UpgradeCommand", ")", ",", "(", "ConvertComm...
External entry point which calls main() and if Stop is raised, calls sys.exit()
[ "External", "entry", "point", "which", "calls", "main", "()", "and", "if", "Stop", "is", "raised", "calls", "sys", ".", "exit", "()" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/main.py#L40-L58
ome/omego
omego/fileutils.py
open_url
def open_url(url, httpuser=None, httppassword=None, method=None): """ Open a URL using an opener that will simulate a browser user-agent url: The URL httpuser, httppassword: HTTP authentication credentials (either both or neither must be provided) method: The HTTP method Caller is reponsi...
python
def open_url(url, httpuser=None, httppassword=None, method=None): """ Open a URL using an opener that will simulate a browser user-agent url: The URL httpuser, httppassword: HTTP authentication credentials (either both or neither must be provided) method: The HTTP method Caller is reponsi...
[ "def", "open_url", "(", "url", ",", "httpuser", "=", "None", ",", "httppassword", "=", "None", ",", "method", "=", "None", ")", ":", "if", "os", ".", "getenv", "(", "'OMEGO_SSL_NO_VERIFY'", ")", "==", "'1'", ":", "# This needs to come first to override the def...
Open a URL using an opener that will simulate a browser user-agent url: The URL httpuser, httppassword: HTTP authentication credentials (either both or neither must be provided) method: The HTTP method Caller is reponsible for calling close() on the returned object
[ "Open", "a", "URL", "using", "an", "opener", "that", "will", "simulate", "a", "browser", "user", "-", "agent", "url", ":", "The", "URL", "httpuser", "httppassword", ":", "HTTP", "authentication", "credentials", "(", "either", "both", "or", "neither", "must",...
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L47-L92
ome/omego
omego/fileutils.py
dereference_url
def dereference_url(url): """ Makes a HEAD request to find the final destination of a URL after following any redirects """ res = open_url(url, method='HEAD') res.close() return res.url
python
def dereference_url(url): """ Makes a HEAD request to find the final destination of a URL after following any redirects """ res = open_url(url, method='HEAD') res.close() return res.url
[ "def", "dereference_url", "(", "url", ")", ":", "res", "=", "open_url", "(", "url", ",", "method", "=", "'HEAD'", ")", "res", ".", "close", "(", ")", "return", "res", ".", "url" ]
Makes a HEAD request to find the final destination of a URL after following any redirects
[ "Makes", "a", "HEAD", "request", "to", "find", "the", "final", "destination", "of", "a", "URL", "after", "following", "any", "redirects" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L95-L102
ome/omego
omego/fileutils.py
read
def read(url, **kwargs): """ Read the contents of a URL into memory, return """ response = open_url(url, **kwargs) try: return response.read() finally: response.close()
python
def read(url, **kwargs): """ Read the contents of a URL into memory, return """ response = open_url(url, **kwargs) try: return response.read() finally: response.close()
[ "def", "read", "(", "url", ",", "*", "*", "kwargs", ")", ":", "response", "=", "open_url", "(", "url", ",", "*", "*", "kwargs", ")", "try", ":", "return", "response", ".", "read", "(", ")", "finally", ":", "response", ".", "close", "(", ")" ]
Read the contents of a URL into memory, return
[ "Read", "the", "contents", "of", "a", "URL", "into", "memory", "return" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L105-L113
ome/omego
omego/fileutils.py
download
def download(url, filename=None, print_progress=0, delete_fail=True, **kwargs): """ Download a file, optionally printing a simple progress bar url: The URL to download filename: The filename to save to, default is to use the URL basename print_progress: The length of the progress bar, u...
python
def download(url, filename=None, print_progress=0, delete_fail=True, **kwargs): """ Download a file, optionally printing a simple progress bar url: The URL to download filename: The filename to save to, default is to use the URL basename print_progress: The length of the progress bar, u...
[ "def", "download", "(", "url", ",", "filename", "=", "None", ",", "print_progress", "=", "0", ",", "delete_fail", "=", "True", ",", "*", "*", "kwargs", ")", ":", "blocksize", "=", "1024", "*", "1024", "downloaded", "=", "0", "progress", "=", "None", ...
Download a file, optionally printing a simple progress bar url: The URL to download filename: The filename to save to, default is to use the URL basename print_progress: The length of the progress bar, use 0 to disable delete_fail: If True delete the file if the download was not successful, defaul...
[ "Download", "a", "file", "optionally", "printing", "a", "simple", "progress", "bar", "url", ":", "The", "URL", "to", "download", "filename", ":", "The", "filename", "to", "save", "to", "default", "is", "to", "use", "the", "URL", "basename", "print_progress",...
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L116-L158
ome/omego
omego/fileutils.py
rename_backup
def rename_backup(name, suffix='.bak'): """ Append a backup prefix to a file or directory, with an increasing numeric suffix (.N) if a file already exists """ newname = '%s%s' % (name, suffix) n = 0 while os.path.exists(newname): n += 1 newname = '%s%s.%d' % (name, suffix, n)...
python
def rename_backup(name, suffix='.bak'): """ Append a backup prefix to a file or directory, with an increasing numeric suffix (.N) if a file already exists """ newname = '%s%s' % (name, suffix) n = 0 while os.path.exists(newname): n += 1 newname = '%s%s.%d' % (name, suffix, n)...
[ "def", "rename_backup", "(", "name", ",", "suffix", "=", "'.bak'", ")", ":", "newname", "=", "'%s%s'", "%", "(", "name", ",", "suffix", ")", "n", "=", "0", "while", "os", ".", "path", ".", "exists", "(", "newname", ")", ":", "n", "+=", "1", "newn...
Append a backup prefix to a file or directory, with an increasing numeric suffix (.N) if a file already exists
[ "Append", "a", "backup", "prefix", "to", "a", "file", "or", "directory", "with", "an", "increasing", "numeric", "suffix", "(", ".", "N", ")", "if", "a", "file", "already", "exists" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L161-L173
ome/omego
omego/fileutils.py
timestamp_filename
def timestamp_filename(basename, ext=None): """ Return a string of the form [basename-TIMESTAMP.ext] where TIMESTAMP is of the form YYYYMMDD-HHMMSS-MILSEC """ dt = datetime.now().strftime('%Y%m%d-%H%M%S-%f') if ext: return '%s-%s.%s' % (basename, dt, ext) return '%s-%s' % (basename, ...
python
def timestamp_filename(basename, ext=None): """ Return a string of the form [basename-TIMESTAMP.ext] where TIMESTAMP is of the form YYYYMMDD-HHMMSS-MILSEC """ dt = datetime.now().strftime('%Y%m%d-%H%M%S-%f') if ext: return '%s-%s.%s' % (basename, dt, ext) return '%s-%s' % (basename, ...
[ "def", "timestamp_filename", "(", "basename", ",", "ext", "=", "None", ")", ":", "dt", "=", "datetime", ".", "now", "(", ")", ".", "strftime", "(", "'%Y%m%d-%H%M%S-%f'", ")", "if", "ext", ":", "return", "'%s-%s.%s'", "%", "(", "basename", ",", "dt", ",...
Return a string of the form [basename-TIMESTAMP.ext] where TIMESTAMP is of the form YYYYMMDD-HHMMSS-MILSEC
[ "Return", "a", "string", "of", "the", "form", "[", "basename", "-", "TIMESTAMP", ".", "ext", "]", "where", "TIMESTAMP", "is", "of", "the", "form", "YYYYMMDD", "-", "HHMMSS", "-", "MILSEC" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L176-L184
ome/omego
omego/fileutils.py
check_extracted_paths
def check_extracted_paths(namelist, subdir=None): """ Check whether zip file paths are all relative, and optionally in a specified subdirectory, raises an exception if not namelist: A list of paths from the zip file subdir: If specified then check whether all paths in the zip file are under t...
python
def check_extracted_paths(namelist, subdir=None): """ Check whether zip file paths are all relative, and optionally in a specified subdirectory, raises an exception if not namelist: A list of paths from the zip file subdir: If specified then check whether all paths in the zip file are under t...
[ "def", "check_extracted_paths", "(", "namelist", ",", "subdir", "=", "None", ")", ":", "def", "relpath", "(", "p", ")", ":", "# relpath strips a trailing sep", "# Windows paths may also use unix sep", "q", "=", "os", ".", "path", ".", "relpath", "(", "p", ")", ...
Check whether zip file paths are all relative, and optionally in a specified subdirectory, raises an exception if not namelist: A list of paths from the zip file subdir: If specified then check whether all paths in the zip file are under this subdirectory Python docs are unclear about the securi...
[ "Check", "whether", "zip", "file", "paths", "are", "all", "relative", "and", "optionally", "in", "a", "specified", "subdirectory", "raises", "an", "exception", "if", "not" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L194-L228
ome/omego
omego/fileutils.py
unzip
def unzip(filename, match_dir=False, destdir=None): """ Extract all files from a zip archive filename: The path to the zip file match_dir: If True all files in the zip must be contained in a subdirectory named after the archive file with extension removed destdir: Extract the zip into this dir...
python
def unzip(filename, match_dir=False, destdir=None): """ Extract all files from a zip archive filename: The path to the zip file match_dir: If True all files in the zip must be contained in a subdirectory named after the archive file with extension removed destdir: Extract the zip into this dir...
[ "def", "unzip", "(", "filename", ",", "match_dir", "=", "False", ",", "destdir", "=", "None", ")", ":", "if", "not", "destdir", ":", "destdir", "=", "'.'", "z", "=", "zipfile", ".", "ZipFile", "(", "filename", ")", "unzipped", "=", "'.'", "if", "matc...
Extract all files from a zip archive filename: The path to the zip file match_dir: If True all files in the zip must be contained in a subdirectory named after the archive file with extension removed destdir: Extract the zip into this directory, default current directory return: If match_dir is T...
[ "Extract", "all", "files", "from", "a", "zip", "archive", "filename", ":", "The", "path", "to", "the", "zip", "file", "match_dir", ":", "If", "True", "all", "files", "in", "the", "zip", "must", "be", "contained", "in", "a", "subdirectory", "named", "afte...
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L231-L266
ome/omego
omego/fileutils.py
zip
def zip(filename, paths, strip_prefix=''): """ Create a new zip archive containing files filename: The name of the zip file to be created paths: A list of files or directories strip_dir: Remove this prefix from all file-paths before adding to zip """ if isinstance(paths, basestring): ...
python
def zip(filename, paths, strip_prefix=''): """ Create a new zip archive containing files filename: The name of the zip file to be created paths: A list of files or directories strip_dir: Remove this prefix from all file-paths before adding to zip """ if isinstance(paths, basestring): ...
[ "def", "zip", "(", "filename", ",", "paths", ",", "strip_prefix", "=", "''", ")", ":", "if", "isinstance", "(", "paths", ",", "basestring", ")", ":", "paths", "=", "[", "paths", "]", "filelist", "=", "set", "(", ")", "for", "p", "in", "paths", ":",...
Create a new zip archive containing files filename: The name of the zip file to be created paths: A list of files or directories strip_dir: Remove this prefix from all file-paths before adding to zip
[ "Create", "a", "new", "zip", "archive", "containing", "files", "filename", ":", "The", "name", "of", "the", "zip", "file", "to", "be", "created", "paths", ":", "A", "list", "of", "files", "or", "directories", "strip_dir", ":", "Remove", "this", "prefix", ...
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L269-L298
ome/omego
omego/fileutils.py
get_as_local_path
def get_as_local_path(path, overwrite, progress=0, httpuser=None, httppassword=None): """ Automatically handle local and remote URLs, files and directories path: Either a local directory, file or remote URL. If a URL is given it will be fetched. If this is a zip it will be autom...
python
def get_as_local_path(path, overwrite, progress=0, httpuser=None, httppassword=None): """ Automatically handle local and remote URLs, files and directories path: Either a local directory, file or remote URL. If a URL is given it will be fetched. If this is a zip it will be autom...
[ "def", "get_as_local_path", "(", "path", ",", "overwrite", ",", "progress", "=", "0", ",", "httpuser", "=", "None", ",", "httppassword", "=", "None", ")", ":", "m", "=", "re", ".", "match", "(", "'([A-Za-z]+)://'", ",", "path", ")", "if", "m", ":", "...
Automatically handle local and remote URLs, files and directories path: Either a local directory, file or remote URL. If a URL is given it will be fetched. If this is a zip it will be automatically expanded by default. overwrite: Whether to overwrite an existing file: 'error': Raise an except...
[ "Automatically", "handle", "local", "and", "remote", "URLs", "files", "and", "directories" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L301-L356
svartalf/python-opus
opus/api/encoder.py
create
def create(fs, channels, application): """Allocates and initializes an encoder state.""" result_code = ctypes.c_int() result = _create(fs, channels, application, ctypes.byref(result_code)) if result_code.value is not constants.OK: raise OpusError(result_code.value) return result
python
def create(fs, channels, application): """Allocates and initializes an encoder state.""" result_code = ctypes.c_int() result = _create(fs, channels, application, ctypes.byref(result_code)) if result_code.value is not constants.OK: raise OpusError(result_code.value) return result
[ "def", "create", "(", "fs", ",", "channels", ",", "application", ")", ":", "result_code", "=", "ctypes", ".", "c_int", "(", ")", "result", "=", "_create", "(", "fs", ",", "channels", ",", "application", ",", "ctypes", ".", "byref", "(", "result_code", ...
Allocates and initializes an encoder state.
[ "Allocates", "and", "initializes", "an", "encoder", "state", "." ]
train
https://github.com/svartalf/python-opus/blob/a3c1d556d2772b5be659ddd08c033ddd4d566b3a/opus/api/encoder.py#L40-L49
svartalf/python-opus
opus/api/encoder.py
encode
def encode(encoder, pcm, frame_size, max_data_bytes): """Encodes an Opus frame Returns string output payload """ pcm = ctypes.cast(pcm, c_int16_pointer) data = (ctypes.c_char * max_data_bytes)() result = _encode(encoder, pcm, frame_size, data, max_data_bytes) if result < 0: raise ...
python
def encode(encoder, pcm, frame_size, max_data_bytes): """Encodes an Opus frame Returns string output payload """ pcm = ctypes.cast(pcm, c_int16_pointer) data = (ctypes.c_char * max_data_bytes)() result = _encode(encoder, pcm, frame_size, data, max_data_bytes) if result < 0: raise ...
[ "def", "encode", "(", "encoder", ",", "pcm", ",", "frame_size", ",", "max_data_bytes", ")", ":", "pcm", "=", "ctypes", ".", "cast", "(", "pcm", ",", "c_int16_pointer", ")", "data", "=", "(", "ctypes", ".", "c_char", "*", "max_data_bytes", ")", "(", ")"...
Encodes an Opus frame Returns string output payload
[ "Encodes", "an", "Opus", "frame" ]
train
https://github.com/svartalf/python-opus/blob/a3c1d556d2772b5be659ddd08c033ddd4d566b3a/opus/api/encoder.py#L68-L81
svartalf/python-opus
opus/api/encoder.py
encode_float
def encode_float(encoder, pcm, frame_size, max_data_bytes): """Encodes an Opus frame from floating point input""" pcm = ctypes.cast(pcm, c_float_pointer) data = (ctypes.c_char * max_data_bytes)() result = _encode_float(encoder, pcm, frame_size, data, max_data_bytes) if result < 0: raise Op...
python
def encode_float(encoder, pcm, frame_size, max_data_bytes): """Encodes an Opus frame from floating point input""" pcm = ctypes.cast(pcm, c_float_pointer) data = (ctypes.c_char * max_data_bytes)() result = _encode_float(encoder, pcm, frame_size, data, max_data_bytes) if result < 0: raise Op...
[ "def", "encode_float", "(", "encoder", ",", "pcm", ",", "frame_size", ",", "max_data_bytes", ")", ":", "pcm", "=", "ctypes", ".", "cast", "(", "pcm", ",", "c_float_pointer", ")", "data", "=", "(", "ctypes", ".", "c_char", "*", "max_data_bytes", ")", "(",...
Encodes an Opus frame from floating point input
[ "Encodes", "an", "Opus", "frame", "from", "floating", "point", "input" ]
train
https://github.com/svartalf/python-opus/blob/a3c1d556d2772b5be659ddd08c033ddd4d566b3a/opus/api/encoder.py#L89-L99
buruzaemon/natto-py
natto/mecab.py
MeCab.__parse_tostr
def __parse_tostr(self, text, **kwargs): '''Builds and returns the MeCab function for parsing Unicode text. Args: fn_name: MeCab function name that determines the function behavior, either 'mecab_sparse_tostr' or 'mecab_nbest_sparse_tostr'. Returns: ...
python
def __parse_tostr(self, text, **kwargs): '''Builds and returns the MeCab function for parsing Unicode text. Args: fn_name: MeCab function name that determines the function behavior, either 'mecab_sparse_tostr' or 'mecab_nbest_sparse_tostr'. Returns: ...
[ "def", "__parse_tostr", "(", "self", ",", "text", ",", "*", "*", "kwargs", ")", ":", "n", "=", "self", ".", "options", ".", "get", "(", "'nbest'", ",", "1", ")", "if", "self", ".", "_KW_BOUNDARY", "in", "kwargs", ":", "patt", "=", "kwargs", ".", ...
Builds and returns the MeCab function for parsing Unicode text. Args: fn_name: MeCab function name that determines the function behavior, either 'mecab_sparse_tostr' or 'mecab_nbest_sparse_tostr'. Returns: A function definition, tailored to parsi...
[ "Builds", "and", "returns", "the", "MeCab", "function", "for", "parsing", "Unicode", "text", "." ]
train
https://github.com/buruzaemon/natto-py/blob/018fe004c47c45c66bdf2e03fe24e981ae089b76/natto/mecab.py#L248-L322
buruzaemon/natto-py
natto/mecab.py
MeCab.__parse_tonodes
def __parse_tonodes(self, text, **kwargs): '''Builds and returns the MeCab function for parsing to nodes using morpheme boundary constraints. Args: format_feature: flag indicating whether or not to format the feature value for each node yielded. Returns: ...
python
def __parse_tonodes(self, text, **kwargs): '''Builds and returns the MeCab function for parsing to nodes using morpheme boundary constraints. Args: format_feature: flag indicating whether or not to format the feature value for each node yielded. Returns: ...
[ "def", "__parse_tonodes", "(", "self", ",", "text", ",", "*", "*", "kwargs", ")", ":", "n", "=", "self", ".", "options", ".", "get", "(", "'nbest'", ",", "1", ")", "try", ":", "if", "self", ".", "_KW_BOUNDARY", "in", "kwargs", ":", "patt", "=", "...
Builds and returns the MeCab function for parsing to nodes using morpheme boundary constraints. Args: format_feature: flag indicating whether or not to format the feature value for each node yielded. Returns: A function which returns a Generator, tailore...
[ "Builds", "and", "returns", "the", "MeCab", "function", "for", "parsing", "to", "nodes", "using", "morpheme", "boundary", "constraints", "." ]
train
https://github.com/buruzaemon/natto-py/blob/018fe004c47c45c66bdf2e03fe24e981ae089b76/natto/mecab.py#L324-L427
buruzaemon/natto-py
natto/mecab.py
MeCab.parse
def parse(self, text, **kwargs): '''Parse the given text and return result from MeCab. :param text: the text to parse. :type text: str :param as_nodes: return generator of MeCabNodes if True; or string if False. :type as_nodes: bool, defaults to False :param ...
python
def parse(self, text, **kwargs): '''Parse the given text and return result from MeCab. :param text: the text to parse. :type text: str :param as_nodes: return generator of MeCabNodes if True; or string if False. :type as_nodes: bool, defaults to False :param ...
[ "def", "parse", "(", "self", ",", "text", ",", "*", "*", "kwargs", ")", ":", "if", "text", "is", "None", ":", "logger", ".", "error", "(", "self", ".", "_ERROR_EMPTY_STR", ")", "raise", "MeCabError", "(", "self", ".", "_ERROR_EMPTY_STR", ")", "elif", ...
Parse the given text and return result from MeCab. :param text: the text to parse. :type text: str :param as_nodes: return generator of MeCabNodes if True; or string if False. :type as_nodes: bool, defaults to False :param boundary_constraints: regular expression for...
[ "Parse", "the", "given", "text", "and", "return", "result", "from", "MeCab", "." ]
train
https://github.com/buruzaemon/natto-py/blob/018fe004c47c45c66bdf2e03fe24e981ae089b76/natto/mecab.py#L441-L488
ome/omego
omego/convert.py
parse
def parse(filename, MAX_TERM_COUNT=1000): """ MAX_TERM_COUNT = 10000 # There are 39,000 terms in the GO! """ with open(filename, "r") as f: termId = None name = None desc = None parents = [] termCount = 0 for l in f.readlines(): if l.st...
python
def parse(filename, MAX_TERM_COUNT=1000): """ MAX_TERM_COUNT = 10000 # There are 39,000 terms in the GO! """ with open(filename, "r") as f: termId = None name = None desc = None parents = [] termCount = 0 for l in f.readlines(): if l.st...
[ "def", "parse", "(", "filename", ",", "MAX_TERM_COUNT", "=", "1000", ")", ":", "with", "open", "(", "filename", ",", "\"r\"", ")", "as", "f", ":", "termId", "=", "None", "name", "=", "None", "desc", "=", "None", "parents", "=", "[", "]", "termCount",...
MAX_TERM_COUNT = 10000 # There are 39,000 terms in the GO!
[ "MAX_TERM_COUNT", "=", "10000", "#", "There", "are", "39", "000", "terms", "in", "the", "GO!" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/convert.py#L59-L109
ome/omego
omego/convert.py
generate
def generate(tagGroups, terms): """ create Tag Groups and Child Tags using data from terms dict """ rv = [] for pid in tagGroups: # In testing we may not have complete set if pid not in terms.keys(): continue groupData = terms[pid] groupName = "[%s] %s" ...
python
def generate(tagGroups, terms): """ create Tag Groups and Child Tags using data from terms dict """ rv = [] for pid in tagGroups: # In testing we may not have complete set if pid not in terms.keys(): continue groupData = terms[pid] groupName = "[%s] %s" ...
[ "def", "generate", "(", "tagGroups", ",", "terms", ")", ":", "rv", "=", "[", "]", "for", "pid", "in", "tagGroups", ":", "# In testing we may not have complete set", "if", "pid", "not", "in", "terms", ".", "keys", "(", ")", ":", "continue", "groupData", "="...
create Tag Groups and Child Tags using data from terms dict
[ "create", "Tag", "Groups", "and", "Child", "Tags", "using", "data", "from", "terms", "dict" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/convert.py#L112-L137
ome/omego
omego/upgrade.py
Install._handle_args
def _handle_args(self, cmd, args): """ We need to support deprecated behaviour for now which makes this quite complicated Current behaviour: - install: Installs a new server, existing server causes an error - install --upgrade: Installs or upgrades a server - ins...
python
def _handle_args(self, cmd, args): """ We need to support deprecated behaviour for now which makes this quite complicated Current behaviour: - install: Installs a new server, existing server causes an error - install --upgrade: Installs or upgrades a server - ins...
[ "def", "_handle_args", "(", "self", ",", "cmd", ",", "args", ")", ":", "if", "cmd", "==", "'install'", ":", "if", "args", ".", "upgrade", ":", "# Current behaviour: install or upgrade", "if", "args", ".", "initdb", "or", "args", ".", "upgradedb", ":", "rai...
We need to support deprecated behaviour for now which makes this quite complicated Current behaviour: - install: Installs a new server, existing server causes an error - install --upgrade: Installs or upgrades a server - install --managedb: Automatically initialise or upgrade th...
[ "We", "need", "to", "support", "deprecated", "behaviour", "for", "now", "which", "makes", "this", "quite", "complicated" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/upgrade.py#L75-L132
ome/omego
omego/upgrade.py
Install.get_server_dir
def get_server_dir(self): """ Either downloads and/or unzips the server if necessary return: the directory of the unzipped server """ if not self.args.server: if self.args.skipunzip: raise Stop(0, 'Unzip disabled, exiting') log.info('Downl...
python
def get_server_dir(self): """ Either downloads and/or unzips the server if necessary return: the directory of the unzipped server """ if not self.args.server: if self.args.skipunzip: raise Stop(0, 'Unzip disabled, exiting') log.info('Downl...
[ "def", "get_server_dir", "(", "self", ")", ":", "if", "not", "self", ".", "args", ".", "server", ":", "if", "self", ".", "args", ".", "skipunzip", ":", "raise", "Stop", "(", "0", ",", "'Unzip disabled, exiting'", ")", "log", ".", "info", "(", "'Downloa...
Either downloads and/or unzips the server if necessary return: the directory of the unzipped server
[ "Either", "downloads", "and", "/", "or", "unzips", "the", "server", "if", "necessary", "return", ":", "the", "directory", "of", "the", "unzipped", "server" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/upgrade.py#L134-L169
ome/omego
omego/upgrade.py
Install.handle_database
def handle_database(self): """ Handle database initialisation and upgrade, taking into account command line arguments """ # TODO: When initdb and upgradedb are dropped we can just test # managedb, but for backwards compatibility we need to support # initdb without...
python
def handle_database(self): """ Handle database initialisation and upgrade, taking into account command line arguments """ # TODO: When initdb and upgradedb are dropped we can just test # managedb, but for backwards compatibility we need to support # initdb without...
[ "def", "handle_database", "(", "self", ")", ":", "# TODO: When initdb and upgradedb are dropped we can just test", "# managedb, but for backwards compatibility we need to support", "# initdb without upgradedb and vice-versa", "if", "self", ".", "args", ".", "initdb", "or", "self", ...
Handle database initialisation and upgrade, taking into account command line arguments
[ "Handle", "database", "initialisation", "and", "upgrade", "taking", "into", "account", "command", "line", "arguments" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/upgrade.py#L263-L302
ome/omego
omego/upgrade.py
Install.run
def run(self, command): """ Runs a command as if from the command-line without the need for using popen or subprocess """ if isinstance(command, basestring): command = command.split() else: command = list(command) self.external.omero_cli(co...
python
def run(self, command): """ Runs a command as if from the command-line without the need for using popen or subprocess """ if isinstance(command, basestring): command = command.split() else: command = list(command) self.external.omero_cli(co...
[ "def", "run", "(", "self", ",", "command", ")", ":", "if", "isinstance", "(", "command", ",", "basestring", ")", ":", "command", "=", "command", ".", "split", "(", ")", "else", ":", "command", "=", "list", "(", "command", ")", "self", ".", "external"...
Runs a command as if from the command-line without the need for using popen or subprocess
[ "Runs", "a", "command", "as", "if", "from", "the", "command", "-", "line", "without", "the", "need", "for", "using", "popen", "or", "subprocess" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/upgrade.py#L314-L323
ome/omego
omego/upgrade.py
Install.bin
def bin(self, command): """ Runs the omero command-line client with an array of arguments using the old environment """ if isinstance(command, basestring): command = command.split() self.external.omero_bin(command)
python
def bin(self, command): """ Runs the omero command-line client with an array of arguments using the old environment """ if isinstance(command, basestring): command = command.split() self.external.omero_bin(command)
[ "def", "bin", "(", "self", ",", "command", ")", ":", "if", "isinstance", "(", "command", ",", "basestring", ")", ":", "command", "=", "command", ".", "split", "(", ")", "self", ".", "external", ".", "omero_bin", "(", "command", ")" ]
Runs the omero command-line client with an array of arguments using the old environment
[ "Runs", "the", "omero", "command", "-", "line", "client", "with", "an", "array", "of", "arguments", "using", "the", "old", "environment" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/upgrade.py#L325-L332
ome/omego
omego/upgrade.py
Install.symlink_check_and_set
def symlink_check_and_set(self): """ The default symlink was changed from OMERO-CURRENT to OMERO.server. If `--sym` was not specified and OMERO-CURRENT exists in the current directory stop and warn. """ if self.args.sym == '': if os.path.exists('OMERO-CURRENT'...
python
def symlink_check_and_set(self): """ The default symlink was changed from OMERO-CURRENT to OMERO.server. If `--sym` was not specified and OMERO-CURRENT exists in the current directory stop and warn. """ if self.args.sym == '': if os.path.exists('OMERO-CURRENT'...
[ "def", "symlink_check_and_set", "(", "self", ")", ":", "if", "self", ".", "args", ".", "sym", "==", "''", ":", "if", "os", ".", "path", ".", "exists", "(", "'OMERO-CURRENT'", ")", ":", "log", ".", "error", "(", "'Deprecated OMERO-CURRENT found but --sym not ...
The default symlink was changed from OMERO-CURRENT to OMERO.server. If `--sym` was not specified and OMERO-CURRENT exists in the current directory stop and warn.
[ "The", "default", "symlink", "was", "changed", "from", "OMERO", "-", "CURRENT", "to", "OMERO", ".", "server", ".", "If", "--", "sym", "was", "not", "specified", "and", "OMERO", "-", "CURRENT", "exists", "in", "the", "current", "directory", "stop", "and", ...
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/upgrade.py#L334-L348
svartalf/python-opus
opus/api/ctl.py
query
def query(request): """Query encoder/decoder with a request value""" def inner(func, obj): result_code = func(obj, request) if result_code is not constants.OK: raise OpusError(result_code) return result_code return inner
python
def query(request): """Query encoder/decoder with a request value""" def inner(func, obj): result_code = func(obj, request) if result_code is not constants.OK: raise OpusError(result_code) return result_code return inner
[ "def", "query", "(", "request", ")", ":", "def", "inner", "(", "func", ",", "obj", ")", ":", "result_code", "=", "func", "(", "obj", ",", "request", ")", "if", "result_code", "is", "not", "constants", ".", "OK", ":", "raise", "OpusError", "(", "resul...
Query encoder/decoder with a request value
[ "Query", "encoder", "/", "decoder", "with", "a", "request", "value" ]
train
https://github.com/svartalf/python-opus/blob/a3c1d556d2772b5be659ddd08c033ddd4d566b3a/opus/api/ctl.py#L19-L30
svartalf/python-opus
opus/api/ctl.py
get
def get(request, result_type): """Get CTL value from a encoder/decoder""" def inner(func, obj): result = result_type() result_code = func(obj, request, ctypes.byref(result)) if result_code is not constants.OK: raise OpusError(result_code) return result.value r...
python
def get(request, result_type): """Get CTL value from a encoder/decoder""" def inner(func, obj): result = result_type() result_code = func(obj, request, ctypes.byref(result)) if result_code is not constants.OK: raise OpusError(result_code) return result.value r...
[ "def", "get", "(", "request", ",", "result_type", ")", ":", "def", "inner", "(", "func", ",", "obj", ")", ":", "result", "=", "result_type", "(", ")", "result_code", "=", "func", "(", "obj", ",", "request", ",", "ctypes", ".", "byref", "(", "result",...
Get CTL value from a encoder/decoder
[ "Get", "CTL", "value", "from", "a", "encoder", "/", "decoder" ]
train
https://github.com/svartalf/python-opus/blob/a3c1d556d2772b5be659ddd08c033ddd4d566b3a/opus/api/ctl.py#L33-L45
svartalf/python-opus
opus/api/ctl.py
set
def set(request): """Set new CTL value to a encoder/decoder""" def inner(func, obj, value): result_code = func(obj, request, value) if result_code is not constants.OK: raise OpusError(result_code) return inner
python
def set(request): """Set new CTL value to a encoder/decoder""" def inner(func, obj, value): result_code = func(obj, request, value) if result_code is not constants.OK: raise OpusError(result_code) return inner
[ "def", "set", "(", "request", ")", ":", "def", "inner", "(", "func", ",", "obj", ",", "value", ")", ":", "result_code", "=", "func", "(", "obj", ",", "request", ",", "value", ")", "if", "result_code", "is", "not", "constants", ".", "OK", ":", "rais...
Set new CTL value to a encoder/decoder
[ "Set", "new", "CTL", "value", "to", "a", "encoder", "/", "decoder" ]
train
https://github.com/svartalf/python-opus/blob/a3c1d556d2772b5be659ddd08c033ddd4d566b3a/opus/api/ctl.py#L48-L56
ome/omego
omego/db.py
sort_schemas
def sort_schemas(schemas): """Sort a list of SQL schemas in order""" def keyfun(v): x = SQL_SCHEMA_REGEXP.match(v).groups() # x3: 'DEV' should come before '' return (int(x[0]), x[1], int(x[2]) if x[2] else None, x[3] if x[3] else 'zzz', int(x[4])) return sorted(schem...
python
def sort_schemas(schemas): """Sort a list of SQL schemas in order""" def keyfun(v): x = SQL_SCHEMA_REGEXP.match(v).groups() # x3: 'DEV' should come before '' return (int(x[0]), x[1], int(x[2]) if x[2] else None, x[3] if x[3] else 'zzz', int(x[4])) return sorted(schem...
[ "def", "sort_schemas", "(", "schemas", ")", ":", "def", "keyfun", "(", "v", ")", ":", "x", "=", "SQL_SCHEMA_REGEXP", ".", "match", "(", "v", ")", ".", "groups", "(", ")", "# x3: 'DEV' should come before ''", "return", "(", "int", "(", "x", "[", "0", "]...
Sort a list of SQL schemas in order
[ "Sort", "a", "list", "of", "SQL", "schemas", "in", "order" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/db.py#L31-L39
ome/omego
omego/db.py
parse_schema_files
def parse_schema_files(files): """ Parse a list of SQL files and return a dictionary of valid schema files where each key is a valid schema file and the corresponding value is a tuple containing the source and the target schema. """ f_dict = {} for f in files: root, ext = os.path.spl...
python
def parse_schema_files(files): """ Parse a list of SQL files and return a dictionary of valid schema files where each key is a valid schema file and the corresponding value is a tuple containing the source and the target schema. """ f_dict = {} for f in files: root, ext = os.path.spl...
[ "def", "parse_schema_files", "(", "files", ")", ":", "f_dict", "=", "{", "}", "for", "f", "in", "files", ":", "root", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "f", ")", "if", "ext", "!=", "\".sql\"", ":", "continue", "vto", ",", ...
Parse a list of SQL files and return a dictionary of valid schema files where each key is a valid schema file and the corresponding value is a tuple containing the source and the target schema.
[ "Parse", "a", "list", "of", "SQL", "files", "and", "return", "a", "dictionary", "of", "valid", "schema", "files", "where", "each", "key", "is", "a", "valid", "schema", "file", "and", "the", "corresponding", "value", "is", "a", "tuple", "containing", "the",...
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/db.py#L42-L57
ome/omego
omego/db.py
DbAdmin.dump
def dump(self): """ Dump the database using the postgres custom format """ dumpfile = self.args.dumpfile if not dumpfile: db, env = self.get_db_args_env() dumpfile = fileutils.timestamp_filename( 'omero-database-%s' % db['name'], 'pgdump') ...
python
def dump(self): """ Dump the database using the postgres custom format """ dumpfile = self.args.dumpfile if not dumpfile: db, env = self.get_db_args_env() dumpfile = fileutils.timestamp_filename( 'omero-database-%s' % db['name'], 'pgdump') ...
[ "def", "dump", "(", "self", ")", ":", "dumpfile", "=", "self", ".", "args", ".", "dumpfile", "if", "not", "dumpfile", ":", "db", ",", "env", "=", "self", ".", "get_db_args_env", "(", ")", "dumpfile", "=", "fileutils", ".", "timestamp_filename", "(", "'...
Dump the database using the postgres custom format
[ "Dump", "the", "database", "using", "the", "postgres", "custom", "format" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/db.py#L206-L218
ome/omego
omego/db.py
DbAdmin.get_db_args_env
def get_db_args_env(self): """ Get a dictionary of database connection parameters, and create an environment for running postgres commands. Falls back to omego defaults. """ db = { 'name': self.args.dbname, 'host': self.args.dbhost, 'us...
python
def get_db_args_env(self): """ Get a dictionary of database connection parameters, and create an environment for running postgres commands. Falls back to omego defaults. """ db = { 'name': self.args.dbname, 'host': self.args.dbhost, 'us...
[ "def", "get_db_args_env", "(", "self", ")", ":", "db", "=", "{", "'name'", ":", "self", ".", "args", ".", "dbname", ",", "'host'", ":", "self", ".", "args", ".", "dbhost", ",", "'user'", ":", "self", ".", "args", ".", "dbuser", ",", "'pass'", ":", ...
Get a dictionary of database connection parameters, and create an environment for running postgres commands. Falls back to omego defaults.
[ "Get", "a", "dictionary", "of", "database", "connection", "parameters", "and", "create", "an", "environment", "for", "running", "postgres", "commands", ".", "Falls", "back", "to", "omego", "defaults", "." ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/db.py#L220-L253
ome/omego
omego/db.py
DbAdmin.psql
def psql(self, *psqlargs): """ Run a psql command """ db, env = self.get_db_args_env() args = [ '-v', 'ON_ERROR_STOP=on', '-d', db['name'], '-h', db['host'], '-U', db['user'], '-w', '-A', '-t' ] + list(psqla...
python
def psql(self, *psqlargs): """ Run a psql command """ db, env = self.get_db_args_env() args = [ '-v', 'ON_ERROR_STOP=on', '-d', db['name'], '-h', db['host'], '-U', db['user'], '-w', '-A', '-t' ] + list(psqla...
[ "def", "psql", "(", "self", ",", "*", "psqlargs", ")", ":", "db", ",", "env", "=", "self", ".", "get_db_args_env", "(", ")", "args", "=", "[", "'-v'", ",", "'ON_ERROR_STOP=on'", ",", "'-d'", ",", "db", "[", "'name'", "]", ",", "'-h'", ",", "db", ...
Run a psql command
[ "Run", "a", "psql", "command" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/db.py#L255-L272
ome/omego
omego/db.py
DbAdmin.pgdump
def pgdump(self, *pgdumpargs): """ Run a pg_dump command """ db, env = self.get_db_args_env() args = ['-d', db['name'], '-h', db['host'], '-U', db['user'], '-w' ] + list(pgdumpargs) stdout, stderr = External.run( 'pg_dump', args, capturestd=Tr...
python
def pgdump(self, *pgdumpargs): """ Run a pg_dump command """ db, env = self.get_db_args_env() args = ['-d', db['name'], '-h', db['host'], '-U', db['user'], '-w' ] + list(pgdumpargs) stdout, stderr = External.run( 'pg_dump', args, capturestd=Tr...
[ "def", "pgdump", "(", "self", ",", "*", "pgdumpargs", ")", ":", "db", ",", "env", "=", "self", ".", "get_db_args_env", "(", ")", "args", "=", "[", "'-d'", ",", "db", "[", "'name'", "]", ",", "'-h'", ",", "db", "[", "'host'", "]", ",", "'-U'", "...
Run a pg_dump command
[ "Run", "a", "pg_dump", "command" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/db.py#L274-L287
ome/omego
omego/external.py
External.set_server_dir
def set_server_dir(self, dir): """ Set the directory of the server to be controlled """ self.dir = os.path.abspath(dir) config = os.path.join(self.dir, 'etc', 'grid', 'config.xml') self.configured = os.path.exists(config)
python
def set_server_dir(self, dir): """ Set the directory of the server to be controlled """ self.dir = os.path.abspath(dir) config = os.path.join(self.dir, 'etc', 'grid', 'config.xml') self.configured = os.path.exists(config)
[ "def", "set_server_dir", "(", "self", ",", "dir", ")", ":", "self", ".", "dir", "=", "os", ".", "path", ".", "abspath", "(", "dir", ")", "config", "=", "os", ".", "path", ".", "join", "(", "self", ".", "dir", ",", "'etc'", ",", "'grid'", ",", "...
Set the directory of the server to be controlled
[ "Set", "the", "directory", "of", "the", "server", "to", "be", "controlled" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/external.py#L55-L61
ome/omego
omego/external.py
External.get_config
def get_config(self, force=False): """ Returns a dictionary of all config.xml properties If `force = True` then ignore any cached state and read config.xml if possible setup_omero_cli() must be called before this method to import the correct omero module to minimise the...
python
def get_config(self, force=False): """ Returns a dictionary of all config.xml properties If `force = True` then ignore any cached state and read config.xml if possible setup_omero_cli() must be called before this method to import the correct omero module to minimise the...
[ "def", "get_config", "(", "self", ",", "force", "=", "False", ")", ":", "if", "not", "force", "and", "not", "self", ".", "has_config", "(", ")", ":", "raise", "Exception", "(", "'No config file'", ")", "configxml", "=", "os", ".", "path", ".", "join", ...
Returns a dictionary of all config.xml properties If `force = True` then ignore any cached state and read config.xml if possible setup_omero_cli() must be called before this method to import the correct omero module to minimise the possibility of version conflicts
[ "Returns", "a", "dictionary", "of", "all", "config", ".", "xml", "properties" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/external.py#L74-L102
ome/omego
omego/external.py
External.setup_omero_cli
def setup_omero_cli(self): """ Imports the omero CLI module so that commands can be run directly. Note Python does not allow a module to be imported multiple times, so this will only work with a single omero instance. This can have several surprising effects, so setup_omero_cli(...
python
def setup_omero_cli(self): """ Imports the omero CLI module so that commands can be run directly. Note Python does not allow a module to be imported multiple times, so this will only work with a single omero instance. This can have several surprising effects, so setup_omero_cli(...
[ "def", "setup_omero_cli", "(", "self", ")", ":", "if", "not", "self", ".", "dir", ":", "raise", "Exception", "(", "'No server directory set'", ")", "if", "'omero.cli'", "in", "sys", ".", "modules", ":", "raise", "Exception", "(", "'omero.cli can only be imported...
Imports the omero CLI module so that commands can be run directly. Note Python does not allow a module to be imported multiple times, so this will only work with a single omero instance. This can have several surprising effects, so setup_omero_cli() must be explcitly called.
[ "Imports", "the", "omero", "CLI", "module", "so", "that", "commands", "can", "be", "run", "directly", ".", "Note", "Python", "does", "not", "allow", "a", "module", "to", "be", "imported", "multiple", "times", "so", "this", "will", "only", "work", "with", ...
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/external.py#L104-L132
ome/omego
omego/external.py
External.setup_previous_omero_env
def setup_previous_omero_env(self, olddir, savevarsfile): """ Create a copy of the current environment for interacting with the current OMERO server installation """ env = self.get_environment(savevarsfile) def addpath(varname, p): if not os.path.exists(p): ...
python
def setup_previous_omero_env(self, olddir, savevarsfile): """ Create a copy of the current environment for interacting with the current OMERO server installation """ env = self.get_environment(savevarsfile) def addpath(varname, p): if not os.path.exists(p): ...
[ "def", "setup_previous_omero_env", "(", "self", ",", "olddir", ",", "savevarsfile", ")", ":", "env", "=", "self", ".", "get_environment", "(", "savevarsfile", ")", "def", "addpath", "(", "varname", ",", "p", ")", ":", "if", "not", "os", ".", "path", ".",...
Create a copy of the current environment for interacting with the current OMERO server installation
[ "Create", "a", "copy", "of", "the", "current", "environment", "for", "interacting", "with", "the", "current", "OMERO", "server", "installation" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/external.py#L134-L155
ome/omego
omego/external.py
External.omero_cli
def omero_cli(self, command): """ Runs a command as if from the OMERO command-line without the need for using popen or subprocess. """ assert isinstance(command, list) if not self.cli: raise Exception('omero.cli not initialised') log.info("Invoking CLI...
python
def omero_cli(self, command): """ Runs a command as if from the OMERO command-line without the need for using popen or subprocess. """ assert isinstance(command, list) if not self.cli: raise Exception('omero.cli not initialised') log.info("Invoking CLI...
[ "def", "omero_cli", "(", "self", ",", "command", ")", ":", "assert", "isinstance", "(", "command", ",", "list", ")", "if", "not", "self", ".", "cli", ":", "raise", "Exception", "(", "'omero.cli not initialised'", ")", "log", ".", "info", "(", "\"Invoking C...
Runs a command as if from the OMERO command-line without the need for using popen or subprocess.
[ "Runs", "a", "command", "as", "if", "from", "the", "OMERO", "command", "-", "line", "without", "the", "need", "for", "using", "popen", "or", "subprocess", "." ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/external.py#L157-L166
ome/omego
omego/external.py
External.omero_bin
def omero_bin(self, command): """ Runs the omero command-line client with an array of arguments using the old environment """ assert isinstance(command, list) if not self.old_env: raise Exception('Old environment not initialised') log.info("Running [ol...
python
def omero_bin(self, command): """ Runs the omero command-line client with an array of arguments using the old environment """ assert isinstance(command, list) if not self.old_env: raise Exception('Old environment not initialised') log.info("Running [ol...
[ "def", "omero_bin", "(", "self", ",", "command", ")", ":", "assert", "isinstance", "(", "command", ",", "list", ")", "if", "not", "self", ".", "old_env", ":", "raise", "Exception", "(", "'Old environment not initialised'", ")", "log", ".", "info", "(", "\"...
Runs the omero command-line client with an array of arguments using the old environment
[ "Runs", "the", "omero", "command", "-", "line", "client", "with", "an", "array", "of", "arguments", "using", "the", "old", "environment" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/external.py#L168-L177
ome/omego
omego/external.py
External.run
def run(exe, args, capturestd=False, env=None): """ Runs an executable with an array of arguments, optionally in the specified environment. Returns stdout and stderr """ command = [exe] + args if env: log.info("Executing [custom environment]: %s", " "....
python
def run(exe, args, capturestd=False, env=None): """ Runs an executable with an array of arguments, optionally in the specified environment. Returns stdout and stderr """ command = [exe] + args if env: log.info("Executing [custom environment]: %s", " "....
[ "def", "run", "(", "exe", ",", "args", ",", "capturestd", "=", "False", ",", "env", "=", "None", ")", ":", "command", "=", "[", "exe", "]", "+", "args", "if", "env", ":", "log", ".", "info", "(", "\"Executing [custom environment]: %s\"", ",", "\" \"", ...
Runs an executable with an array of arguments, optionally in the specified environment. Returns stdout and stderr
[ "Runs", "an", "executable", "with", "an", "array", "of", "arguments", "optionally", "in", "the", "specified", "environment", ".", "Returns", "stdout", "and", "stderr" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/external.py#L180-L225
buruzaemon/natto-py
natto/support.py
string_support
def string_support(py3enc): '''Create byte-to-string and string-to-byte conversion functions for internal use. :param py3enc: Encoding used by Python 3 environment. :type py3enc: str ''' if sys.version < '3': def bytes2str(b): '''Identity, returns the argument string (bytes)...
python
def string_support(py3enc): '''Create byte-to-string and string-to-byte conversion functions for internal use. :param py3enc: Encoding used by Python 3 environment. :type py3enc: str ''' if sys.version < '3': def bytes2str(b): '''Identity, returns the argument string (bytes)...
[ "def", "string_support", "(", "py3enc", ")", ":", "if", "sys", ".", "version", "<", "'3'", ":", "def", "bytes2str", "(", "b", ")", ":", "'''Identity, returns the argument string (bytes).'''", "return", "b", "def", "str2bytes", "(", "s", ")", ":", "'''Identity,...
Create byte-to-string and string-to-byte conversion functions for internal use. :param py3enc: Encoding used by Python 3 environment. :type py3enc: str
[ "Create", "byte", "-", "to", "-", "string", "and", "string", "-", "to", "-", "byte", "conversion", "functions", "for", "internal", "use", "." ]
train
https://github.com/buruzaemon/natto-py/blob/018fe004c47c45c66bdf2e03fe24e981ae089b76/natto/support.py#L9-L30
buruzaemon/natto-py
natto/support.py
splitter_support
def splitter_support(py2enc): '''Create tokenizer for use in boundary constraint parsing. :param py2enc: Encoding used by Python 2 environment. :type py2enc: str ''' if sys.version < '3': def _fn_sentence(pattern, sentence): if REGEXTYPE == type(pattern): if patt...
python
def splitter_support(py2enc): '''Create tokenizer for use in boundary constraint parsing. :param py2enc: Encoding used by Python 2 environment. :type py2enc: str ''' if sys.version < '3': def _fn_sentence(pattern, sentence): if REGEXTYPE == type(pattern): if patt...
[ "def", "splitter_support", "(", "py2enc", ")", ":", "if", "sys", ".", "version", "<", "'3'", ":", "def", "_fn_sentence", "(", "pattern", ",", "sentence", ")", ":", "if", "REGEXTYPE", "==", "type", "(", "pattern", ")", ":", "if", "pattern", ".", "flags"...
Create tokenizer for use in boundary constraint parsing. :param py2enc: Encoding used by Python 2 environment. :type py2enc: str
[ "Create", "tokenizer", "for", "use", "in", "boundary", "constraint", "parsing", "." ]
train
https://github.com/buruzaemon/natto-py/blob/018fe004c47c45c66bdf2e03fe24e981ae089b76/natto/support.py#L32-L96
yougov/elastic-doc-manager
mongo_connector/doc_managers/elastic_doc_manager.py
DocManager.update
def update(self, document_id, update_spec, namespace, timestamp): """Apply updates given in update_spec to the document whose id matches that of doc. """ index, doc_type = self._index_and_mapping(namespace) with self.lock: # Check if document source is stored in loca...
python
def update(self, document_id, update_spec, namespace, timestamp): """Apply updates given in update_spec to the document whose id matches that of doc. """ index, doc_type = self._index_and_mapping(namespace) with self.lock: # Check if document source is stored in loca...
[ "def", "update", "(", "self", ",", "document_id", ",", "update_spec", ",", "namespace", ",", "timestamp", ")", ":", "index", ",", "doc_type", "=", "self", ".", "_index_and_mapping", "(", "namespace", ")", "with", "self", ".", "lock", ":", "# Check if documen...
Apply updates given in update_spec to the document whose id matches that of doc.
[ "Apply", "updates", "given", "in", "update_spec", "to", "the", "document", "whose", "id", "matches", "that", "of", "doc", "." ]
train
https://github.com/yougov/elastic-doc-manager/blob/17c35f4dd3d081b171c45ba0eb9616da9dc89e82/mongo_connector/doc_managers/elastic_doc_manager.py#L243-L268
yougov/elastic-doc-manager
mongo_connector/doc_managers/elastic_doc_manager.py
DocManager.upsert
def upsert(self, doc, namespace, timestamp, update_spec=None): """Insert a document into Elasticsearch.""" index, doc_type = self._index_and_mapping(namespace) # No need to duplicate '_id' in source document doc_id = u(doc.pop("_id")) metadata = { 'ns': namespace, ...
python
def upsert(self, doc, namespace, timestamp, update_spec=None): """Insert a document into Elasticsearch.""" index, doc_type = self._index_and_mapping(namespace) # No need to duplicate '_id' in source document doc_id = u(doc.pop("_id")) metadata = { 'ns': namespace, ...
[ "def", "upsert", "(", "self", ",", "doc", ",", "namespace", ",", "timestamp", ",", "update_spec", "=", "None", ")", ":", "index", ",", "doc_type", "=", "self", ".", "_index_and_mapping", "(", "namespace", ")", "# No need to duplicate '_id' in source document", "...
Insert a document into Elasticsearch.
[ "Insert", "a", "document", "into", "Elasticsearch", "." ]
train
https://github.com/yougov/elastic-doc-manager/blob/17c35f4dd3d081b171c45ba0eb9616da9dc89e82/mongo_connector/doc_managers/elastic_doc_manager.py#L271-L301
yougov/elastic-doc-manager
mongo_connector/doc_managers/elastic_doc_manager.py
DocManager.bulk_upsert
def bulk_upsert(self, docs, namespace, timestamp): """Insert multiple documents into Elasticsearch.""" def docs_to_upsert(): doc = None for doc in docs: # Remove metadata and redundant _id index, doc_type = self._index_and_mapping(namespace) ...
python
def bulk_upsert(self, docs, namespace, timestamp): """Insert multiple documents into Elasticsearch.""" def docs_to_upsert(): doc = None for doc in docs: # Remove metadata and redundant _id index, doc_type = self._index_and_mapping(namespace) ...
[ "def", "bulk_upsert", "(", "self", ",", "docs", ",", "namespace", ",", "timestamp", ")", ":", "def", "docs_to_upsert", "(", ")", ":", "doc", "=", "None", "for", "doc", "in", "docs", ":", "# Remove metadata and redundant _id", "index", ",", "doc_type", "=", ...
Insert multiple documents into Elasticsearch.
[ "Insert", "multiple", "documents", "into", "Elasticsearch", "." ]
train
https://github.com/yougov/elastic-doc-manager/blob/17c35f4dd3d081b171c45ba0eb9616da9dc89e82/mongo_connector/doc_managers/elastic_doc_manager.py#L304-L352
yougov/elastic-doc-manager
mongo_connector/doc_managers/elastic_doc_manager.py
DocManager.remove
def remove(self, document_id, namespace, timestamp): """Remove a document from Elasticsearch.""" index, doc_type = self._index_and_mapping(namespace) action = { '_op_type': 'delete', '_index': index, '_type': doc_type, '_id': u(document_id) ...
python
def remove(self, document_id, namespace, timestamp): """Remove a document from Elasticsearch.""" index, doc_type = self._index_and_mapping(namespace) action = { '_op_type': 'delete', '_index': index, '_type': doc_type, '_id': u(document_id) ...
[ "def", "remove", "(", "self", ",", "document_id", ",", "namespace", ",", "timestamp", ")", ":", "index", ",", "doc_type", "=", "self", ".", "_index_and_mapping", "(", "namespace", ")", "action", "=", "{", "'_op_type'", ":", "'delete'", ",", "'_index'", ":"...
Remove a document from Elasticsearch.
[ "Remove", "a", "document", "from", "Elasticsearch", "." ]
train
https://github.com/yougov/elastic-doc-manager/blob/17c35f4dd3d081b171c45ba0eb9616da9dc89e82/mongo_connector/doc_managers/elastic_doc_manager.py#L398-L416
yougov/elastic-doc-manager
mongo_connector/doc_managers/elastic_doc_manager.py
DocManager.send_buffered_operations
def send_buffered_operations(self): """Send buffered operations to Elasticsearch. This method is periodically called by the AutoCommitThread. """ with self.lock: try: action_buffer = self.BulkBuffer.get_buffer() if action_buffer: ...
python
def send_buffered_operations(self): """Send buffered operations to Elasticsearch. This method is periodically called by the AutoCommitThread. """ with self.lock: try: action_buffer = self.BulkBuffer.get_buffer() if action_buffer: ...
[ "def", "send_buffered_operations", "(", "self", ")", ":", "with", "self", ".", "lock", ":", "try", ":", "action_buffer", "=", "self", ".", "BulkBuffer", ".", "get_buffer", "(", ")", "if", "action_buffer", ":", "successes", ",", "errors", "=", "bulk", "(", ...
Send buffered operations to Elasticsearch. This method is periodically called by the AutoCommitThread.
[ "Send", "buffered", "operations", "to", "Elasticsearch", "." ]
train
https://github.com/yougov/elastic-doc-manager/blob/17c35f4dd3d081b171c45ba0eb9616da9dc89e82/mongo_connector/doc_managers/elastic_doc_manager.py#L454-L470
yougov/elastic-doc-manager
mongo_connector/doc_managers/elastic_doc_manager.py
DocManager.get_last_doc
def get_last_doc(self): """Get the most recently modified document from Elasticsearch. This method is used to help define a time window within which documents may be in conflict after a MongoDB rollback. """ try: result = self.elastic.search( index=se...
python
def get_last_doc(self): """Get the most recently modified document from Elasticsearch. This method is used to help define a time window within which documents may be in conflict after a MongoDB rollback. """ try: result = self.elastic.search( index=se...
[ "def", "get_last_doc", "(", "self", ")", ":", "try", ":", "result", "=", "self", ".", "elastic", ".", "search", "(", "index", "=", "self", ".", "meta_index_name", ",", "body", "=", "{", "\"query\"", ":", "{", "\"match_all\"", ":", "{", "}", "}", ",",...
Get the most recently modified document from Elasticsearch. This method is used to help define a time window within which documents may be in conflict after a MongoDB rollback.
[ "Get", "the", "most", "recently", "modified", "document", "from", "Elasticsearch", "." ]
train
https://github.com/yougov/elastic-doc-manager/blob/17c35f4dd3d081b171c45ba0eb9616da9dc89e82/mongo_connector/doc_managers/elastic_doc_manager.py#L478-L498
djungelorm/sphinx-csharp
sphinx_csharp/csharp.py
split_sig
def split_sig(params): """ Split a list of parameters/types by commas, whilst respecting brackets. For example: String arg0, int arg2 = 1, List<int> arg3 = [1, 2, 3] => ['String arg0', 'int arg2 = 1', 'List<int> arg3 = [1, 2, 3]'] """ result = [] current = '' level = 0 f...
python
def split_sig(params): """ Split a list of parameters/types by commas, whilst respecting brackets. For example: String arg0, int arg2 = 1, List<int> arg3 = [1, 2, 3] => ['String arg0', 'int arg2 = 1', 'List<int> arg3 = [1, 2, 3]'] """ result = [] current = '' level = 0 f...
[ "def", "split_sig", "(", "params", ")", ":", "result", "=", "[", "]", "current", "=", "''", "level", "=", "0", "for", "char", "in", "params", ":", "if", "char", "in", "(", "'<'", ",", "'{'", ",", "'['", ")", ":", "level", "+=", "1", "elif", "ch...
Split a list of parameters/types by commas, whilst respecting brackets. For example: String arg0, int arg2 = 1, List<int> arg3 = [1, 2, 3] => ['String arg0', 'int arg2 = 1', 'List<int> arg3 = [1, 2, 3]']
[ "Split", "a", "list", "of", "parameters", "/", "types", "by", "commas", "whilst", "respecting", "brackets", "." ]
train
https://github.com/djungelorm/sphinx-csharp/blob/aaa0c5fbe514d7f0b1a89625185fc608e5d30702/sphinx_csharp/csharp.py#L39-L63
djungelorm/sphinx-csharp
sphinx_csharp/csharp.py
parse_method_signature
def parse_method_signature(sig): """ Parse a method signature of the form: modifier* type name (params) """ match = METH_SIG_RE.match(sig.strip()) if not match: raise RuntimeError('Method signature invalid: ' + sig) modifiers, return_type, name, generic_types, params = match.groups() if para...
python
def parse_method_signature(sig): """ Parse a method signature of the form: modifier* type name (params) """ match = METH_SIG_RE.match(sig.strip()) if not match: raise RuntimeError('Method signature invalid: ' + sig) modifiers, return_type, name, generic_types, params = match.groups() if para...
[ "def", "parse_method_signature", "(", "sig", ")", ":", "match", "=", "METH_SIG_RE", ".", "match", "(", "sig", ".", "strip", "(", ")", ")", "if", "not", "match", ":", "raise", "RuntimeError", "(", "'Method signature invalid: '", "+", "sig", ")", "modifiers", ...
Parse a method signature of the form: modifier* type name (params)
[ "Parse", "a", "method", "signature", "of", "the", "form", ":", "modifier", "*", "type", "name", "(", "params", ")" ]
train
https://github.com/djungelorm/sphinx-csharp/blob/aaa0c5fbe514d7f0b1a89625185fc608e5d30702/sphinx_csharp/csharp.py#L66-L77
djungelorm/sphinx-csharp
sphinx_csharp/csharp.py
parse_property_signature
def parse_property_signature(sig): """ Parse a property signature of the form: modifier* type name { (get;)? (set;)? } """ match = PROP_SIG_RE.match(sig.strip()) if not match: raise RuntimeError('Property signature invalid: ' + sig) groups = match.groups() if groups[0] is not None: ...
python
def parse_property_signature(sig): """ Parse a property signature of the form: modifier* type name { (get;)? (set;)? } """ match = PROP_SIG_RE.match(sig.strip()) if not match: raise RuntimeError('Property signature invalid: ' + sig) groups = match.groups() if groups[0] is not None: ...
[ "def", "parse_property_signature", "(", "sig", ")", ":", "match", "=", "PROP_SIG_RE", ".", "match", "(", "sig", ".", "strip", "(", ")", ")", "if", "not", "match", ":", "raise", "RuntimeError", "(", "'Property signature invalid: '", "+", "sig", ")", "groups",...
Parse a property signature of the form: modifier* type name { (get;)? (set;)? }
[ "Parse", "a", "property", "signature", "of", "the", "form", ":", "modifier", "*", "type", "name", "{", "(", "get", ";", ")", "?", "(", "set", ";", ")", "?", "}" ]
train
https://github.com/djungelorm/sphinx-csharp/blob/aaa0c5fbe514d7f0b1a89625185fc608e5d30702/sphinx_csharp/csharp.py#L80-L94
djungelorm/sphinx-csharp
sphinx_csharp/csharp.py
parse_indexer_signature
def parse_indexer_signature(sig): """ Parse a indexer signature of the form: modifier* type this[params] { (get;)? (set;)? } """ match = IDXR_SIG_RE.match(sig.strip()) if not match: raise RuntimeError('Indexer signature invalid: ' + sig) modifiers, return_type, params, getter, setter = m...
python
def parse_indexer_signature(sig): """ Parse a indexer signature of the form: modifier* type this[params] { (get;)? (set;)? } """ match = IDXR_SIG_RE.match(sig.strip()) if not match: raise RuntimeError('Indexer signature invalid: ' + sig) modifiers, return_type, params, getter, setter = m...
[ "def", "parse_indexer_signature", "(", "sig", ")", ":", "match", "=", "IDXR_SIG_RE", ".", "match", "(", "sig", ".", "strip", "(", ")", ")", "if", "not", "match", ":", "raise", "RuntimeError", "(", "'Indexer signature invalid: '", "+", "sig", ")", "modifiers"...
Parse a indexer signature of the form: modifier* type this[params] { (get;)? (set;)? }
[ "Parse", "a", "indexer", "signature", "of", "the", "form", ":", "modifier", "*", "type", "this", "[", "params", "]", "{", "(", "get", ";", ")", "?", "(", "set", ";", ")", "?", "}" ]
train
https://github.com/djungelorm/sphinx-csharp/blob/aaa0c5fbe514d7f0b1a89625185fc608e5d30702/sphinx_csharp/csharp.py#L97-L107
djungelorm/sphinx-csharp
sphinx_csharp/csharp.py
parse_param_signature
def parse_param_signature(sig): """ Parse a parameter signature of the form: type name (= default)? """ match = PARAM_SIG_RE.match(sig.strip()) if not match: raise RuntimeError('Parameter signature invalid, got ' + sig) groups = match.groups() modifiers = groups[0].split() typ, name, _, ...
python
def parse_param_signature(sig): """ Parse a parameter signature of the form: type name (= default)? """ match = PARAM_SIG_RE.match(sig.strip()) if not match: raise RuntimeError('Parameter signature invalid, got ' + sig) groups = match.groups() modifiers = groups[0].split() typ, name, _, ...
[ "def", "parse_param_signature", "(", "sig", ")", ":", "match", "=", "PARAM_SIG_RE", ".", "match", "(", "sig", ".", "strip", "(", ")", ")", "if", "not", "match", ":", "raise", "RuntimeError", "(", "'Parameter signature invalid, got '", "+", "sig", ")", "group...
Parse a parameter signature of the form: type name (= default)?
[ "Parse", "a", "parameter", "signature", "of", "the", "form", ":", "type", "name", "(", "=", "default", ")", "?" ]
train
https://github.com/djungelorm/sphinx-csharp/blob/aaa0c5fbe514d7f0b1a89625185fc608e5d30702/sphinx_csharp/csharp.py#L110-L119
djungelorm/sphinx-csharp
sphinx_csharp/csharp.py
parse_type_signature
def parse_type_signature(sig): """ Parse a type signature """ match = TYPE_SIG_RE.match(sig.strip()) if not match: raise RuntimeError('Type signature invalid, got ' + sig) groups = match.groups() typ = groups[0] generic_types = groups[1] if not generic_types: generic_types = ...
python
def parse_type_signature(sig): """ Parse a type signature """ match = TYPE_SIG_RE.match(sig.strip()) if not match: raise RuntimeError('Type signature invalid, got ' + sig) groups = match.groups() typ = groups[0] generic_types = groups[1] if not generic_types: generic_types = ...
[ "def", "parse_type_signature", "(", "sig", ")", ":", "match", "=", "TYPE_SIG_RE", ".", "match", "(", "sig", ".", "strip", "(", ")", ")", "if", "not", "match", ":", "raise", "RuntimeError", "(", "'Type signature invalid, got '", "+", "sig", ")", "groups", "...
Parse a type signature
[ "Parse", "a", "type", "signature" ]
train
https://github.com/djungelorm/sphinx-csharp/blob/aaa0c5fbe514d7f0b1a89625185fc608e5d30702/sphinx_csharp/csharp.py#L122-L135
djungelorm/sphinx-csharp
sphinx_csharp/csharp.py
parse_attr_signature
def parse_attr_signature(sig): """ Parse an attribute signature """ match = ATTR_SIG_RE.match(sig.strip()) if not match: raise RuntimeError('Attribute signature invalid, got ' + sig) name, _, params = match.groups() if params is not None and params.strip() != '': params = split_sig(p...
python
def parse_attr_signature(sig): """ Parse an attribute signature """ match = ATTR_SIG_RE.match(sig.strip()) if not match: raise RuntimeError('Attribute signature invalid, got ' + sig) name, _, params = match.groups() if params is not None and params.strip() != '': params = split_sig(p...
[ "def", "parse_attr_signature", "(", "sig", ")", ":", "match", "=", "ATTR_SIG_RE", ".", "match", "(", "sig", ".", "strip", "(", ")", ")", "if", "not", "match", ":", "raise", "RuntimeError", "(", "'Attribute signature invalid, got '", "+", "sig", ")", "name", ...
Parse an attribute signature
[ "Parse", "an", "attribute", "signature" ]
train
https://github.com/djungelorm/sphinx-csharp/blob/aaa0c5fbe514d7f0b1a89625185fc608e5d30702/sphinx_csharp/csharp.py#L138-L149
djungelorm/sphinx-csharp
sphinx_csharp/csharp.py
get_msdn_ref
def get_msdn_ref(name): """ Try and create a reference to a type on MSDN """ in_msdn = False if name in MSDN_VALUE_TYPES: name = MSDN_VALUE_TYPES[name] in_msdn = True if name.startswith('System.'): in_msdn = True if in_msdn: link = name.split('<')[0] if link i...
python
def get_msdn_ref(name): """ Try and create a reference to a type on MSDN """ in_msdn = False if name in MSDN_VALUE_TYPES: name = MSDN_VALUE_TYPES[name] in_msdn = True if name.startswith('System.'): in_msdn = True if in_msdn: link = name.split('<')[0] if link i...
[ "def", "get_msdn_ref", "(", "name", ")", ":", "in_msdn", "=", "False", "if", "name", "in", "MSDN_VALUE_TYPES", ":", "name", "=", "MSDN_VALUE_TYPES", "[", "name", "]", "in_msdn", "=", "True", "if", "name", ".", "startswith", "(", "'System.'", ")", ":", "i...
Try and create a reference to a type on MSDN
[ "Try", "and", "create", "a", "reference", "to", "a", "type", "on", "MSDN" ]
train
https://github.com/djungelorm/sphinx-csharp/blob/aaa0c5fbe514d7f0b1a89625185fc608e5d30702/sphinx_csharp/csharp.py#L172-L192
djungelorm/sphinx-csharp
sphinx_csharp/csharp.py
shorten_type
def shorten_type(typ): """ Shorten a type. E.g. drops 'System.' """ offset = 0 for prefix in SHORTEN_TYPE_PREFIXES: if typ.startswith(prefix): if len(prefix) > offset: offset = len(prefix) return typ[offset:]
python
def shorten_type(typ): """ Shorten a type. E.g. drops 'System.' """ offset = 0 for prefix in SHORTEN_TYPE_PREFIXES: if typ.startswith(prefix): if len(prefix) > offset: offset = len(prefix) return typ[offset:]
[ "def", "shorten_type", "(", "typ", ")", ":", "offset", "=", "0", "for", "prefix", "in", "SHORTEN_TYPE_PREFIXES", ":", "if", "typ", ".", "startswith", "(", "prefix", ")", ":", "if", "len", "(", "prefix", ")", ">", "offset", ":", "offset", "=", "len", ...
Shorten a type. E.g. drops 'System.'
[ "Shorten", "a", "type", ".", "E", ".", "g", ".", "drops", "System", "." ]
train
https://github.com/djungelorm/sphinx-csharp/blob/aaa0c5fbe514d7f0b1a89625185fc608e5d30702/sphinx_csharp/csharp.py#L201-L208
buruzaemon/natto-py
natto/option_parse.py
OptionParse.parse_mecab_options
def parse_mecab_options(self, options): '''Parses the MeCab options, returning them in a dictionary. Lattice-level option has been deprecated; please use marginal or nbest instead. :options string or dictionary of options to use when instantiating the MeCab insta...
python
def parse_mecab_options(self, options): '''Parses the MeCab options, returning them in a dictionary. Lattice-level option has been deprecated; please use marginal or nbest instead. :options string or dictionary of options to use when instantiating the MeCab insta...
[ "def", "parse_mecab_options", "(", "self", ",", "options", ")", ":", "class", "MeCabArgumentParser", "(", "argparse", ".", "ArgumentParser", ")", ":", "'''MeCab option parser for natto-py.'''", "def", "error", "(", "self", ",", "message", ")", ":", "'''error(message...
Parses the MeCab options, returning them in a dictionary. Lattice-level option has been deprecated; please use marginal or nbest instead. :options string or dictionary of options to use when instantiating the MeCab instance. May be in short- or long-form, or in a ...
[ "Parses", "the", "MeCab", "options", "returning", "them", "in", "a", "dictionary", ".", "Lattice", "-", "level", "option", "has", "been", "deprecated", ";", "please", "use", "marginal", "or", "nbest", "instead", ".", ":", "options", "string", "or", "dictiona...
train
https://github.com/buruzaemon/natto-py/blob/018fe004c47c45c66bdf2e03fe24e981ae089b76/natto/option_parse.py#L47-L173
buruzaemon/natto-py
natto/option_parse.py
OptionParse.build_options_str
def build_options_str(self, options): '''Returns a string concatenation of the MeCab options. Args: options: dictionary of options to use when instantiating the MeCab instance. Returns: A string concatenation of the options used when instantiatin...
python
def build_options_str(self, options): '''Returns a string concatenation of the MeCab options. Args: options: dictionary of options to use when instantiating the MeCab instance. Returns: A string concatenation of the options used when instantiatin...
[ "def", "build_options_str", "(", "self", ",", "options", ")", ":", "opts", "=", "[", "]", "for", "name", "in", "iter", "(", "list", "(", "self", ".", "_SUPPORTED_OPTS", ".", "values", "(", ")", ")", ")", ":", "if", "name", "in", "options", ":", "ke...
Returns a string concatenation of the MeCab options. Args: options: dictionary of options to use when instantiating the MeCab instance. Returns: A string concatenation of the options used when instantiating the MeCab instance, in long-form.
[ "Returns", "a", "string", "concatenation", "of", "the", "MeCab", "options", ".", "Args", ":", "options", ":", "dictionary", "of", "options", "to", "use", "when", "instantiating", "the", "MeCab", "instance", ".", "Returns", ":", "A", "string", "concatenation", ...
train
https://github.com/buruzaemon/natto-py/blob/018fe004c47c45c66bdf2e03fe24e981ae089b76/natto/option_parse.py#L175-L196
svartalf/python-opus
opus/api/decoder.py
create
def create(fs, channels): """Allocates and initializes a decoder state""" result_code = ctypes.c_int() result = _create(fs, channels, ctypes.byref(result_code)) if result_code.value is not 0: raise OpusError(result_code.value) return result
python
def create(fs, channels): """Allocates and initializes a decoder state""" result_code = ctypes.c_int() result = _create(fs, channels, ctypes.byref(result_code)) if result_code.value is not 0: raise OpusError(result_code.value) return result
[ "def", "create", "(", "fs", ",", "channels", ")", ":", "result_code", "=", "ctypes", ".", "c_int", "(", ")", "result", "=", "_create", "(", "fs", ",", "channels", ",", "ctypes", ".", "byref", "(", "result_code", ")", ")", "if", "result_code", ".", "v...
Allocates and initializes a decoder state
[ "Allocates", "and", "initializes", "a", "decoder", "state" ]
train
https://github.com/svartalf/python-opus/blob/a3c1d556d2772b5be659ddd08c033ddd4d566b3a/opus/api/decoder.py#L32-L41
svartalf/python-opus
opus/api/decoder.py
packet_get_bandwidth
def packet_get_bandwidth(data): """Gets the bandwidth of an Opus packet.""" data_pointer = ctypes.c_char_p(data) result = _packet_get_bandwidth(data_pointer) if result < 0: raise OpusError(result) return result
python
def packet_get_bandwidth(data): """Gets the bandwidth of an Opus packet.""" data_pointer = ctypes.c_char_p(data) result = _packet_get_bandwidth(data_pointer) if result < 0: raise OpusError(result) return result
[ "def", "packet_get_bandwidth", "(", "data", ")", ":", "data_pointer", "=", "ctypes", ".", "c_char_p", "(", "data", ")", "result", "=", "_packet_get_bandwidth", "(", "data_pointer", ")", "if", "result", "<", "0", ":", "raise", "OpusError", "(", "result", ")",...
Gets the bandwidth of an Opus packet.
[ "Gets", "the", "bandwidth", "of", "an", "Opus", "packet", "." ]
train
https://github.com/svartalf/python-opus/blob/a3c1d556d2772b5be659ddd08c033ddd4d566b3a/opus/api/decoder.py#L49-L58
svartalf/python-opus
opus/api/decoder.py
packet_get_nb_channels
def packet_get_nb_channels(data): """Gets the number of channels from an Opus packet""" data_pointer = ctypes.c_char_p(data) result = _packet_get_nb_channels(data_pointer) if result < 0: raise OpusError(result) return result
python
def packet_get_nb_channels(data): """Gets the number of channels from an Opus packet""" data_pointer = ctypes.c_char_p(data) result = _packet_get_nb_channels(data_pointer) if result < 0: raise OpusError(result) return result
[ "def", "packet_get_nb_channels", "(", "data", ")", ":", "data_pointer", "=", "ctypes", ".", "c_char_p", "(", "data", ")", "result", "=", "_packet_get_nb_channels", "(", "data_pointer", ")", "if", "result", "<", "0", ":", "raise", "OpusError", "(", "result", ...
Gets the number of channels from an Opus packet
[ "Gets", "the", "number", "of", "channels", "from", "an", "Opus", "packet" ]
train
https://github.com/svartalf/python-opus/blob/a3c1d556d2772b5be659ddd08c033ddd4d566b3a/opus/api/decoder.py#L66-L75
svartalf/python-opus
opus/api/decoder.py
packet_get_nb_frames
def packet_get_nb_frames(data, length=None): """Gets the number of frames in an Opus packet""" data_pointer = ctypes.c_char_p(data) if length is None: length = len(data) result = _packet_get_nb_frames(data_pointer, ctypes.c_int(length)) if result < 0: raise OpusError(result) r...
python
def packet_get_nb_frames(data, length=None): """Gets the number of frames in an Opus packet""" data_pointer = ctypes.c_char_p(data) if length is None: length = len(data) result = _packet_get_nb_frames(data_pointer, ctypes.c_int(length)) if result < 0: raise OpusError(result) r...
[ "def", "packet_get_nb_frames", "(", "data", ",", "length", "=", "None", ")", ":", "data_pointer", "=", "ctypes", ".", "c_char_p", "(", "data", ")", "if", "length", "is", "None", ":", "length", "=", "len", "(", "data", ")", "result", "=", "_packet_get_nb_...
Gets the number of frames in an Opus packet
[ "Gets", "the", "number", "of", "frames", "in", "an", "Opus", "packet" ]
train
https://github.com/svartalf/python-opus/blob/a3c1d556d2772b5be659ddd08c033ddd4d566b3a/opus/api/decoder.py#L83-L94
svartalf/python-opus
opus/api/decoder.py
packet_get_samples_per_frame
def packet_get_samples_per_frame(data, fs): """Gets the number of samples per frame from an Opus packet""" data_pointer = ctypes.c_char_p(data) result = _packet_get_nb_frames(data_pointer, ctypes.c_int(fs)) if result < 0: raise OpusError(result) return result
python
def packet_get_samples_per_frame(data, fs): """Gets the number of samples per frame from an Opus packet""" data_pointer = ctypes.c_char_p(data) result = _packet_get_nb_frames(data_pointer, ctypes.c_int(fs)) if result < 0: raise OpusError(result) return result
[ "def", "packet_get_samples_per_frame", "(", "data", ",", "fs", ")", ":", "data_pointer", "=", "ctypes", ".", "c_char_p", "(", "data", ")", "result", "=", "_packet_get_nb_frames", "(", "data_pointer", ",", "ctypes", ".", "c_int", "(", "fs", ")", ")", "if", ...
Gets the number of samples per frame from an Opus packet
[ "Gets", "the", "number", "of", "samples", "per", "frame", "from", "an", "Opus", "packet" ]
train
https://github.com/svartalf/python-opus/blob/a3c1d556d2772b5be659ddd08c033ddd4d566b3a/opus/api/decoder.py#L102-L111
svartalf/python-opus
opus/api/decoder.py
decode
def decode(decoder, data, length, frame_size, decode_fec, channels=2): """Decode an Opus frame Unlike the `opus_decode` function , this function takes an additional parameter `channels`, which indicates the number of channels in the frame """ pcm_size = frame_size * channels * ctypes.sizeof(ctypes...
python
def decode(decoder, data, length, frame_size, decode_fec, channels=2): """Decode an Opus frame Unlike the `opus_decode` function , this function takes an additional parameter `channels`, which indicates the number of channels in the frame """ pcm_size = frame_size * channels * ctypes.sizeof(ctypes...
[ "def", "decode", "(", "decoder", ",", "data", ",", "length", ",", "frame_size", ",", "decode_fec", ",", "channels", "=", "2", ")", ":", "pcm_size", "=", "frame_size", "*", "channels", "*", "ctypes", ".", "sizeof", "(", "ctypes", ".", "c_int16", ")", "p...
Decode an Opus frame Unlike the `opus_decode` function , this function takes an additional parameter `channels`, which indicates the number of channels in the frame
[ "Decode", "an", "Opus", "frame" ]
train
https://github.com/svartalf/python-opus/blob/a3c1d556d2772b5be659ddd08c033ddd4d566b3a/opus/api/decoder.py#L132-L150
ome/omego
omego/artifacts.py
JenkinsArtifacts.label_list_parser
def label_list_parser(self, url): """ Extracts comma separate tag=value pairs from a string Assumes all characters other than / and , are valid """ labels = re.findall('([^/,]+=[^/,]+)', url) slabels = set(labels) if '' in slabels: slabels.remove('') ...
python
def label_list_parser(self, url): """ Extracts comma separate tag=value pairs from a string Assumes all characters other than / and , are valid """ labels = re.findall('([^/,]+=[^/,]+)', url) slabels = set(labels) if '' in slabels: slabels.remove('') ...
[ "def", "label_list_parser", "(", "self", ",", "url", ")", ":", "labels", "=", "re", ".", "findall", "(", "'([^/,]+=[^/,]+)'", ",", "url", ")", "slabels", "=", "set", "(", "labels", ")", "if", "''", "in", "slabels", ":", "slabels", ".", "remove", "(", ...
Extracts comma separate tag=value pairs from a string Assumes all characters other than / and , are valid
[ "Extracts", "comma", "separate", "tag", "=", "value", "pairs", "from", "a", "string", "Assumes", "all", "characters", "other", "than", "/", "and", "are", "valid" ]
train
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/artifacts.py#L327-L336
stevelittlefish/flaskfilemanager
flaskfilemanager/filemanager.py
init
def init(app, register_blueprint=True, url_prefix='/fm', access_control_function=None, custom_config_json_path=None, custom_init_js_path=None): """ :param app: The Flask app :param register_blueprint: Override to False to stop the blueprint from automatically being registered to the ...
python
def init(app, register_blueprint=True, url_prefix='/fm', access_control_function=None, custom_config_json_path=None, custom_init_js_path=None): """ :param app: The Flask app :param register_blueprint: Override to False to stop the blueprint from automatically being registered to the ...
[ "def", "init", "(", "app", ",", "register_blueprint", "=", "True", ",", "url_prefix", "=", "'/fm'", ",", "access_control_function", "=", "None", ",", "custom_config_json_path", "=", "None", ",", "custom_init_js_path", "=", "None", ")", ":", "global", "_initialis...
:param app: The Flask app :param register_blueprint: Override to False to stop the blueprint from automatically being registered to the app :param url_prefix: The URL prefix for the blueprint, defaults to /fm :param access_control_function: Pass in a function here to implement...
[ ":", "param", "app", ":", "The", "Flask", "app", ":", "param", "register_blueprint", ":", "Override", "to", "False", "to", "stop", "the", "blueprint", "from", "automatically", "being", "registered", "to", "the", "app", ":", "param", "url_prefix", ":", "The",...
train
https://github.com/stevelittlefish/flaskfilemanager/blob/e37faf5cb4c1370e069bf009ce65c88ad8ee0e94/flaskfilemanager/filemanager.py#L48-L93
stevelittlefish/flaskfilemanager
flaskfilemanager/filemanager.py
get_file
def get_file(path=None, content=None): """ :param path: relative path, or None to get from request :param content: file content, output in data. Used for editfile """ if path is None: path = request.args.get('path') if path is None: return error('No path in request') fi...
python
def get_file(path=None, content=None): """ :param path: relative path, or None to get from request :param content: file content, output in data. Used for editfile """ if path is None: path = request.args.get('path') if path is None: return error('No path in request') fi...
[ "def", "get_file", "(", "path", "=", "None", ",", "content", "=", "None", ")", ":", "if", "path", "is", "None", ":", "path", "=", "request", ".", "args", ".", "get", "(", "'path'", ")", "if", "path", "is", "None", ":", "return", "error", "(", "'N...
:param path: relative path, or None to get from request :param content: file content, output in data. Used for editfile
[ ":", "param", "path", ":", "relative", "path", "or", "None", "to", "get", "from", "request", ":", "param", "content", ":", "file", "content", "output", "in", "data", ".", "Used", "for", "editfile" ]
train
https://github.com/stevelittlefish/flaskfilemanager/blob/e37faf5cb4c1370e069bf009ce65c88ad8ee0e94/flaskfilemanager/filemanager.py#L274-L329
buruzaemon/natto-py
natto/environment.py
MeCabEnv.__get_charset
def __get_charset(self): '''Return the character encoding (charset) used internally by MeCab. Charset is that of the system dictionary used by MeCab. Will defer to the user-specified MECAB_CHARSET environment variable, if set. Defaults to shift-jis on Windows. Defaults t...
python
def __get_charset(self): '''Return the character encoding (charset) used internally by MeCab. Charset is that of the system dictionary used by MeCab. Will defer to the user-specified MECAB_CHARSET environment variable, if set. Defaults to shift-jis on Windows. Defaults t...
[ "def", "__get_charset", "(", "self", ")", ":", "cset", "=", "os", ".", "getenv", "(", "self", ".", "MECAB_CHARSET", ")", "if", "cset", ":", "logger", ".", "debug", "(", "self", ".", "_DEBUG_CSET_DEFAULT", ".", "format", "(", "cset", ")", ")", "return",...
Return the character encoding (charset) used internally by MeCab. Charset is that of the system dictionary used by MeCab. Will defer to the user-specified MECAB_CHARSET environment variable, if set. Defaults to shift-jis on Windows. Defaults to utf-8 on Mac OS. Defaults ...
[ "Return", "the", "character", "encoding", "(", "charset", ")", "used", "internally", "by", "MeCab", ".", "Charset", "is", "that", "of", "the", "system", "dictionary", "used", "by", "MeCab", ".", "Will", "defer", "to", "the", "user", "-", "specified", "MECA...
train
https://github.com/buruzaemon/natto-py/blob/018fe004c47c45c66bdf2e03fe24e981ae089b76/natto/environment.py#L55-L96
buruzaemon/natto-py
natto/environment.py
MeCabEnv.__get_libpath
def __get_libpath(self): '''Return the absolute path to the MeCab library. On Windows, the path to the system dictionary is used to deduce the path to libmecab.dll. Otherwise, mecab-config is used find the libmecab shared object or dynamic library (*NIX or Mac OS, respec...
python
def __get_libpath(self): '''Return the absolute path to the MeCab library. On Windows, the path to the system dictionary is used to deduce the path to libmecab.dll. Otherwise, mecab-config is used find the libmecab shared object or dynamic library (*NIX or Mac OS, respec...
[ "def", "__get_libpath", "(", "self", ")", ":", "libp", "=", "os", ".", "getenv", "(", "self", ".", "MECAB_PATH", ")", "if", "libp", ":", "return", "os", ".", "path", ".", "abspath", "(", "libp", ")", "else", ":", "plat", "=", "sys", ".", "platform"...
Return the absolute path to the MeCab library. On Windows, the path to the system dictionary is used to deduce the path to libmecab.dll. Otherwise, mecab-config is used find the libmecab shared object or dynamic library (*NIX or Mac OS, respectively). Will defer to the...
[ "Return", "the", "absolute", "path", "to", "the", "MeCab", "library", ".", "On", "Windows", "the", "path", "to", "the", "system", "dictionary", "is", "used", "to", "deduce", "the", "path", "to", "libmecab", ".", "dll", ".", "Otherwise", "mecab", "-", "co...
train
https://github.com/buruzaemon/natto-py/blob/018fe004c47c45c66bdf2e03fe24e981ae089b76/natto/environment.py#L98-L162
buruzaemon/natto-py
natto/environment.py
MeCabEnv.__regkey_value
def __regkey_value(self, path, name='', start_key=None): r'''Return the data of value mecabrc at MeCab HKEY node. On Windows, the path to the mecabrc as set in the Windows Registry is used to deduce the path to libmecab.dll. Returns: The full path to the mecabrc on W...
python
def __regkey_value(self, path, name='', start_key=None): r'''Return the data of value mecabrc at MeCab HKEY node. On Windows, the path to the mecabrc as set in the Windows Registry is used to deduce the path to libmecab.dll. Returns: The full path to the mecabrc on W...
[ "def", "__regkey_value", "(", "self", ",", "path", ",", "name", "=", "''", ",", "start_key", "=", "None", ")", ":", "if", "sys", ".", "version", "<", "'3'", ":", "import", "_winreg", "as", "reg", "else", ":", "import", "winreg", "as", "reg", "def", ...
r'''Return the data of value mecabrc at MeCab HKEY node. On Windows, the path to the mecabrc as set in the Windows Registry is used to deduce the path to libmecab.dll. Returns: The full path to the mecabrc on Windows. Raises: WindowsError: A problem wa...
[ "r", "Return", "the", "data", "of", "value", "mecabrc", "at", "MeCab", "HKEY", "node", ".", "On", "Windows", "the", "path", "to", "the", "mecabrc", "as", "set", "in", "the", "Windows", "Registry", "is", "used", "to", "deduce", "the", "path", "to", "lib...
train
https://github.com/buruzaemon/natto-py/blob/018fe004c47c45c66bdf2e03fe24e981ae089b76/natto/environment.py#L164-L199
christian-oudard/htmltreediff
htmltreediff/html.py
diff
def diff(old_html, new_html, cutoff=0.0, plaintext=False, pretty=False): """Show the differences between the old and new html document, as html. Return the document html with extra tags added to show changes. Add <ins> tags around newly added sections, and <del> tags to show sections that have been del...
python
def diff(old_html, new_html, cutoff=0.0, plaintext=False, pretty=False): """Show the differences between the old and new html document, as html. Return the document html with extra tags added to show changes. Add <ins> tags around newly added sections, and <del> tags to show sections that have been del...
[ "def", "diff", "(", "old_html", ",", "new_html", ",", "cutoff", "=", "0.0", ",", "plaintext", "=", "False", ",", "pretty", "=", "False", ")", ":", "if", "plaintext", ":", "old_dom", "=", "parse_text", "(", "old_html", ")", "new_dom", "=", "parse_text", ...
Show the differences between the old and new html document, as html. Return the document html with extra tags added to show changes. Add <ins> tags around newly added sections, and <del> tags to show sections that have been deleted.
[ "Show", "the", "differences", "between", "the", "old", "and", "new", "html", "document", "as", "html", "." ]
train
https://github.com/christian-oudard/htmltreediff/blob/0e28f56492ae7e69bb0f74f9a79a8909a5ad588d/htmltreediff/html.py#L12-L42
christian-oudard/htmltreediff
htmltreediff/diff_core.py
adjusted_ops
def adjusted_ops(opcodes): """ Iterate through opcodes, turning them into a series of insert and delete operations, adjusting indices to account for the size of insertions and deletions. >>> def sequence_opcodes(old, new): return difflib.SequenceMatcher(a=old, b=new).get_opcodes() >>> list(adju...
python
def adjusted_ops(opcodes): """ Iterate through opcodes, turning them into a series of insert and delete operations, adjusting indices to account for the size of insertions and deletions. >>> def sequence_opcodes(old, new): return difflib.SequenceMatcher(a=old, b=new).get_opcodes() >>> list(adju...
[ "def", "adjusted_ops", "(", "opcodes", ")", ":", "while", "opcodes", ":", "op", "=", "opcodes", ".", "pop", "(", "0", ")", "tag", ",", "i1", ",", "i2", ",", "j1", ",", "j2", "=", "op", "shift", "=", "0", "if", "tag", "==", "'equal'", ":", "cont...
Iterate through opcodes, turning them into a series of insert and delete operations, adjusting indices to account for the size of insertions and deletions. >>> def sequence_opcodes(old, new): return difflib.SequenceMatcher(a=old, b=new).get_opcodes() >>> list(adjusted_ops(sequence_opcodes('abc', 'b')))...
[ "Iterate", "through", "opcodes", "turning", "them", "into", "a", "series", "of", "insert", "and", "delete", "operations", "adjusting", "indices", "to", "account", "for", "the", "size", "of", "insertions", "and", "deletions", "." ]
train
https://github.com/christian-oudard/htmltreediff/blob/0e28f56492ae7e69bb0f74f9a79a8909a5ad588d/htmltreediff/diff_core.py#L161-L209
christian-oudard/htmltreediff
htmltreediff/diff_core.py
match_indices
def match_indices(match): """Yield index tuples (old_index, new_index) for each place in the match.""" a, b, size = match for i in range(size): yield a + i, b + i
python
def match_indices(match): """Yield index tuples (old_index, new_index) for each place in the match.""" a, b, size = match for i in range(size): yield a + i, b + i
[ "def", "match_indices", "(", "match", ")", ":", "a", ",", "b", ",", "size", "=", "match", "for", "i", "in", "range", "(", "size", ")", ":", "yield", "a", "+", "i", ",", "b", "+", "i" ]
Yield index tuples (old_index, new_index) for each place in the match.
[ "Yield", "index", "tuples", "(", "old_index", "new_index", ")", "for", "each", "place", "in", "the", "match", "." ]
train
https://github.com/christian-oudard/htmltreediff/blob/0e28f56492ae7e69bb0f74f9a79a8909a5ad588d/htmltreediff/diff_core.py#L224-L228
christian-oudard/htmltreediff
htmltreediff/diff_core.py
get_opcodes
def get_opcodes(matching_blocks): """Use difflib to get the opcodes for a set of matching blocks.""" sm = difflib.SequenceMatcher(a=[], b=[]) sm.matching_blocks = matching_blocks return sm.get_opcodes()
python
def get_opcodes(matching_blocks): """Use difflib to get the opcodes for a set of matching blocks.""" sm = difflib.SequenceMatcher(a=[], b=[]) sm.matching_blocks = matching_blocks return sm.get_opcodes()
[ "def", "get_opcodes", "(", "matching_blocks", ")", ":", "sm", "=", "difflib", ".", "SequenceMatcher", "(", "a", "=", "[", "]", ",", "b", "=", "[", "]", ")", "sm", ".", "matching_blocks", "=", "matching_blocks", "return", "sm", ".", "get_opcodes", "(", ...
Use difflib to get the opcodes for a set of matching blocks.
[ "Use", "difflib", "to", "get", "the", "opcodes", "for", "a", "set", "of", "matching", "blocks", "." ]
train
https://github.com/christian-oudard/htmltreediff/blob/0e28f56492ae7e69bb0f74f9a79a8909a5ad588d/htmltreediff/diff_core.py#L230-L234
christian-oudard/htmltreediff
htmltreediff/diff_core.py
match_blocks
def match_blocks(hash_func, old_children, new_children): """Use difflib to find matching blocks.""" sm = difflib.SequenceMatcher( _is_junk, a=[hash_func(c) for c in old_children], b=[hash_func(c) for c in new_children], ) return sm
python
def match_blocks(hash_func, old_children, new_children): """Use difflib to find matching blocks.""" sm = difflib.SequenceMatcher( _is_junk, a=[hash_func(c) for c in old_children], b=[hash_func(c) for c in new_children], ) return sm
[ "def", "match_blocks", "(", "hash_func", ",", "old_children", ",", "new_children", ")", ":", "sm", "=", "difflib", ".", "SequenceMatcher", "(", "_is_junk", ",", "a", "=", "[", "hash_func", "(", "c", ")", "for", "c", "in", "old_children", "]", ",", "b", ...
Use difflib to find matching blocks.
[ "Use", "difflib", "to", "find", "matching", "blocks", "." ]
train
https://github.com/christian-oudard/htmltreediff/blob/0e28f56492ae7e69bb0f74f9a79a8909a5ad588d/htmltreediff/diff_core.py#L246-L253
christian-oudard/htmltreediff
htmltreediff/diff_core.py
get_nonmatching_blocks
def get_nonmatching_blocks(matching_blocks): """Given a list of matching blocks, output the gaps between them. Non-matches have the format (alo, ahi, blo, bhi). This specifies two index ranges, one in the A sequence, and one in the B sequence. """ i = j = 0 for match in matching_blocks: ...
python
def get_nonmatching_blocks(matching_blocks): """Given a list of matching blocks, output the gaps between them. Non-matches have the format (alo, ahi, blo, bhi). This specifies two index ranges, one in the A sequence, and one in the B sequence. """ i = j = 0 for match in matching_blocks: ...
[ "def", "get_nonmatching_blocks", "(", "matching_blocks", ")", ":", "i", "=", "j", "=", "0", "for", "match", "in", "matching_blocks", ":", "a", ",", "b", ",", "size", "=", "match", "yield", "(", "i", ",", "a", ",", "j", ",", "b", ")", "i", "=", "a...
Given a list of matching blocks, output the gaps between them. Non-matches have the format (alo, ahi, blo, bhi). This specifies two index ranges, one in the A sequence, and one in the B sequence.
[ "Given", "a", "list", "of", "matching", "blocks", "output", "the", "gaps", "between", "them", "." ]
train
https://github.com/christian-oudard/htmltreediff/blob/0e28f56492ae7e69bb0f74f9a79a8909a5ad588d/htmltreediff/diff_core.py#L255-L266
christian-oudard/htmltreediff
htmltreediff/diff_core.py
merge_blocks
def merge_blocks(a_blocks, b_blocks): """Given two lists of blocks, combine them, in the proper order. Ensure that there are no overlaps, and that they are for sequences of the same length. """ # Check sentinels for sequence length. assert a_blocks[-1][2] == b_blocks[-1][2] == 0 # sentinel size...
python
def merge_blocks(a_blocks, b_blocks): """Given two lists of blocks, combine them, in the proper order. Ensure that there are no overlaps, and that they are for sequences of the same length. """ # Check sentinels for sequence length. assert a_blocks[-1][2] == b_blocks[-1][2] == 0 # sentinel size...
[ "def", "merge_blocks", "(", "a_blocks", ",", "b_blocks", ")", ":", "# Check sentinels for sequence length.", "assert", "a_blocks", "[", "-", "1", "]", "[", "2", "]", "==", "b_blocks", "[", "-", "1", "]", "[", "2", "]", "==", "0", "# sentinel size is 0", "a...
Given two lists of blocks, combine them, in the proper order. Ensure that there are no overlaps, and that they are for sequences of the same length.
[ "Given", "two", "lists", "of", "blocks", "combine", "them", "in", "the", "proper", "order", "." ]
train
https://github.com/christian-oudard/htmltreediff/blob/0e28f56492ae7e69bb0f74f9a79a8909a5ad588d/htmltreediff/diff_core.py#L268-L285