repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
speechinformaticslab/vfclust | vfclust/vfclust.py | ParsedResponse.combine_same_stem_units | def combine_same_stem_units(self, index):
"""Combines adjacent words with the same stem into a single unit.
:param int index: Index of Unit in self.unit_list to be combined with the
subsequent Unit.
Modifies:
- self.unit_list: Modifies the .original_text property of... | python | def combine_same_stem_units(self, index):
"""Combines adjacent words with the same stem into a single unit.
:param int index: Index of Unit in self.unit_list to be combined with the
subsequent Unit.
Modifies:
- self.unit_list: Modifies the .original_text property of... | [
"def",
"combine_same_stem_units",
"(",
"self",
",",
"index",
")",
":",
"if",
"not",
"self",
".",
"quiet",
":",
"combined_word",
"=",
"\"\"",
"for",
"word",
"in",
"self",
".",
"unit_list",
"[",
"index",
":",
"index",
"+",
"2",
"]",
":",
"for",
"original... | Combines adjacent words with the same stem into a single unit.
:param int index: Index of Unit in self.unit_list to be combined with the
subsequent Unit.
Modifies:
- self.unit_list: Modifies the .original_text property of the Unit
corresponding to the in... | [
"Combines",
"adjacent",
"words",
"with",
"the",
"same",
"stem",
"into",
"a",
"single",
"unit",
"."
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L318-L347 | train | Combines adjacent words with the same stem into a single unit. |
speechinformaticslab/vfclust | vfclust/vfclust.py | ParsedResponse.display | def display(self):
"""Pretty-prints the ParsedResponse to the screen."""
table_list = []
table_list.append(("Text","Orig. Text","Start time","End time", "Phonetic"))
for unit in self.unit_list:
table_list.append((unit.text,
"/".join(unit.origin... | python | def display(self):
"""Pretty-prints the ParsedResponse to the screen."""
table_list = []
table_list.append(("Text","Orig. Text","Start time","End time", "Phonetic"))
for unit in self.unit_list:
table_list.append((unit.text,
"/".join(unit.origin... | [
"def",
"display",
"(",
"self",
")",
":",
"table_list",
"=",
"[",
"]",
"table_list",
".",
"append",
"(",
"(",
"\"Text\"",
",",
"\"Orig. Text\"",
",",
"\"Start time\"",
",",
"\"End time\"",
",",
"\"Phonetic\"",
")",
")",
"for",
"unit",
"in",
"self",
".",
"... | Pretty-prints the ParsedResponse to the screen. | [
"Pretty",
"-",
"prints",
"the",
"ParsedResponse",
"to",
"the",
"screen",
"."
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L350-L361 | train | Pretty - prints the ParsedResponse to the screen. |
speechinformaticslab/vfclust | vfclust/vfclust.py | ParsedResponse.generate_phonetic_representation | def generate_phonetic_representation(self, word):
"""
Returns a generated phonetic representation for a word.
:param str word: a word to be phoneticized.
:return: A list of phonemes representing the phoneticized word.
This method is used for words for which there is no pronunic... | python | def generate_phonetic_representation(self, word):
"""
Returns a generated phonetic representation for a word.
:param str word: a word to be phoneticized.
:return: A list of phonemes representing the phoneticized word.
This method is used for words for which there is no pronunic... | [
"def",
"generate_phonetic_representation",
"(",
"self",
",",
"word",
")",
":",
"with",
"NamedTemporaryFile",
"(",
")",
"as",
"temp_file",
":",
"# Write the word to a temp file",
"temp_file",
".",
"write",
"(",
"word",
")",
"#todo - clean up this messy t2p path",
"t2parg... | Returns a generated phonetic representation for a word.
:param str word: a word to be phoneticized.
:return: A list of phonemes representing the phoneticized word.
This method is used for words for which there is no pronunication
entry in the CMU dictionary. The function generates a
... | [
"Returns",
"a",
"generated",
"phonetic",
"representation",
"for",
"a",
"word",
"."
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L363-L392 | train | Generates a phonetic representation for a word. |
speechinformaticslab/vfclust | vfclust/vfclust.py | ParsedResponse.modify_phonetic_representation | def modify_phonetic_representation(self, phonetic_representation):
""" Returns a compact phonetic representation given a CMUdict-formatted representation.
:param list phonetic_representation: a phonetic representation in standard
CMUdict formatting, i.e. a list of phonemes like ['HH', 'EH0'... | python | def modify_phonetic_representation(self, phonetic_representation):
""" Returns a compact phonetic representation given a CMUdict-formatted representation.
:param list phonetic_representation: a phonetic representation in standard
CMUdict formatting, i.e. a list of phonemes like ['HH', 'EH0'... | [
"def",
"modify_phonetic_representation",
"(",
"self",
",",
"phonetic_representation",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"phonetic_representation",
")",
")",
":",
"# Remove numerical stress indicators",
"phonetic_representation",
"[",
"i",
"]",
"=",... | Returns a compact phonetic representation given a CMUdict-formatted representation.
:param list phonetic_representation: a phonetic representation in standard
CMUdict formatting, i.e. a list of phonemes like ['HH', 'EH0', 'L', 'OW1']
:returns: A string representing a custom phonetic represe... | [
"Returns",
"a",
"compact",
"phonetic",
"representation",
"given",
"a",
"CMUdict",
"-",
"formatted",
"representation",
"."
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L394-L424 | train | Returns a compact phonetic representation given a CMUdict - formatted representation. |
speechinformaticslab/vfclust | vfclust/vfclust.py | ParsedResponse.clean | def clean(self):
""" Removes any Units that are not applicable given the current semantic or phonetic category.
Modifies:
- self.unit_list: Removes Units from this list that do not fit into the clustering category.
it does by by either combining units to make compound words,... | python | def clean(self):
""" Removes any Units that are not applicable given the current semantic or phonetic category.
Modifies:
- self.unit_list: Removes Units from this list that do not fit into the clustering category.
it does by by either combining units to make compound words,... | [
"def",
"clean",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"quiet",
":",
"print",
"print",
"\"Preprocessing input...\"",
"print",
"\"Raw response:\"",
"print",
"self",
".",
"display",
"(",
")",
"if",
"not",
"self",
".",
"quiet",
":",
"print",
"print"... | Removes any Units that are not applicable given the current semantic or phonetic category.
Modifies:
- self.unit_list: Removes Units from this list that do not fit into the clustering category.
it does by by either combining units to make compound words, combining units with the
... | [
"Removes",
"any",
"Units",
"that",
"are",
"not",
"applicable",
"given",
"the",
"current",
"semantic",
"or",
"phonetic",
"category",
"."
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L426-L504 | train | This method removes any Units that are not applicable given the current semantic or phonetic category. |
speechinformaticslab/vfclust | vfclust/vfclust.py | VFClustEngine.load_lsa_information | def load_lsa_information(self):
"""Loads a dictionary from disk that maps permissible words to their LSA term vectors."""
if not (49 < int(self.clustering_parameter) < 101):
raise Exception('Only LSA dimensionalities in the range 50-100' +
' are supported.')
... | python | def load_lsa_information(self):
"""Loads a dictionary from disk that maps permissible words to their LSA term vectors."""
if not (49 < int(self.clustering_parameter) < 101):
raise Exception('Only LSA dimensionalities in the range 50-100' +
' are supported.')
... | [
"def",
"load_lsa_information",
"(",
"self",
")",
":",
"if",
"not",
"(",
"49",
"<",
"int",
"(",
"self",
".",
"clustering_parameter",
")",
"<",
"101",
")",
":",
"raise",
"Exception",
"(",
"'Only LSA dimensionalities in the range 50-100'",
"+",
"' are supported.'",
... | Loads a dictionary from disk that maps permissible words to their LSA term vectors. | [
"Loads",
"a",
"dictionary",
"from",
"disk",
"that",
"maps",
"permissible",
"words",
"to",
"their",
"LSA",
"term",
"vectors",
"."
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L766-L780 | train | Loads a dictionary that maps permissible words to their LSA term vectors. |
speechinformaticslab/vfclust | vfclust/vfclust.py | VFClustEngine.get_similarity_measures | def get_similarity_measures(self):
"""Helper function for computing similarity measures."""
if not self.quiet:
print
print "Computing", self.current_similarity_measure, "similarity..."
self.compute_similarity_scores() | python | def get_similarity_measures(self):
"""Helper function for computing similarity measures."""
if not self.quiet:
print
print "Computing", self.current_similarity_measure, "similarity..."
self.compute_similarity_scores() | [
"def",
"get_similarity_measures",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"quiet",
":",
"print",
"print",
"\"Computing\"",
",",
"self",
".",
"current_similarity_measure",
",",
"\"similarity...\"",
"self",
".",
"compute_similarity_scores",
"(",
")"
] | Helper function for computing similarity measures. | [
"Helper",
"function",
"for",
"computing",
"similarity",
"measures",
"."
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L783-L789 | train | Helper function for computing similarity measures. |
speechinformaticslab/vfclust | vfclust/vfclust.py | VFClustEngine.get_collections | def get_collections(self):
"""Helper function for determining what the clusters/chains/other collections are."""
if not self.quiet:
print
print "Finding " + self.current_collection_type + "s..."
self.compute_collections()
if not self.quiet:
print sel... | python | def get_collections(self):
"""Helper function for determining what the clusters/chains/other collections are."""
if not self.quiet:
print
print "Finding " + self.current_collection_type + "s..."
self.compute_collections()
if not self.quiet:
print sel... | [
"def",
"get_collections",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"quiet",
":",
"print",
"print",
"\"Finding \"",
"+",
"self",
".",
"current_collection_type",
"+",
"\"s...\"",
"self",
".",
"compute_collections",
"(",
")",
"if",
"not",
"self",
".",
... | Helper function for determining what the clusters/chains/other collections are. | [
"Helper",
"function",
"for",
"determining",
"what",
"the",
"clusters",
"/",
"chains",
"/",
"other",
"collections",
"are",
"."
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L792-L805 | train | Helper function for determining what the clusters and chains are other collections. |
speechinformaticslab/vfclust | vfclust/vfclust.py | VFClustEngine.get_collection_measures | def get_collection_measures(self):
"""Helper function for calculating measurements derived from clusters/chains/collections"""
if not self.quiet:
print
print "Computing duration-independent", self.current_collection_type, "measures..."
self.compute_collection_measures()... | python | def get_collection_measures(self):
"""Helper function for calculating measurements derived from clusters/chains/collections"""
if not self.quiet:
print
print "Computing duration-independent", self.current_collection_type, "measures..."
self.compute_collection_measures()... | [
"def",
"get_collection_measures",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"quiet",
":",
"print",
"print",
"\"Computing duration-independent\"",
",",
"self",
".",
"current_collection_type",
",",
"\"measures...\"",
"self",
".",
"compute_collection_measures",
"(... | Helper function for calculating measurements derived from clusters/chains/collections | [
"Helper",
"function",
"for",
"calculating",
"measurements",
"derived",
"from",
"clusters",
"/",
"chains",
"/",
"collections"
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L808-L832 | train | Helper function for calculating clustering measures derived from clusters chains collections. |
speechinformaticslab/vfclust | vfclust/vfclust.py | VFClustEngine.get_raw_counts | def get_raw_counts(self):
"""Determines counts for unique words, repetitions, etc using the raw text response.
Adds the following measures to the self.measures dictionary:
- COUNT_total_words: count of words (i.e. utterances with semantic content) spoken
by the subject. Fill... | python | def get_raw_counts(self):
"""Determines counts for unique words, repetitions, etc using the raw text response.
Adds the following measures to the self.measures dictionary:
- COUNT_total_words: count of words (i.e. utterances with semantic content) spoken
by the subject. Fill... | [
"def",
"get_raw_counts",
"(",
"self",
")",
":",
"#for making the table at the end",
"words",
"=",
"[",
"]",
"labels",
"=",
"[",
"]",
"words_said",
"=",
"set",
"(",
")",
"# Words like \"polar_bear\" as one semantically but two phonetically",
"# Uncategorizable words are coun... | Determines counts for unique words, repetitions, etc using the raw text response.
Adds the following measures to the self.measures dictionary:
- COUNT_total_words: count of words (i.e. utterances with semantic content) spoken
by the subject. Filled pauses, silences, coughs, breaths,... | [
"Determines",
"counts",
"for",
"unique",
"words",
"repetitions",
"etc",
"using",
"the",
"raw",
"text",
"response",
"."
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L836-L934 | train | Determines the counts for unique words that are spoken by the subject and the subject that are not part of the test criteria. |
speechinformaticslab/vfclust | vfclust/vfclust.py | VFClustEngine.compute_similarity_score | def compute_similarity_score(self, unit1, unit2):
""" Returns the similarity score between two words.
The type of similarity scoring method used depends on the currently active
method and clustering type.
:param unit1: Unit object corresponding to the first word.
:type unit1:... | python | def compute_similarity_score(self, unit1, unit2):
""" Returns the similarity score between two words.
The type of similarity scoring method used depends on the currently active
method and clustering type.
:param unit1: Unit object corresponding to the first word.
:type unit1:... | [
"def",
"compute_similarity_score",
"(",
"self",
",",
"unit1",
",",
"unit2",
")",
":",
"if",
"self",
".",
"type",
"==",
"\"PHONETIC\"",
":",
"word1",
"=",
"unit1",
".",
"phonetic_representation",
"word2",
"=",
"unit2",
".",
"phonetic_representation",
"if",
"sel... | Returns the similarity score between two words.
The type of similarity scoring method used depends on the currently active
method and clustering type.
:param unit1: Unit object corresponding to the first word.
:type unit1: Unit
:param unit2: Unit object corresponding to the s... | [
"Returns",
"the",
"similarity",
"score",
"between",
"two",
"words",
"."
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L943-L1042 | train | This method calculates the similarity score between two words. |
speechinformaticslab/vfclust | vfclust/vfclust.py | VFClustEngine.compute_similarity_scores | def compute_similarity_scores(self):
""" Produce a list of similarity scores for each contiguous pair in a response.
Calls compute_similarity_score method for every adjacent pair of words. The results
are not used in clustering; this is merely to provide a visual representation to
print... | python | def compute_similarity_scores(self):
""" Produce a list of similarity scores for each contiguous pair in a response.
Calls compute_similarity_score method for every adjacent pair of words. The results
are not used in clustering; this is merely to provide a visual representation to
print... | [
"def",
"compute_similarity_scores",
"(",
"self",
")",
":",
"for",
"i",
",",
"unit",
"in",
"enumerate",
"(",
"self",
".",
"parsed_response",
")",
":",
"if",
"i",
"<",
"len",
"(",
"self",
".",
"parsed_response",
")",
"-",
"1",
":",
"next_unit",
"=",
"sel... | Produce a list of similarity scores for each contiguous pair in a response.
Calls compute_similarity_score method for every adjacent pair of words. The results
are not used in clustering; this is merely to provide a visual representation to
print to the screen.
Modifies:
- ... | [
"Produce",
"a",
"list",
"of",
"similarity",
"scores",
"for",
"each",
"contiguous",
"pair",
"in",
"a",
"response",
"."
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L1044-L1067 | train | Compute the similarity scores between adjacent words and each other. |
speechinformaticslab/vfclust | vfclust/vfclust.py | VFClustEngine.compute_collections | def compute_collections(self):
""" Finds the collections (clusters,chains) that exist in parsed_response.
Modified:
- self.collection_sizes: populated with a list of integers indicating
the number of units belonging to each collection
- self.collection_indices: p... | python | def compute_collections(self):
""" Finds the collections (clusters,chains) that exist in parsed_response.
Modified:
- self.collection_sizes: populated with a list of integers indicating
the number of units belonging to each collection
- self.collection_indices: p... | [
"def",
"compute_collections",
"(",
"self",
")",
":",
"if",
"self",
".",
"custom_threshold",
":",
"self",
".",
"similarity_threshold",
"=",
"self",
".",
"custom_threshold",
"elif",
"self",
".",
"type",
"==",
"\"PHONETIC\"",
":",
"if",
"self",
".",
"current_simi... | Finds the collections (clusters,chains) that exist in parsed_response.
Modified:
- self.collection_sizes: populated with a list of integers indicating
the number of units belonging to each collection
- self.collection_indices: populated with a list of strings indicating
... | [
"Finds",
"the",
"collections",
"(",
"clusters",
"chains",
")",
"that",
"exist",
"in",
"parsed_response",
"."
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L1075-L1220 | train | Computes the collections for the current entry in the resource. |
speechinformaticslab/vfclust | vfclust/vfclust.py | VFClustEngine.compute_pairwise_similarity_score | def compute_pairwise_similarity_score(self):
"""Computes the average pairwise similarity score between all pairs of Units.
The pairwise similarity is calculated as the sum of similarity scores for all pairwise
word pairs in a response -- except any pair composed of a word and
itself -- ... | python | def compute_pairwise_similarity_score(self):
"""Computes the average pairwise similarity score between all pairs of Units.
The pairwise similarity is calculated as the sum of similarity scores for all pairwise
word pairs in a response -- except any pair composed of a word and
itself -- ... | [
"def",
"compute_pairwise_similarity_score",
"(",
"self",
")",
":",
"pairs",
"=",
"[",
"]",
"all_scores",
"=",
"[",
"]",
"for",
"i",
",",
"unit",
"in",
"enumerate",
"(",
"self",
".",
"parsed_response",
")",
":",
"for",
"j",
",",
"other_unit",
"in",
"enume... | Computes the average pairwise similarity score between all pairs of Units.
The pairwise similarity is calculated as the sum of similarity scores for all pairwise
word pairs in a response -- except any pair composed of a word and
itself -- divided by the total number of words in an attempt. I.e.... | [
"Computes",
"the",
"average",
"pairwise",
"similarity",
"score",
"between",
"all",
"pairs",
"of",
"Units",
"."
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L1231-L1261 | train | Computes the average pairwise similarity score between all pairs of Units. |
speechinformaticslab/vfclust | vfclust/vfclust.py | VFClustEngine.compute_collection_measures | def compute_collection_measures(self, no_singletons=False):
""" Computes summaries of measures using the discovered collections.
:param no_singletons: if True, omits collections of length 1 from all measures
and includes "no_singletons_" in the measure name.
Adds the following meas... | python | def compute_collection_measures(self, no_singletons=False):
""" Computes summaries of measures using the discovered collections.
:param no_singletons: if True, omits collections of length 1 from all measures
and includes "no_singletons_" in the measure name.
Adds the following meas... | [
"def",
"compute_collection_measures",
"(",
"self",
",",
"no_singletons",
"=",
"False",
")",
":",
"prefix",
"=",
"\"COLLECTION_\"",
"+",
"self",
".",
"current_similarity_measure",
"+",
"\"_\"",
"+",
"self",
".",
"current_collection_type",
"+",
"\"_\"",
"if",
"no_si... | Computes summaries of measures using the discovered collections.
:param no_singletons: if True, omits collections of length 1 from all measures
and includes "no_singletons_" in the measure name.
Adds the following measures to the self.measures dictionary, prefaced by
COLLECTION_(si... | [
"Computes",
"summaries",
"of",
"measures",
"using",
"the",
"discovered",
"collections",
"."
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L1264-L1296 | train | Computes the summary of the measures for the current cluster and stores them in the self. measures dictionary. |
speechinformaticslab/vfclust | vfclust/vfclust.py | VFClustEngine.compute_duration_measures | def compute_duration_measures(self):
""" Helper function for computing measures derived from timing information.
These are only computed if the response is textgrid with timing information.
All times are in seconds.
"""
prefix = "TIMING_" + self.current_similarity_measure + "_... | python | def compute_duration_measures(self):
""" Helper function for computing measures derived from timing information.
These are only computed if the response is textgrid with timing information.
All times are in seconds.
"""
prefix = "TIMING_" + self.current_similarity_measure + "_... | [
"def",
"compute_duration_measures",
"(",
"self",
")",
":",
"prefix",
"=",
"\"TIMING_\"",
"+",
"self",
".",
"current_similarity_measure",
"+",
"\"_\"",
"+",
"self",
".",
"current_collection_type",
"+",
"\"_\"",
"if",
"self",
".",
"response_format",
"==",
"'TextGrid... | Helper function for computing measures derived from timing information.
These are only computed if the response is textgrid with timing information.
All times are in seconds. | [
"Helper",
"function",
"for",
"computing",
"measures",
"derived",
"from",
"timing",
"information",
"."
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L1305-L1326 | train | This function is used to compute the duration of the measures derived from the timing information. |
speechinformaticslab/vfclust | vfclust/vfclust.py | VFClustEngine.compute_response_vowel_duration | def compute_response_vowel_duration(self, prefix):
"""Computes mean vowel duration in entire response.
:param str prefix: Prefix for the key entry in self.measures.
Adds the following measures to the self.measures dictionary:
- TIMING_(similarity_measure)_(collection_type)_response... | python | def compute_response_vowel_duration(self, prefix):
"""Computes mean vowel duration in entire response.
:param str prefix: Prefix for the key entry in self.measures.
Adds the following measures to the self.measures dictionary:
- TIMING_(similarity_measure)_(collection_type)_response... | [
"def",
"compute_response_vowel_duration",
"(",
"self",
",",
"prefix",
")",
":",
"durations",
"=",
"[",
"]",
"for",
"word",
"in",
"self",
".",
"full_timed_response",
":",
"if",
"word",
".",
"phones",
":",
"for",
"phone",
"in",
"word",
".",
"phones",
":",
... | Computes mean vowel duration in entire response.
:param str prefix: Prefix for the key entry in self.measures.
Adds the following measures to the self.measures dictionary:
- TIMING_(similarity_measure)_(collection_type)_response_vowel_duration_mean: average
vowel duration o... | [
"Computes",
"mean",
"vowel",
"duration",
"in",
"entire",
"response",
"."
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L1329-L1349 | train | Computes the mean vowel duration in all vowels in the response. |
speechinformaticslab/vfclust | vfclust/vfclust.py | VFClustEngine.compute_between_collection_interval_duration | def compute_between_collection_interval_duration(self, prefix):
"""Calculates BETWEEN-collection intervals for the current collection and measure type
and takes their mean.
:param str prefix: Prefix for the key entry in self.measures.
Negative intervals (for overlapping clusters) a... | python | def compute_between_collection_interval_duration(self, prefix):
"""Calculates BETWEEN-collection intervals for the current collection and measure type
and takes their mean.
:param str prefix: Prefix for the key entry in self.measures.
Negative intervals (for overlapping clusters) a... | [
"def",
"compute_between_collection_interval_duration",
"(",
"self",
",",
"prefix",
")",
":",
"durations",
"=",
"[",
"]",
"# duration of each collection",
"for",
"collection",
"in",
"self",
".",
"collection_list",
":",
"# Entry, with timing, in timed_response for first word in... | Calculates BETWEEN-collection intervals for the current collection and measure type
and takes their mean.
:param str prefix: Prefix for the key entry in self.measures.
Negative intervals (for overlapping clusters) are counted as 0 seconds. Intervals are
calculated as being the dif... | [
"Calculates",
"BETWEEN",
"-",
"collection",
"intervals",
"for",
"the",
"current",
"collection",
"and",
"measure",
"type",
"and",
"takes",
"their",
"mean",
"."
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L1377-L1425 | train | Calculates the duration of each interval between the current collection and measure type
and takes their mean. |
speechinformaticslab/vfclust | vfclust/vfclust.py | VFClustEngine.compute_within_collection_interval_duration | def compute_within_collection_interval_duration(self, prefix):
"""Calculates mean between-word duration WITHIN collections.
:param str prefix: Prefix for the key entry in self.measures.
Calculates the mean time between the end of each word in the collection
and the beginning of the nex... | python | def compute_within_collection_interval_duration(self, prefix):
"""Calculates mean between-word duration WITHIN collections.
:param str prefix: Prefix for the key entry in self.measures.
Calculates the mean time between the end of each word in the collection
and the beginning of the nex... | [
"def",
"compute_within_collection_interval_duration",
"(",
"self",
",",
"prefix",
")",
":",
"interstices",
"=",
"[",
"]",
"for",
"cluster",
"in",
"self",
".",
"collection_list",
":",
"# Make sure cluster is not a singleton",
"if",
"len",
"(",
"cluster",
")",
">",
... | Calculates mean between-word duration WITHIN collections.
:param str prefix: Prefix for the key entry in self.measures.
Calculates the mean time between the end of each word in the collection
and the beginning of the next word. Note that these times do not necessarily
reflect pauses, ... | [
"Calculates",
"mean",
"between",
"-",
"word",
"duration",
"WITHIN",
"collections",
"."
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L1430-L1457 | train | Calculates the mean between - word duration WITHIN collections. |
speechinformaticslab/vfclust | vfclust/vfclust.py | VFClustEngine.compute_within_collection_vowel_duration | def compute_within_collection_vowel_duration(self, prefix, no_singletons=False):
""" Computes the mean duration of vowels from Units within clusters.
:param str prefix: Prefix for the key entry in self.measures
:param bool no_singletons: If False, excludes collections of length 1 from calculati... | python | def compute_within_collection_vowel_duration(self, prefix, no_singletons=False):
""" Computes the mean duration of vowels from Units within clusters.
:param str prefix: Prefix for the key entry in self.measures
:param bool no_singletons: If False, excludes collections of length 1 from calculati... | [
"def",
"compute_within_collection_vowel_duration",
"(",
"self",
",",
"prefix",
",",
"no_singletons",
"=",
"False",
")",
":",
"if",
"no_singletons",
":",
"min_size",
"=",
"2",
"else",
":",
"prefix",
"+=",
"\"no_singletons_\"",
"min_size",
"=",
"1",
"durations",
"... | Computes the mean duration of vowels from Units within clusters.
:param str prefix: Prefix for the key entry in self.measures
:param bool no_singletons: If False, excludes collections of length 1 from calculations
and adds "no_singletons" to the prefix
Adds the following measures t... | [
"Computes",
"the",
"mean",
"duration",
"of",
"vowels",
"from",
"Units",
"within",
"clusters",
"."
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L1461-L1498 | train | Computes the mean duration of vowels from Units within clusters. |
speechinformaticslab/vfclust | vfclust/vfclust.py | VFClustEngine.print_output | def print_output(self):
""" Outputs final list of measures to screen a csv file.
The .csv file created has the same name as the input file, with
"vfclust_TYPE_CATEGORY" appended to the filename, where TYPE indicates
the type of task performed done (SEMANTIC or PHONETIC) and CATEGORY
... | python | def print_output(self):
""" Outputs final list of measures to screen a csv file.
The .csv file created has the same name as the input file, with
"vfclust_TYPE_CATEGORY" appended to the filename, where TYPE indicates
the type of task performed done (SEMANTIC or PHONETIC) and CATEGORY
... | [
"def",
"print_output",
"(",
"self",
")",
":",
"if",
"self",
".",
"response_format",
"==",
"\"csv\"",
":",
"for",
"key",
"in",
"self",
".",
"measures",
":",
"if",
"\"TIMING_\"",
"in",
"key",
":",
"self",
".",
"measures",
"[",
"key",
"]",
"=",
"\"NA\"",
... | Outputs final list of measures to screen a csv file.
The .csv file created has the same name as the input file, with
"vfclust_TYPE_CATEGORY" appended to the filename, where TYPE indicates
the type of task performed done (SEMANTIC or PHONETIC) and CATEGORY
indicates the category requirem... | [
"Outputs",
"final",
"list",
"of",
"measures",
"to",
"screen",
"a",
"csv",
"file",
"."
] | 7ca733dea4782c828024765726cce65de095d33c | https://github.com/speechinformaticslab/vfclust/blob/7ca733dea4782c828024765726cce65de095d33c/vfclust/vfclust.py#L1546-L1593 | train | Prints final list of measures to screen a. csv file. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/contrib/versioning.py | PIDNodeVersioning.insert_child | def insert_child(self, child_pid, index=-1):
"""Insert a Version child PID."""
if child_pid.status != PIDStatus.REGISTERED:
raise PIDRelationConsistencyError(
"Version PIDs should have status 'REGISTERED'. Use "
"insert_draft_child to insert 'RESERVED' draft P... | python | def insert_child(self, child_pid, index=-1):
"""Insert a Version child PID."""
if child_pid.status != PIDStatus.REGISTERED:
raise PIDRelationConsistencyError(
"Version PIDs should have status 'REGISTERED'. Use "
"insert_draft_child to insert 'RESERVED' draft P... | [
"def",
"insert_child",
"(",
"self",
",",
"child_pid",
",",
"index",
"=",
"-",
"1",
")",
":",
"if",
"child_pid",
".",
"status",
"!=",
"PIDStatus",
".",
"REGISTERED",
":",
"raise",
"PIDRelationConsistencyError",
"(",
"\"Version PIDs should have status 'REGISTERED'. Us... | Insert a Version child PID. | [
"Insert",
"a",
"Version",
"child",
"PID",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/contrib/versioning.py#L79-L92 | train | Insert a Version child PID. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/contrib/versioning.py | PIDNodeVersioning.remove_child | def remove_child(self, child_pid):
"""Remove a Version child PID.
Extends the base method call by redirecting from the parent to the
last child.
"""
if child_pid.status == PIDStatus.RESERVED:
raise PIDRelationConsistencyError(
"Version PIDs should not... | python | def remove_child(self, child_pid):
"""Remove a Version child PID.
Extends the base method call by redirecting from the parent to the
last child.
"""
if child_pid.status == PIDStatus.RESERVED:
raise PIDRelationConsistencyError(
"Version PIDs should not... | [
"def",
"remove_child",
"(",
"self",
",",
"child_pid",
")",
":",
"if",
"child_pid",
".",
"status",
"==",
"PIDStatus",
".",
"RESERVED",
":",
"raise",
"PIDRelationConsistencyError",
"(",
"\"Version PIDs should not have status 'RESERVED'. Use \"",
"\"remove_draft_child to remov... | Remove a Version child PID.
Extends the base method call by redirecting from the parent to the
last child. | [
"Remove",
"a",
"Version",
"child",
"PID",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/contrib/versioning.py#L94-L107 | train | Removes a Version child PID. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/contrib/versioning.py | PIDNodeVersioning.draft_child | def draft_child(self):
"""Get the draft (RESERVED) child."""
return super(PIDNodeVersioning, self).children.status(
PIDStatus.RESERVED
).one_or_none() | python | def draft_child(self):
"""Get the draft (RESERVED) child."""
return super(PIDNodeVersioning, self).children.status(
PIDStatus.RESERVED
).one_or_none() | [
"def",
"draft_child",
"(",
"self",
")",
":",
"return",
"super",
"(",
"PIDNodeVersioning",
",",
"self",
")",
".",
"children",
".",
"status",
"(",
"PIDStatus",
".",
"RESERVED",
")",
".",
"one_or_none",
"(",
")"
] | Get the draft (RESERVED) child. | [
"Get",
"the",
"draft",
"(",
"RESERVED",
")",
"child",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/contrib/versioning.py#L110-L114 | train | Get the draft child. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/contrib/versioning.py | PIDNodeVersioning.insert_draft_child | def insert_draft_child(self, child_pid):
"""Insert a draft child to versioning."""
if child_pid.status != PIDStatus.RESERVED:
raise PIDRelationConsistencyError(
"Draft child should have status 'RESERVED'")
if not self.draft_child:
with db.session.begin_ne... | python | def insert_draft_child(self, child_pid):
"""Insert a draft child to versioning."""
if child_pid.status != PIDStatus.RESERVED:
raise PIDRelationConsistencyError(
"Draft child should have status 'RESERVED'")
if not self.draft_child:
with db.session.begin_ne... | [
"def",
"insert_draft_child",
"(",
"self",
",",
"child_pid",
")",
":",
"if",
"child_pid",
".",
"status",
"!=",
"PIDStatus",
".",
"RESERVED",
":",
"raise",
"PIDRelationConsistencyError",
"(",
"\"Draft child should have status 'RESERVED'\"",
")",
"if",
"not",
"self",
"... | Insert a draft child to versioning. | [
"Insert",
"a",
"draft",
"child",
"to",
"versioning",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/contrib/versioning.py#L127-L140 | train | Insert a draft child to versioning. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/contrib/versioning.py | PIDNodeVersioning.remove_draft_child | def remove_draft_child(self):
"""Remove the draft child from versioning."""
if self.draft_child:
with db.session.begin_nested():
super(PIDNodeVersioning, self).remove_child(self.draft_child,
reorder=True) | python | def remove_draft_child(self):
"""Remove the draft child from versioning."""
if self.draft_child:
with db.session.begin_nested():
super(PIDNodeVersioning, self).remove_child(self.draft_child,
reorder=True) | [
"def",
"remove_draft_child",
"(",
"self",
")",
":",
"if",
"self",
".",
"draft_child",
":",
"with",
"db",
".",
"session",
".",
"begin_nested",
"(",
")",
":",
"super",
"(",
"PIDNodeVersioning",
",",
"self",
")",
".",
"remove_child",
"(",
"self",
".",
"draf... | Remove the draft child from versioning. | [
"Remove",
"the",
"draft",
"child",
"from",
"versioning",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/contrib/versioning.py#L142-L147 | train | Remove the draft child from versioning. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/contrib/versioning.py | PIDNodeVersioning.update_redirect | def update_redirect(self):
"""Update the parent redirect to the current last child.
This method should be called on the parent PID node.
Use this method when the status of a PID changed (ex: draft changed
from RESERVED to REGISTERED)
"""
if self.last_child:
... | python | def update_redirect(self):
"""Update the parent redirect to the current last child.
This method should be called on the parent PID node.
Use this method when the status of a PID changed (ex: draft changed
from RESERVED to REGISTERED)
"""
if self.last_child:
... | [
"def",
"update_redirect",
"(",
"self",
")",
":",
"if",
"self",
".",
"last_child",
":",
"self",
".",
"_resolved_pid",
".",
"redirect",
"(",
"self",
".",
"last_child",
")",
"elif",
"any",
"(",
"map",
"(",
"lambda",
"pid",
":",
"pid",
".",
"status",
"not"... | Update the parent redirect to the current last child.
This method should be called on the parent PID node.
Use this method when the status of a PID changed (ex: draft changed
from RESERVED to REGISTERED) | [
"Update",
"the",
"parent",
"redirect",
"to",
"the",
"current",
"last",
"child",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/contrib/versioning.py#L149-L166 | train | Update the parent redirect to the current last child. |
adaptive-learning/proso-apps | proso_feedback/views.py | feedback | def feedback(request):
"""
Send feedback to the authors of the system.
GET parameters:
html
turn on the HTML version of the API
POST parameters (JSON):
text:
the main feedback content
email (optional):
user's e-mail
username (optional... | python | def feedback(request):
"""
Send feedback to the authors of the system.
GET parameters:
html
turn on the HTML version of the API
POST parameters (JSON):
text:
the main feedback content
email (optional):
user's e-mail
username (optional... | [
"def",
"feedback",
"(",
"request",
")",
":",
"if",
"request",
".",
"method",
"==",
"'GET'",
":",
"return",
"render",
"(",
"request",
",",
"'feedback_feedback.html'",
",",
"{",
"}",
",",
"help_text",
"=",
"feedback",
".",
"__doc__",
")",
"if",
"request",
... | Send feedback to the authors of the system.
GET parameters:
html
turn on the HTML version of the API
POST parameters (JSON):
text:
the main feedback content
email (optional):
user's e-mail
username (optional):
user's name | [
"Send",
"feedback",
"to",
"the",
"authors",
"of",
"the",
"system",
"."
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_feedback/views.py#L23-L79 | train | Send feedback to the authors of the system. |
adaptive-learning/proso-apps | proso_feedback/views.py | rating | def rating(request):
"""
Rate the current practice.
GET parameters:
html
turn on the HTML version of the API
POST parameters (JSON):
value:
one of the following numbers (how difficult questions are?):
(1) too easy,
(2) appropriate... | python | def rating(request):
"""
Rate the current practice.
GET parameters:
html
turn on the HTML version of the API
POST parameters (JSON):
value:
one of the following numbers (how difficult questions are?):
(1) too easy,
(2) appropriate... | [
"def",
"rating",
"(",
"request",
")",
":",
"if",
"request",
".",
"method",
"==",
"'GET'",
":",
"return",
"render",
"(",
"request",
",",
"'feedback_rating.html'",
",",
"{",
"}",
",",
"help_text",
"=",
"rating",
".",
"__doc__",
")",
"if",
"request",
".",
... | Rate the current practice.
GET parameters:
html
turn on the HTML version of the API
POST parameters (JSON):
value:
one of the following numbers (how difficult questions are?):
(1) too easy,
(2) appropriate,
(3) too difficu... | [
"Rate",
"the",
"current",
"practice",
"."
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_feedback/views.py#L83-L121 | train | Rate the current practice. |
adaptive-learning/proso-apps | proso_models/admin.py | pretty_date | def pretty_date(time=False):
"""
Get a datetime object or a int() Epoch timestamp and return a
pretty string like 'an hour ago', 'Yesterday', '3 months ago',
'just now', etc
"""
from datetime import datetime
from django.utils import timezone
now = timezone.now()
if isinstance(time, i... | python | def pretty_date(time=False):
"""
Get a datetime object or a int() Epoch timestamp and return a
pretty string like 'an hour ago', 'Yesterday', '3 months ago',
'just now', etc
"""
from datetime import datetime
from django.utils import timezone
now = timezone.now()
if isinstance(time, i... | [
"def",
"pretty_date",
"(",
"time",
"=",
"False",
")",
":",
"from",
"datetime",
"import",
"datetime",
"from",
"django",
".",
"utils",
"import",
"timezone",
"now",
"=",
"timezone",
".",
"now",
"(",
")",
"if",
"isinstance",
"(",
"time",
",",
"int",
")",
"... | Get a datetime object or a int() Epoch timestamp and return a
pretty string like 'an hour ago', 'Yesterday', '3 months ago',
'just now', etc | [
"Get",
"a",
"datetime",
"object",
"or",
"a",
"int",
"()",
"Epoch",
"timestamp",
"and",
"return",
"a",
"pretty",
"string",
"like",
"an",
"hour",
"ago",
"Yesterday",
"3",
"months",
"ago",
"just",
"now",
"etc"
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_models/admin.py#L7-L49 | train | Returns a pretty string of the date in the a
|
projectshift/shift-boiler | boiler/cli/colors.py | colour | def colour(colour, message, bold=False):
""" Color a message """
return style(fg=colour, text=message, bold=bold) | python | def colour(colour, message, bold=False):
""" Color a message """
return style(fg=colour, text=message, bold=bold) | [
"def",
"colour",
"(",
"colour",
",",
"message",
",",
"bold",
"=",
"False",
")",
":",
"return",
"style",
"(",
"fg",
"=",
"colour",
",",
"text",
"=",
"message",
",",
"bold",
"=",
"bold",
")"
] | Color a message | [
"Color",
"a",
"message"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/colors.py#L4-L6 | train | Color a message |
kata198/QueryableList | QueryableList/Base.py | getFiltersFromArgs | def getFiltersFromArgs(kwargs):
'''
getFiltersFromArgs - Returns a dictionary of each filter type, and the corrosponding field/value
@param kwargs <dict> - Dictionary of filter arguments
@return - Dictionary of each filter type (minus the ones that are optimized into others), each contain... | python | def getFiltersFromArgs(kwargs):
'''
getFiltersFromArgs - Returns a dictionary of each filter type, and the corrosponding field/value
@param kwargs <dict> - Dictionary of filter arguments
@return - Dictionary of each filter type (minus the ones that are optimized into others), each contain... | [
"def",
"getFiltersFromArgs",
"(",
"kwargs",
")",
":",
"# Create a copy of each possible filter in FILTER_TYPES and link to empty list.",
"# This object will be filled with all of the filters requested",
"ret",
"=",
"{",
"filterType",
":",
"list",
"(",
")",
"for",
"filterType",
"... | getFiltersFromArgs - Returns a dictionary of each filter type, and the corrosponding field/value
@param kwargs <dict> - Dictionary of filter arguments
@return - Dictionary of each filter type (minus the ones that are optimized into others), each containing a list of tuples, (fieldName, matchingValue) | [
"getFiltersFromArgs",
"-",
"Returns",
"a",
"dictionary",
"of",
"each",
"filter",
"type",
"and",
"the",
"corrosponding",
"field",
"/",
"value"
] | 279286d46205ce8268af42e03b75820a7483fddb | https://github.com/kata198/QueryableList/blob/279286d46205ce8268af42e03b75820a7483fddb/QueryableList/Base.py#L22-L86 | train | Returns a dictionary of each filter type and the corrosponding field and matching value. |
kata198/QueryableList | QueryableList/Base.py | QueryableListBase.customFilter | def customFilter(self, filterFunc):
'''
customFilter - Apply a custom filter to elements and return a QueryableList of matches
@param filterFunc <lambda/function< - A lambda/function that is passed an item, and
returns True if the item matches (will be returned), otherwis... | python | def customFilter(self, filterFunc):
'''
customFilter - Apply a custom filter to elements and return a QueryableList of matches
@param filterFunc <lambda/function< - A lambda/function that is passed an item, and
returns True if the item matches (will be returned), otherwis... | [
"def",
"customFilter",
"(",
"self",
",",
"filterFunc",
")",
":",
"ret",
"=",
"self",
".",
"__class__",
"(",
")",
"for",
"item",
"in",
"self",
":",
"if",
"filterFunc",
"(",
"item",
")",
":",
"ret",
".",
"append",
"(",
"item",
")",
"return",
"ret"
] | customFilter - Apply a custom filter to elements and return a QueryableList of matches
@param filterFunc <lambda/function< - A lambda/function that is passed an item, and
returns True if the item matches (will be returned), otherwise False.
@return - A QueryableList object of th... | [
"customFilter",
"-",
"Apply",
"a",
"custom",
"filter",
"to",
"elements",
"and",
"return",
"a",
"QueryableList",
"of",
"matches"
] | 279286d46205ce8268af42e03b75820a7483fddb | https://github.com/kata198/QueryableList/blob/279286d46205ce8268af42e03b75820a7483fddb/QueryableList/Base.py#L152-L166 | train | Apply a custom filter to elements and return a QueryableList of matches
|
kata198/QueryableList | QueryableList/Base.py | QueryableListBase.sort_by | def sort_by(self, fieldName, reverse=False):
'''
sort_by - Return a copy of this collection, sorted by the given fieldName.
The fieldName is accessed the same way as other filtering, so it supports custom properties, etc.
@param fieldName <str> - The name of the field o... | python | def sort_by(self, fieldName, reverse=False):
'''
sort_by - Return a copy of this collection, sorted by the given fieldName.
The fieldName is accessed the same way as other filtering, so it supports custom properties, etc.
@param fieldName <str> - The name of the field o... | [
"def",
"sort_by",
"(",
"self",
",",
"fieldName",
",",
"reverse",
"=",
"False",
")",
":",
"return",
"self",
".",
"__class__",
"(",
"sorted",
"(",
"self",
",",
"key",
"=",
"lambda",
"item",
":",
"self",
".",
"_get_item_value",
"(",
"item",
",",
"fieldNam... | sort_by - Return a copy of this collection, sorted by the given fieldName.
The fieldName is accessed the same way as other filtering, so it supports custom properties, etc.
@param fieldName <str> - The name of the field on which to sort by
@param reverse <bool> Default False... | [
"sort_by",
"-",
"Return",
"a",
"copy",
"of",
"this",
"collection",
"sorted",
"by",
"the",
"given",
"fieldName",
"."
] | 279286d46205ce8268af42e03b75820a7483fddb | https://github.com/kata198/QueryableList/blob/279286d46205ce8268af42e03b75820a7483fddb/QueryableList/Base.py#L180-L194 | train | Returns a copy of this collection sorted by the given fieldName. |
kata198/QueryableList | QueryableList/Base.py | QueryableListBase.filterAnd | def filterAnd(self, **kwargs):
'''
filter/filterAnd - Performs a filter and returns a QueryableList object of the same type.
All the provided filters must match for the item to be returned.
@params are in the format of fieldName__operation=value where fieldName is the ... | python | def filterAnd(self, **kwargs):
'''
filter/filterAnd - Performs a filter and returns a QueryableList object of the same type.
All the provided filters must match for the item to be returned.
@params are in the format of fieldName__operation=value where fieldName is the ... | [
"def",
"filterAnd",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"filters",
"=",
"getFiltersFromArgs",
"(",
"kwargs",
")",
"ret",
"=",
"self",
".",
"__class__",
"(",
")",
"if",
"USE_CACHED",
":",
"caches",
"=",
"[",
"dict",
"(",
")",
"for",
"i",
... | filter/filterAnd - Performs a filter and returns a QueryableList object of the same type.
All the provided filters must match for the item to be returned.
@params are in the format of fieldName__operation=value where fieldName is the name of the field on any given item, "operation" is one... | [
"filter",
"/",
"filterAnd",
"-",
"Performs",
"a",
"filter",
"and",
"returns",
"a",
"QueryableList",
"object",
"of",
"the",
"same",
"type",
"."
] | 279286d46205ce8268af42e03b75820a7483fddb | https://github.com/kata198/QueryableList/blob/279286d46205ce8268af42e03b75820a7483fddb/QueryableList/Base.py#L197-L549 | train | Filter and return a new list of items with only the matching items. |
kata198/QueryableList | QueryableList/Base.py | QueryableListBase.filterOr | def filterOr(self, **kwargs):
'''
filterOr - Performs a filter and returns a QueryableList object of the same type.
Anythe provided filters can match for the item to be returned.
@params are in the format of fieldName__operation=value where fieldName is the name of the... | python | def filterOr(self, **kwargs):
'''
filterOr - Performs a filter and returns a QueryableList object of the same type.
Anythe provided filters can match for the item to be returned.
@params are in the format of fieldName__operation=value where fieldName is the name of the... | [
"def",
"filterOr",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"filters",
"=",
"getFiltersFromArgs",
"(",
"kwargs",
")",
"ret",
"=",
"self",
".",
"__class__",
"(",
")",
"if",
"USE_CACHED",
":",
"caches",
"=",
"[",
"dict",
"(",
")",
"for",
"i",
... | filterOr - Performs a filter and returns a QueryableList object of the same type.
Anythe provided filters can match for the item to be returned.
@params are in the format of fieldName__operation=value where fieldName is the name of the field on any given item, "operation" is one of the gi... | [
"filterOr",
"-",
"Performs",
"a",
"filter",
"and",
"returns",
"a",
"QueryableList",
"object",
"of",
"the",
"same",
"type",
"."
] | 279286d46205ce8268af42e03b75820a7483fddb | https://github.com/kata198/QueryableList/blob/279286d46205ce8268af42e03b75820a7483fddb/QueryableList/Base.py#L559-L937 | train | This method filters the items in the collection and returns a QueryableList object with only the matching objects returned. |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | Credential.uri | def uri(self):
"""
Return sqlalchemy connect string URI.
"""
return self.uri_template.format(
host=self.host,
port="" if self.port is None else self.port,
database=self.database,
username=self.username,
password="" if self.passw... | python | def uri(self):
"""
Return sqlalchemy connect string URI.
"""
return self.uri_template.format(
host=self.host,
port="" if self.port is None else self.port,
database=self.database,
username=self.username,
password="" if self.passw... | [
"def",
"uri",
"(",
"self",
")",
":",
"return",
"self",
".",
"uri_template",
".",
"format",
"(",
"host",
"=",
"self",
".",
"host",
",",
"port",
"=",
"\"\"",
"if",
"self",
".",
"port",
"is",
"None",
"else",
"self",
".",
"port",
",",
"database",
"=",
... | Return sqlalchemy connect string URI. | [
"Return",
"sqlalchemy",
"connect",
"string",
"URI",
"."
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L46-L58 | train | Return sqlalchemy connect string URI. |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | Credential.from_json | def from_json(cls, json_file, json_path=None, key_mapping=None):
"""
Load connection credential from json file.
:param json_file: str, path to json file
:param json_path: str, dot notation of the path to the credential dict.
:param key_mapping: dict, map 'host', 'port', 'databas... | python | def from_json(cls, json_file, json_path=None, key_mapping=None):
"""
Load connection credential from json file.
:param json_file: str, path to json file
:param json_path: str, dot notation of the path to the credential dict.
:param key_mapping: dict, map 'host', 'port', 'databas... | [
"def",
"from_json",
"(",
"cls",
",",
"json_file",
",",
"json_path",
"=",
"None",
",",
"key_mapping",
"=",
"None",
")",
":",
"cls",
".",
"_validate_key_mapping",
"(",
"key_mapping",
")",
"with",
"open",
"(",
"json_file",
",",
"\"rb\"",
")",
"as",
"f",
":"... | Load connection credential from json file.
:param json_file: str, path to json file
:param json_path: str, dot notation of the path to the credential dict.
:param key_mapping: dict, map 'host', 'port', 'database', 'username', 'password'
to custom alias, for example ``{'host': 'h', '... | [
"Load",
"connection",
"credential",
"from",
"json",
"file",
"."
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L86-L127 | train | Load a new instance of the class from a json file. |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | Credential.from_home_db_json | def from_home_db_json(cls, identifier, key_mapping=None): # pragma: no cover
"""
Read credential from $HOME/.db.json file.
:type identifier: str
:param identifier: str, database identifier.
:type key_mapping: Dict[str, str]
:param key_mapping: dict
``.db.json`... | python | def from_home_db_json(cls, identifier, key_mapping=None): # pragma: no cover
"""
Read credential from $HOME/.db.json file.
:type identifier: str
:param identifier: str, database identifier.
:type key_mapping: Dict[str, str]
:param key_mapping: dict
``.db.json`... | [
"def",
"from_home_db_json",
"(",
"cls",
",",
"identifier",
",",
"key_mapping",
"=",
"None",
")",
":",
"# pragma: no cover",
"return",
"cls",
".",
"from_json",
"(",
"json_file",
"=",
"cls",
".",
"path_db_json",
",",
"json_path",
"=",
"identifier",
",",
"key_map... | Read credential from $HOME/.db.json file.
:type identifier: str
:param identifier: str, database identifier.
:type key_mapping: Dict[str, str]
:param key_mapping: dict
``.db.json````::
{
"identifier1": {
"host": "example.com",
... | [
"Read",
"credential",
"from",
"$HOME",
"/",
".",
"db",
".",
"json",
"file",
"."
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L130-L156 | train | Read credential from home. db. json file. |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | Credential.from_s3_json | def from_s3_json(cls, bucket_name, key,
json_path=None, key_mapping=None,
aws_profile=None,
aws_access_key_id=None,
aws_secret_access_key=None,
region_name=None): # pragma: no cover
"""
Load databas... | python | def from_s3_json(cls, bucket_name, key,
json_path=None, key_mapping=None,
aws_profile=None,
aws_access_key_id=None,
aws_secret_access_key=None,
region_name=None): # pragma: no cover
"""
Load databas... | [
"def",
"from_s3_json",
"(",
"cls",
",",
"bucket_name",
",",
"key",
",",
"json_path",
"=",
"None",
",",
"key_mapping",
"=",
"None",
",",
"aws_profile",
"=",
"None",
",",
"aws_access_key_id",
"=",
"None",
",",
"aws_secret_access_key",
"=",
"None",
",",
"region... | Load database credential from json on s3.
:param bucket_name: str
:param key: str
:param aws_profile: if None, assume that you are using this from
AWS cloud. (service on the same cloud doesn't need profile name)
:param aws_access_key_id: str, not recommend to use
:pa... | [
"Load",
"database",
"credential",
"from",
"json",
"on",
"s3",
"."
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L159-L188 | train | Load database credential from json on s3. |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | Credential.from_env | def from_env(cls, prefix, kms_decrypt=False, aws_profile=None):
"""
Load database credential from env variable.
- host: ENV.{PREFIX}_HOST
- port: ENV.{PREFIX}_PORT
- database: ENV.{PREFIX}_DATABASE
- username: ENV.{PREFIX}_USERNAME
- password: ENV.{PREFIX}_PASSWO... | python | def from_env(cls, prefix, kms_decrypt=False, aws_profile=None):
"""
Load database credential from env variable.
- host: ENV.{PREFIX}_HOST
- port: ENV.{PREFIX}_PORT
- database: ENV.{PREFIX}_DATABASE
- username: ENV.{PREFIX}_USERNAME
- password: ENV.{PREFIX}_PASSWO... | [
"def",
"from_env",
"(",
"cls",
",",
"prefix",
",",
"kms_decrypt",
"=",
"False",
",",
"aws_profile",
"=",
"None",
")",
":",
"if",
"len",
"(",
"prefix",
")",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"\"prefix can't be empty\"",
")",
"if",
"len",
"(",
"... | Load database credential from env variable.
- host: ENV.{PREFIX}_HOST
- port: ENV.{PREFIX}_PORT
- database: ENV.{PREFIX}_DATABASE
- username: ENV.{PREFIX}_USERNAME
- password: ENV.{PREFIX}_PASSWORD
:param prefix: str
:param kms_decrypt: bool
:param aws_p... | [
"Load",
"database",
"credential",
"from",
"env",
"variable",
"."
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L191-L241 | train | Load database credential from environment variable. |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | Credential.to_dict | def to_dict(self):
"""
Convert credentials into a dict.
"""
return dict(
host=self.host,
port=self.port,
database=self.database,
username=self.username,
password=self.password,
) | python | def to_dict(self):
"""
Convert credentials into a dict.
"""
return dict(
host=self.host,
port=self.port,
database=self.database,
username=self.username,
password=self.password,
) | [
"def",
"to_dict",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"host",
"=",
"self",
".",
"host",
",",
"port",
"=",
"self",
".",
"port",
",",
"database",
"=",
"self",
".",
"database",
",",
"username",
"=",
"self",
".",
"username",
",",
"password",
... | Convert credentials into a dict. | [
"Convert",
"credentials",
"into",
"a",
"dict",
"."
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L243-L253 | train | Convert credentials into a dict. |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | EngineCreator.create_sqlite | def create_sqlite(cls, path=":memory:", **kwargs):
"""
:rtype: Engine
"""
return sa.create_engine("sqlite:///{path}".format(path=path), **kwargs) | python | def create_sqlite(cls, path=":memory:", **kwargs):
"""
:rtype: Engine
"""
return sa.create_engine("sqlite:///{path}".format(path=path), **kwargs) | [
"def",
"create_sqlite",
"(",
"cls",
",",
"path",
"=",
"\":memory:\"",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"sa",
".",
"create_engine",
"(",
"\"sqlite:///{path}\"",
".",
"format",
"(",
"path",
"=",
"path",
")",
",",
"*",
"*",
"kwargs",
")"
] | :rtype: Engine | [
":",
"rtype",
":",
"Engine"
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L287-L291 | train | Create an engine for storing the current session s database entries. |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | EngineCreator.create_postgresql | def create_postgresql(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.psql), **kwargs
) | python | def create_postgresql(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.psql), **kwargs
) | [
"def",
"create_postgresql",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_ce",
"(",
"self",
".",
"_ccs",
"(",
"self",
".",
"DialectAndDriver",
".",
"psql",
")",
",",
"*",
"*",
"kwargs",
")"
] | :rtype: Engine | [
":",
"rtype",
":",
"Engine"
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L313-L319 | train | create a Postgresql engine |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | EngineCreator.create_postgresql_psycopg2 | def create_postgresql_psycopg2(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.psql_psycopg2), **kwargs
) | python | def create_postgresql_psycopg2(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.psql_psycopg2), **kwargs
) | [
"def",
"create_postgresql_psycopg2",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_ce",
"(",
"self",
".",
"_ccs",
"(",
"self",
".",
"DialectAndDriver",
".",
"psql_psycopg2",
")",
",",
"*",
"*",
"kwargs",
")"
] | :rtype: Engine | [
":",
"rtype",
":",
"Engine"
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L321-L327 | train | create an Engine object for PostgreSQL PSY copg2 |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | EngineCreator.create_postgresql_pg8000 | def create_postgresql_pg8000(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.psql_pg8000), **kwargs
) | python | def create_postgresql_pg8000(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.psql_pg8000), **kwargs
) | [
"def",
"create_postgresql_pg8000",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_ce",
"(",
"self",
".",
"_ccs",
"(",
"self",
".",
"DialectAndDriver",
".",
"psql_pg8000",
")",
",",
"*",
"*",
"kwargs",
")"
] | :rtype: Engine | [
":",
"rtype",
":",
"Engine"
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L329-L335 | train | create an Engine object for PostgreSQL PG8000 |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | EngineCreator._create_postgresql_pygresql | def _create_postgresql_pygresql(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.psql_pygresql), **kwargs
) | python | def _create_postgresql_pygresql(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.psql_pygresql), **kwargs
) | [
"def",
"_create_postgresql_pygresql",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_ce",
"(",
"self",
".",
"_ccs",
"(",
"self",
".",
"DialectAndDriver",
".",
"psql_pygresql",
")",
",",
"*",
"*",
"kwargs",
")"
] | :rtype: Engine | [
":",
"rtype",
":",
"Engine"
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L337-L343 | train | Create an Engine object for PostgreSQL and PySQL. |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | EngineCreator.create_postgresql_psycopg2cffi | def create_postgresql_psycopg2cffi(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.psql_psycopg2cffi), **kwargs
) | python | def create_postgresql_psycopg2cffi(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.psql_psycopg2cffi), **kwargs
) | [
"def",
"create_postgresql_psycopg2cffi",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_ce",
"(",
"self",
".",
"_ccs",
"(",
"self",
".",
"DialectAndDriver",
".",
"psql_psycopg2cffi",
")",
",",
"*",
"*",
"kwargs",
")"
] | :rtype: Engine | [
":",
"rtype",
":",
"Engine"
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L345-L351 | train | create an Engine object for PostgreSQL PSY CFFI |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | EngineCreator.create_postgresql_pypostgresql | def create_postgresql_pypostgresql(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.psql_pypostgresql), **kwargs
) | python | def create_postgresql_pypostgresql(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.psql_pypostgresql), **kwargs
) | [
"def",
"create_postgresql_pypostgresql",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_ce",
"(",
"self",
".",
"_ccs",
"(",
"self",
".",
"DialectAndDriver",
".",
"psql_pypostgresql",
")",
",",
"*",
"*",
"kwargs",
")"
] | :rtype: Engine | [
":",
"rtype",
":",
"Engine"
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L353-L359 | train | create an Engine object for PostgreSQL and PySQL |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | EngineCreator.create_mysql | def create_mysql(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.mysql), **kwargs
) | python | def create_mysql(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.mysql), **kwargs
) | [
"def",
"create_mysql",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_ce",
"(",
"self",
".",
"_ccs",
"(",
"self",
".",
"DialectAndDriver",
".",
"mysql",
")",
",",
"*",
"*",
"kwargs",
")"
] | :rtype: Engine | [
":",
"rtype",
":",
"Engine"
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L362-L368 | train | Returns an Engine
instance for the given mysql data. |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | EngineCreator.create_mysql_mysqldb | def create_mysql_mysqldb(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.mysql_mysqldb), **kwargs
) | python | def create_mysql_mysqldb(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.mysql_mysqldb), **kwargs
) | [
"def",
"create_mysql_mysqldb",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_ce",
"(",
"self",
".",
"_ccs",
"(",
"self",
".",
"DialectAndDriver",
".",
"mysql_mysqldb",
")",
",",
"*",
"*",
"kwargs",
")"
] | :rtype: Engine | [
":",
"rtype",
":",
"Engine"
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L370-L376 | train | Returns an Engine object for the MySQL database. |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | EngineCreator.create_mysql_mysqlconnector | def create_mysql_mysqlconnector(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.mysql_mysqlconnector), **kwargs
) | python | def create_mysql_mysqlconnector(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.mysql_mysqlconnector), **kwargs
) | [
"def",
"create_mysql_mysqlconnector",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_ce",
"(",
"self",
".",
"_ccs",
"(",
"self",
".",
"DialectAndDriver",
".",
"mysql_mysqlconnector",
")",
",",
"*",
"*",
"kwargs",
")"
] | :rtype: Engine | [
":",
"rtype",
":",
"Engine"
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L378-L384 | train | Returns a new MySQL connector instance. |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | EngineCreator.create_mysql_oursql | def create_mysql_oursql(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.mysql_oursql), **kwargs
) | python | def create_mysql_oursql(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.mysql_oursql), **kwargs
) | [
"def",
"create_mysql_oursql",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_ce",
"(",
"self",
".",
"_ccs",
"(",
"self",
".",
"DialectAndDriver",
".",
"mysql_oursql",
")",
",",
"*",
"*",
"kwargs",
")"
] | :rtype: Engine | [
":",
"rtype",
":",
"Engine"
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L386-L392 | train | Returns an Engine object for the mysql_oursql column. |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | EngineCreator.create_mysql_pymysql | def create_mysql_pymysql(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.mysql_pymysql), **kwargs
) | python | def create_mysql_pymysql(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.mysql_pymysql), **kwargs
) | [
"def",
"create_mysql_pymysql",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_ce",
"(",
"self",
".",
"_ccs",
"(",
"self",
".",
"DialectAndDriver",
".",
"mysql_pymysql",
")",
",",
"*",
"*",
"kwargs",
")"
] | :rtype: Engine | [
":",
"rtype",
":",
"Engine"
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L394-L400 | train | Returns an Engine
for MySQL_PYMYSQL. |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | EngineCreator.create_mysql_cymysql | def create_mysql_cymysql(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.mysql_cymysql), **kwargs
) | python | def create_mysql_cymysql(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.mysql_cymysql), **kwargs
) | [
"def",
"create_mysql_cymysql",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_ce",
"(",
"self",
".",
"_ccs",
"(",
"self",
".",
"DialectAndDriver",
".",
"mysql_cymysql",
")",
",",
"*",
"*",
"kwargs",
")"
] | :rtype: Engine | [
":",
"rtype",
":",
"Engine"
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L402-L408 | train | Returns an Engine
for the given mysql_cymysql. |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | EngineCreator.create_oracle | def create_oracle(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.oracle), **kwargs
) | python | def create_oracle(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.oracle), **kwargs
) | [
"def",
"create_oracle",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_ce",
"(",
"self",
".",
"_ccs",
"(",
"self",
".",
"DialectAndDriver",
".",
"oracle",
")",
",",
"*",
"*",
"kwargs",
")"
] | :rtype: Engine | [
":",
"rtype",
":",
"Engine"
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L411-L417 | train | Returns an Engine object for the given database entry. |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | EngineCreator.create_oracle_cx_oracle | def create_oracle_cx_oracle(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.oracle_cx_oracle), **kwargs
) | python | def create_oracle_cx_oracle(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.oracle_cx_oracle), **kwargs
) | [
"def",
"create_oracle_cx_oracle",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_ce",
"(",
"self",
".",
"_ccs",
"(",
"self",
".",
"DialectAndDriver",
".",
"oracle_cx_oracle",
")",
",",
"*",
"*",
"kwargs",
")"
] | :rtype: Engine | [
":",
"rtype",
":",
"Engine"
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L419-L425 | train | Returns an Engine object for the Oracle CX oracle. |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | EngineCreator.create_mssql_pyodbc | def create_mssql_pyodbc(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.mssql_pyodbc), **kwargs
) | python | def create_mssql_pyodbc(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.mssql_pyodbc), **kwargs
) | [
"def",
"create_mssql_pyodbc",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_ce",
"(",
"self",
".",
"_ccs",
"(",
"self",
".",
"DialectAndDriver",
".",
"mssql_pyodbc",
")",
",",
"*",
"*",
"kwargs",
")"
] | :rtype: Engine | [
":",
"rtype",
":",
"Engine"
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L428-L434 | train | create mssql_pyodbc engine |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | EngineCreator.create_mssql_pymssql | def create_mssql_pymssql(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.mssql_pymssql), **kwargs
) | python | def create_mssql_pymssql(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.mssql_pymssql), **kwargs
) | [
"def",
"create_mssql_pymssql",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_ce",
"(",
"self",
".",
"_ccs",
"(",
"self",
".",
"DialectAndDriver",
".",
"mssql_pymssql",
")",
",",
"*",
"*",
"kwargs",
")"
] | :rtype: Engine | [
":",
"rtype",
":",
"Engine"
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L436-L442 | train | Returns an Engine object for the mssql_pymssql dialect. |
MacHu-GWU/sqlalchemy_mate-project | sqlalchemy_mate/credential.py | EngineCreator.create_redshift | def create_redshift(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.redshift_psycopg2), **kwargs
) | python | def create_redshift(self, **kwargs):
"""
:rtype: Engine
"""
return self._ce(
self._ccs(self.DialectAndDriver.redshift_psycopg2), **kwargs
) | [
"def",
"create_redshift",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_ce",
"(",
"self",
".",
"_ccs",
"(",
"self",
".",
"DialectAndDriver",
".",
"redshift_psycopg2",
")",
",",
"*",
"*",
"kwargs",
")"
] | :rtype: Engine | [
":",
"rtype",
":",
"Engine"
] | 946754744c8870f083fd7b4339fca15d1d6128b2 | https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/credential.py#L445-L451 | train | Returns an instance of the Redshift Engine. |
gregoil/ipdbugger | ipdbugger/__init__.py | start_debugging | def start_debugging():
"""Start a debugging session after catching an exception.
This prints the traceback and start ipdb session in the frame of the error.
"""
exc_type, exc_value, exc_tb = sys.exc_info()
# If the exception has been annotated to be re-raised, raise the exception
if hasattr(ex... | python | def start_debugging():
"""Start a debugging session after catching an exception.
This prints the traceback and start ipdb session in the frame of the error.
"""
exc_type, exc_value, exc_tb = sys.exc_info()
# If the exception has been annotated to be re-raised, raise the exception
if hasattr(ex... | [
"def",
"start_debugging",
"(",
")",
":",
"exc_type",
",",
"exc_value",
",",
"exc_tb",
"=",
"sys",
".",
"exc_info",
"(",
")",
"# If the exception has been annotated to be re-raised, raise the exception",
"if",
"hasattr",
"(",
"exc_value",
",",
"'_ipdbugger_let_raise'",
"... | Start a debugging session after catching an exception.
This prints the traceback and start ipdb session in the frame of the error. | [
"Start",
"a",
"debugging",
"session",
"after",
"catching",
"an",
"exception",
"."
] | 9575734ec26f6be86ae263496d50eb60bb988b21 | https://github.com/gregoil/ipdbugger/blob/9575734ec26f6be86ae263496d50eb60bb988b21/ipdbugger/__init__.py#L85-L105 | train | Start a debugging session after catching an exception. This prints the traceback and starts ipdb session in the frame of the error. |
gregoil/ipdbugger | ipdbugger/__init__.py | get_last_lineno | def get_last_lineno(node):
"""Recursively find the last line number of the ast node."""
max_lineno = 0
if hasattr(node, "lineno"):
max_lineno = node.lineno
for _, field in ast.iter_fields(node):
if isinstance(field, list):
for value in field:
if isinstance(v... | python | def get_last_lineno(node):
"""Recursively find the last line number of the ast node."""
max_lineno = 0
if hasattr(node, "lineno"):
max_lineno = node.lineno
for _, field in ast.iter_fields(node):
if isinstance(field, list):
for value in field:
if isinstance(v... | [
"def",
"get_last_lineno",
"(",
"node",
")",
":",
"max_lineno",
"=",
"0",
"if",
"hasattr",
"(",
"node",
",",
"\"lineno\"",
")",
":",
"max_lineno",
"=",
"node",
".",
"lineno",
"for",
"_",
",",
"field",
"in",
"ast",
".",
"iter_fields",
"(",
"node",
")",
... | Recursively find the last line number of the ast node. | [
"Recursively",
"find",
"the",
"last",
"line",
"number",
"of",
"the",
"ast",
"node",
"."
] | 9575734ec26f6be86ae263496d50eb60bb988b21 | https://github.com/gregoil/ipdbugger/blob/9575734ec26f6be86ae263496d50eb60bb988b21/ipdbugger/__init__.py#L271-L287 | train | Recursively find the last line number of the ast node. |
gregoil/ipdbugger | ipdbugger/__init__.py | debug | def debug(victim=None, ignore_exceptions=(), catch_exception=None, depth=0):
"""A decorator function to catch exceptions and enter debug mode.
Args:
victim (typing.Union(type, function)): either a class or function to
wrap and debug.
ignore_exceptions (list): list of classes of exce... | python | def debug(victim=None, ignore_exceptions=(), catch_exception=None, depth=0):
"""A decorator function to catch exceptions and enter debug mode.
Args:
victim (typing.Union(type, function)): either a class or function to
wrap and debug.
ignore_exceptions (list): list of classes of exce... | [
"def",
"debug",
"(",
"victim",
"=",
"None",
",",
"ignore_exceptions",
"=",
"(",
")",
",",
"catch_exception",
"=",
"None",
",",
"depth",
"=",
"0",
")",
":",
"if",
"victim",
"is",
"None",
":",
"# Debug is used as a decorator so we need to return wrap function to",
... | A decorator function to catch exceptions and enter debug mode.
Args:
victim (typing.Union(type, function)): either a class or function to
wrap and debug.
ignore_exceptions (list): list of classes of exceptions not to catch.
catch_exception (type): class of exception to catch and... | [
"A",
"decorator",
"function",
"to",
"catch",
"exceptions",
"and",
"enter",
"debug",
"mode",
"."
] | 9575734ec26f6be86ae263496d50eb60bb988b21 | https://github.com/gregoil/ipdbugger/blob/9575734ec26f6be86ae263496d50eb60bb988b21/ipdbugger/__init__.py#L290-L428 | train | A function to catch exceptions and enter debug mode. |
gregoil/ipdbugger | ipdbugger/__init__.py | IPDBugger.do_raise | def do_raise(self, arg):
"""Raise the last exception caught."""
self.do_continue(arg)
# Annotating the exception for a continual re-raise
_, exc_value, _ = self.exc_info
exc_value._ipdbugger_let_raise = True
raise_(*self.exc_info) | python | def do_raise(self, arg):
"""Raise the last exception caught."""
self.do_continue(arg)
# Annotating the exception for a continual re-raise
_, exc_value, _ = self.exc_info
exc_value._ipdbugger_let_raise = True
raise_(*self.exc_info) | [
"def",
"do_raise",
"(",
"self",
",",
"arg",
")",
":",
"self",
".",
"do_continue",
"(",
"arg",
")",
"# Annotating the exception for a continual re-raise",
"_",
",",
"exc_value",
",",
"_",
"=",
"self",
".",
"exc_info",
"exc_value",
".",
"_ipdbugger_let_raise",
"="... | Raise the last exception caught. | [
"Raise",
"the",
"last",
"exception",
"caught",
"."
] | 9575734ec26f6be86ae263496d50eb60bb988b21 | https://github.com/gregoil/ipdbugger/blob/9575734ec26f6be86ae263496d50eb60bb988b21/ipdbugger/__init__.py#L48-L56 | train | Raise the last exception caught. |
gregoil/ipdbugger | ipdbugger/__init__.py | IPDBugger.do_retry | def do_retry(self, arg):
"""Rerun the previous command."""
prev_line = self.curframe.f_lineno - 1
# Make sure not to jump to the middle of the previous statement
while True:
try:
self.curframe.f_lineno = prev_line
break
except Valu... | python | def do_retry(self, arg):
"""Rerun the previous command."""
prev_line = self.curframe.f_lineno - 1
# Make sure not to jump to the middle of the previous statement
while True:
try:
self.curframe.f_lineno = prev_line
break
except Valu... | [
"def",
"do_retry",
"(",
"self",
",",
"arg",
")",
":",
"prev_line",
"=",
"self",
".",
"curframe",
".",
"f_lineno",
"-",
"1",
"# Make sure not to jump to the middle of the previous statement",
"while",
"True",
":",
"try",
":",
"self",
".",
"curframe",
".",
"f_line... | Rerun the previous command. | [
"Rerun",
"the",
"previous",
"command",
"."
] | 9575734ec26f6be86ae263496d50eb60bb988b21 | https://github.com/gregoil/ipdbugger/blob/9575734ec26f6be86ae263496d50eb60bb988b21/ipdbugger/__init__.py#L58-L72 | train | Rerun the previous command. |
gregoil/ipdbugger | ipdbugger/__init__.py | IPDBugger.dispatch_line | def dispatch_line(self, frame):
"""Handle line action and return the next line callback."""
callback = TerminalPdb.dispatch_line(self, frame)
# If the ipdb session ended, don't return a callback for the next line
if self.stoplineno == -1:
return None
return callback | python | def dispatch_line(self, frame):
"""Handle line action and return the next line callback."""
callback = TerminalPdb.dispatch_line(self, frame)
# If the ipdb session ended, don't return a callback for the next line
if self.stoplineno == -1:
return None
return callback | [
"def",
"dispatch_line",
"(",
"self",
",",
"frame",
")",
":",
"callback",
"=",
"TerminalPdb",
".",
"dispatch_line",
"(",
"self",
",",
"frame",
")",
"# If the ipdb session ended, don't return a callback for the next line",
"if",
"self",
".",
"stoplineno",
"==",
"-",
"... | Handle line action and return the next line callback. | [
"Handle",
"line",
"action",
"and",
"return",
"the",
"next",
"line",
"callback",
"."
] | 9575734ec26f6be86ae263496d50eb60bb988b21 | https://github.com/gregoil/ipdbugger/blob/9575734ec26f6be86ae263496d50eb60bb988b21/ipdbugger/__init__.py#L74-L82 | train | Handle line action and return the next line callback. |
gregoil/ipdbugger | ipdbugger/__init__.py | ErrorsCatchTransformer.wrap_with_try | def wrap_with_try(self, node):
"""Wrap an ast node in a 'try' node to enter debug on exception."""
handlers = []
if self.ignore_exceptions is None:
handlers.append(ast.ExceptHandler(type=None,
name=None,
... | python | def wrap_with_try(self, node):
"""Wrap an ast node in a 'try' node to enter debug on exception."""
handlers = []
if self.ignore_exceptions is None:
handlers.append(ast.ExceptHandler(type=None,
name=None,
... | [
"def",
"wrap_with_try",
"(",
"self",
",",
"node",
")",
":",
"handlers",
"=",
"[",
"]",
"if",
"self",
".",
"ignore_exceptions",
"is",
"None",
":",
"handlers",
".",
"append",
"(",
"ast",
".",
"ExceptHandler",
"(",
"type",
"=",
"None",
",",
"name",
"=",
... | Wrap an ast node in a 'try' node to enter debug on exception. | [
"Wrap",
"an",
"ast",
"node",
"in",
"a",
"try",
"node",
"to",
"enter",
"debug",
"on",
"exception",
"."
] | 9575734ec26f6be86ae263496d50eb60bb988b21 | https://github.com/gregoil/ipdbugger/blob/9575734ec26f6be86ae263496d50eb60bb988b21/ipdbugger/__init__.py#L134-L175 | train | Wrap an ast node in a try node to enter debug on exception. |
gregoil/ipdbugger | ipdbugger/__init__.py | ErrorsCatchTransformer.try_except_handler | def try_except_handler(self, node):
"""Handler for try except statement to ignore excepted exceptions."""
# List all excepted exception's names
excepted_types = []
for handler in node.handlers:
if handler.type is None:
excepted_types = None
bre... | python | def try_except_handler(self, node):
"""Handler for try except statement to ignore excepted exceptions."""
# List all excepted exception's names
excepted_types = []
for handler in node.handlers:
if handler.type is None:
excepted_types = None
bre... | [
"def",
"try_except_handler",
"(",
"self",
",",
"node",
")",
":",
"# List all excepted exception's names",
"excepted_types",
"=",
"[",
"]",
"for",
"handler",
"in",
"node",
".",
"handlers",
":",
"if",
"handler",
".",
"type",
"is",
"None",
":",
"excepted_types",
... | Handler for try except statement to ignore excepted exceptions. | [
"Handler",
"for",
"try",
"except",
"statement",
"to",
"ignore",
"excepted",
"exceptions",
"."
] | 9575734ec26f6be86ae263496d50eb60bb988b21 | https://github.com/gregoil/ipdbugger/blob/9575734ec26f6be86ae263496d50eb60bb988b21/ipdbugger/__init__.py#L177-L210 | train | Handler for try except statement to ignore excepted exceptions. |
gregoil/ipdbugger | ipdbugger/__init__.py | ErrorsCatchTransformer.visit_Call | def visit_Call(self, node):
"""Propagate 'debug' wrapper into inner function calls if needed.
Args:
node (ast.AST): node statement to surround.
"""
if self.depth == 0:
return node
if self.ignore_exceptions is None:
ignore_exceptions = ast.Nam... | python | def visit_Call(self, node):
"""Propagate 'debug' wrapper into inner function calls if needed.
Args:
node (ast.AST): node statement to surround.
"""
if self.depth == 0:
return node
if self.ignore_exceptions is None:
ignore_exceptions = ast.Nam... | [
"def",
"visit_Call",
"(",
"self",
",",
"node",
")",
":",
"if",
"self",
".",
"depth",
"==",
"0",
":",
"return",
"node",
"if",
"self",
".",
"ignore_exceptions",
"is",
"None",
":",
"ignore_exceptions",
"=",
"ast",
".",
"Name",
"(",
"\"None\"",
",",
"ast",... | Propagate 'debug' wrapper into inner function calls if needed.
Args:
node (ast.AST): node statement to surround. | [
"Propagate",
"debug",
"wrapper",
"into",
"inner",
"function",
"calls",
"if",
"needed",
"."
] | 9575734ec26f6be86ae263496d50eb60bb988b21 | https://github.com/gregoil/ipdbugger/blob/9575734ec26f6be86ae263496d50eb60bb988b21/ipdbugger/__init__.py#L213-L241 | train | Propagate debug wrapper into inner function calls if needed. |
gregoil/ipdbugger | ipdbugger/__init__.py | ErrorsCatchTransformer.generic_visit | def generic_visit(self, node):
"""Surround node statement with a try/except block to catch errors.
This method is called for every node of the parsed code, and only
changes statement lines.
Args:
node (ast.AST): node statement to surround.
"""
if (isinstance... | python | def generic_visit(self, node):
"""Surround node statement with a try/except block to catch errors.
This method is called for every node of the parsed code, and only
changes statement lines.
Args:
node (ast.AST): node statement to surround.
"""
if (isinstance... | [
"def",
"generic_visit",
"(",
"self",
",",
"node",
")",
":",
"if",
"(",
"isinstance",
"(",
"node",
",",
"ast",
".",
"stmt",
")",
"and",
"not",
"isinstance",
"(",
"node",
",",
"ast",
".",
"FunctionDef",
")",
")",
":",
"new_node",
"=",
"self",
".",
"w... | Surround node statement with a try/except block to catch errors.
This method is called for every node of the parsed code, and only
changes statement lines.
Args:
node (ast.AST): node statement to surround. | [
"Surround",
"node",
"statement",
"with",
"a",
"try",
"/",
"except",
"block",
"to",
"catch",
"errors",
"."
] | 9575734ec26f6be86ae263496d50eb60bb988b21 | https://github.com/gregoil/ipdbugger/blob/9575734ec26f6be86ae263496d50eb60bb988b21/ipdbugger/__init__.py#L243-L268 | train | Surround node statement with a try block to catch errors. |
PBR/MQ2 | MQ2/plugins/csv_plugin.py | is_csv_file | def is_csv_file(inputfile):
""" Return whether the provided file is a CSV file or not.
This checks if the first row of the file can be splitted by ',' and
if the resulting line contains more than 4 columns (Markers, linkage
group, chromosome, trait).
"""
try:
stream = open(inputfile)
... | python | def is_csv_file(inputfile):
""" Return whether the provided file is a CSV file or not.
This checks if the first row of the file can be splitted by ',' and
if the resulting line contains more than 4 columns (Markers, linkage
group, chromosome, trait).
"""
try:
stream = open(inputfile)
... | [
"def",
"is_csv_file",
"(",
"inputfile",
")",
":",
"try",
":",
"stream",
"=",
"open",
"(",
"inputfile",
")",
"row",
"=",
"stream",
".",
"readline",
"(",
")",
"except",
"(",
"IOError",
",",
"UnicodeDecodeError",
")",
":",
"# pragma: no cover",
"return",
"Fal... | Return whether the provided file is a CSV file or not.
This checks if the first row of the file can be splitted by ',' and
if the resulting line contains more than 4 columns (Markers, linkage
group, chromosome, trait). | [
"Return",
"whether",
"the",
"provided",
"file",
"is",
"a",
"CSV",
"file",
"or",
"not",
".",
"This",
"checks",
"if",
"the",
"first",
"row",
"of",
"the",
"file",
"can",
"be",
"splitted",
"by",
"and",
"if",
"the",
"resulting",
"line",
"contains",
"more",
... | 6d84dea47e6751333004743f588f03158e35c28d | https://github.com/PBR/MQ2/blob/6d84dea47e6751333004743f588f03158e35c28d/MQ2/plugins/csv_plugin.py#L37-L52 | train | Return whether the provided file is a CSV file or not. |
PBR/MQ2 | MQ2/plugins/csv_plugin.py | get_qtls_from_rqtl_data | def get_qtls_from_rqtl_data(matrix, lod_threshold):
""" Retrieve the list of significants QTLs for the given input
matrix and using the specified LOD threshold.
This assumes one QTL per linkage group.
:arg matrix, the MapQTL file read in memory
:arg threshold, threshold used to determine if a given... | python | def get_qtls_from_rqtl_data(matrix, lod_threshold):
""" Retrieve the list of significants QTLs for the given input
matrix and using the specified LOD threshold.
This assumes one QTL per linkage group.
:arg matrix, the MapQTL file read in memory
:arg threshold, threshold used to determine if a given... | [
"def",
"get_qtls_from_rqtl_data",
"(",
"matrix",
",",
"lod_threshold",
")",
":",
"t_matrix",
"=",
"list",
"(",
"zip",
"(",
"*",
"matrix",
")",
")",
"qtls",
"=",
"[",
"[",
"'Trait'",
",",
"'Linkage Group'",
",",
"'Position'",
",",
"'Exact marker'",
",",
"'L... | Retrieve the list of significants QTLs for the given input
matrix and using the specified LOD threshold.
This assumes one QTL per linkage group.
:arg matrix, the MapQTL file read in memory
:arg threshold, threshold used to determine if a given LOD value is
reflective the presence of a QTL. | [
"Retrieve",
"the",
"list",
"of",
"significants",
"QTLs",
"for",
"the",
"given",
"input",
"matrix",
"and",
"using",
"the",
"specified",
"LOD",
"threshold",
".",
"This",
"assumes",
"one",
"QTL",
"per",
"linkage",
"group",
"."
] | 6d84dea47e6751333004743f588f03158e35c28d | https://github.com/PBR/MQ2/blob/6d84dea47e6751333004743f588f03158e35c28d/MQ2/plugins/csv_plugin.py#L55-L100 | train | Retrieve the list of significants QTLs for the given input
matrix and using the specified LOD threshold. |
PBR/MQ2 | MQ2/plugins/csv_plugin.py | get_map_matrix | def get_map_matrix(inputfile):
""" Return the matrix representation of the genetic map.
:arg inputfile: the path to the input file from which to retrieve the
genetic map.
"""
matrix = read_input_file(inputfile, sep=',', noquote=True)
output = [['Locus', 'Group', 'Position']]
for row in... | python | def get_map_matrix(inputfile):
""" Return the matrix representation of the genetic map.
:arg inputfile: the path to the input file from which to retrieve the
genetic map.
"""
matrix = read_input_file(inputfile, sep=',', noquote=True)
output = [['Locus', 'Group', 'Position']]
for row in... | [
"def",
"get_map_matrix",
"(",
"inputfile",
")",
":",
"matrix",
"=",
"read_input_file",
"(",
"inputfile",
",",
"sep",
"=",
"','",
",",
"noquote",
"=",
"True",
")",
"output",
"=",
"[",
"[",
"'Locus'",
",",
"'Group'",
",",
"'Position'",
"]",
"]",
"for",
"... | Return the matrix representation of the genetic map.
:arg inputfile: the path to the input file from which to retrieve the
genetic map. | [
"Return",
"the",
"matrix",
"representation",
"of",
"the",
"genetic",
"map",
"."
] | 6d84dea47e6751333004743f588f03158e35c28d | https://github.com/PBR/MQ2/blob/6d84dea47e6751333004743f588f03158e35c28d/MQ2/plugins/csv_plugin.py#L103-L115 | train | Returns the matrix representation of the genetic map. |
PBR/MQ2 | MQ2/plugins/csv_plugin.py | CSVPlugin.get_files | def get_files(cls, folder):
""" Retrieve the list of files the plugin can work on.
Find this list based on the files name, files extension or even
actually by reading in the file.
:arg folder: the path to the folder containing the files to
check. This folder may contain sub-... | python | def get_files(cls, folder):
""" Retrieve the list of files the plugin can work on.
Find this list based on the files name, files extension or even
actually by reading in the file.
:arg folder: the path to the folder containing the files to
check. This folder may contain sub-... | [
"def",
"get_files",
"(",
"cls",
",",
"folder",
")",
":",
"filelist",
"=",
"[",
"]",
"if",
"folder",
"is",
"None",
"or",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"folder",
")",
":",
"return",
"filelist",
"for",
"root",
",",
"dirs",
",",
"files",... | Retrieve the list of files the plugin can work on.
Find this list based on the files name, files extension or even
actually by reading in the file.
:arg folder: the path to the folder containing the files to
check. This folder may contain sub-folders. | [
"Retrieve",
"the",
"list",
"of",
"files",
"the",
"plugin",
"can",
"work",
"on",
".",
"Find",
"this",
"list",
"based",
"on",
"the",
"files",
"name",
"files",
"extension",
"or",
"even",
"actually",
"by",
"reading",
"in",
"the",
"file",
"."
] | 6d84dea47e6751333004743f588f03158e35c28d | https://github.com/PBR/MQ2/blob/6d84dea47e6751333004743f588f03158e35c28d/MQ2/plugins/csv_plugin.py#L145-L162 | train | Retrieve the list of files that can be used in the plugin. |
PBR/MQ2 | MQ2/plugins/csv_plugin.py | CSVPlugin.convert_inputfiles | def convert_inputfiles(cls,
folder=None,
inputfile=None,
session=None,
lod_threshold=None,
qtls_file='qtls.csv',
matrix_file='qtls_matrix.csv',
... | python | def convert_inputfiles(cls,
folder=None,
inputfile=None,
session=None,
lod_threshold=None,
qtls_file='qtls.csv',
matrix_file='qtls_matrix.csv',
... | [
"def",
"convert_inputfiles",
"(",
"cls",
",",
"folder",
"=",
"None",
",",
"inputfile",
"=",
"None",
",",
"session",
"=",
"None",
",",
"lod_threshold",
"=",
"None",
",",
"qtls_file",
"=",
"'qtls.csv'",
",",
"matrix_file",
"=",
"'qtls_matrix.csv'",
",",
"map_f... | Convert the input files present in the given folder or
inputfile.
This method creates the matrix representation of the QTLs
results providing for each marker position the LOD value found
for each trait as well as a representation of the genetic map
used in the experiment.
... | [
"Convert",
"the",
"input",
"files",
"present",
"in",
"the",
"given",
"folder",
"or",
"inputfile",
".",
"This",
"method",
"creates",
"the",
"matrix",
"representation",
"of",
"the",
"QTLs",
"results",
"providing",
"for",
"each",
"marker",
"position",
"the",
"LOD... | 6d84dea47e6751333004743f588f03158e35c28d | https://github.com/PBR/MQ2/blob/6d84dea47e6751333004743f588f03158e35c28d/MQ2/plugins/csv_plugin.py#L165-L245 | train | This method converts the input files present in the folder or inputfile into a genetic map. |
projectshift/shift-boiler | boiler/user/session_interface.py | BoilerSessionInterface.save_session | def save_session(self, *args, **kwargs):
"""
Save session
Skip setting session cookie if requested via g.stateless_sessions
"""
# do not send session cookie
if g.get('stateless_sessions'):
return
# send cookie
return super(BoilerSessionInterf... | python | def save_session(self, *args, **kwargs):
"""
Save session
Skip setting session cookie if requested via g.stateless_sessions
"""
# do not send session cookie
if g.get('stateless_sessions'):
return
# send cookie
return super(BoilerSessionInterf... | [
"def",
"save_session",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# do not send session cookie",
"if",
"g",
".",
"get",
"(",
"'stateless_sessions'",
")",
":",
"return",
"# send cookie",
"return",
"super",
"(",
"BoilerSessionInterface",
... | Save session
Skip setting session cookie if requested via g.stateless_sessions | [
"Save",
"session",
"Skip",
"setting",
"session",
"cookie",
"if",
"requested",
"via",
"g",
".",
"stateless_sessions"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/user/session_interface.py#L45-L59 | train | Save session if requested via g. stateless_sessions
|
brunato/lograptor | lograptor/channels.py | MailChannel.send_report | def send_report(self, report_parts):
"""
Publish by sending the report by e-mail
"""
logger.info('Creating an email message')
report_parts = sorted(
filter(lambda x: x.fmt in self.formats, report_parts),
key=lambda x: self.formats.index(x.fmt)
)
... | python | def send_report(self, report_parts):
"""
Publish by sending the report by e-mail
"""
logger.info('Creating an email message')
report_parts = sorted(
filter(lambda x: x.fmt in self.formats, report_parts),
key=lambda x: self.formats.index(x.fmt)
)
... | [
"def",
"send_report",
"(",
"self",
",",
"report_parts",
")",
":",
"logger",
".",
"info",
"(",
"'Creating an email message'",
")",
"report_parts",
"=",
"sorted",
"(",
"filter",
"(",
"lambda",
"x",
":",
"x",
".",
"fmt",
"in",
"self",
".",
"formats",
",",
"... | Publish by sending the report by e-mail | [
"Publish",
"by",
"sending",
"the",
"report",
"by",
"e",
"-",
"mail"
] | b1f09fe1b429ed15110610092704ef12d253f3c9 | https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/channels.py#L351-L463 | train | Send a report by e - mail by sending it by e - mail. |
brunato/lograptor | lograptor/channels.py | FileChannel.prune_old | def prune_old(self):
"""
Removes the directories that are older than a certain date.
"""
path = self.pubdir
dirmask = self.dirmask
expire = self.expire
expire_limit = int(time.time()) - (86400 * expire)
logger.info('Pruning directories older than %d days'... | python | def prune_old(self):
"""
Removes the directories that are older than a certain date.
"""
path = self.pubdir
dirmask = self.dirmask
expire = self.expire
expire_limit = int(time.time()) - (86400 * expire)
logger.info('Pruning directories older than %d days'... | [
"def",
"prune_old",
"(",
"self",
")",
":",
"path",
"=",
"self",
".",
"pubdir",
"dirmask",
"=",
"self",
".",
"dirmask",
"expire",
"=",
"self",
".",
"expire",
"expire_limit",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
"-",
"(",
"86400",
"*"... | Removes the directories that are older than a certain date. | [
"Removes",
"the",
"directories",
"that",
"are",
"older",
"than",
"a",
"certain",
"date",
"."
] | b1f09fe1b429ed15110610092704ef12d253f3c9 | https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/channels.py#L512-L545 | train | Removes the directories that are older than a certain date. |
brunato/lograptor | lograptor/channels.py | FileChannel.send_report | def send_report(self, report_parts):
"""
Publish the report parts to local files. Each report part is a text
with a title and specific extension. For html and plaintext sending
the report part is unique, for csv send also the stats and unparsed
string are plain text and report it... | python | def send_report(self, report_parts):
"""
Publish the report parts to local files. Each report part is a text
with a title and specific extension. For html and plaintext sending
the report part is unique, for csv send also the stats and unparsed
string are plain text and report it... | [
"def",
"send_report",
"(",
"self",
",",
"report_parts",
")",
":",
"logger",
".",
"info",
"(",
"'Checking and creating the report directory'",
")",
"report_parts",
"=",
"sorted",
"(",
"filter",
"(",
"lambda",
"x",
":",
"x",
".",
"fmt",
"in",
"self",
".",
"for... | Publish the report parts to local files. Each report part is a text
with a title and specific extension. For html and plaintext sending
the report part is unique, for csv send also the stats and unparsed
string are plain text and report items are csv texts. | [
"Publish",
"the",
"report",
"parts",
"to",
"local",
"files",
".",
"Each",
"report",
"part",
"is",
"a",
"text",
"with",
"a",
"title",
"and",
"specific",
"extension",
".",
"For",
"html",
"and",
"plaintext",
"sending",
"the",
"report",
"part",
"is",
"unique",... | b1f09fe1b429ed15110610092704ef12d253f3c9 | https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/channels.py#L562-L623 | train | Send the report parts to local files. |
mardix/Mocha | mocha/utils.py | is_email_valid | def is_email_valid(email):
"""
Check if email is valid
"""
pattern = re.compile(r'[\w\.-]+@[\w\.-]+[.]\w+')
return bool(pattern.match(email)) | python | def is_email_valid(email):
"""
Check if email is valid
"""
pattern = re.compile(r'[\w\.-]+@[\w\.-]+[.]\w+')
return bool(pattern.match(email)) | [
"def",
"is_email_valid",
"(",
"email",
")",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"r'[\\w\\.-]+@[\\w\\.-]+[.]\\w+'",
")",
"return",
"bool",
"(",
"pattern",
".",
"match",
"(",
"email",
")",
")"
] | Check if email is valid | [
"Check",
"if",
"email",
"is",
"valid"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/utils.py#L51-L56 | train | Check if email is valid |
mardix/Mocha | mocha/utils.py | is_password_valid | def is_password_valid(password):
"""
Check if a password is valid
"""
pattern = re.compile(r"^.{4,75}$")
return bool(pattern.match(password)) | python | def is_password_valid(password):
"""
Check if a password is valid
"""
pattern = re.compile(r"^.{4,75}$")
return bool(pattern.match(password)) | [
"def",
"is_password_valid",
"(",
"password",
")",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"r\"^.{4,75}$\"",
")",
"return",
"bool",
"(",
"pattern",
".",
"match",
"(",
"password",
")",
")"
] | Check if a password is valid | [
"Check",
"if",
"a",
"password",
"is",
"valid"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/utils.py#L59-L64 | train | Check if a password is valid |
mardix/Mocha | mocha/utils.py | is_username_valid | def is_username_valid(username):
"""
Check if a valid username.
valid:
oracle
bill-gates
steve.jobs
micro_soft
not valid
Bill Gates - no space allowed
me@yo.com - @ is not a valid character
:param username: string
:return:
"""
pattern = re.... | python | def is_username_valid(username):
"""
Check if a valid username.
valid:
oracle
bill-gates
steve.jobs
micro_soft
not valid
Bill Gates - no space allowed
me@yo.com - @ is not a valid character
:param username: string
:return:
"""
pattern = re.... | [
"def",
"is_username_valid",
"(",
"username",
")",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"r\"^[a-zA-Z0-9_.-]+$\"",
")",
"return",
"bool",
"(",
"pattern",
".",
"match",
"(",
"username",
")",
")"
] | Check if a valid username.
valid:
oracle
bill-gates
steve.jobs
micro_soft
not valid
Bill Gates - no space allowed
me@yo.com - @ is not a valid character
:param username: string
:return: | [
"Check",
"if",
"a",
"valid",
"username",
".",
"valid",
":",
"oracle",
"bill",
"-",
"gates",
"steve",
".",
"jobs",
"micro_soft",
"not",
"valid",
"Bill",
"Gates",
"-",
"no",
"space",
"allowed",
"me"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/utils.py#L67-L82 | train | Check if a valid username. |
mardix/Mocha | mocha/utils.py | md5 | def md5(value):
"""
Create MD5
:param value:
:return:
"""
m = hashlib.md5()
m.update(value)
return str(m.hexdigest()) | python | def md5(value):
"""
Create MD5
:param value:
:return:
"""
m = hashlib.md5()
m.update(value)
return str(m.hexdigest()) | [
"def",
"md5",
"(",
"value",
")",
":",
"m",
"=",
"hashlib",
".",
"md5",
"(",
")",
"m",
".",
"update",
"(",
"value",
")",
"return",
"str",
"(",
"m",
".",
"hexdigest",
"(",
")",
")"
] | Create MD5
:param value:
:return: | [
"Create",
"MD5",
":",
"param",
"value",
":",
":",
"return",
":"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/utils.py#L103-L111 | train | Create MD5
|
mardix/Mocha | mocha/utils.py | chunk_list | def chunk_list(items, size):
"""
Return a list of chunks
:param items: List
:param size: int The number of items per chunk
:return: List
"""
size = max(1, size)
return [items[i:i + size] for i in range(0, len(items), size)] | python | def chunk_list(items, size):
"""
Return a list of chunks
:param items: List
:param size: int The number of items per chunk
:return: List
"""
size = max(1, size)
return [items[i:i + size] for i in range(0, len(items), size)] | [
"def",
"chunk_list",
"(",
"items",
",",
"size",
")",
":",
"size",
"=",
"max",
"(",
"1",
",",
"size",
")",
"return",
"[",
"items",
"[",
"i",
":",
"i",
"+",
"size",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"items",
")",
",",
... | Return a list of chunks
:param items: List
:param size: int The number of items per chunk
:return: List | [
"Return",
"a",
"list",
"of",
"chunks",
":",
"param",
"items",
":",
"List",
":",
"param",
"size",
":",
"int",
"The",
"number",
"of",
"items",
"per",
"chunk",
":",
"return",
":",
"List"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/utils.py#L122-L130 | train | Returns a list of chunks of size |
mardix/Mocha | mocha/utils.py | list_replace | def list_replace(subject_list, replacement, string):
"""
To replace a list of items by a single replacement
:param subject_list: list
:param replacement: string
:param string: string
:return: string
"""
for s in subject_list:
string = string.replace(s, replacement)
return str... | python | def list_replace(subject_list, replacement, string):
"""
To replace a list of items by a single replacement
:param subject_list: list
:param replacement: string
:param string: string
:return: string
"""
for s in subject_list:
string = string.replace(s, replacement)
return str... | [
"def",
"list_replace",
"(",
"subject_list",
",",
"replacement",
",",
"string",
")",
":",
"for",
"s",
"in",
"subject_list",
":",
"string",
"=",
"string",
".",
"replace",
"(",
"s",
",",
"replacement",
")",
"return",
"string"
] | To replace a list of items by a single replacement
:param subject_list: list
:param replacement: string
:param string: string
:return: string | [
"To",
"replace",
"a",
"list",
"of",
"items",
"by",
"a",
"single",
"replacement",
":",
"param",
"subject_list",
":",
"list",
":",
"param",
"replacement",
":",
"string",
":",
"param",
"string",
":",
"string",
":",
"return",
":",
"string"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/utils.py#L193-L203 | train | Replace a list of items by a single replacement |
mardix/Mocha | mocha/utils.py | dict_replace | def dict_replace(subject_dict, string):
"""
Replace a dict map, key to its value in the stirng
:param subject_dict: dict
:param string: string
:return: string
"""
for i, j in subject_dict.items():
string = string.replace(i, j)
return string | python | def dict_replace(subject_dict, string):
"""
Replace a dict map, key to its value in the stirng
:param subject_dict: dict
:param string: string
:return: string
"""
for i, j in subject_dict.items():
string = string.replace(i, j)
return string | [
"def",
"dict_replace",
"(",
"subject_dict",
",",
"string",
")",
":",
"for",
"i",
",",
"j",
"in",
"subject_dict",
".",
"items",
"(",
")",
":",
"string",
"=",
"string",
".",
"replace",
"(",
"i",
",",
"j",
")",
"return",
"string"
] | Replace a dict map, key to its value in the stirng
:param subject_dict: dict
:param string: string
:return: string | [
"Replace",
"a",
"dict",
"map",
"key",
"to",
"its",
"value",
"in",
"the",
"stirng",
":",
"param",
"subject_dict",
":",
"dict",
":",
"param",
"string",
":",
"string",
":",
"return",
":",
"string"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/utils.py#L206-L215 | train | Replace a dict key to its value in the stirng
|
mardix/Mocha | mocha/utils.py | sign_jwt | def sign_jwt(data, secret_key, expires_in, salt=None, **kw):
"""
To create a signed JWT
:param data:
:param secret_key:
:param expires_in:
:param salt:
:param kw:
:return: string
"""
s = itsdangerous.TimedJSONWebSignatureSerializer(secret_key=secret_key,
... | python | def sign_jwt(data, secret_key, expires_in, salt=None, **kw):
"""
To create a signed JWT
:param data:
:param secret_key:
:param expires_in:
:param salt:
:param kw:
:return: string
"""
s = itsdangerous.TimedJSONWebSignatureSerializer(secret_key=secret_key,
... | [
"def",
"sign_jwt",
"(",
"data",
",",
"secret_key",
",",
"expires_in",
",",
"salt",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"s",
"=",
"itsdangerous",
".",
"TimedJSONWebSignatureSerializer",
"(",
"secret_key",
"=",
"secret_key",
",",
"expires_in",
"=",
"... | To create a signed JWT
:param data:
:param secret_key:
:param expires_in:
:param salt:
:param kw:
:return: string | [
"To",
"create",
"a",
"signed",
"JWT",
":",
"param",
"data",
":",
":",
"param",
"secret_key",
":",
":",
"param",
"expires_in",
":",
":",
"param",
"salt",
":",
":",
"param",
"kw",
":",
":",
"return",
":",
"string"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/utils.py#L218-L232 | train | Create a signed JWT using the secret key and the given key and the given expires in. |
mardix/Mocha | mocha/utils.py | unsign_jwt | def unsign_jwt(token, secret_key, salt=None, **kw):
"""
To unsign a JWT token
:param token:
:param kw:
:return: mixed data
"""
s = itsdangerous.TimedJSONWebSignatureSerializer(secret_key, salt=salt, **kw)
return s.loads(token) | python | def unsign_jwt(token, secret_key, salt=None, **kw):
"""
To unsign a JWT token
:param token:
:param kw:
:return: mixed data
"""
s = itsdangerous.TimedJSONWebSignatureSerializer(secret_key, salt=salt, **kw)
return s.loads(token) | [
"def",
"unsign_jwt",
"(",
"token",
",",
"secret_key",
",",
"salt",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"s",
"=",
"itsdangerous",
".",
"TimedJSONWebSignatureSerializer",
"(",
"secret_key",
",",
"salt",
"=",
"salt",
",",
"*",
"*",
"kw",
")",
"ret... | To unsign a JWT token
:param token:
:param kw:
:return: mixed data | [
"To",
"unsign",
"a",
"JWT",
"token",
":",
"param",
"token",
":",
":",
"param",
"kw",
":",
":",
"return",
":",
"mixed",
"data"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/utils.py#L235-L243 | train | Unsign a JWT token |
mardix/Mocha | mocha/utils.py | sign_url_safe | def sign_url_safe(data, secret_key, expires_in=None, salt=None, **kw):
"""
To sign url safe data.
If expires_in is provided it will Time the signature
:param data: (mixed) the data to sign
:param secret_key: (string) the secret key
:param expires_in: (int) in minutes. Time to expire
:param s... | python | def sign_url_safe(data, secret_key, expires_in=None, salt=None, **kw):
"""
To sign url safe data.
If expires_in is provided it will Time the signature
:param data: (mixed) the data to sign
:param secret_key: (string) the secret key
:param expires_in: (int) in minutes. Time to expire
:param s... | [
"def",
"sign_url_safe",
"(",
"data",
",",
"secret_key",
",",
"expires_in",
"=",
"None",
",",
"salt",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"if",
"expires_in",
":",
"expires_in",
"*=",
"60",
"s",
"=",
"URLSafeTimedSerializer2",
"(",
"secret_key",
"=... | To sign url safe data.
If expires_in is provided it will Time the signature
:param data: (mixed) the data to sign
:param secret_key: (string) the secret key
:param expires_in: (int) in minutes. Time to expire
:param salt: (string) a namespace key
:param kw: kwargs for itsdangerous.URLSafeSeriali... | [
"To",
"sign",
"url",
"safe",
"data",
".",
"If",
"expires_in",
"is",
"provided",
"it",
"will",
"Time",
"the",
"signature",
":",
"param",
"data",
":",
"(",
"mixed",
")",
"the",
"data",
"to",
"sign",
":",
"param",
"secret_key",
":",
"(",
"string",
")",
... | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/utils.py#L267-L288 | train | Signs data in url safe format. |
mardix/Mocha | mocha/utils.py | unsign_url_safe | def unsign_url_safe(token, secret_key, salt=None, **kw):
"""
To sign url safe data.
If expires_in is provided it will Time the signature
:param token:
:param secret_key:
:param salt: (string) a namespace key
:param kw:
:return:
"""
if len(token.split(".")) == 3:
s = URLSa... | python | def unsign_url_safe(token, secret_key, salt=None, **kw):
"""
To sign url safe data.
If expires_in is provided it will Time the signature
:param token:
:param secret_key:
:param salt: (string) a namespace key
:param kw:
:return:
"""
if len(token.split(".")) == 3:
s = URLSa... | [
"def",
"unsign_url_safe",
"(",
"token",
",",
"secret_key",
",",
"salt",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"if",
"len",
"(",
"token",
".",
"split",
"(",
"\".\"",
")",
")",
"==",
"3",
":",
"s",
"=",
"URLSafeTimedSerializer2",
"(",
"secret_key... | To sign url safe data.
If expires_in is provided it will Time the signature
:param token:
:param secret_key:
:param salt: (string) a namespace key
:param kw:
:return: | [
"To",
"sign",
"url",
"safe",
"data",
".",
"If",
"expires_in",
"is",
"provided",
"it",
"will",
"Time",
"the",
"signature",
":",
"param",
"token",
":",
":",
"param",
"secret_key",
":",
":",
"param",
"salt",
":",
"(",
"string",
")",
"a",
"namespace",
"key... | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/utils.py#L291-L314 | train | Unsign url safe data. |
mardix/Mocha | mocha/utils.py | how_old | def how_old(dob):
"""
Calculate the age
:param dob: datetime object
:return: int
"""
today = datetime.date.today()
return today.year - dob.year - ((today.month, today.day) < (dob.month, dob.day)) | python | def how_old(dob):
"""
Calculate the age
:param dob: datetime object
:return: int
"""
today = datetime.date.today()
return today.year - dob.year - ((today.month, today.day) < (dob.month, dob.day)) | [
"def",
"how_old",
"(",
"dob",
")",
":",
"today",
"=",
"datetime",
".",
"date",
".",
"today",
"(",
")",
"return",
"today",
".",
"year",
"-",
"dob",
".",
"year",
"-",
"(",
"(",
"today",
".",
"month",
",",
"today",
".",
"day",
")",
"<",
"(",
"dob"... | Calculate the age
:param dob: datetime object
:return: int | [
"Calculate",
"the",
"age",
":",
"param",
"dob",
":",
"datetime",
"object",
":",
"return",
":",
"int"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/utils.py#L443-L450 | train | Calculate the age of the current node in the tree. |
mardix/Mocha | mocha/utils.py | dict_dot.get | def get(self, key, default=None):
"""
Access data via
:param key:
:param default: the default value
:return:
"""
try:
val = self
if "." not in key:
return self[key]
for k in key.split('.'):
if k.i... | python | def get(self, key, default=None):
"""
Access data via
:param key:
:param default: the default value
:return:
"""
try:
val = self
if "." not in key:
return self[key]
for k in key.split('.'):
if k.i... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"try",
":",
"val",
"=",
"self",
"if",
"\".\"",
"not",
"in",
"key",
":",
"return",
"self",
"[",
"key",
"]",
"for",
"k",
"in",
"key",
".",
"split",
"(",
"'.'",
")",
"... | Access data via
:param key:
:param default: the default value
:return: | [
"Access",
"data",
"via",
":",
"param",
"key",
":",
":",
"param",
"default",
":",
"the",
"default",
"value",
":",
"return",
":"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/utils.py#L173-L190 | train | Get the value of the key in the object. |
mardix/Mocha | mocha/utils.py | _InspectMethodsDecorators.parse | def parse(self):
"""
Return the list of string of all the decorators found
"""
self._parse(self.method)
return list(set([deco for deco in self.decos if deco])) | python | def parse(self):
"""
Return the list of string of all the decorators found
"""
self._parse(self.method)
return list(set([deco for deco in self.decos if deco])) | [
"def",
"parse",
"(",
"self",
")",
":",
"self",
".",
"_parse",
"(",
"self",
".",
"method",
")",
"return",
"list",
"(",
"set",
"(",
"[",
"deco",
"for",
"deco",
"in",
"self",
".",
"decos",
"if",
"deco",
"]",
")",
")"
] | Return the list of string of all the decorators found | [
"Return",
"the",
"list",
"of",
"string",
"of",
"all",
"the",
"decorators",
"found"
] | bce481cb31a0972061dd99bc548701411dcb9de3 | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/utils.py#L365-L370 | train | Parse the method and return a list of all the decorators found |
trendels/rhino | rhino/response.py | filter_304_headers | def filter_304_headers(headers):
"""Filter a list of headers to include in a "304 Not Modified" response."""
return [(k, v) for k, v in headers if k.lower() not in _filter_from_304] | python | def filter_304_headers(headers):
"""Filter a list of headers to include in a "304 Not Modified" response."""
return [(k, v) for k, v in headers if k.lower() not in _filter_from_304] | [
"def",
"filter_304_headers",
"(",
"headers",
")",
":",
"return",
"[",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"headers",
"if",
"k",
".",
"lower",
"(",
")",
"not",
"in",
"_filter_from_304",
"]"
] | Filter a list of headers to include in a "304 Not Modified" response. | [
"Filter",
"a",
"list",
"of",
"headers",
"to",
"include",
"in",
"a",
"304",
"Not",
"Modified",
"response",
"."
] | f1f0ef21b6080a2bd130b38b5bef163074c94aed | https://github.com/trendels/rhino/blob/f1f0ef21b6080a2bd130b38b5bef163074c94aed/rhino/response.py#L41-L43 | train | Filter a list of headers to include in a 304 Not Modified response. |
trendels/rhino | rhino/response.py | response | def response(code, body='', etag=None, last_modified=None, expires=None, **kw):
"""Helper to build an HTTP response.
Parameters:
code
: An integer status code.
body
: The response body. See `Response.__init__` for details.
etag
: A value for the ETag header. Double quotes will be... | python | def response(code, body='', etag=None, last_modified=None, expires=None, **kw):
"""Helper to build an HTTP response.
Parameters:
code
: An integer status code.
body
: The response body. See `Response.__init__` for details.
etag
: A value for the ETag header. Double quotes will be... | [
"def",
"response",
"(",
"code",
",",
"body",
"=",
"''",
",",
"etag",
"=",
"None",
",",
"last_modified",
"=",
"None",
",",
"expires",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"if",
"etag",
"is",
"not",
"None",
":",
"if",
"not",
"(",
"etag",
"... | Helper to build an HTTP response.
Parameters:
code
: An integer status code.
body
: The response body. See `Response.__init__` for details.
etag
: A value for the ETag header. Double quotes will be added unless the
string starts and ends with a double quote.
last_modified... | [
"Helper",
"to",
"build",
"an",
"HTTP",
"response",
"."
] | f1f0ef21b6080a2bd130b38b5bef163074c94aed | https://github.com/trendels/rhino/blob/f1f0ef21b6080a2bd130b38b5bef163074c94aed/rhino/response.py#L362-L404 | train | Returns a new Response object. |
trendels/rhino | rhino/response.py | ok | def ok(body='', code=200, **kw):
"""Shortcut for response(200, ...).
The status code must be in the 2xx range."""
if not 200 <= code < 300:
raise ValueError("Not a 2xx status code: '%s'" % code)
return response(code=code, body=body, **kw) | python | def ok(body='', code=200, **kw):
"""Shortcut for response(200, ...).
The status code must be in the 2xx range."""
if not 200 <= code < 300:
raise ValueError("Not a 2xx status code: '%s'" % code)
return response(code=code, body=body, **kw) | [
"def",
"ok",
"(",
"body",
"=",
"''",
",",
"code",
"=",
"200",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"200",
"<=",
"code",
"<",
"300",
":",
"raise",
"ValueError",
"(",
"\"Not a 2xx status code: '%s'\"",
"%",
"code",
")",
"return",
"response",
"("... | Shortcut for response(200, ...).
The status code must be in the 2xx range. | [
"Shortcut",
"for",
"response",
"(",
"200",
"...",
")",
"."
] | f1f0ef21b6080a2bd130b38b5bef163074c94aed | https://github.com/trendels/rhino/blob/f1f0ef21b6080a2bd130b38b5bef163074c94aed/rhino/response.py#L407-L413 | train | Shortcut for response. ok |
trendels/rhino | rhino/response.py | redirect | def redirect(location, code=302, **kw):
"""Shortcut for response(302, location=location, ...)
The status code must be in the 3xx range."""
if not 300 <= code < 400:
raise ValueError("Not a 3xx status code: '%s'" % code)
return response(code=code, location=location, **kw) | python | def redirect(location, code=302, **kw):
"""Shortcut for response(302, location=location, ...)
The status code must be in the 3xx range."""
if not 300 <= code < 400:
raise ValueError("Not a 3xx status code: '%s'" % code)
return response(code=code, location=location, **kw) | [
"def",
"redirect",
"(",
"location",
",",
"code",
"=",
"302",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"300",
"<=",
"code",
"<",
"400",
":",
"raise",
"ValueError",
"(",
"\"Not a 3xx status code: '%s'\"",
"%",
"code",
")",
"return",
"response",
"(",
"... | Shortcut for response(302, location=location, ...)
The status code must be in the 3xx range. | [
"Shortcut",
"for",
"response",
"(",
"302",
"location",
"=",
"location",
"...",
")"
] | f1f0ef21b6080a2bd130b38b5bef163074c94aed | https://github.com/trendels/rhino/blob/f1f0ef21b6080a2bd130b38b5bef163074c94aed/rhino/response.py#L426-L432 | train | Shortcut for response |
trendels/rhino | rhino/response.py | Response.body | def body(self):
"""Seralizes and returns the response body.
On subsequent access, returns the cached value."""
if self._body is None:
raw_body = self._raw_body
if self._body_writer is None:
self._body = raw_body() if callable(raw_body) else raw_body
... | python | def body(self):
"""Seralizes and returns the response body.
On subsequent access, returns the cached value."""
if self._body is None:
raw_body = self._raw_body
if self._body_writer is None:
self._body = raw_body() if callable(raw_body) else raw_body
... | [
"def",
"body",
"(",
"self",
")",
":",
"if",
"self",
".",
"_body",
"is",
"None",
":",
"raw_body",
"=",
"self",
".",
"_raw_body",
"if",
"self",
".",
"_body_writer",
"is",
"None",
":",
"self",
".",
"_body",
"=",
"raw_body",
"(",
")",
"if",
"callable",
... | Seralizes and returns the response body.
On subsequent access, returns the cached value. | [
"Seralizes",
"and",
"returns",
"the",
"response",
"body",
"."
] | f1f0ef21b6080a2bd130b38b5bef163074c94aed | https://github.com/trendels/rhino/blob/f1f0ef21b6080a2bd130b38b5bef163074c94aed/rhino/response.py#L189-L200 | train | Seralizes and returns the response body. On subsequent access returns the cached value. On subsequent access returns the cached value. |
trendels/rhino | rhino/response.py | Response.set_cookie | def set_cookie(self, key, value='', max_age=None, path='/', domain=None,
secure=False, httponly=False, expires=None):
"""Set a response cookie.
Parameters:
key
: The cookie name.
value
: The cookie value.
max_age
: The maximum ag... | python | def set_cookie(self, key, value='', max_age=None, path='/', domain=None,
secure=False, httponly=False, expires=None):
"""Set a response cookie.
Parameters:
key
: The cookie name.
value
: The cookie value.
max_age
: The maximum ag... | [
"def",
"set_cookie",
"(",
"self",
",",
"key",
",",
"value",
"=",
"''",
",",
"max_age",
"=",
"None",
",",
"path",
"=",
"'/'",
",",
"domain",
"=",
"None",
",",
"secure",
"=",
"False",
",",
"httponly",
"=",
"False",
",",
"expires",
"=",
"None",
")",
... | Set a response cookie.
Parameters:
key
: The cookie name.
value
: The cookie value.
max_age
: The maximum age of the cookie in seconds, or as a
datetime.timedelta object.
path
: Restrict the cookie to this path (default: '/').... | [
"Set",
"a",
"response",
"cookie",
"."
] | f1f0ef21b6080a2bd130b38b5bef163074c94aed | https://github.com/trendels/rhino/blob/f1f0ef21b6080a2bd130b38b5bef163074c94aed/rhino/response.py#L210-L259 | train | Set a response cookie. |
trendels/rhino | rhino/response.py | Response.delete_cookie | def delete_cookie(self, key, path='/', domain=None):
"""Delete a cookie (by setting it to a blank value).
The path and domain values must match that of the original cookie.
"""
self.set_cookie(key, value='', max_age=0, path=path, domain=domain,
expires=datetime.u... | python | def delete_cookie(self, key, path='/', domain=None):
"""Delete a cookie (by setting it to a blank value).
The path and domain values must match that of the original cookie.
"""
self.set_cookie(key, value='', max_age=0, path=path, domain=domain,
expires=datetime.u... | [
"def",
"delete_cookie",
"(",
"self",
",",
"key",
",",
"path",
"=",
"'/'",
",",
"domain",
"=",
"None",
")",
":",
"self",
".",
"set_cookie",
"(",
"key",
",",
"value",
"=",
"''",
",",
"max_age",
"=",
"0",
",",
"path",
"=",
"path",
",",
"domain",
"="... | Delete a cookie (by setting it to a blank value).
The path and domain values must match that of the original cookie. | [
"Delete",
"a",
"cookie",
"(",
"by",
"setting",
"it",
"to",
"a",
"blank",
"value",
")",
"."
] | f1f0ef21b6080a2bd130b38b5bef163074c94aed | https://github.com/trendels/rhino/blob/f1f0ef21b6080a2bd130b38b5bef163074c94aed/rhino/response.py#L261-L267 | train | Delete a cookie by setting it to a blank value. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.