repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
christophertbrown/bioscripts
ctbBio/nr_fasta.py
append_index_id
def append_index_id(id, ids): """ add index to id to make it unique wrt ids """ index = 1 mod = '%s_%s' % (id, index) while mod in ids: index += 1 mod = '%s_%s' % (id, index) ids.append(mod) return mod, ids
python
def append_index_id(id, ids): """ add index to id to make it unique wrt ids """ index = 1 mod = '%s_%s' % (id, index) while mod in ids: index += 1 mod = '%s_%s' % (id, index) ids.append(mod) return mod, ids
[ "def", "append_index_id", "(", "id", ",", "ids", ")", ":", "index", "=", "1", "mod", "=", "'%s_%s'", "%", "(", "id", ",", "index", ")", "while", "mod", "in", "ids", ":", "index", "+=", "1", "mod", "=", "'%s_%s'", "%", "(", "id", ",", "index", "...
add index to id to make it unique wrt ids
[ "add", "index", "to", "id", "to", "make", "it", "unique", "wrt", "ids" ]
83b2566b3a5745437ec651cd6cafddd056846240
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/nr_fasta.py#L11-L21
train
christophertbrown/bioscripts
ctbBio/nr_fasta.py
de_rep
def de_rep(fastas, append_index, return_original = False): """ de-replicate fastas based on sequence names """ ids = [] for fasta in fastas: for seq in parse_fasta(fasta): header = seq[0].split('>')[1].split() id = header[0] if id not in ids: ...
python
def de_rep(fastas, append_index, return_original = False): """ de-replicate fastas based on sequence names """ ids = [] for fasta in fastas: for seq in parse_fasta(fasta): header = seq[0].split('>')[1].split() id = header[0] if id not in ids: ...
[ "def", "de_rep", "(", "fastas", ",", "append_index", ",", "return_original", "=", "False", ")", ":", "ids", "=", "[", "]", "for", "fasta", "in", "fastas", ":", "for", "seq", "in", "parse_fasta", "(", "fasta", ")", ":", "header", "=", "seq", "[", "0",...
de-replicate fastas based on sequence names
[ "de", "-", "replicate", "fastas", "based", "on", "sequence", "names" ]
83b2566b3a5745437ec651cd6cafddd056846240
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/nr_fasta.py#L23-L43
train
e-dard/postcodes
postcodes.py
get
def get(postcode): """ Request data associated with `postcode`. :param postcode: the postcode to search for. The postcode may contain spaces (they will be removed). :returns: a dict of the nearest postcode's data or None if no postcode data is found. """ po...
python
def get(postcode): """ Request data associated with `postcode`. :param postcode: the postcode to search for. The postcode may contain spaces (they will be removed). :returns: a dict of the nearest postcode's data or None if no postcode data is found. """ po...
[ "def", "get", "(", "postcode", ")", ":", "postcode", "=", "quote", "(", "postcode", ".", "replace", "(", "' '", ",", "''", ")", ")", "url", "=", "'%s/postcode/%s.json'", "%", "(", "END_POINT", ",", "postcode", ")", "return", "_get_json_resp", "(", "url",...
Request data associated with `postcode`. :param postcode: the postcode to search for. The postcode may contain spaces (they will be removed). :returns: a dict of the nearest postcode's data or None if no postcode data is found.
[ "Request", "data", "associated", "with", "postcode", "." ]
d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005
https://github.com/e-dard/postcodes/blob/d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005/postcodes.py#L22-L34
train
e-dard/postcodes
postcodes.py
get_from_postcode
def get_from_postcode(postcode, distance): """ Request all postcode data within `distance` miles of `postcode`. :param postcode: the postcode to search for. The postcode may contain spaces (they will be removed). :param distance: distance in miles to `postcode`. :returns: a ...
python
def get_from_postcode(postcode, distance): """ Request all postcode data within `distance` miles of `postcode`. :param postcode: the postcode to search for. The postcode may contain spaces (they will be removed). :param distance: distance in miles to `postcode`. :returns: a ...
[ "def", "get_from_postcode", "(", "postcode", ",", "distance", ")", ":", "postcode", "=", "quote", "(", "postcode", ".", "replace", "(", "' '", ",", "''", ")", ")", "return", "_get_from", "(", "distance", ",", "'postcode=%s'", "%", "postcode", ")" ]
Request all postcode data within `distance` miles of `postcode`. :param postcode: the postcode to search for. The postcode may contain spaces (they will be removed). :param distance: distance in miles to `postcode`. :returns: a list of dicts containing postcode data within the ...
[ "Request", "all", "postcode", "data", "within", "distance", "miles", "of", "postcode", "." ]
d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005
https://github.com/e-dard/postcodes/blob/d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005/postcodes.py#L56-L69
train
e-dard/postcodes
postcodes.py
PostCoder._check_point
def _check_point(self, lat, lng): """ Checks if latitude and longitude correct """ if abs(lat) > 90 or abs(lng) > 180: msg = "Illegal lat and/or lng, (%s, %s) provided." % (lat, lng) raise IllegalPointException(msg)
python
def _check_point(self, lat, lng): """ Checks if latitude and longitude correct """ if abs(lat) > 90 or abs(lng) > 180: msg = "Illegal lat and/or lng, (%s, %s) provided." % (lat, lng) raise IllegalPointException(msg)
[ "def", "_check_point", "(", "self", ",", "lat", ",", "lng", ")", ":", "if", "abs", "(", "lat", ")", ">", "90", "or", "abs", "(", "lng", ")", ">", "180", ":", "msg", "=", "\"Illegal lat and/or lng, (%s, %s) provided.\"", "%", "(", "lat", ",", "lng", "...
Checks if latitude and longitude correct
[ "Checks", "if", "latitude", "and", "longitude", "correct" ]
d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005
https://github.com/e-dard/postcodes/blob/d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005/postcodes.py#L123-L127
train
e-dard/postcodes
postcodes.py
PostCoder._lookup
def _lookup(self, skip_cache, fun, *args, **kwargs): """ Checks for cached responses, before requesting from web-service """ if args not in self.cache or skip_cache: self.cache[args] = fun(*args, **kwargs) return self.cache[args]
python
def _lookup(self, skip_cache, fun, *args, **kwargs): """ Checks for cached responses, before requesting from web-service """ if args not in self.cache or skip_cache: self.cache[args] = fun(*args, **kwargs) return self.cache[args]
[ "def", "_lookup", "(", "self", ",", "skip_cache", ",", "fun", ",", "*", "args", ",", "**", "kwargs", ")", ":", "if", "args", "not", "in", "self", ".", "cache", "or", "skip_cache", ":", "self", ".", "cache", "[", "args", "]", "=", "fun", "(", "*",...
Checks for cached responses, before requesting from web-service
[ "Checks", "for", "cached", "responses", "before", "requesting", "from", "web", "-", "service" ]
d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005
https://github.com/e-dard/postcodes/blob/d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005/postcodes.py#L129-L136
train
e-dard/postcodes
postcodes.py
PostCoder.get_nearest
def get_nearest(self, lat, lng, skip_cache=False): """ Calls `postcodes.get_nearest` but checks correctness of `lat` and `long`, and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache and make an exp...
python
def get_nearest(self, lat, lng, skip_cache=False): """ Calls `postcodes.get_nearest` but checks correctness of `lat` and `long`, and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache and make an exp...
[ "def", "get_nearest", "(", "self", ",", "lat", ",", "lng", ",", "skip_cache", "=", "False", ")", ":", "lat", ",", "lng", "=", "float", "(", "lat", ")", ",", "float", "(", "lng", ")", "self", ".", "_check_point", "(", "lat", ",", "lng", ")", "retu...
Calls `postcodes.get_nearest` but checks correctness of `lat` and `long`, and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache and make an explicit request. :raises IllegalPointException: if the latitude o...
[ "Calls", "postcodes", ".", "get_nearest", "but", "checks", "correctness", "of", "lat", "and", "long", "and", "by", "default", "utilises", "a", "local", "cache", "." ]
d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005
https://github.com/e-dard/postcodes/blob/d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005/postcodes.py#L152-L167
train
e-dard/postcodes
postcodes.py
PostCoder.get_from_postcode
def get_from_postcode(self, postcode, distance, skip_cache=False): """ Calls `postcodes.get_from_postcode` but checks correctness of `distance`, and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache ...
python
def get_from_postcode(self, postcode, distance, skip_cache=False): """ Calls `postcodes.get_from_postcode` but checks correctness of `distance`, and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache ...
[ "def", "get_from_postcode", "(", "self", ",", "postcode", ",", "distance", ",", "skip_cache", "=", "False", ")", ":", "distance", "=", "float", "(", "distance", ")", "if", "distance", "<", "0", ":", "raise", "IllegalDistanceException", "(", "\"Distance must no...
Calls `postcodes.get_from_postcode` but checks correctness of `distance`, and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache and make an explicit request. :raises IllegalPointException: if the latitude o...
[ "Calls", "postcodes", ".", "get_from_postcode", "but", "checks", "correctness", "of", "distance", "and", "by", "default", "utilises", "a", "local", "cache", "." ]
d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005
https://github.com/e-dard/postcodes/blob/d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005/postcodes.py#L169-L189
train
e-dard/postcodes
postcodes.py
PostCoder.get_from_geo
def get_from_geo(self, lat, lng, distance, skip_cache=False): """ Calls `postcodes.get_from_geo` but checks the correctness of all arguments, and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache and...
python
def get_from_geo(self, lat, lng, distance, skip_cache=False): """ Calls `postcodes.get_from_geo` but checks the correctness of all arguments, and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache and...
[ "def", "get_from_geo", "(", "self", ",", "lat", ",", "lng", ",", "distance", ",", "skip_cache", "=", "False", ")", ":", "lat", ",", "lng", ",", "distance", "=", "float", "(", "lat", ")", ",", "float", "(", "lng", ")", ",", "float", "(", "distance",...
Calls `postcodes.get_from_geo` but checks the correctness of all arguments, and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache and make an explicit request. :raises IllegalPointException: if the latitude...
[ "Calls", "postcodes", ".", "get_from_geo", "but", "checks", "the", "correctness", "of", "all", "arguments", "and", "by", "default", "utilises", "a", "local", "cache", "." ]
d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005
https://github.com/e-dard/postcodes/blob/d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005/postcodes.py#L191-L210
train
christophertbrown/bioscripts
ctbBio/rRNA_insertions.py
insertions_from_masked
def insertions_from_masked(seq): """ get coordinates of insertions from insertion-masked sequence """ insertions = [] prev = True for i, base in enumerate(seq): if base.isupper() and prev is True: insertions.append([]) prev = False elif base.islower(): ...
python
def insertions_from_masked(seq): """ get coordinates of insertions from insertion-masked sequence """ insertions = [] prev = True for i, base in enumerate(seq): if base.isupper() and prev is True: insertions.append([]) prev = False elif base.islower(): ...
[ "def", "insertions_from_masked", "(", "seq", ")", ":", "insertions", "=", "[", "]", "prev", "=", "True", "for", "i", ",", "base", "in", "enumerate", "(", "seq", ")", ":", "if", "base", ".", "isupper", "(", ")", "and", "prev", "is", "True", ":", "in...
get coordinates of insertions from insertion-masked sequence
[ "get", "coordinates", "of", "insertions", "from", "insertion", "-", "masked", "sequence" ]
83b2566b3a5745437ec651cd6cafddd056846240
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L15-L28
train
christophertbrown/bioscripts
ctbBio/rRNA_insertions.py
seq_info
def seq_info(names, id2names, insertions, sequences): """ get insertion information from header """ seqs = {} # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns]], ...]] for name in names: id = id2names[name] gene = name.split('fromHMM::', 1)[0].rs...
python
def seq_info(names, id2names, insertions, sequences): """ get insertion information from header """ seqs = {} # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns]], ...]] for name in names: id = id2names[name] gene = name.split('fromHMM::', 1)[0].rs...
[ "def", "seq_info", "(", "names", ",", "id2names", ",", "insertions", ",", "sequences", ")", ":", "seqs", "=", "{", "}", "for", "name", "in", "names", ":", "id", "=", "id2names", "[", "name", "]", "gene", "=", "name", ".", "split", "(", "'fromHMM::'",...
get insertion information from header
[ "get", "insertion", "information", "from", "header" ]
83b2566b3a5745437ec651cd6cafddd056846240
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L64-L86
train
christophertbrown/bioscripts
ctbBio/rRNA_insertions.py
check_overlap
def check_overlap(pos, ins, thresh): """ make sure thresh % feature is contained within insertion """ ins_pos = ins[0] ins_len = ins[2] ol = overlap(ins_pos, pos) feat_len = pos[1] - pos[0] + 1 # print float(ol) / float(feat_len) if float(ol) / float(feat_len) >= thresh: retur...
python
def check_overlap(pos, ins, thresh): """ make sure thresh % feature is contained within insertion """ ins_pos = ins[0] ins_len = ins[2] ol = overlap(ins_pos, pos) feat_len = pos[1] - pos[0] + 1 # print float(ol) / float(feat_len) if float(ol) / float(feat_len) >= thresh: retur...
[ "def", "check_overlap", "(", "pos", ",", "ins", ",", "thresh", ")", ":", "ins_pos", "=", "ins", "[", "0", "]", "ins_len", "=", "ins", "[", "2", "]", "ol", "=", "overlap", "(", "ins_pos", ",", "pos", ")", "feat_len", "=", "pos", "[", "1", "]", "...
make sure thresh % feature is contained within insertion
[ "make", "sure", "thresh", "%", "feature", "is", "contained", "within", "insertion" ]
83b2566b3a5745437ec651cd6cafddd056846240
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L91-L102
train
christophertbrown/bioscripts
ctbBio/rRNA_insertions.py
max_insertion
def max_insertion(seqs, gene, domain): """ length of largest insertion """ seqs = [i[2] for i in list(seqs.values()) if i[2] != [] and i[0] == gene and i[1] == domain] lengths = [] for seq in seqs: for ins in seq: lengths.append(int(ins[2])) if lengths == []: retu...
python
def max_insertion(seqs, gene, domain): """ length of largest insertion """ seqs = [i[2] for i in list(seqs.values()) if i[2] != [] and i[0] == gene and i[1] == domain] lengths = [] for seq in seqs: for ins in seq: lengths.append(int(ins[2])) if lengths == []: retu...
[ "def", "max_insertion", "(", "seqs", ",", "gene", ",", "domain", ")", ":", "seqs", "=", "[", "i", "[", "2", "]", "for", "i", "in", "list", "(", "seqs", ".", "values", "(", ")", ")", "if", "i", "[", "2", "]", "!=", "[", "]", "and", "i", "[",...
length of largest insertion
[ "length", "of", "largest", "insertion" ]
83b2566b3a5745437ec651cd6cafddd056846240
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L305-L316
train
christophertbrown/bioscripts
ctbBio/rRNA_insertions.py
model_length
def model_length(gene, domain): """ get length of model """ if gene == '16S': domain2max = {'E_coli_K12': int(1538), 'bacteria': int(1689), 'archaea': int(1563), 'eukarya': int(2652)} return domain2max[domain] elif gene == '23S': domain2max = {'E_coli_K12': int(2903), 'bacter...
python
def model_length(gene, domain): """ get length of model """ if gene == '16S': domain2max = {'E_coli_K12': int(1538), 'bacteria': int(1689), 'archaea': int(1563), 'eukarya': int(2652)} return domain2max[domain] elif gene == '23S': domain2max = {'E_coli_K12': int(2903), 'bacter...
[ "def", "model_length", "(", "gene", ",", "domain", ")", ":", "if", "gene", "==", "'16S'", ":", "domain2max", "=", "{", "'E_coli_K12'", ":", "int", "(", "1538", ")", ",", "'bacteria'", ":", "int", "(", "1689", ")", ",", "'archaea'", ":", "int", "(", ...
get length of model
[ "get", "length", "of", "model" ]
83b2566b3a5745437ec651cd6cafddd056846240
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L318-L330
train
christophertbrown/bioscripts
ctbBio/rRNA_insertions.py
setup_markers
def setup_markers(seqs): """ setup unique marker for every orf annotation - change size if necessary """ family2marker = {} # family2marker[family] = [marker, size] markers = cycle(['^', 'p', '*', '+', 'x', 'd', '|', 'v', '>', '<', '8']) size = 60 families = [] for seq in list(seqs.v...
python
def setup_markers(seqs): """ setup unique marker for every orf annotation - change size if necessary """ family2marker = {} # family2marker[family] = [marker, size] markers = cycle(['^', 'p', '*', '+', 'x', 'd', '|', 'v', '>', '<', '8']) size = 60 families = [] for seq in list(seqs.v...
[ "def", "setup_markers", "(", "seqs", ")", ":", "family2marker", "=", "{", "}", "markers", "=", "cycle", "(", "[", "'^'", ",", "'p'", ",", "'*'", ",", "'+'", ",", "'x'", ",", "'d'", ",", "'|'", ",", "'v'", ",", "'>'", ",", "'<'", ",", "'8'", "]"...
setup unique marker for every orf annotation - change size if necessary
[ "setup", "unique", "marker", "for", "every", "orf", "annotation", "-", "change", "size", "if", "necessary" ]
83b2566b3a5745437ec651cd6cafddd056846240
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L332-L351
train
christophertbrown/bioscripts
ctbBio/rRNA_insertions.py
plot_by_gene_and_domain
def plot_by_gene_and_domain(name, seqs, tax, id2name): """ plot insertions for each gene and domain """ for gene in set([seq[0] for seq in list(seqs.values())]): for domain in set([seq[1] for seq in list(seqs.values())]): plot_insertions(name, seqs, gene, domain, tax, id2name)
python
def plot_by_gene_and_domain(name, seqs, tax, id2name): """ plot insertions for each gene and domain """ for gene in set([seq[0] for seq in list(seqs.values())]): for domain in set([seq[1] for seq in list(seqs.values())]): plot_insertions(name, seqs, gene, domain, tax, id2name)
[ "def", "plot_by_gene_and_domain", "(", "name", ",", "seqs", ",", "tax", ",", "id2name", ")", ":", "for", "gene", "in", "set", "(", "[", "seq", "[", "0", "]", "for", "seq", "in", "list", "(", "seqs", ".", "values", "(", ")", ")", "]", ")", ":", ...
plot insertions for each gene and domain
[ "plot", "insertions", "for", "each", "gene", "and", "domain" ]
83b2566b3a5745437ec651cd6cafddd056846240
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L551-L557
train
christophertbrown/bioscripts
ctbBio/neto.py
get_descriptions
def get_descriptions(fastas): """ get the description for each ORF """ id2desc = {} for fasta in fastas: for seq in parse_fasta(fasta): header = seq[0].split('>')[1].split(' ') id = header[0] if len(header) > 1: desc = ' '.join(header[1:])...
python
def get_descriptions(fastas): """ get the description for each ORF """ id2desc = {} for fasta in fastas: for seq in parse_fasta(fasta): header = seq[0].split('>')[1].split(' ') id = header[0] if len(header) > 1: desc = ' '.join(header[1:])...
[ "def", "get_descriptions", "(", "fastas", ")", ":", "id2desc", "=", "{", "}", "for", "fasta", "in", "fastas", ":", "for", "seq", "in", "parse_fasta", "(", "fasta", ")", ":", "header", "=", "seq", "[", "0", "]", ".", "split", "(", "'>'", ")", "[", ...
get the description for each ORF
[ "get", "the", "description", "for", "each", "ORF" ]
83b2566b3a5745437ec651cd6cafddd056846240
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/neto.py#L37-L52
train
christophertbrown/bioscripts
ctbBio/neto.py
print_genome_matrix
def print_genome_matrix(hits, fastas, id2desc, file_name): """ optimize later? slow ... should combine with calculate_threshold module """ out = open(file_name, 'w') fastas = sorted(fastas) print('## percent identity between genomes', file=out) print('# - \t %s' % ('\t'.join(fastas)), fi...
python
def print_genome_matrix(hits, fastas, id2desc, file_name): """ optimize later? slow ... should combine with calculate_threshold module """ out = open(file_name, 'w') fastas = sorted(fastas) print('## percent identity between genomes', file=out) print('# - \t %s' % ('\t'.join(fastas)), fi...
[ "def", "print_genome_matrix", "(", "hits", ",", "fastas", ",", "id2desc", ",", "file_name", ")", ":", "out", "=", "open", "(", "file_name", ",", "'w'", ")", "fastas", "=", "sorted", "(", "fastas", ")", "print", "(", "'## percent identity between genomes'", "...
optimize later? slow ... should combine with calculate_threshold module
[ "optimize", "later?", "slow", "...", "should", "combine", "with", "calculate_threshold", "module" ]
83b2566b3a5745437ec651cd6cafddd056846240
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/neto.py#L140-L171
train
christophertbrown/bioscripts
ctbBio/neto.py
self_compare
def self_compare(fastas, id2desc, algorithm): """ compare genome to self to get the best possible bit score for each ORF """ for fasta in fastas: blast = open(search(fasta, fasta, method = algorithm, alignment = 'local')) for hit in best_blast(blast, 1): id, bit = hit[0].spli...
python
def self_compare(fastas, id2desc, algorithm): """ compare genome to self to get the best possible bit score for each ORF """ for fasta in fastas: blast = open(search(fasta, fasta, method = algorithm, alignment = 'local')) for hit in best_blast(blast, 1): id, bit = hit[0].spli...
[ "def", "self_compare", "(", "fastas", ",", "id2desc", ",", "algorithm", ")", ":", "for", "fasta", "in", "fastas", ":", "blast", "=", "open", "(", "search", "(", "fasta", ",", "fasta", ",", "method", "=", "algorithm", ",", "alignment", "=", "'local'", "...
compare genome to self to get the best possible bit score for each ORF
[ "compare", "genome", "to", "self", "to", "get", "the", "best", "possible", "bit", "score", "for", "each", "ORF" ]
83b2566b3a5745437ec651cd6cafddd056846240
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/neto.py#L240-L249
train
christophertbrown/bioscripts
ctbBio/neto.py
calc_thresholds
def calc_thresholds(rbh, file_name, thresholds = [False, False, False, False], stdevs = 2): """ if thresholds are not specififed, calculate based on the distribution of normalized bit scores """ calc_threshold = thresholds[-1] norm_threshold = {} for pair in itertools.permutations([i for i in rb...
python
def calc_thresholds(rbh, file_name, thresholds = [False, False, False, False], stdevs = 2): """ if thresholds are not specififed, calculate based on the distribution of normalized bit scores """ calc_threshold = thresholds[-1] norm_threshold = {} for pair in itertools.permutations([i for i in rb...
[ "def", "calc_thresholds", "(", "rbh", ",", "file_name", ",", "thresholds", "=", "[", "False", ",", "False", ",", "False", ",", "False", "]", ",", "stdevs", "=", "2", ")", ":", "calc_threshold", "=", "thresholds", "[", "-", "1", "]", "norm_threshold", "...
if thresholds are not specififed, calculate based on the distribution of normalized bit scores
[ "if", "thresholds", "are", "not", "specififed", "calculate", "based", "on", "the", "distribution", "of", "normalized", "bit", "scores" ]
83b2566b3a5745437ec651cd6cafddd056846240
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/neto.py#L303-L352
train
christophertbrown/bioscripts
ctbBio/neto.py
neto
def neto(fastas, algorithm = 'usearch', e = 0.01, bit = 40, length = .65, norm_bit = False): """ make and split a rbh network """ thresholds = [e, bit, length, norm_bit] id2desc = get_descriptions(fastas) # get [fasta, description, length] for ORF id id2desc = self_compare(fastas, id...
python
def neto(fastas, algorithm = 'usearch', e = 0.01, bit = 40, length = .65, norm_bit = False): """ make and split a rbh network """ thresholds = [e, bit, length, norm_bit] id2desc = get_descriptions(fastas) # get [fasta, description, length] for ORF id id2desc = self_compare(fastas, id...
[ "def", "neto", "(", "fastas", ",", "algorithm", "=", "'usearch'", ",", "e", "=", "0.01", ",", "bit", "=", "40", ",", "length", "=", ".65", ",", "norm_bit", "=", "False", ")", ":", "thresholds", "=", "[", "e", ",", "bit", ",", "length", ",", "norm...
make and split a rbh network
[ "make", "and", "split", "a", "rbh", "network" ]
83b2566b3a5745437ec651cd6cafddd056846240
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/neto.py#L416-L445
train
consbio/gis-metadata-parser
gis_metadata/iso_metadata_parser.py
IsoParser._parse_raster_info
def _parse_raster_info(self, prop=RASTER_INFO): """ Collapses multiple dimensions into a single raster_info complex struct """ raster_info = {}.fromkeys(_iso_definitions[prop], u'') # Ensure conversion of lists to newlines is in place raster_info['dimensions'] = get_default_for_complex...
python
def _parse_raster_info(self, prop=RASTER_INFO): """ Collapses multiple dimensions into a single raster_info complex struct """ raster_info = {}.fromkeys(_iso_definitions[prop], u'') # Ensure conversion of lists to newlines is in place raster_info['dimensions'] = get_default_for_complex...
[ "def", "_parse_raster_info", "(", "self", ",", "prop", "=", "RASTER_INFO", ")", ":", "raster_info", "=", "{", "}", ".", "fromkeys", "(", "_iso_definitions", "[", "prop", "]", ",", "u''", ")", "raster_info", "[", "'dimensions'", "]", "=", "get_default_for_com...
Collapses multiple dimensions into a single raster_info complex struct
[ "Collapses", "multiple", "dimensions", "into", "a", "single", "raster_info", "complex", "struct" ]
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/iso_metadata_parser.py#L472-L502
train
consbio/gis-metadata-parser
gis_metadata/iso_metadata_parser.py
IsoParser._update_raster_info
def _update_raster_info(self, **update_props): """ Derives multiple dimensions from a single raster_info complex struct """ tree_to_update = update_props['tree_to_update'] prop = update_props['prop'] values = update_props.pop('values') # Update number of dimensions at raster_in...
python
def _update_raster_info(self, **update_props): """ Derives multiple dimensions from a single raster_info complex struct """ tree_to_update = update_props['tree_to_update'] prop = update_props['prop'] values = update_props.pop('values') # Update number of dimensions at raster_in...
[ "def", "_update_raster_info", "(", "self", ",", "**", "update_props", ")", ":", "tree_to_update", "=", "update_props", "[", "'tree_to_update'", "]", "prop", "=", "update_props", "[", "'prop'", "]", "values", "=", "update_props", ".", "pop", "(", "'values'", ")...
Derives multiple dimensions from a single raster_info complex struct
[ "Derives", "multiple", "dimensions", "from", "a", "single", "raster_info", "complex", "struct" ]
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/iso_metadata_parser.py#L622-L666
train
consbio/gis-metadata-parser
gis_metadata/iso_metadata_parser.py
IsoParser._trim_xpath
def _trim_xpath(self, xpath, prop): """ Removes primitive type tags from an XPATH """ xroot = self._get_xroot_for(prop) if xroot is None and isinstance(xpath, string_types): xtags = xpath.split(XPATH_DELIM) if xtags[-1] in _iso_tag_primitives: xroot = X...
python
def _trim_xpath(self, xpath, prop): """ Removes primitive type tags from an XPATH """ xroot = self._get_xroot_for(prop) if xroot is None and isinstance(xpath, string_types): xtags = xpath.split(XPATH_DELIM) if xtags[-1] in _iso_tag_primitives: xroot = X...
[ "def", "_trim_xpath", "(", "self", ",", "xpath", ",", "prop", ")", ":", "xroot", "=", "self", ".", "_get_xroot_for", "(", "prop", ")", "if", "xroot", "is", "None", "and", "isinstance", "(", "xpath", ",", "string_types", ")", ":", "xtags", "=", "xpath",...
Removes primitive type tags from an XPATH
[ "Removes", "primitive", "type", "tags", "from", "an", "XPATH" ]
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/iso_metadata_parser.py#L691-L702
train
scottrice/pysteam
pysteam/shortcuts.py
shortcut_app_id
def shortcut_app_id(shortcut): """ Generates the app id for a given shortcut. Steam uses app ids as a unique identifier for games, but since shortcuts dont have a canonical serverside representation they need to be generated on the fly. The important part about this function is that it will generate the same ...
python
def shortcut_app_id(shortcut): """ Generates the app id for a given shortcut. Steam uses app ids as a unique identifier for games, but since shortcuts dont have a canonical serverside representation they need to be generated on the fly. The important part about this function is that it will generate the same ...
[ "def", "shortcut_app_id", "(", "shortcut", ")", ":", "algorithm", "=", "Crc", "(", "width", "=", "32", ",", "poly", "=", "0x04C11DB7", ",", "reflect_in", "=", "True", ",", "xor_in", "=", "0xffffffff", ",", "reflect_out", "=", "True", ",", "xor_out", "=",...
Generates the app id for a given shortcut. Steam uses app ids as a unique identifier for games, but since shortcuts dont have a canonical serverside representation they need to be generated on the fly. The important part about this function is that it will generate the same app id as Steam does for a given shor...
[ "Generates", "the", "app", "id", "for", "a", "given", "shortcut", ".", "Steam", "uses", "app", "ids", "as", "a", "unique", "identifier", "for", "games", "but", "since", "shortcuts", "dont", "have", "a", "canonical", "serverside", "representation", "they", "n...
1eb2254b5235a053a953e596fa7602d0b110245d
https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/shortcuts.py#L9-L21
train
mkouhei/bootstrap-py
bootstrap_py/vcs.py
VCS._config
def _config(self): """Execute git config.""" cfg_wr = self.repo.config_writer() cfg_wr.add_section('user') cfg_wr.set_value('user', 'name', self.metadata.author) cfg_wr.set_value('user', 'email', self.metadata.email) cfg_wr.release()
python
def _config(self): """Execute git config.""" cfg_wr = self.repo.config_writer() cfg_wr.add_section('user') cfg_wr.set_value('user', 'name', self.metadata.author) cfg_wr.set_value('user', 'email', self.metadata.email) cfg_wr.release()
[ "def", "_config", "(", "self", ")", ":", "cfg_wr", "=", "self", ".", "repo", ".", "config_writer", "(", ")", "cfg_wr", ".", "add_section", "(", "'user'", ")", "cfg_wr", ".", "set_value", "(", "'user'", ",", "'name'", ",", "self", ".", "metadata", ".", ...
Execute git config.
[ "Execute", "git", "config", "." ]
95d56ed98ef409fd9f019dc352fd1c3711533275
https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/vcs.py#L35-L41
train
mkouhei/bootstrap-py
bootstrap_py/vcs.py
VCS._remote_add
def _remote_add(self): """Execute git remote add.""" self.repo.create_remote( 'origin', 'git@github.com:{username}/{repo}.git'.format( username=self.metadata.username, repo=self.metadata.name))
python
def _remote_add(self): """Execute git remote add.""" self.repo.create_remote( 'origin', 'git@github.com:{username}/{repo}.git'.format( username=self.metadata.username, repo=self.metadata.name))
[ "def", "_remote_add", "(", "self", ")", ":", "self", ".", "repo", ".", "create_remote", "(", "'origin'", ",", "'git@github.com:{username}/{repo}.git'", ".", "format", "(", "username", "=", "self", ".", "metadata", ".", "username", ",", "repo", "=", "self", "...
Execute git remote add.
[ "Execute", "git", "remote", "add", "." ]
95d56ed98ef409fd9f019dc352fd1c3711533275
https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/vcs.py#L47-L53
train
deep-compute/basescript
basescript/basescript.py
BaseScript.start
def start(self): ''' Starts execution of the script ''' # invoke the appropriate sub-command as requested from command-line try: self.args.func() except SystemExit as e: if e.code != 0: raise except KeyboardInterrupt: ...
python
def start(self): ''' Starts execution of the script ''' # invoke the appropriate sub-command as requested from command-line try: self.args.func() except SystemExit as e: if e.code != 0: raise except KeyboardInterrupt: ...
[ "def", "start", "(", "self", ")", ":", "try", ":", "self", ".", "args", ".", "func", "(", ")", "except", "SystemExit", "as", "e", ":", "if", "e", ".", "code", "!=", "0", ":", "raise", "except", "KeyboardInterrupt", ":", "self", ".", "log", ".", "...
Starts execution of the script
[ "Starts", "execution", "of", "the", "script" ]
f7233963c5291530fcb2444a7f45b556e6407b90
https://github.com/deep-compute/basescript/blob/f7233963c5291530fcb2444a7f45b556e6407b90/basescript/basescript.py#L67-L87
train
deep-compute/basescript
basescript/basescript.py
BaseScript.define_baseargs
def define_baseargs(self, parser): ''' Define basic command-line arguments required by the script. @parser is a parser object created using the `argparse` module. returns: None ''' parser.add_argument('--name', default=sys.argv[0], help='Name to identify this ...
python
def define_baseargs(self, parser): ''' Define basic command-line arguments required by the script. @parser is a parser object created using the `argparse` module. returns: None ''' parser.add_argument('--name', default=sys.argv[0], help='Name to identify this ...
[ "def", "define_baseargs", "(", "self", ",", "parser", ")", ":", "parser", ".", "add_argument", "(", "'--name'", ",", "default", "=", "sys", ".", "argv", "[", "0", "]", ",", "help", "=", "'Name to identify this instance'", ")", "parser", ".", "add_argument", ...
Define basic command-line arguments required by the script. @parser is a parser object created using the `argparse` module. returns: None
[ "Define", "basic", "command", "-", "line", "arguments", "required", "by", "the", "script", "." ]
f7233963c5291530fcb2444a7f45b556e6407b90
https://github.com/deep-compute/basescript/blob/f7233963c5291530fcb2444a7f45b556e6407b90/basescript/basescript.py#L123-L151
train
elbow-jason/Uno-deprecated
uno/parser/source_coder.py
SourceCoder.cleanup_payload
def cleanup_payload(self, payload): """ Basically, turns payload that looks like ' \\n ' to ''. In the calling function, if this function returns '' no object is added for that payload. """ p = payload.replace('\n', '') p = p.rstrip() p = p.lstrip() ...
python
def cleanup_payload(self, payload): """ Basically, turns payload that looks like ' \\n ' to ''. In the calling function, if this function returns '' no object is added for that payload. """ p = payload.replace('\n', '') p = p.rstrip() p = p.lstrip() ...
[ "def", "cleanup_payload", "(", "self", ",", "payload", ")", ":", "p", "=", "payload", ".", "replace", "(", "'\\n'", ",", "''", ")", "p", "=", "p", ".", "rstrip", "(", ")", "p", "=", "p", ".", "lstrip", "(", ")", "return", "p" ]
Basically, turns payload that looks like ' \\n ' to ''. In the calling function, if this function returns '' no object is added for that payload.
[ "Basically", "turns", "payload", "that", "looks", "like", "\\\\", "n", "to", ".", "In", "the", "calling", "function", "if", "this", "function", "returns", "no", "object", "is", "added", "for", "that", "payload", "." ]
4ad07d7b84e5b6e3e2b2c89db69448906f24b4e4
https://github.com/elbow-jason/Uno-deprecated/blob/4ad07d7b84e5b6e3e2b2c89db69448906f24b4e4/uno/parser/source_coder.py#L73-L82
train
consbio/gis-metadata-parser
gis_metadata/utils.py
get_default_for
def get_default_for(prop, value): """ Ensures complex property types have the correct default values """ prop = prop.strip('_') # Handle alternate props (leading underscores) val = reduce_value(value) # Filtering of value happens here if prop in _COMPLEX_LISTS: return wrap_value(val) ...
python
def get_default_for(prop, value): """ Ensures complex property types have the correct default values """ prop = prop.strip('_') # Handle alternate props (leading underscores) val = reduce_value(value) # Filtering of value happens here if prop in _COMPLEX_LISTS: return wrap_value(val) ...
[ "def", "get_default_for", "(", "prop", ",", "value", ")", ":", "prop", "=", "prop", ".", "strip", "(", "'_'", ")", "val", "=", "reduce_value", "(", "value", ")", "if", "prop", "in", "_COMPLEX_LISTS", ":", "return", "wrap_value", "(", "val", ")", "elif"...
Ensures complex property types have the correct default values
[ "Ensures", "complex", "property", "types", "have", "the", "correct", "default", "values" ]
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L223-L234
train
consbio/gis-metadata-parser
gis_metadata/utils.py
update_property
def update_property(tree_to_update, xpath_root, xpaths, prop, values, supported=None): """ Either update the tree the default way, or call the custom updater Default Way: Existing values in the tree are overwritten. If xpaths contains a single path, then each value is written to the tree at that path. ...
python
def update_property(tree_to_update, xpath_root, xpaths, prop, values, supported=None): """ Either update the tree the default way, or call the custom updater Default Way: Existing values in the tree are overwritten. If xpaths contains a single path, then each value is written to the tree at that path. ...
[ "def", "update_property", "(", "tree_to_update", ",", "xpath_root", ",", "xpaths", ",", "prop", ",", "values", ",", "supported", "=", "None", ")", ":", "if", "supported", "and", "prop", ".", "startswith", "(", "'_'", ")", "and", "prop", ".", "strip", "("...
Either update the tree the default way, or call the custom updater Default Way: Existing values in the tree are overwritten. If xpaths contains a single path, then each value is written to the tree at that path. If xpaths contains a list of xpaths, then the values corresponding to each xpath index are writ...
[ "Either", "update", "the", "tree", "the", "default", "way", "or", "call", "the", "custom", "updater" ]
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L392-L423
train
consbio/gis-metadata-parser
gis_metadata/utils.py
_update_property
def _update_property(tree_to_update, xpath_root, xpaths, values): """ Default update operation for a single parser property. If xpaths contains one xpath, then one element per value will be inserted at that location in the tree_to_update; otherwise, the number of values must match the number of xpaths. ...
python
def _update_property(tree_to_update, xpath_root, xpaths, values): """ Default update operation for a single parser property. If xpaths contains one xpath, then one element per value will be inserted at that location in the tree_to_update; otherwise, the number of values must match the number of xpaths. ...
[ "def", "_update_property", "(", "tree_to_update", ",", "xpath_root", ",", "xpaths", ",", "values", ")", ":", "def", "update_element", "(", "elem", ",", "idx", ",", "root", ",", "path", ",", "vals", ")", ":", "has_root", "=", "bool", "(", "root", "and", ...
Default update operation for a single parser property. If xpaths contains one xpath, then one element per value will be inserted at that location in the tree_to_update; otherwise, the number of values must match the number of xpaths.
[ "Default", "update", "operation", "for", "a", "single", "parser", "property", ".", "If", "xpaths", "contains", "one", "xpath", "then", "one", "element", "per", "value", "will", "be", "inserted", "at", "that", "location", "in", "the", "tree_to_update", ";", "...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L426-L486
train
consbio/gis-metadata-parser
gis_metadata/utils.py
validate_complex
def validate_complex(prop, value, xpath_map=None): """ Default validation for single complex data structure """ if value is not None: validate_type(prop, value, dict) if prop in _complex_definitions: complex_keys = _complex_definitions[prop] else: complex_keys =...
python
def validate_complex(prop, value, xpath_map=None): """ Default validation for single complex data structure """ if value is not None: validate_type(prop, value, dict) if prop in _complex_definitions: complex_keys = _complex_definitions[prop] else: complex_keys =...
[ "def", "validate_complex", "(", "prop", ",", "value", ",", "xpath_map", "=", "None", ")", ":", "if", "value", "is", "not", "None", ":", "validate_type", "(", "prop", ",", "value", ",", "dict", ")", "if", "prop", "in", "_complex_definitions", ":", "comple...
Default validation for single complex data structure
[ "Default", "validation", "for", "single", "complex", "data", "structure" ]
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L572-L589
train
consbio/gis-metadata-parser
gis_metadata/utils.py
validate_complex_list
def validate_complex_list(prop, value, xpath_map=None): """ Default validation for Attribute Details data structure """ if value is not None: validate_type(prop, value, (dict, list)) if prop in _complex_definitions: complex_keys = _complex_definitions[prop] else: ...
python
def validate_complex_list(prop, value, xpath_map=None): """ Default validation for Attribute Details data structure """ if value is not None: validate_type(prop, value, (dict, list)) if prop in _complex_definitions: complex_keys = _complex_definitions[prop] else: ...
[ "def", "validate_complex_list", "(", "prop", ",", "value", ",", "xpath_map", "=", "None", ")", ":", "if", "value", "is", "not", "None", ":", "validate_type", "(", "prop", ",", "value", ",", "(", "dict", ",", "list", ")", ")", "if", "prop", "in", "_co...
Default validation for Attribute Details data structure
[ "Default", "validation", "for", "Attribute", "Details", "data", "structure" ]
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L592-L618
train
consbio/gis-metadata-parser
gis_metadata/utils.py
validate_dates
def validate_dates(prop, value, xpath_map=None): """ Default validation for Date Types data structure """ if value is not None: validate_type(prop, value, dict) date_keys = set(value) if date_keys: if DATE_TYPE not in date_keys or DATE_VALUES not in date_keys: ...
python
def validate_dates(prop, value, xpath_map=None): """ Default validation for Date Types data structure """ if value is not None: validate_type(prop, value, dict) date_keys = set(value) if date_keys: if DATE_TYPE not in date_keys or DATE_VALUES not in date_keys: ...
[ "def", "validate_dates", "(", "prop", ",", "value", ",", "xpath_map", "=", "None", ")", ":", "if", "value", "is", "not", "None", ":", "validate_type", "(", "prop", ",", "value", ",", "dict", ")", "date_keys", "=", "set", "(", "value", ")", "if", "dat...
Default validation for Date Types data structure
[ "Default", "validation", "for", "Date", "Types", "data", "structure" ]
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L621-L663
train
consbio/gis-metadata-parser
gis_metadata/utils.py
validate_process_steps
def validate_process_steps(prop, value): """ Default validation for Process Steps data structure """ if value is not None: validate_type(prop, value, (dict, list)) procstep_keys = set(_complex_definitions[prop]) for idx, procstep in enumerate(wrap_value(value)): ps_idx = p...
python
def validate_process_steps(prop, value): """ Default validation for Process Steps data structure """ if value is not None: validate_type(prop, value, (dict, list)) procstep_keys = set(_complex_definitions[prop]) for idx, procstep in enumerate(wrap_value(value)): ps_idx = p...
[ "def", "validate_process_steps", "(", "prop", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "validate_type", "(", "prop", ",", "value", ",", "(", "dict", ",", "list", ")", ")", "procstep_keys", "=", "set", "(", "_complex_definitions", ...
Default validation for Process Steps data structure
[ "Default", "validation", "for", "Process", "Steps", "data", "structure" ]
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L666-L691
train
consbio/gis-metadata-parser
gis_metadata/utils.py
validate_type
def validate_type(prop, value, expected): """ Default validation for all types """ # Validate on expected type(s), but ignore None: defaults handled elsewhere if value is not None and not isinstance(value, expected): _validation_error(prop, type(value).__name__, None, expected)
python
def validate_type(prop, value, expected): """ Default validation for all types """ # Validate on expected type(s), but ignore None: defaults handled elsewhere if value is not None and not isinstance(value, expected): _validation_error(prop, type(value).__name__, None, expected)
[ "def", "validate_type", "(", "prop", ",", "value", ",", "expected", ")", ":", "if", "value", "is", "not", "None", "and", "not", "isinstance", "(", "value", ",", "expected", ")", ":", "_validation_error", "(", "prop", ",", "type", "(", "value", ")", "."...
Default validation for all types
[ "Default", "validation", "for", "all", "types" ]
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L710-L715
train
consbio/gis-metadata-parser
gis_metadata/utils.py
_validation_error
def _validation_error(prop, prop_type, prop_value, expected): """ Default validation for updated properties """ if prop_type is None: attrib = 'value' assigned = prop_value else: attrib = 'type' assigned = prop_type raise ValidationError( 'Invalid property {attr...
python
def _validation_error(prop, prop_type, prop_value, expected): """ Default validation for updated properties """ if prop_type is None: attrib = 'value' assigned = prop_value else: attrib = 'type' assigned = prop_type raise ValidationError( 'Invalid property {attr...
[ "def", "_validation_error", "(", "prop", ",", "prop_type", ",", "prop_value", ",", "expected", ")", ":", "if", "prop_type", "is", "None", ":", "attrib", "=", "'value'", "assigned", "=", "prop_value", "else", ":", "attrib", "=", "'type'", "assigned", "=", "...
Default validation for updated properties
[ "Default", "validation", "for", "updated", "properties" ]
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L718-L732
train
consbio/gis-metadata-parser
gis_metadata/utils.py
ParserProperty.get_prop
def get_prop(self, prop): """ Calls the getter with no arguments and returns its value """ if self._parser is None: raise ConfigurationError('Cannot call ParserProperty."get_prop" with no parser configured') return self._parser(prop) if prop else self._parser()
python
def get_prop(self, prop): """ Calls the getter with no arguments and returns its value """ if self._parser is None: raise ConfigurationError('Cannot call ParserProperty."get_prop" with no parser configured') return self._parser(prop) if prop else self._parser()
[ "def", "get_prop", "(", "self", ",", "prop", ")", ":", "if", "self", ".", "_parser", "is", "None", ":", "raise", "ConfigurationError", "(", "'Cannot call ParserProperty.\"get_prop\" with no parser configured'", ")", "return", "self", ".", "_parser", "(", "prop", "...
Calls the getter with no arguments and returns its value
[ "Calls", "the", "getter", "with", "no", "arguments", "and", "returns", "its", "value" ]
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L765-L771
train
disqus/nydus
nydus/db/backends/memcache.py
can_group_commands
def can_group_commands(command, next_command): """ Returns a boolean representing whether these commands can be grouped together or not. A few things are taken into account for this decision: For ``set`` commands: - Are all arguments other than the key/value the same? For ``delete`` and ...
python
def can_group_commands(command, next_command): """ Returns a boolean representing whether these commands can be grouped together or not. A few things are taken into account for this decision: For ``set`` commands: - Are all arguments other than the key/value the same? For ``delete`` and ...
[ "def", "can_group_commands", "(", "command", ",", "next_command", ")", ":", "multi_capable_commands", "=", "(", "'get'", ",", "'set'", ",", "'delete'", ")", "if", "next_command", "is", "None", ":", "return", "False", "name", "=", "command", ".", "get_name", ...
Returns a boolean representing whether these commands can be grouped together or not. A few things are taken into account for this decision: For ``set`` commands: - Are all arguments other than the key/value the same? For ``delete`` and ``get`` commands: - Are all arguments other than the k...
[ "Returns", "a", "boolean", "representing", "whether", "these", "commands", "can", "be", "grouped", "together", "or", "not", "." ]
9b505840da47a34f758a830c3992fa5dcb7bb7ad
https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/db/backends/memcache.py#L97-L135
train
christophertbrown/bioscripts
ctbBio/rp16.py
find_databases
def find_databases(databases): """ define ribosomal proteins and location of curated databases """ # 16 ribosomal proteins in their expected order proteins = ['L15', 'L18', 'L6', 'S8', 'L5', 'L24', 'L14', 'S17', 'L16', 'S3', 'L22', 'S19', 'L2', 'L4', 'L3', 'S10'] # curated databases ...
python
def find_databases(databases): """ define ribosomal proteins and location of curated databases """ # 16 ribosomal proteins in their expected order proteins = ['L15', 'L18', 'L6', 'S8', 'L5', 'L24', 'L14', 'S17', 'L16', 'S3', 'L22', 'S19', 'L2', 'L4', 'L3', 'S10'] # curated databases ...
[ "def", "find_databases", "(", "databases", ")", ":", "proteins", "=", "[", "'L15'", ",", "'L18'", ",", "'L6'", ",", "'S8'", ",", "'L5'", ",", "'L24'", ",", "'L14'", ",", "'S17'", ",", "'L16'", ",", "'S3'", ",", "'L22'", ",", "'S19'", ",", "'L2'", "...
define ribosomal proteins and location of curated databases
[ "define", "ribosomal", "proteins", "and", "location", "of", "curated", "databases" ]
83b2566b3a5745437ec651cd6cafddd056846240
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rp16.py#L21-L48
train
christophertbrown/bioscripts
ctbBio/rp16.py
find_next
def find_next(start, stop, i2hits): """ which protein has the best hit, the one to the 'right' or to the 'left?' """ if start not in i2hits and stop in i2hits: index = stop elif stop not in i2hits and start in i2hits: index = start elif start not in i2hits and stop not in i2hits:...
python
def find_next(start, stop, i2hits): """ which protein has the best hit, the one to the 'right' or to the 'left?' """ if start not in i2hits and stop in i2hits: index = stop elif stop not in i2hits and start in i2hits: index = start elif start not in i2hits and stop not in i2hits:...
[ "def", "find_next", "(", "start", ",", "stop", ",", "i2hits", ")", ":", "if", "start", "not", "in", "i2hits", "and", "stop", "in", "i2hits", ":", "index", "=", "stop", "elif", "stop", "not", "in", "i2hits", "and", "start", "in", "i2hits", ":", "index...
which protein has the best hit, the one to the 'right' or to the 'left?'
[ "which", "protein", "has", "the", "best", "hit", "the", "one", "to", "the", "right", "or", "to", "the", "left?" ]
83b2566b3a5745437ec651cd6cafddd056846240
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rp16.py#L77-L102
train
christophertbrown/bioscripts
ctbBio/rp16.py
find_ribosomal
def find_ribosomal(rps, scaffolds, s2rp, min_hits, max_hits_rp, max_errors): """ determine which hits represent real ribosomal proteins, identify each in syntenic block max_hits_rp = maximum number of hits to consider per ribosomal protein per scaffold """ for scaffold, proteins in list(s2rp.items()...
python
def find_ribosomal(rps, scaffolds, s2rp, min_hits, max_hits_rp, max_errors): """ determine which hits represent real ribosomal proteins, identify each in syntenic block max_hits_rp = maximum number of hits to consider per ribosomal protein per scaffold """ for scaffold, proteins in list(s2rp.items()...
[ "def", "find_ribosomal", "(", "rps", ",", "scaffolds", ",", "s2rp", ",", "min_hits", ",", "max_hits_rp", ",", "max_errors", ")", ":", "for", "scaffold", ",", "proteins", "in", "list", "(", "s2rp", ".", "items", "(", ")", ")", ":", "hits", "=", "{", "...
determine which hits represent real ribosomal proteins, identify each in syntenic block max_hits_rp = maximum number of hits to consider per ribosomal protein per scaffold
[ "determine", "which", "hits", "represent", "real", "ribosomal", "proteins", "identify", "each", "in", "syntenic", "block", "max_hits_rp", "=", "maximum", "number", "of", "hits", "to", "consider", "per", "ribosomal", "protein", "per", "scaffold" ]
83b2566b3a5745437ec651cd6cafddd056846240
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rp16.py#L134-L150
train
smdabdoub/phylotoast
bin/filter_rep_set.py
filter_rep_set
def filter_rep_set(inF, otuSet): """ Parse the rep set file and remove all sequences not associated with unique OTUs. :@type inF: file :@param inF: The representative sequence set :@rtype: list :@return: The set of sequences associated with unique OTUs """ seqs = [] for record ...
python
def filter_rep_set(inF, otuSet): """ Parse the rep set file and remove all sequences not associated with unique OTUs. :@type inF: file :@param inF: The representative sequence set :@rtype: list :@return: The set of sequences associated with unique OTUs """ seqs = [] for record ...
[ "def", "filter_rep_set", "(", "inF", ",", "otuSet", ")", ":", "seqs", "=", "[", "]", "for", "record", "in", "SeqIO", ".", "parse", "(", "inF", ",", "\"fasta\"", ")", ":", "if", "record", ".", "id", "in", "otuSet", ":", "seqs", ".", "append", "(", ...
Parse the rep set file and remove all sequences not associated with unique OTUs. :@type inF: file :@param inF: The representative sequence set :@rtype: list :@return: The set of sequences associated with unique OTUs
[ "Parse", "the", "rep", "set", "file", "and", "remove", "all", "sequences", "not", "associated", "with", "unique", "OTUs", "." ]
0b74ef171e6a84761710548501dfac71285a58a3
https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/filter_rep_set.py#L32-L47
train
consbio/gis-metadata-parser
gis_metadata/arcgis_metadata_parser.py
ArcGISParser._update_report_item
def _update_report_item(self, **update_props): """ Update the text for each element at the configured path if attribute matches """ tree_to_update = update_props['tree_to_update'] prop = update_props['prop'] values = wrap_value(update_props['values']) xroot = self._get_xroot_for...
python
def _update_report_item(self, **update_props): """ Update the text for each element at the configured path if attribute matches """ tree_to_update = update_props['tree_to_update'] prop = update_props['prop'] values = wrap_value(update_props['values']) xroot = self._get_xroot_for...
[ "def", "_update_report_item", "(", "self", ",", "**", "update_props", ")", ":", "tree_to_update", "=", "update_props", "[", "'tree_to_update'", "]", "prop", "=", "update_props", "[", "'prop'", "]", "values", "=", "wrap_value", "(", "update_props", "[", "'values'...
Update the text for each element at the configured path if attribute matches
[ "Update", "the", "text", "for", "each", "element", "at", "the", "configured", "path", "if", "attribute", "matches" ]
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/arcgis_metadata_parser.py#L407-L440
train
adafruit/Adafruit_Python_VCNL40xx
Adafruit_VCNL40xx/VCNL40xx.py
VCNL4010._clear_interrupt
def _clear_interrupt(self, intbit): """Clear the specified interrupt bit in the interrupt status register. """ int_status = self._device.readU8(VCNL4010_INTSTAT); int_status &= ~intbit; self._device.write8(VCNL4010_INTSTAT, int_status);
python
def _clear_interrupt(self, intbit): """Clear the specified interrupt bit in the interrupt status register. """ int_status = self._device.readU8(VCNL4010_INTSTAT); int_status &= ~intbit; self._device.write8(VCNL4010_INTSTAT, int_status);
[ "def", "_clear_interrupt", "(", "self", ",", "intbit", ")", ":", "int_status", "=", "self", ".", "_device", ".", "readU8", "(", "VCNL4010_INTSTAT", ")", "int_status", "&=", "~", "intbit", "self", ".", "_device", ".", "write8", "(", "VCNL4010_INTSTAT", ",", ...
Clear the specified interrupt bit in the interrupt status register.
[ "Clear", "the", "specified", "interrupt", "bit", "in", "the", "interrupt", "status", "register", "." ]
f88ec755fd23017028b6dec1be0607ff4a018e10
https://github.com/adafruit/Adafruit_Python_VCNL40xx/blob/f88ec755fd23017028b6dec1be0607ff4a018e10/Adafruit_VCNL40xx/VCNL40xx.py#L123-L128
train
skojaku/core-periphery-detection
cpalgorithm/Rombach.py
SimAlg.move
def move(self): """Swaps two nodes""" a = random.randint(0, len(self.state) - 1) b = random.randint(0, len(self.state) - 1) self.state[[a,b]] = self.state[[b,a]]
python
def move(self): """Swaps two nodes""" a = random.randint(0, len(self.state) - 1) b = random.randint(0, len(self.state) - 1) self.state[[a,b]] = self.state[[b,a]]
[ "def", "move", "(", "self", ")", ":", "a", "=", "random", ".", "randint", "(", "0", ",", "len", "(", "self", ".", "state", ")", "-", "1", ")", "b", "=", "random", ".", "randint", "(", "0", ",", "len", "(", "self", ".", "state", ")", "-", "1...
Swaps two nodes
[ "Swaps", "two", "nodes" ]
d724e6441066622506ddb54d81ee9a1cfd15f766
https://github.com/skojaku/core-periphery-detection/blob/d724e6441066622506ddb54d81ee9a1cfd15f766/cpalgorithm/Rombach.py#L19-L23
train
wbond/certbuilder
certbuilder/__init__.py
CertificateBuilder.self_signed
def self_signed(self, value): """ A bool - if the certificate should be self-signed. """ self._self_signed = bool(value) if self._self_signed: self._issuer = None
python
def self_signed(self, value): """ A bool - if the certificate should be self-signed. """ self._self_signed = bool(value) if self._self_signed: self._issuer = None
[ "def", "self_signed", "(", "self", ",", "value", ")", ":", "self", ".", "_self_signed", "=", "bool", "(", "value", ")", "if", "self", ".", "_self_signed", ":", "self", ".", "_issuer", "=", "None" ]
A bool - if the certificate should be self-signed.
[ "A", "bool", "-", "if", "the", "certificate", "should", "be", "self", "-", "signed", "." ]
969dae884fa7f73988bbf1dcbec4fb51e234a3c5
https://github.com/wbond/certbuilder/blob/969dae884fa7f73988bbf1dcbec4fb51e234a3c5/certbuilder/__init__.py#L122-L130
train
wbond/certbuilder
certbuilder/__init__.py
CertificateBuilder._get_crl_url
def _get_crl_url(self, distribution_points): """ Grabs the first URL out of a asn1crypto.x509.CRLDistributionPoints object :param distribution_points: The x509.CRLDistributionPoints object to pull the URL out of :return: A unicode string or None ...
python
def _get_crl_url(self, distribution_points): """ Grabs the first URL out of a asn1crypto.x509.CRLDistributionPoints object :param distribution_points: The x509.CRLDistributionPoints object to pull the URL out of :return: A unicode string or None ...
[ "def", "_get_crl_url", "(", "self", ",", "distribution_points", ")", ":", "if", "distribution_points", "is", "None", ":", "return", "None", "for", "distribution_point", "in", "distribution_points", ":", "name", "=", "distribution_point", "[", "'distribution_point'", ...
Grabs the first URL out of a asn1crypto.x509.CRLDistributionPoints object :param distribution_points: The x509.CRLDistributionPoints object to pull the URL out of :return: A unicode string or None
[ "Grabs", "the", "first", "URL", "out", "of", "a", "asn1crypto", ".", "x509", ".", "CRLDistributionPoints", "object" ]
969dae884fa7f73988bbf1dcbec4fb51e234a3c5
https://github.com/wbond/certbuilder/blob/969dae884fa7f73988bbf1dcbec4fb51e234a3c5/certbuilder/__init__.py#L544-L564
train
wbond/certbuilder
certbuilder/__init__.py
CertificateBuilder.ocsp_no_check
def ocsp_no_check(self, value): """ A bool - if the certificate should have the OCSP no check extension. Only applicable to certificates created for signing OCSP responses. Such certificates should normally be issued for a very short period of time since they are effectively whit...
python
def ocsp_no_check(self, value): """ A bool - if the certificate should have the OCSP no check extension. Only applicable to certificates created for signing OCSP responses. Such certificates should normally be issued for a very short period of time since they are effectively whit...
[ "def", "ocsp_no_check", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "self", ".", "_ocsp_no_check", "=", "None", "else", ":", "self", ".", "_ocsp_no_check", "=", "bool", "(", "value", ")" ]
A bool - if the certificate should have the OCSP no check extension. Only applicable to certificates created for signing OCSP responses. Such certificates should normally be issued for a very short period of time since they are effectively whitelisted by clients.
[ "A", "bool", "-", "if", "the", "certificate", "should", "have", "the", "OCSP", "no", "check", "extension", ".", "Only", "applicable", "to", "certificates", "created", "for", "signing", "OCSP", "responses", ".", "Such", "certificates", "should", "normally", "be...
969dae884fa7f73988bbf1dcbec4fb51e234a3c5
https://github.com/wbond/certbuilder/blob/969dae884fa7f73988bbf1dcbec4fb51e234a3c5/certbuilder/__init__.py#L688-L699
train
tell-k/django-modelsdoc
modelsdoc/templatetags/modelsdoc_tags.py
emptylineless
def emptylineless(parser, token): """ Removes empty line. Example usage:: {% emptylineless %} test1 test2 test3 {% endemptylineless %} This example would return this HTML:: test1 test2 test3 """ nodeli...
python
def emptylineless(parser, token): """ Removes empty line. Example usage:: {% emptylineless %} test1 test2 test3 {% endemptylineless %} This example would return this HTML:: test1 test2 test3 """ nodeli...
[ "def", "emptylineless", "(", "parser", ",", "token", ")", ":", "nodelist", "=", "parser", ".", "parse", "(", "(", "'endemptylineless'", ",", ")", ")", "parser", ".", "delete_first_token", "(", ")", "return", "EmptylinelessNode", "(", "nodelist", ")" ]
Removes empty line. Example usage:: {% emptylineless %} test1 test2 test3 {% endemptylineless %} This example would return this HTML:: test1 test2 test3
[ "Removes", "empty", "line", "." ]
c9d336e76251feb142347b3a41365430d3365436
https://github.com/tell-k/django-modelsdoc/blob/c9d336e76251feb142347b3a41365430d3365436/modelsdoc/templatetags/modelsdoc_tags.py#L31-L54
train
justquick/python-varnish
varnish.py
http_purge_url
def http_purge_url(url): """ Do an HTTP PURGE of the given asset. The URL is run through urlparse and must point to the varnish instance not the varnishadm """ url = urlparse(url) connection = HTTPConnection(url.hostname, url.port or 80) path = url.path or '/' connection.request('PURGE',...
python
def http_purge_url(url): """ Do an HTTP PURGE of the given asset. The URL is run through urlparse and must point to the varnish instance not the varnishadm """ url = urlparse(url) connection = HTTPConnection(url.hostname, url.port or 80) path = url.path or '/' connection.request('PURGE',...
[ "def", "http_purge_url", "(", "url", ")", ":", "url", "=", "urlparse", "(", "url", ")", "connection", "=", "HTTPConnection", "(", "url", ".", "hostname", ",", "url", ".", "port", "or", "80", ")", "path", "=", "url", ".", "path", "or", "'/'", "connect...
Do an HTTP PURGE of the given asset. The URL is run through urlparse and must point to the varnish instance not the varnishadm
[ "Do", "an", "HTTP", "PURGE", "of", "the", "given", "asset", ".", "The", "URL", "is", "run", "through", "urlparse", "and", "must", "point", "to", "the", "varnish", "instance", "not", "the", "varnishadm" ]
8f114c74898e6c5ade2ce49c8b595040bd150465
https://github.com/justquick/python-varnish/blob/8f114c74898e6c5ade2ce49c8b595040bd150465/varnish.py#L47-L60
train
justquick/python-varnish
varnish.py
run
def run(addr, *commands, **kwargs): """ Non-threaded batch command runner returning output results """ results = [] handler = VarnishHandler(addr, **kwargs) for cmd in commands: if isinstance(cmd, tuple) and len(cmd)>1: results.extend([getattr(handler, c[0].replace('.','_'))(...
python
def run(addr, *commands, **kwargs): """ Non-threaded batch command runner returning output results """ results = [] handler = VarnishHandler(addr, **kwargs) for cmd in commands: if isinstance(cmd, tuple) and len(cmd)>1: results.extend([getattr(handler, c[0].replace('.','_'))(...
[ "def", "run", "(", "addr", ",", "*", "commands", ",", "**", "kwargs", ")", ":", "results", "=", "[", "]", "handler", "=", "VarnishHandler", "(", "addr", ",", "**", "kwargs", ")", "for", "cmd", "in", "commands", ":", "if", "isinstance", "(", "cmd", ...
Non-threaded batch command runner returning output results
[ "Non", "-", "threaded", "batch", "command", "runner", "returning", "output", "results" ]
8f114c74898e6c5ade2ce49c8b595040bd150465
https://github.com/justquick/python-varnish/blob/8f114c74898e6c5ade2ce49c8b595040bd150465/varnish.py#L289-L302
train
madeindjs/Super-Markdown
SuperMarkdown/SuperMarkdown.py
SuperMarkdown.add_stylesheets
def add_stylesheets(self, *css_files): """add stylesheet files in HTML head""" for css_file in css_files: self.main_soup.style.append(self._text_file(css_file))
python
def add_stylesheets(self, *css_files): """add stylesheet files in HTML head""" for css_file in css_files: self.main_soup.style.append(self._text_file(css_file))
[ "def", "add_stylesheets", "(", "self", ",", "*", "css_files", ")", ":", "for", "css_file", "in", "css_files", ":", "self", ".", "main_soup", ".", "style", ".", "append", "(", "self", ".", "_text_file", "(", "css_file", ")", ")" ]
add stylesheet files in HTML head
[ "add", "stylesheet", "files", "in", "HTML", "head" ]
fe2da746afa6a27aaaad27a2db1dca234f802eb0
https://github.com/madeindjs/Super-Markdown/blob/fe2da746afa6a27aaaad27a2db1dca234f802eb0/SuperMarkdown/SuperMarkdown.py#L43-L46
train
madeindjs/Super-Markdown
SuperMarkdown/SuperMarkdown.py
SuperMarkdown.add_javascripts
def add_javascripts(self, *js_files): """add javascripts files in HTML body""" # create the script tag if don't exists if self.main_soup.script is None: script_tag = self.main_soup.new_tag('script') self.main_soup.body.append(script_tag) for js_file in js_files: ...
python
def add_javascripts(self, *js_files): """add javascripts files in HTML body""" # create the script tag if don't exists if self.main_soup.script is None: script_tag = self.main_soup.new_tag('script') self.main_soup.body.append(script_tag) for js_file in js_files: ...
[ "def", "add_javascripts", "(", "self", ",", "*", "js_files", ")", ":", "if", "self", ".", "main_soup", ".", "script", "is", "None", ":", "script_tag", "=", "self", ".", "main_soup", ".", "new_tag", "(", "'script'", ")", "self", ".", "main_soup", ".", "...
add javascripts files in HTML body
[ "add", "javascripts", "files", "in", "HTML", "body" ]
fe2da746afa6a27aaaad27a2db1dca234f802eb0
https://github.com/madeindjs/Super-Markdown/blob/fe2da746afa6a27aaaad27a2db1dca234f802eb0/SuperMarkdown/SuperMarkdown.py#L48-L56
train
madeindjs/Super-Markdown
SuperMarkdown/SuperMarkdown.py
SuperMarkdown.export
def export(self): """return the object in a file""" with open(self.export_url, 'w', encoding='utf-8') as file: file.write(self.build()) if self.open_browser: webbrowser.open_new_tab(self.export_url)
python
def export(self): """return the object in a file""" with open(self.export_url, 'w', encoding='utf-8') as file: file.write(self.build()) if self.open_browser: webbrowser.open_new_tab(self.export_url)
[ "def", "export", "(", "self", ")", ":", "with", "open", "(", "self", ".", "export_url", ",", "'w'", ",", "encoding", "=", "'utf-8'", ")", "as", "file", ":", "file", ".", "write", "(", "self", ".", "build", "(", ")", ")", "if", "self", ".", "open_...
return the object in a file
[ "return", "the", "object", "in", "a", "file" ]
fe2da746afa6a27aaaad27a2db1dca234f802eb0
https://github.com/madeindjs/Super-Markdown/blob/fe2da746afa6a27aaaad27a2db1dca234f802eb0/SuperMarkdown/SuperMarkdown.py#L58-L64
train
madeindjs/Super-Markdown
SuperMarkdown/SuperMarkdown.py
SuperMarkdown.build
def build(self): """convert Markdown text as html. return the html file as string""" markdown_html = markdown.markdown(self.markdown_text, extensions=[ TocExtension(), 'fenced_code', 'markdown_checklist.extension', 'markdown.extensions.tables']) markdown_soup = Be...
python
def build(self): """convert Markdown text as html. return the html file as string""" markdown_html = markdown.markdown(self.markdown_text, extensions=[ TocExtension(), 'fenced_code', 'markdown_checklist.extension', 'markdown.extensions.tables']) markdown_soup = Be...
[ "def", "build", "(", "self", ")", ":", "markdown_html", "=", "markdown", ".", "markdown", "(", "self", ".", "markdown_text", ",", "extensions", "=", "[", "TocExtension", "(", ")", ",", "'fenced_code'", ",", "'markdown_checklist.extension'", ",", "'markdown.exten...
convert Markdown text as html. return the html file as string
[ "convert", "Markdown", "text", "as", "html", ".", "return", "the", "html", "file", "as", "string" ]
fe2da746afa6a27aaaad27a2db1dca234f802eb0
https://github.com/madeindjs/Super-Markdown/blob/fe2da746afa6a27aaaad27a2db1dca234f802eb0/SuperMarkdown/SuperMarkdown.py#L66-L84
train
madeindjs/Super-Markdown
SuperMarkdown/SuperMarkdown.py
SuperMarkdown._text_file
def _text_file(self, url): """return the content of a file""" try: with open(url, 'r', encoding='utf-8') as file: return file.read() except FileNotFoundError: print('File `{}` not found'.format(url)) sys.exit(0)
python
def _text_file(self, url): """return the content of a file""" try: with open(url, 'r', encoding='utf-8') as file: return file.read() except FileNotFoundError: print('File `{}` not found'.format(url)) sys.exit(0)
[ "def", "_text_file", "(", "self", ",", "url", ")", ":", "try", ":", "with", "open", "(", "url", ",", "'r'", ",", "encoding", "=", "'utf-8'", ")", "as", "file", ":", "return", "file", ".", "read", "(", ")", "except", "FileNotFoundError", ":", "print",...
return the content of a file
[ "return", "the", "content", "of", "a", "file" ]
fe2da746afa6a27aaaad27a2db1dca234f802eb0
https://github.com/madeindjs/Super-Markdown/blob/fe2da746afa6a27aaaad27a2db1dca234f802eb0/SuperMarkdown/SuperMarkdown.py#L86-L93
train
madeindjs/Super-Markdown
SuperMarkdown/SuperMarkdown.py
SuperMarkdown._text_to_graphiz
def _text_to_graphiz(self, text): """create a graphviz graph from text""" dot = Source(text, format='svg') return dot.pipe().decode('utf-8')
python
def _text_to_graphiz(self, text): """create a graphviz graph from text""" dot = Source(text, format='svg') return dot.pipe().decode('utf-8')
[ "def", "_text_to_graphiz", "(", "self", ",", "text", ")", ":", "dot", "=", "Source", "(", "text", ",", "format", "=", "'svg'", ")", "return", "dot", ".", "pipe", "(", ")", ".", "decode", "(", "'utf-8'", ")" ]
create a graphviz graph from text
[ "create", "a", "graphviz", "graph", "from", "text" ]
fe2da746afa6a27aaaad27a2db1dca234f802eb0
https://github.com/madeindjs/Super-Markdown/blob/fe2da746afa6a27aaaad27a2db1dca234f802eb0/SuperMarkdown/SuperMarkdown.py#L95-L98
train
madeindjs/Super-Markdown
SuperMarkdown/SuperMarkdown.py
SuperMarkdown._add_mermaid_js
def _add_mermaid_js(self): """add js libraries and css files of mermaid js_file""" self.add_javascripts('{}/js/jquery-1.11.3.min.js'.format(self.resources_path)) self.add_javascripts('{}/js/mermaid.min.js'.format(self.resources_path)) self.add_stylesheets('{}/css/mermaid.css'.format(self...
python
def _add_mermaid_js(self): """add js libraries and css files of mermaid js_file""" self.add_javascripts('{}/js/jquery-1.11.3.min.js'.format(self.resources_path)) self.add_javascripts('{}/js/mermaid.min.js'.format(self.resources_path)) self.add_stylesheets('{}/css/mermaid.css'.format(self...
[ "def", "_add_mermaid_js", "(", "self", ")", ":", "self", ".", "add_javascripts", "(", "'{}/js/jquery-1.11.3.min.js'", ".", "format", "(", "self", ".", "resources_path", ")", ")", "self", ".", "add_javascripts", "(", "'{}/js/mermaid.min.js'", ".", "format", "(", ...
add js libraries and css files of mermaid js_file
[ "add", "js", "libraries", "and", "css", "files", "of", "mermaid", "js_file" ]
fe2da746afa6a27aaaad27a2db1dca234f802eb0
https://github.com/madeindjs/Super-Markdown/blob/fe2da746afa6a27aaaad27a2db1dca234f802eb0/SuperMarkdown/SuperMarkdown.py#L100-L105
train
paul-wolf/strgen
strgen/__init__.py
StringGenerator.getCharacterSet
def getCharacterSet(self): '''Get a character set with individual members or ranges. Current index is on '[', the start of the character set. ''' chars = u'' c = None cnt = 1 start = 0 while True: escaped_slash = False c...
python
def getCharacterSet(self): '''Get a character set with individual members or ranges. Current index is on '[', the start of the character set. ''' chars = u'' c = None cnt = 1 start = 0 while True: escaped_slash = False c...
[ "def", "getCharacterSet", "(", "self", ")", ":", "chars", "=", "u''", "c", "=", "None", "cnt", "=", "1", "start", "=", "0", "while", "True", ":", "escaped_slash", "=", "False", "c", "=", "self", ".", "next", "(", ")", "if", "self", ".", "lookahead"...
Get a character set with individual members or ranges. Current index is on '[', the start of the character set.
[ "Get", "a", "character", "set", "with", "individual", "members", "or", "ranges", "." ]
ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f
https://github.com/paul-wolf/strgen/blob/ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f/strgen/__init__.py#L368-L419
train
paul-wolf/strgen
strgen/__init__.py
StringGenerator.getLiteral
def getLiteral(self): '''Get a sequence of non-special characters.''' # we are on the first non-special character chars = u'' c = self.current() while True: if c and c == u"\\": c = self.next() if c: chars += c ...
python
def getLiteral(self): '''Get a sequence of non-special characters.''' # we are on the first non-special character chars = u'' c = self.current() while True: if c and c == u"\\": c = self.next() if c: chars += c ...
[ "def", "getLiteral", "(", "self", ")", ":", "chars", "=", "u''", "c", "=", "self", ".", "current", "(", ")", "while", "True", ":", "if", "c", "and", "c", "==", "u\"\\\\\"", ":", "c", "=", "self", ".", "next", "(", ")", "if", "c", ":", "chars", ...
Get a sequence of non-special characters.
[ "Get", "a", "sequence", "of", "non", "-", "special", "characters", "." ]
ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f
https://github.com/paul-wolf/strgen/blob/ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f/strgen/__init__.py#L421-L439
train
paul-wolf/strgen
strgen/__init__.py
StringGenerator.getSequence
def getSequence(self, level=0): '''Get a sequence of nodes.''' seq = [] op = '' left_operand = None right_operand = None sequence_closed = False while True: c = self.next() if not c: break if c and c not in self...
python
def getSequence(self, level=0): '''Get a sequence of nodes.''' seq = [] op = '' left_operand = None right_operand = None sequence_closed = False while True: c = self.next() if not c: break if c and c not in self...
[ "def", "getSequence", "(", "self", ",", "level", "=", "0", ")", ":", "seq", "=", "[", "]", "op", "=", "''", "left_operand", "=", "None", "right_operand", "=", "None", "sequence_closed", "=", "False", "while", "True", ":", "c", "=", "self", ".", "next...
Get a sequence of nodes.
[ "Get", "a", "sequence", "of", "nodes", "." ]
ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f
https://github.com/paul-wolf/strgen/blob/ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f/strgen/__init__.py#L441-L501
train
paul-wolf/strgen
strgen/__init__.py
StringGenerator.dump
def dump(self, **kwargs): import sys '''Print the parse tree and then call render for an example.''' if not self.seq: self.seq = self.getSequence() print("StringGenerator version: %s" % (__version__)) print("Python version: %s" % sys.version) # this doesn't wo...
python
def dump(self, **kwargs): import sys '''Print the parse tree and then call render for an example.''' if not self.seq: self.seq = self.getSequence() print("StringGenerator version: %s" % (__version__)) print("Python version: %s" % sys.version) # this doesn't wo...
[ "def", "dump", "(", "self", ",", "**", "kwargs", ")", ":", "import", "sys", "if", "not", "self", ".", "seq", ":", "self", ".", "seq", "=", "self", ".", "getSequence", "(", ")", "print", "(", "\"StringGenerator version: %s\"", "%", "(", "__version__", "...
Print the parse tree and then call render for an example.
[ "Print", "the", "parse", "tree", "and", "then", "call", "render", "for", "an", "example", "." ]
ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f
https://github.com/paul-wolf/strgen/blob/ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f/strgen/__init__.py#L521-L531
train
paul-wolf/strgen
strgen/__init__.py
StringGenerator.render_list
def render_list(self, cnt, unique=False, progress_callback=None, **kwargs): '''Return a list of generated strings. Args: cnt (int): length of list unique (bool): whether to make entries unique Returns: list. We keep track of total attempts because a...
python
def render_list(self, cnt, unique=False, progress_callback=None, **kwargs): '''Return a list of generated strings. Args: cnt (int): length of list unique (bool): whether to make entries unique Returns: list. We keep track of total attempts because a...
[ "def", "render_list", "(", "self", ",", "cnt", ",", "unique", "=", "False", ",", "progress_callback", "=", "None", ",", "**", "kwargs", ")", ":", "rendered_list", "=", "[", "]", "i", "=", "0", "total_attempts", "=", "0", "while", "True", ":", "if", "...
Return a list of generated strings. Args: cnt (int): length of list unique (bool): whether to make entries unique Returns: list. We keep track of total attempts because a template may specify something impossible to attain, like [1-9]{} with cnt==10...
[ "Return", "a", "list", "of", "generated", "strings", "." ]
ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f
https://github.com/paul-wolf/strgen/blob/ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f/strgen/__init__.py#L533-L570
train
seperman/s3utils
s3utils/s3utils.py
S3utils.connect
def connect(self): """ Establish the connection. This is done automatically for you. If you lose the connection, you can manually run this to be re-connected. """ self.conn = boto.connect_s3(self.AWS_ACCESS_KEY_ID, self.AWS_SECRET_ACCESS_KEY, debug=self.S3UTILS_DEBUG_LEVEL) ...
python
def connect(self): """ Establish the connection. This is done automatically for you. If you lose the connection, you can manually run this to be re-connected. """ self.conn = boto.connect_s3(self.AWS_ACCESS_KEY_ID, self.AWS_SECRET_ACCESS_KEY, debug=self.S3UTILS_DEBUG_LEVEL) ...
[ "def", "connect", "(", "self", ")", ":", "self", ".", "conn", "=", "boto", ".", "connect_s3", "(", "self", ".", "AWS_ACCESS_KEY_ID", ",", "self", ".", "AWS_SECRET_ACCESS_KEY", ",", "debug", "=", "self", ".", "S3UTILS_DEBUG_LEVEL", ")", "self", ".", "bucket...
Establish the connection. This is done automatically for you. If you lose the connection, you can manually run this to be re-connected.
[ "Establish", "the", "connection", ".", "This", "is", "done", "automatically", "for", "you", "." ]
aea41388a023dcf1e95588402077e31097514cf1
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L145-L155
train
seperman/s3utils
s3utils/s3utils.py
S3utils.connect_cloudfront
def connect_cloudfront(self): "Connect to Cloud Front. This is done automatically for you when needed." self.conn_cloudfront = connect_cloudfront(self.AWS_ACCESS_KEY_ID, self.AWS_SECRET_ACCESS_KEY, debug=self.S3UTILS_DEBUG_LEVEL)
python
def connect_cloudfront(self): "Connect to Cloud Front. This is done automatically for you when needed." self.conn_cloudfront = connect_cloudfront(self.AWS_ACCESS_KEY_ID, self.AWS_SECRET_ACCESS_KEY, debug=self.S3UTILS_DEBUG_LEVEL)
[ "def", "connect_cloudfront", "(", "self", ")", ":", "\"Connect to Cloud Front. This is done automatically for you when needed.\"", "self", ".", "conn_cloudfront", "=", "connect_cloudfront", "(", "self", ".", "AWS_ACCESS_KEY_ID", ",", "self", ".", "AWS_SECRET_ACCESS_KEY", ",",...
Connect to Cloud Front. This is done automatically for you when needed.
[ "Connect", "to", "Cloud", "Front", ".", "This", "is", "done", "automatically", "for", "you", "when", "needed", "." ]
aea41388a023dcf1e95588402077e31097514cf1
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L166-L168
train
seperman/s3utils
s3utils/s3utils.py
S3utils.mkdir
def mkdir(self, target_folder): """ Create a folder on S3. Examples -------- >>> s3utils.mkdir("path/to/my_folder") Making directory: path/to/my_folder """ self.printv("Making directory: %s" % target_folder) self.k.key = re.sub(r"^/|/$", "...
python
def mkdir(self, target_folder): """ Create a folder on S3. Examples -------- >>> s3utils.mkdir("path/to/my_folder") Making directory: path/to/my_folder """ self.printv("Making directory: %s" % target_folder) self.k.key = re.sub(r"^/|/$", "...
[ "def", "mkdir", "(", "self", ",", "target_folder", ")", ":", "self", ".", "printv", "(", "\"Making directory: %s\"", "%", "target_folder", ")", "self", ".", "k", ".", "key", "=", "re", ".", "sub", "(", "r\"^/|/$\"", ",", "\"\"", ",", "target_folder", ")"...
Create a folder on S3. Examples -------- >>> s3utils.mkdir("path/to/my_folder") Making directory: path/to/my_folder
[ "Create", "a", "folder", "on", "S3", "." ]
aea41388a023dcf1e95588402077e31097514cf1
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L171-L183
train
seperman/s3utils
s3utils/s3utils.py
S3utils.rm
def rm(self, path): """ Delete the path and anything under the path. Example ------- >>> s3utils.rm("path/to/file_or_folder") """ list_of_files = list(self.ls(path)) if list_of_files: if len(list_of_files) == 1: self.buck...
python
def rm(self, path): """ Delete the path and anything under the path. Example ------- >>> s3utils.rm("path/to/file_or_folder") """ list_of_files = list(self.ls(path)) if list_of_files: if len(list_of_files) == 1: self.buck...
[ "def", "rm", "(", "self", ",", "path", ")", ":", "list_of_files", "=", "list", "(", "self", ".", "ls", "(", "path", ")", ")", "if", "list_of_files", ":", "if", "len", "(", "list_of_files", ")", "==", "1", ":", "self", ".", "bucket", ".", "delete_ke...
Delete the path and anything under the path. Example ------- >>> s3utils.rm("path/to/file_or_folder")
[ "Delete", "the", "path", "and", "anything", "under", "the", "path", "." ]
aea41388a023dcf1e95588402077e31097514cf1
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L186-L204
train
seperman/s3utils
s3utils/s3utils.py
S3utils.__put_key
def __put_key(self, local_file, target_file, acl='public-read', del_after_upload=False, overwrite=True, source="filename"): """Copy a file to s3.""" action_word = "moving" if del_after_upload else "copying" try: self.k.key = target_file # setting the path (key) of file in the conta...
python
def __put_key(self, local_file, target_file, acl='public-read', del_after_upload=False, overwrite=True, source="filename"): """Copy a file to s3.""" action_word = "moving" if del_after_upload else "copying" try: self.k.key = target_file # setting the path (key) of file in the conta...
[ "def", "__put_key", "(", "self", ",", "local_file", ",", "target_file", ",", "acl", "=", "'public-read'", ",", "del_after_upload", "=", "False", ",", "overwrite", "=", "True", ",", "source", "=", "\"filename\"", ")", ":", "action_word", "=", "\"moving\"", "i...
Copy a file to s3.
[ "Copy", "a", "file", "to", "s3", "." ]
aea41388a023dcf1e95588402077e31097514cf1
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L207-L238
train
seperman/s3utils
s3utils/s3utils.py
S3utils.cp
def cp(self, local_path, target_path, acl='public-read', del_after_upload=False, overwrite=True, invalidate=False): """ Copy a file or folder from local to s3. Parameters ---------- local_path : string Path to file or folder. Or if you want to copy only t...
python
def cp(self, local_path, target_path, acl='public-read', del_after_upload=False, overwrite=True, invalidate=False): """ Copy a file or folder from local to s3. Parameters ---------- local_path : string Path to file or folder. Or if you want to copy only t...
[ "def", "cp", "(", "self", ",", "local_path", ",", "target_path", ",", "acl", "=", "'public-read'", ",", "del_after_upload", "=", "False", ",", "overwrite", "=", "True", ",", "invalidate", "=", "False", ")", ":", "result", "=", "None", "if", "overwrite", ...
Copy a file or folder from local to s3. Parameters ---------- local_path : string Path to file or folder. Or if you want to copy only the contents of folder, add /* at the end of folder name target_path : string Target path on S3 bucket. acl : string, ...
[ "Copy", "a", "file", "or", "folder", "from", "local", "to", "s3", "." ]
aea41388a023dcf1e95588402077e31097514cf1
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L240-L336
train
seperman/s3utils
s3utils/s3utils.py
S3utils.mv
def mv(self, local_file, target_file, acl='public-read', overwrite=True, invalidate=False): """ Similar to Linux mv command. Move the file to the S3 and deletes the local copy It is basically s3utils.cp that has del_after_upload=True Examples -------- >>> s...
python
def mv(self, local_file, target_file, acl='public-read', overwrite=True, invalidate=False): """ Similar to Linux mv command. Move the file to the S3 and deletes the local copy It is basically s3utils.cp that has del_after_upload=True Examples -------- >>> s...
[ "def", "mv", "(", "self", ",", "local_file", ",", "target_file", ",", "acl", "=", "'public-read'", ",", "overwrite", "=", "True", ",", "invalidate", "=", "False", ")", ":", "self", ".", "cp", "(", "local_file", ",", "target_file", ",", "acl", "=", "acl...
Similar to Linux mv command. Move the file to the S3 and deletes the local copy It is basically s3utils.cp that has del_after_upload=True Examples -------- >>> s3utils.mv("path/to/folder","/test/") moving /path/to/myfolder/test2.txt to test/myfolder/test2.txt ...
[ "Similar", "to", "Linux", "mv", "command", "." ]
aea41388a023dcf1e95588402077e31097514cf1
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L483-L507
train
seperman/s3utils
s3utils/s3utils.py
S3utils.cp_cropduster_image
def cp_cropduster_image(self, the_image_path, del_after_upload=False, overwrite=False, invalidate=False): """ Deal with saving cropduster images to S3. Cropduster is a Django library for resizing editorial images. S3utils was originally written to put cropduster images on S3 bucket. Ext...
python
def cp_cropduster_image(self, the_image_path, del_after_upload=False, overwrite=False, invalidate=False): """ Deal with saving cropduster images to S3. Cropduster is a Django library for resizing editorial images. S3utils was originally written to put cropduster images on S3 bucket. Ext...
[ "def", "cp_cropduster_image", "(", "self", ",", "the_image_path", ",", "del_after_upload", "=", "False", ",", "overwrite", "=", "False", ",", "invalidate", "=", "False", ")", ":", "local_file", "=", "os", ".", "path", ".", "join", "(", "settings", ".", "ME...
Deal with saving cropduster images to S3. Cropduster is a Django library for resizing editorial images. S3utils was originally written to put cropduster images on S3 bucket. Extra Items in your Django Settings ----------------------------------- MEDIA_ROOT : string Django m...
[ "Deal", "with", "saving", "cropduster", "images", "to", "S3", ".", "Cropduster", "is", "a", "Django", "library", "for", "resizing", "editorial", "images", ".", "S3utils", "was", "originally", "written", "to", "put", "cropduster", "images", "on", "S3", "bucket"...
aea41388a023dcf1e95588402077e31097514cf1
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L510-L551
train
seperman/s3utils
s3utils/s3utils.py
S3utils.chmod
def chmod(self, target_file, acl='public-read'): """ sets permissions for a file on S3 Parameters ---------- target_file : string Path to file on S3 acl : string, optional File permissions on S3. Default is public-read options: ...
python
def chmod(self, target_file, acl='public-read'): """ sets permissions for a file on S3 Parameters ---------- target_file : string Path to file on S3 acl : string, optional File permissions on S3. Default is public-read options: ...
[ "def", "chmod", "(", "self", ",", "target_file", ",", "acl", "=", "'public-read'", ")", ":", "self", ".", "k", ".", "key", "=", "target_file", "self", ".", "k", ".", "set_acl", "(", "acl", ")", "self", ".", "k", ".", "close", "(", ")" ]
sets permissions for a file on S3 Parameters ---------- target_file : string Path to file on S3 acl : string, optional File permissions on S3. Default is public-read options: - private: Owner gets FULL_CONTROL. No one else has any a...
[ "sets", "permissions", "for", "a", "file", "on", "S3" ]
aea41388a023dcf1e95588402077e31097514cf1
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L582-L610
train
seperman/s3utils
s3utils/s3utils.py
S3utils.ll
def ll(self, folder="", begin_from_file="", num=-1, all_grant_data=False): """ Get the list of files and permissions from S3. This is similar to LL (ls -lah) in Linux: List of files with permissions. Parameters ---------- folder : string Path to file on S3 ...
python
def ll(self, folder="", begin_from_file="", num=-1, all_grant_data=False): """ Get the list of files and permissions from S3. This is similar to LL (ls -lah) in Linux: List of files with permissions. Parameters ---------- folder : string Path to file on S3 ...
[ "def", "ll", "(", "self", ",", "folder", "=", "\"\"", ",", "begin_from_file", "=", "\"\"", ",", "num", "=", "-", "1", ",", "all_grant_data", "=", "False", ")", ":", "return", "self", ".", "ls", "(", "folder", "=", "folder", ",", "begin_from_file", "=...
Get the list of files and permissions from S3. This is similar to LL (ls -lah) in Linux: List of files with permissions. Parameters ---------- folder : string Path to file on S3 num: integer, optional number of results to return, by default it returns ...
[ "Get", "the", "list", "of", "files", "and", "permissions", "from", "S3", "." ]
aea41388a023dcf1e95588402077e31097514cf1
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L669-L764
train
uktrade/directory-signature-auth
sigauth/helpers.py
get_path
def get_path(url): """ Get the path from a given url, including the querystring. Args: url (str) Returns: str """ url = urlsplit(url) path = url.path if url.query: path += "?{}".format(url.query) return path
python
def get_path(url): """ Get the path from a given url, including the querystring. Args: url (str) Returns: str """ url = urlsplit(url) path = url.path if url.query: path += "?{}".format(url.query) return path
[ "def", "get_path", "(", "url", ")", ":", "url", "=", "urlsplit", "(", "url", ")", "path", "=", "url", ".", "path", "if", "url", ".", "query", ":", "path", "+=", "\"?{}\"", ".", "format", "(", "url", ".", "query", ")", "return", "path" ]
Get the path from a given url, including the querystring. Args: url (str) Returns: str
[ "Get", "the", "path", "from", "a", "given", "url", "including", "the", "querystring", "." ]
1a1b1e887b25a938133d7bcc146d3fecf1079313
https://github.com/uktrade/directory-signature-auth/blob/1a1b1e887b25a938133d7bcc146d3fecf1079313/sigauth/helpers.py#L79-L94
train
vkruoso/receita-tools
receita/tools/build.py
Build.run
def run(self): """Reads data from disk and generates CSV files.""" # Try to create the directory if not os.path.exists(self.output): try: os.mkdir(self.output) except: print 'failed to create output directory %s' % self.output # Be...
python
def run(self): """Reads data from disk and generates CSV files.""" # Try to create the directory if not os.path.exists(self.output): try: os.mkdir(self.output) except: print 'failed to create output directory %s' % self.output # Be...
[ "def", "run", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "output", ")", ":", "try", ":", "os", ".", "mkdir", "(", "self", ".", "output", ")", "except", ":", "print", "'failed to create output directory %s'",...
Reads data from disk and generates CSV files.
[ "Reads", "data", "from", "disk", "and", "generates", "CSV", "files", "." ]
fd62a252c76541c9feac6470b9048b31348ffe86
https://github.com/vkruoso/receita-tools/blob/fd62a252c76541c9feac6470b9048b31348ffe86/receita/tools/build.py#L144-L175
train
marrow/mongo
marrow/mongo/core/index.py
Index.process_fields
def process_fields(self, fields): """Process a list of simple string field definitions and assign their order based on prefix.""" result = [] strip = ''.join(self.PREFIX_MAP) for field in fields: direction = self.PREFIX_MAP[''] if field[0] in self.PREFIX_MAP: direction = self.PREFIX_MAP[fiel...
python
def process_fields(self, fields): """Process a list of simple string field definitions and assign their order based on prefix.""" result = [] strip = ''.join(self.PREFIX_MAP) for field in fields: direction = self.PREFIX_MAP[''] if field[0] in self.PREFIX_MAP: direction = self.PREFIX_MAP[fiel...
[ "def", "process_fields", "(", "self", ",", "fields", ")", ":", "result", "=", "[", "]", "strip", "=", "''", ".", "join", "(", "self", ".", "PREFIX_MAP", ")", "for", "field", "in", "fields", ":", "direction", "=", "self", ".", "PREFIX_MAP", "[", "''",...
Process a list of simple string field definitions and assign their order based on prefix.
[ "Process", "a", "list", "of", "simple", "string", "field", "definitions", "and", "assign", "their", "order", "based", "on", "prefix", "." ]
2066dc73e281b8a46cb5fc965267d6b8e1b18467
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/index.py#L60-L75
train
svartalf/python-2gis
dgis/__init__.py
API.search_in_rubric
def search_in_rubric(self, **kwargs): """Firms search in rubric http://api.2gis.ru/doc/firms/searches/searchinrubric/ """ point = kwargs.pop('point', False) if point: kwargs['point'] = '%s,%s' % point bound = kwargs.pop('bound', False) if bound: ...
python
def search_in_rubric(self, **kwargs): """Firms search in rubric http://api.2gis.ru/doc/firms/searches/searchinrubric/ """ point = kwargs.pop('point', False) if point: kwargs['point'] = '%s,%s' % point bound = kwargs.pop('bound', False) if bound: ...
[ "def", "search_in_rubric", "(", "self", ",", "**", "kwargs", ")", ":", "point", "=", "kwargs", ".", "pop", "(", "'point'", ",", "False", ")", "if", "point", ":", "kwargs", "[", "'point'", "]", "=", "'%s,%s'", "%", "point", "bound", "=", "kwargs", "."...
Firms search in rubric http://api.2gis.ru/doc/firms/searches/searchinrubric/
[ "Firms", "search", "in", "rubric" ]
6eccd6073c99494b7abf20b38a5455cbd55d6420
https://github.com/svartalf/python-2gis/blob/6eccd6073c99494b7abf20b38a5455cbd55d6420/dgis/__init__.py#L89-L109
train
tonybaloney/retox
retox/ui.py
RetoxRefreshMixin.refresh
def refresh(self): ''' Refresh the list and the screen ''' self._screen.force_update() self._screen.refresh() self._update(1)
python
def refresh(self): ''' Refresh the list and the screen ''' self._screen.force_update() self._screen.refresh() self._update(1)
[ "def", "refresh", "(", "self", ")", ":", "self", ".", "_screen", ".", "force_update", "(", ")", "self", ".", "_screen", ".", "refresh", "(", ")", "self", ".", "_update", "(", "1", ")" ]
Refresh the list and the screen
[ "Refresh", "the", "list", "and", "the", "screen" ]
4635e31001d2ac083423f46766249ac8daca7c9c
https://github.com/tonybaloney/retox/blob/4635e31001d2ac083423f46766249ac8daca7c9c/retox/ui.py#L54-L60
train
tonybaloney/retox
retox/ui.py
VirtualEnvironmentFrame.start
def start(self, activity, action): ''' Mark an action as started :param activity: The virtualenv activity name :type activity: ``str`` :param action: The virtualenv action :type action: :class:`tox.session.Action` ''' try: self._start_actio...
python
def start(self, activity, action): ''' Mark an action as started :param activity: The virtualenv activity name :type activity: ``str`` :param action: The virtualenv action :type action: :class:`tox.session.Action` ''' try: self._start_actio...
[ "def", "start", "(", "self", ",", "activity", ",", "action", ")", ":", "try", ":", "self", ".", "_start_action", "(", "activity", ",", "action", ")", "except", "ValueError", ":", "retox_log", ".", "debug", "(", "\"Could not find action %s in env %s\"", "%", ...
Mark an action as started :param activity: The virtualenv activity name :type activity: ``str`` :param action: The virtualenv action :type action: :class:`tox.session.Action`
[ "Mark", "an", "action", "as", "started" ]
4635e31001d2ac083423f46766249ac8daca7c9c
https://github.com/tonybaloney/retox/blob/4635e31001d2ac083423f46766249ac8daca7c9c/retox/ui.py#L233-L247
train
tonybaloney/retox
retox/ui.py
VirtualEnvironmentFrame.stop
def stop(self, activity, action): ''' Mark a task as completed :param activity: The virtualenv activity name :type activity: ``str`` :param action: The virtualenv action :type action: :class:`tox.session.Action` ''' try: self._remove_runnin...
python
def stop(self, activity, action): ''' Mark a task as completed :param activity: The virtualenv activity name :type activity: ``str`` :param action: The virtualenv action :type action: :class:`tox.session.Action` ''' try: self._remove_runnin...
[ "def", "stop", "(", "self", ",", "activity", ",", "action", ")", ":", "try", ":", "self", ".", "_remove_running_action", "(", "activity", ",", "action", ")", "except", "ValueError", ":", "retox_log", ".", "debug", "(", "\"Could not find action %s in env %s\"", ...
Mark a task as completed :param activity: The virtualenv activity name :type activity: ``str`` :param action: The virtualenv action :type action: :class:`tox.session.Action`
[ "Mark", "a", "task", "as", "completed" ]
4635e31001d2ac083423f46766249ac8daca7c9c
https://github.com/tonybaloney/retox/blob/4635e31001d2ac083423f46766249ac8daca7c9c/retox/ui.py#L249-L264
train
tonybaloney/retox
retox/ui.py
VirtualEnvironmentFrame.finish
def finish(self, status): ''' Move laggard tasks over :param activity: The virtualenv status :type activity: ``str`` ''' retox_log.info("Completing %s with status %s" % (self.name, status)) result = Screen.COLOUR_GREEN if not status else Screen.COLOUR_RED ...
python
def finish(self, status): ''' Move laggard tasks over :param activity: The virtualenv status :type activity: ``str`` ''' retox_log.info("Completing %s with status %s" % (self.name, status)) result = Screen.COLOUR_GREEN if not status else Screen.COLOUR_RED ...
[ "def", "finish", "(", "self", ",", "status", ")", ":", "retox_log", ".", "info", "(", "\"Completing %s with status %s\"", "%", "(", "self", ".", "name", ",", "status", ")", ")", "result", "=", "Screen", ".", "COLOUR_GREEN", "if", "not", "status", "else", ...
Move laggard tasks over :param activity: The virtualenv status :type activity: ``str``
[ "Move", "laggard", "tasks", "over" ]
4635e31001d2ac083423f46766249ac8daca7c9c
https://github.com/tonybaloney/retox/blob/4635e31001d2ac083423f46766249ac8daca7c9c/retox/ui.py#L266-L279
train
tonybaloney/retox
retox/ui.py
VirtualEnvironmentFrame.reset
def reset(self): ''' Reset the frame between jobs ''' self.palette['title'] = (Screen.COLOUR_WHITE, Screen.A_BOLD, Screen.COLOUR_BLUE) self._completed_view.options = [] self._task_view.options = [] self.refresh()
python
def reset(self): ''' Reset the frame between jobs ''' self.palette['title'] = (Screen.COLOUR_WHITE, Screen.A_BOLD, Screen.COLOUR_BLUE) self._completed_view.options = [] self._task_view.options = [] self.refresh()
[ "def", "reset", "(", "self", ")", ":", "self", ".", "palette", "[", "'title'", "]", "=", "(", "Screen", ".", "COLOUR_WHITE", ",", "Screen", ".", "A_BOLD", ",", "Screen", ".", "COLOUR_BLUE", ")", "self", ".", "_completed_view", ".", "options", "=", "[",...
Reset the frame between jobs
[ "Reset", "the", "frame", "between", "jobs" ]
4635e31001d2ac083423f46766249ac8daca7c9c
https://github.com/tonybaloney/retox/blob/4635e31001d2ac083423f46766249ac8daca7c9c/retox/ui.py#L281-L288
train
ryukinix/decorating
decorating/decorator.py
Decorator.default_arguments
def default_arguments(cls): """Returns the available kwargs of the called class""" func = cls.__init__ args = func.__code__.co_varnames defaults = func.__defaults__ index = -len(defaults) return {k: v for k, v in zip(args[index:], defaults)}
python
def default_arguments(cls): """Returns the available kwargs of the called class""" func = cls.__init__ args = func.__code__.co_varnames defaults = func.__defaults__ index = -len(defaults) return {k: v for k, v in zip(args[index:], defaults)}
[ "def", "default_arguments", "(", "cls", ")", ":", "func", "=", "cls", ".", "__init__", "args", "=", "func", ".", "__code__", ".", "co_varnames", "defaults", "=", "func", ".", "__defaults__", "index", "=", "-", "len", "(", "defaults", ")", "return", "{", ...
Returns the available kwargs of the called class
[ "Returns", "the", "available", "kwargs", "of", "the", "called", "class" ]
df78c3f87800205701704c0bc0fb9b6bb908ba7e
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/decorator.py#L134-L140
train
ryukinix/decorating
decorating/decorator.py
Decorator.recreate
def recreate(cls, *args, **kwargs): """Recreate the class based in your args, multiple uses""" cls.check_arguments(kwargs) first_is_callable = True if any(args) and callable(args[0]) else False signature = cls.default_arguments() allowed_arguments = {k: v for k, v in kwargs.items...
python
def recreate(cls, *args, **kwargs): """Recreate the class based in your args, multiple uses""" cls.check_arguments(kwargs) first_is_callable = True if any(args) and callable(args[0]) else False signature = cls.default_arguments() allowed_arguments = {k: v for k, v in kwargs.items...
[ "def", "recreate", "(", "cls", ",", "*", "args", ",", "**", "kwargs", ")", ":", "cls", ".", "check_arguments", "(", "kwargs", ")", "first_is_callable", "=", "True", "if", "any", "(", "args", ")", "and", "callable", "(", "args", "[", "0", "]", ")", ...
Recreate the class based in your args, multiple uses
[ "Recreate", "the", "class", "based", "in", "your", "args", "multiple", "uses" ]
df78c3f87800205701704c0bc0fb9b6bb908ba7e
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/decorator.py#L143-L155
train
ryukinix/decorating
decorating/decorator.py
Decorator.check_arguments
def check_arguments(cls, passed): """Put warnings of arguments whose can't be handle by the class""" defaults = list(cls.default_arguments().keys()) template = ("Pass arg {argument:!r} in {cname:!r}, can be a typo? " "Supported key arguments: {defaults}") fails = [] ...
python
def check_arguments(cls, passed): """Put warnings of arguments whose can't be handle by the class""" defaults = list(cls.default_arguments().keys()) template = ("Pass arg {argument:!r} in {cname:!r}, can be a typo? " "Supported key arguments: {defaults}") fails = [] ...
[ "def", "check_arguments", "(", "cls", ",", "passed", ")", ":", "defaults", "=", "list", "(", "cls", ".", "default_arguments", "(", ")", ".", "keys", "(", ")", ")", "template", "=", "(", "\"Pass arg {argument:!r} in {cname:!r}, can be a typo? \"", "\"Supported key ...
Put warnings of arguments whose can't be handle by the class
[ "Put", "warnings", "of", "arguments", "whose", "can", "t", "be", "handle", "by", "the", "class" ]
df78c3f87800205701704c0bc0fb9b6bb908ba7e
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/decorator.py#L158-L171
train
ovnicraft/suds2
suds/builder.py
Builder.process
def process(self, data, type, history): """ process the specified type then process its children """ if type in history: return if type.enum(): return history.append(type) resolved = type.resolve() value = None if type.multi_occurrence(): ...
python
def process(self, data, type, history): """ process the specified type then process its children """ if type in history: return if type.enum(): return history.append(type) resolved = type.resolve() value = None if type.multi_occurrence(): ...
[ "def", "process", "(", "self", ",", "data", ",", "type", ",", "history", ")", ":", "if", "type", "in", "history", ":", "return", "if", "type", ".", "enum", "(", ")", ":", "return", "history", ".", "append", "(", "type", ")", "resolved", "=", "type"...
process the specified type then process its children
[ "process", "the", "specified", "type", "then", "process", "its", "children" ]
e5b540792206a41efc22f5d5b9cfac2dbe7a7992
https://github.com/ovnicraft/suds2/blob/e5b540792206a41efc22f5d5b9cfac2dbe7a7992/suds/builder.py#L60-L90
train
ovnicraft/suds2
suds/builder.py
Builder.skip_child
def skip_child(self, child, ancestry): """ get whether or not to skip the specified child """ if child.any(): return True for x in ancestry: if x.choice(): return True return False
python
def skip_child(self, child, ancestry): """ get whether or not to skip the specified child """ if child.any(): return True for x in ancestry: if x.choice(): return True return False
[ "def", "skip_child", "(", "self", ",", "child", ",", "ancestry", ")", ":", "if", "child", ".", "any", "(", ")", ":", "return", "True", "for", "x", "in", "ancestry", ":", "if", "x", ".", "choice", "(", ")", ":", "return", "True", "return", "False" ]
get whether or not to skip the specified child
[ "get", "whether", "or", "not", "to", "skip", "the", "specified", "child" ]
e5b540792206a41efc22f5d5b9cfac2dbe7a7992
https://github.com/ovnicraft/suds2/blob/e5b540792206a41efc22f5d5b9cfac2dbe7a7992/suds/builder.py#L99-L105
train
nephila/django-knocker
knocker/signals.py
active_knocks
def active_knocks(obj): """ Checks whether knocks are enabled for the model given as argument :param obj: model instance :return True if knocks are active """ if not hasattr(_thread_locals, 'knock_enabled'): return True return _thread_locals.knock_enabled.get(obj.__class__, True)
python
def active_knocks(obj): """ Checks whether knocks are enabled for the model given as argument :param obj: model instance :return True if knocks are active """ if not hasattr(_thread_locals, 'knock_enabled'): return True return _thread_locals.knock_enabled.get(obj.__class__, True)
[ "def", "active_knocks", "(", "obj", ")", ":", "if", "not", "hasattr", "(", "_thread_locals", ",", "'knock_enabled'", ")", ":", "return", "True", "return", "_thread_locals", ".", "knock_enabled", ".", "get", "(", "obj", ".", "__class__", ",", "True", ")" ]
Checks whether knocks are enabled for the model given as argument :param obj: model instance :return True if knocks are active
[ "Checks", "whether", "knocks", "are", "enabled", "for", "the", "model", "given", "as", "argument" ]
d25380d43a1f91285f1581dcf9db8510fe87f354
https://github.com/nephila/django-knocker/blob/d25380d43a1f91285f1581dcf9db8510fe87f354/knocker/signals.py#L34-L43
train
nephila/django-knocker
knocker/signals.py
pause_knocks
def pause_knocks(obj): """ Context manager to suspend sending knocks for the given model :param obj: model instance """ if not hasattr(_thread_locals, 'knock_enabled'): _thread_locals.knock_enabled = {} obj.__class__._disconnect() _thread_locals.knock_enabled[obj.__class__] = False ...
python
def pause_knocks(obj): """ Context manager to suspend sending knocks for the given model :param obj: model instance """ if not hasattr(_thread_locals, 'knock_enabled'): _thread_locals.knock_enabled = {} obj.__class__._disconnect() _thread_locals.knock_enabled[obj.__class__] = False ...
[ "def", "pause_knocks", "(", "obj", ")", ":", "if", "not", "hasattr", "(", "_thread_locals", ",", "'knock_enabled'", ")", ":", "_thread_locals", ".", "knock_enabled", "=", "{", "}", "obj", ".", "__class__", ".", "_disconnect", "(", ")", "_thread_locals", ".",...
Context manager to suspend sending knocks for the given model :param obj: model instance
[ "Context", "manager", "to", "suspend", "sending", "knocks", "for", "the", "given", "model" ]
d25380d43a1f91285f1581dcf9db8510fe87f354
https://github.com/nephila/django-knocker/blob/d25380d43a1f91285f1581dcf9db8510fe87f354/knocker/signals.py#L47-L59
train
tonybaloney/retox
retox/reporter.py
RetoxReporter._loopreport
def _loopreport(self): ''' Loop over the report progress ''' while 1: eventlet.sleep(0.2) ac2popenlist = {} for action in self.session._actions: for popen in action._popenlist: if popen.poll() is None: ...
python
def _loopreport(self): ''' Loop over the report progress ''' while 1: eventlet.sleep(0.2) ac2popenlist = {} for action in self.session._actions: for popen in action._popenlist: if popen.poll() is None: ...
[ "def", "_loopreport", "(", "self", ")", ":", "while", "1", ":", "eventlet", ".", "sleep", "(", "0.2", ")", "ac2popenlist", "=", "{", "}", "for", "action", "in", "self", ".", "session", ".", "_actions", ":", "for", "popen", "in", "action", ".", "_pope...
Loop over the report progress
[ "Loop", "over", "the", "report", "progress" ]
4635e31001d2ac083423f46766249ac8daca7c9c
https://github.com/tonybaloney/retox/blob/4635e31001d2ac083423f46766249ac8daca7c9c/retox/reporter.py#L49-L65
train
yejianye/mdmail
mdmail/api.py
send
def send(email, subject=None, from_email=None, to_email=None, cc=None, bcc=None, reply_to=None, smtp=None): """Send markdown email Args: email (str/obj): A markdown string or EmailContent object subject (str): subject line from_email (str): sender email addre...
python
def send(email, subject=None, from_email=None, to_email=None, cc=None, bcc=None, reply_to=None, smtp=None): """Send markdown email Args: email (str/obj): A markdown string or EmailContent object subject (str): subject line from_email (str): sender email addre...
[ "def", "send", "(", "email", ",", "subject", "=", "None", ",", "from_email", "=", "None", ",", "to_email", "=", "None", ",", "cc", "=", "None", ",", "bcc", "=", "None", ",", "reply_to", "=", "None", ",", "smtp", "=", "None", ")", ":", "if", "is_s...
Send markdown email Args: email (str/obj): A markdown string or EmailContent object subject (str): subject line from_email (str): sender email address to_email (str/list): recipient email addresses cc (str/list): CC email addresses (string or a list) bcc (str/list):...
[ "Send", "markdown", "email" ]
ef03da8d5836b5ae0a4ad8c44f2fe4936a896644
https://github.com/yejianye/mdmail/blob/ef03da8d5836b5ae0a4ad8c44f2fe4936a896644/mdmail/api.py#L11-L63
train
marrow/mongo
marrow/mongo/core/field/date.py
Date._process_tz
def _process_tz(self, dt, naive, tz): """Process timezone casting and conversion.""" def _tz(t): if t in (None, 'naive'): return t if t == 'local': if __debug__ and not localtz: raise ValueError("Requested conversion to local timezone, but `localtz` not installed.") t = localtz ...
python
def _process_tz(self, dt, naive, tz): """Process timezone casting and conversion.""" def _tz(t): if t in (None, 'naive'): return t if t == 'local': if __debug__ and not localtz: raise ValueError("Requested conversion to local timezone, but `localtz` not installed.") t = localtz ...
[ "def", "_process_tz", "(", "self", ",", "dt", ",", "naive", ",", "tz", ")", ":", "def", "_tz", "(", "t", ")", ":", "if", "t", "in", "(", "None", ",", "'naive'", ")", ":", "return", "t", "if", "t", "==", "'local'", ":", "if", "__debug__", "and",...
Process timezone casting and conversion.
[ "Process", "timezone", "casting", "and", "conversion", "." ]
2066dc73e281b8a46cb5fc965267d6b8e1b18467
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/field/date.py#L59-L102
train
marrow/mongo
marrow/mongo/core/document.py
Document._prepare_defaults
def _prepare_defaults(self): """Trigger assignment of default values.""" for name, field in self.__fields__.items(): if field.assign: getattr(self, name)
python
def _prepare_defaults(self): """Trigger assignment of default values.""" for name, field in self.__fields__.items(): if field.assign: getattr(self, name)
[ "def", "_prepare_defaults", "(", "self", ")", ":", "for", "name", ",", "field", "in", "self", ".", "__fields__", ".", "items", "(", ")", ":", "if", "field", ".", "assign", ":", "getattr", "(", "self", ",", "name", ")" ]
Trigger assignment of default values.
[ "Trigger", "assignment", "of", "default", "values", "." ]
2066dc73e281b8a46cb5fc965267d6b8e1b18467
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/document.py#L71-L76
train
marrow/mongo
marrow/mongo/core/document.py
Document.from_mongo
def from_mongo(cls, doc): """Convert data coming in from the MongoDB wire driver into a Document instance.""" if doc is None: # To support simplified iterative use, None should return None. return None if isinstance(doc, Document): # No need to perform processing on existing Document instances. retu...
python
def from_mongo(cls, doc): """Convert data coming in from the MongoDB wire driver into a Document instance.""" if doc is None: # To support simplified iterative use, None should return None. return None if isinstance(doc, Document): # No need to perform processing on existing Document instances. retu...
[ "def", "from_mongo", "(", "cls", ",", "doc", ")", ":", "if", "doc", "is", "None", ":", "return", "None", "if", "isinstance", "(", "doc", ",", "Document", ")", ":", "return", "doc", "if", "cls", ".", "__type_store__", "and", "cls", ".", "__type_store__"...
Convert data coming in from the MongoDB wire driver into a Document instance.
[ "Convert", "data", "coming", "in", "from", "the", "MongoDB", "wire", "driver", "into", "a", "Document", "instance", "." ]
2066dc73e281b8a46cb5fc965267d6b8e1b18467
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/document.py#L81-L98
train
marrow/mongo
marrow/mongo/core/document.py
Document.pop
def pop(self, name, default=SENTINEL): """Retrieve and remove a value from the backing store, optionally with a default.""" if default is SENTINEL: return self.__data__.pop(name) return self.__data__.pop(name, default)
python
def pop(self, name, default=SENTINEL): """Retrieve and remove a value from the backing store, optionally with a default.""" if default is SENTINEL: return self.__data__.pop(name) return self.__data__.pop(name, default)
[ "def", "pop", "(", "self", ",", "name", ",", "default", "=", "SENTINEL", ")", ":", "if", "default", "is", "SENTINEL", ":", "return", "self", ".", "__data__", ".", "pop", "(", "name", ")", "return", "self", ".", "__data__", ".", "pop", "(", "name", ...
Retrieve and remove a value from the backing store, optionally with a default.
[ "Retrieve", "and", "remove", "a", "value", "from", "the", "backing", "store", "optionally", "with", "a", "default", "." ]
2066dc73e281b8a46cb5fc965267d6b8e1b18467
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/document.py#L246-L252
train
marrow/mongo
marrow/mongo/query/query.py
Q._op
def _op(self, operation, other, *allowed): """A basic operation operating on a single value.""" f = self._field if self._combining: # We are a field-compound query fragment, e.g. (Foo.bar & Foo.baz). return reduce(self._combining, (q._op(operation, other, *allowed) for q in f)) # pylint:disable=pr...
python
def _op(self, operation, other, *allowed): """A basic operation operating on a single value.""" f = self._field if self._combining: # We are a field-compound query fragment, e.g. (Foo.bar & Foo.baz). return reduce(self._combining, (q._op(operation, other, *allowed) for q in f)) # pylint:disable=pr...
[ "def", "_op", "(", "self", ",", "operation", ",", "other", ",", "*", "allowed", ")", ":", "f", "=", "self", ".", "_field", "if", "self", ".", "_combining", ":", "return", "reduce", "(", "self", ".", "_combining", ",", "(", "q", ".", "_op", "(", "...
A basic operation operating on a single value.
[ "A", "basic", "operation", "operating", "on", "a", "single", "value", "." ]
2066dc73e281b8a46cb5fc965267d6b8e1b18467
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/query/query.py#L154-L170
train
marrow/mongo
marrow/mongo/query/query.py
Q._iop
def _iop(self, operation, other, *allowed): """An iterative operation operating on multiple values. Consumes iterators to construct a concrete list at time of execution. """ f = self._field if self._combining: # We are a field-compound query fragment, e.g. (Foo.bar & Foo.baz). return reduce(self....
python
def _iop(self, operation, other, *allowed): """An iterative operation operating on multiple values. Consumes iterators to construct a concrete list at time of execution. """ f = self._field if self._combining: # We are a field-compound query fragment, e.g. (Foo.bar & Foo.baz). return reduce(self....
[ "def", "_iop", "(", "self", ",", "operation", ",", "other", ",", "*", "allowed", ")", ":", "f", "=", "self", ".", "_field", "if", "self", ".", "_combining", ":", "return", "reduce", "(", "self", ".", "_combining", ",", "(", "q", ".", "_iop", "(", ...
An iterative operation operating on multiple values. Consumes iterators to construct a concrete list at time of execution.
[ "An", "iterative", "operation", "operating", "on", "multiple", "values", ".", "Consumes", "iterators", "to", "construct", "a", "concrete", "list", "at", "time", "of", "execution", "." ]
2066dc73e281b8a46cb5fc965267d6b8e1b18467
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/query/query.py#L172-L196
train