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 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
obulpathi/cdn-fastly-python | bin/fastly_upload_vcl.py | main | def main():
"""
Upload a vcl file to a fastly service, cloning the current version if
necessary. The uploaded vcl is set as main unless --include is given.
All existing vcl files will be deleted first if --delete is given.
"""
parser = OptionParser(description=
"Upload ... | python | def main():
"""
Upload a vcl file to a fastly service, cloning the current version if
necessary. The uploaded vcl is set as main unless --include is given.
All existing vcl files will be deleted first if --delete is given.
"""
parser = OptionParser(description=
"Upload ... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"OptionParser",
"(",
"description",
"=",
"\"Upload a vcl file (set as main) to a given fastly service. All arguments are required.\"",
")",
"parser",
".",
"add_option",
"(",
"\"-k\"",
",",
"\"--key\"",
",",
"dest",
"=",
"\"ap... | Upload a vcl file to a fastly service, cloning the current version if
necessary. The uploaded vcl is set as main unless --include is given.
All existing vcl files will be deleted first if --delete is given. | [
"Upload",
"a",
"vcl",
"file",
"to",
"a",
"fastly",
"service",
"cloning",
"the",
"current",
"version",
"if",
"necessary",
".",
"The",
"uploaded",
"vcl",
"is",
"set",
"as",
"main",
"unless",
"--",
"include",
"is",
"given",
".",
"All",
"existing",
"vcl",
"f... | db2564b047e8af4bce72c3b88d6c27d3d0291425 | https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/bin/fastly_upload_vcl.py#L34-L111 | train |
OLC-Bioinformatics/sipprverse | customsippr/customsippr.py | CustomGenes.main | def main(self):
"""
Run the necessary methods in the correct order
"""
self.target_validate()
self.gene_names()
Sippr(inputobject=self,
k=self.kmer_size,
allow_soft_clips=self.allow_soft_clips)
self.report() | python | def main(self):
"""
Run the necessary methods in the correct order
"""
self.target_validate()
self.gene_names()
Sippr(inputobject=self,
k=self.kmer_size,
allow_soft_clips=self.allow_soft_clips)
self.report() | [
"def",
"main",
"(",
"self",
")",
":",
"self",
".",
"target_validate",
"(",
")",
"self",
".",
"gene_names",
"(",
")",
"Sippr",
"(",
"inputobject",
"=",
"self",
",",
"k",
"=",
"self",
".",
"kmer_size",
",",
"allow_soft_clips",
"=",
"self",
".",
"allow_so... | Run the necessary methods in the correct order | [
"Run",
"the",
"necessary",
"methods",
"in",
"the",
"correct",
"order"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/customsippr/customsippr.py#L13-L22 | train |
OLC-Bioinformatics/sipprverse | customsippr/customsippr.py | CustomGenes.gene_names | def gene_names(self):
"""
Extract the names of the user-supplied targets
"""
# Iterate through all the target names in the formatted targets file
for record in SeqIO.parse(self.targets, 'fasta'):
# Append all the gene names to the list of names
self.genes.... | python | def gene_names(self):
"""
Extract the names of the user-supplied targets
"""
# Iterate through all the target names in the formatted targets file
for record in SeqIO.parse(self.targets, 'fasta'):
# Append all the gene names to the list of names
self.genes.... | [
"def",
"gene_names",
"(",
"self",
")",
":",
"# Iterate through all the target names in the formatted targets file",
"for",
"record",
"in",
"SeqIO",
".",
"parse",
"(",
"self",
".",
"targets",
",",
"'fasta'",
")",
":",
"# Append all the gene names to the list of names",
"se... | Extract the names of the user-supplied targets | [
"Extract",
"the",
"names",
"of",
"the",
"user",
"-",
"supplied",
"targets"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/customsippr/customsippr.py#L32-L39 | train |
OLC-Bioinformatics/sipprverse | customsippr/customsippr.py | CustomGenes.report | def report(self):
"""
Create the report for the user-supplied targets
"""
# Add all the genes to the header
header = 'Sample,'
data = str()
with open(os.path.join(self.reportpath, '{at}.csv'.format(at=self.analysistype)), 'w') as report:
write_header =... | python | def report(self):
"""
Create the report for the user-supplied targets
"""
# Add all the genes to the header
header = 'Sample,'
data = str()
with open(os.path.join(self.reportpath, '{at}.csv'.format(at=self.analysistype)), 'w') as report:
write_header =... | [
"def",
"report",
"(",
"self",
")",
":",
"# Add all the genes to the header",
"header",
"=",
"'Sample,'",
"data",
"=",
"str",
"(",
")",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"reportpath",
",",
"'{at}.csv'",
".",
"format",
... | Create the report for the user-supplied targets | [
"Create",
"the",
"report",
"for",
"the",
"user",
"-",
"supplied",
"targets"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/customsippr/customsippr.py#L41-L81 | train |
benoitkugler/abstractDataLibrary | pyDLib/GUI/fields.py | Tels.on_add | def on_add(self, item):
"""Convert to pseuso acces"""
super(Tels, self).on_add(list_views.PseudoAccesCategorie(item)) | python | def on_add(self, item):
"""Convert to pseuso acces"""
super(Tels, self).on_add(list_views.PseudoAccesCategorie(item)) | [
"def",
"on_add",
"(",
"self",
",",
"item",
")",
":",
"super",
"(",
"Tels",
",",
"self",
")",
".",
"on_add",
"(",
"list_views",
".",
"PseudoAccesCategorie",
"(",
"item",
")",
")"
] | Convert to pseuso acces | [
"Convert",
"to",
"pseuso",
"acces"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/fields.py#L70-L72 | train |
benoitkugler/abstractDataLibrary | pyDLib/GUI/fields.py | Duree.set_data | def set_data(self, *args):
"""we cant to call set_data to manually update"""
db = self.begining.get_data() or formats.DATE_DEFAULT
df = self.end.get_data() or formats.DATE_DEFAULT
jours = max((df - db).days + 1, 0)
self.setText(str(jours) + (jours >= 2 and " jours" or " jour")) | python | def set_data(self, *args):
"""we cant to call set_data to manually update"""
db = self.begining.get_data() or formats.DATE_DEFAULT
df = self.end.get_data() or formats.DATE_DEFAULT
jours = max((df - db).days + 1, 0)
self.setText(str(jours) + (jours >= 2 and " jours" or " jour")) | [
"def",
"set_data",
"(",
"self",
",",
"*",
"args",
")",
":",
"db",
"=",
"self",
".",
"begining",
".",
"get_data",
"(",
")",
"or",
"formats",
".",
"DATE_DEFAULT",
"df",
"=",
"self",
".",
"end",
".",
"get_data",
"(",
")",
"or",
"formats",
".",
"DATE_D... | we cant to call set_data to manually update | [
"we",
"cant",
"to",
"call",
"set_data",
"to",
"manually",
"update"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/fields.py#L95-L100 | train |
OLC-Bioinformatics/sipprverse | genesippr/genesippr.py | GeneSippr.runner | def runner(self):
"""
Run the necessary methods in the correct order
"""
logging.info('Starting {} analysis pipeline'.format(self.analysistype))
if not self.pipeline:
general = None
for sample in self.runmetadata.samples:
general = getattr(... | python | def runner(self):
"""
Run the necessary methods in the correct order
"""
logging.info('Starting {} analysis pipeline'.format(self.analysistype))
if not self.pipeline:
general = None
for sample in self.runmetadata.samples:
general = getattr(... | [
"def",
"runner",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Starting {} analysis pipeline'",
".",
"format",
"(",
"self",
".",
"analysistype",
")",
")",
"if",
"not",
"self",
".",
"pipeline",
":",
"general",
"=",
"None",
"for",
"sample",
"in",
"... | Run the necessary methods in the correct order | [
"Run",
"the",
"necessary",
"methods",
"in",
"the",
"correct",
"order"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/genesippr/genesippr.py#L19-L39 | train |
tsnaomi/finnsyll | finnsyll/prev/v01.py | same_syllabic_feature | def same_syllabic_feature(ch1, ch2):
'''Return True if ch1 and ch2 are both vowels or both consonants.'''
if ch1 == '.' or ch2 == '.':
return False
ch1 = 'V' if ch1 in VOWELS else 'C' if ch1 in CONSONANTS else None
ch2 = 'V' if ch2 in VOWELS else 'C' if ch2 in CONSONANTS else None
return c... | python | def same_syllabic_feature(ch1, ch2):
'''Return True if ch1 and ch2 are both vowels or both consonants.'''
if ch1 == '.' or ch2 == '.':
return False
ch1 = 'V' if ch1 in VOWELS else 'C' if ch1 in CONSONANTS else None
ch2 = 'V' if ch2 in VOWELS else 'C' if ch2 in CONSONANTS else None
return c... | [
"def",
"same_syllabic_feature",
"(",
"ch1",
",",
"ch2",
")",
":",
"if",
"ch1",
"==",
"'.'",
"or",
"ch2",
"==",
"'.'",
":",
"return",
"False",
"ch1",
"=",
"'V'",
"if",
"ch1",
"in",
"VOWELS",
"else",
"'C'",
"if",
"ch1",
"in",
"CONSONANTS",
"else",
"Non... | Return True if ch1 and ch2 are both vowels or both consonants. | [
"Return",
"True",
"if",
"ch1",
"and",
"ch2",
"are",
"both",
"vowels",
"or",
"both",
"consonants",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v01.py#L14-L22 | train |
tsnaomi/finnsyll | finnsyll/prev/v01.py | syllabify | def syllabify(word):
'''Syllabify the given word.'''
word = replace_umlauts(word)
word = apply_T1(word)
word = apply_T2(word)
word = apply_T4(word)
word = apply_T5(word)
word = apply_T6(word)
word = apply_T7(word)
word = replace_umlauts(word, put_back=True)[1:] # FENCEPOST
r... | python | def syllabify(word):
'''Syllabify the given word.'''
word = replace_umlauts(word)
word = apply_T1(word)
word = apply_T2(word)
word = apply_T4(word)
word = apply_T5(word)
word = apply_T6(word)
word = apply_T7(word)
word = replace_umlauts(word, put_back=True)[1:] # FENCEPOST
r... | [
"def",
"syllabify",
"(",
"word",
")",
":",
"word",
"=",
"replace_umlauts",
"(",
"word",
")",
"word",
"=",
"apply_T1",
"(",
"word",
")",
"word",
"=",
"apply_T2",
"(",
"word",
")",
"word",
"=",
"apply_T4",
"(",
"word",
")",
"word",
"=",
"apply_T5",
"("... | Syllabify the given word. | [
"Syllabify",
"the",
"given",
"word",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v01.py#L56-L70 | train |
tsnaomi/finnsyll | finnsyll/prev/v01.py | apply_T1 | def apply_T1(word):
'''There is a syllable boundary in front of every CV-sequence.'''
WORD = _split_consonants_and_vowels(word)
for k, v in WORD.iteritems():
if k == 1 and is_consonantal_onset(v):
WORD[k] = '.' + v
elif is_consonant(v[0]) and WORD.get(k + 1, 0):
WO... | python | def apply_T1(word):
'''There is a syllable boundary in front of every CV-sequence.'''
WORD = _split_consonants_and_vowels(word)
for k, v in WORD.iteritems():
if k == 1 and is_consonantal_onset(v):
WORD[k] = '.' + v
elif is_consonant(v[0]) and WORD.get(k + 1, 0):
WO... | [
"def",
"apply_T1",
"(",
"word",
")",
":",
"WORD",
"=",
"_split_consonants_and_vowels",
"(",
"word",
")",
"for",
"k",
",",
"v",
"in",
"WORD",
".",
"iteritems",
"(",
")",
":",
"if",
"k",
"==",
"1",
"and",
"is_consonantal_onset",
"(",
"v",
")",
":",
"WO... | There is a syllable boundary in front of every CV-sequence. | [
"There",
"is",
"a",
"syllable",
"boundary",
"in",
"front",
"of",
"every",
"CV",
"-",
"sequence",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v01.py#L75-L89 | train |
tsnaomi/finnsyll | finnsyll/prev/v01.py | apply_T2 | def apply_T2(word):
'''There is a syllable boundary within a sequence VV of two nonidentical
that are not a genuine diphthong, e.g., [ta.e], [ko.et.taa].'''
WORD = _split_consonants_and_vowels(word)
for k, v in WORD.iteritems():
if is_diphthong(v):
continue
if len(v) == 2 ... | python | def apply_T2(word):
'''There is a syllable boundary within a sequence VV of two nonidentical
that are not a genuine diphthong, e.g., [ta.e], [ko.et.taa].'''
WORD = _split_consonants_and_vowels(word)
for k, v in WORD.iteritems():
if is_diphthong(v):
continue
if len(v) == 2 ... | [
"def",
"apply_T2",
"(",
"word",
")",
":",
"WORD",
"=",
"_split_consonants_and_vowels",
"(",
"word",
")",
"for",
"k",
",",
"v",
"in",
"WORD",
".",
"iteritems",
"(",
")",
":",
"if",
"is_diphthong",
"(",
"v",
")",
":",
"continue",
"if",
"len",
"(",
"v",... | There is a syllable boundary within a sequence VV of two nonidentical
that are not a genuine diphthong, e.g., [ta.e], [ko.et.taa]. | [
"There",
"is",
"a",
"syllable",
"boundary",
"within",
"a",
"sequence",
"VV",
"of",
"two",
"nonidentical",
"that",
"are",
"not",
"a",
"genuine",
"diphthong",
"e",
".",
"g",
".",
"[",
"ta",
".",
"e",
"]",
"[",
"ko",
".",
"et",
".",
"taa",
"]",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v01.py#L94-L111 | train |
tsnaomi/finnsyll | finnsyll/prev/v01.py | apply_T4 | def apply_T4(word): # OPTIMIZE
'''An agglutination diphthong that ends in /u, y/ usually contains a
syllable boundary when -C# or -CCV follow, e.g., [lau.ka.us],
[va.ka.ut.taa].'''
WORD = _split_consonants_and_vowels(word)
for k, v in WORD.iteritems():
if len(v) == 2 and v.endswith(('u', ... | python | def apply_T4(word): # OPTIMIZE
'''An agglutination diphthong that ends in /u, y/ usually contains a
syllable boundary when -C# or -CCV follow, e.g., [lau.ka.us],
[va.ka.ut.taa].'''
WORD = _split_consonants_and_vowels(word)
for k, v in WORD.iteritems():
if len(v) == 2 and v.endswith(('u', ... | [
"def",
"apply_T4",
"(",
"word",
")",
":",
"# OPTIMIZE",
"WORD",
"=",
"_split_consonants_and_vowels",
"(",
"word",
")",
"for",
"k",
",",
"v",
"in",
"WORD",
".",
"iteritems",
"(",
")",
":",
"if",
"len",
"(",
"v",
")",
"==",
"2",
"and",
"v",
".",
"end... | An agglutination diphthong that ends in /u, y/ usually contains a
syllable boundary when -C# or -CCV follow, e.g., [lau.ka.us],
[va.ka.ut.taa]. | [
"An",
"agglutination",
"diphthong",
"that",
"ends",
"in",
"/",
"u",
"y",
"/",
"usually",
"contains",
"a",
"syllable",
"boundary",
"when",
"-",
"C#",
"or",
"-",
"CCV",
"follow",
"e",
".",
"g",
".",
"[",
"lau",
".",
"ka",
".",
"us",
"]",
"[",
"va",
... | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v01.py#L116-L141 | train |
tsnaomi/finnsyll | finnsyll/prev/v01.py | apply_T5 | def apply_T5(word):
'''If a (V)VVV-sequence contains a VV-sequence that could be an /i/-final
diphthong, there is a syllable boundary between it and the third vowel,
e.g., [raa.ois.sa], [huo.uim.me], [la.eis.sa], [sel.vi.äi.si], [tai.an],
[säi.e], [oi.om.me].'''
WORD = _split_consonants_and_vowels(w... | python | def apply_T5(word):
'''If a (V)VVV-sequence contains a VV-sequence that could be an /i/-final
diphthong, there is a syllable boundary between it and the third vowel,
e.g., [raa.ois.sa], [huo.uim.me], [la.eis.sa], [sel.vi.äi.si], [tai.an],
[säi.e], [oi.om.me].'''
WORD = _split_consonants_and_vowels(w... | [
"def",
"apply_T5",
"(",
"word",
")",
":",
"WORD",
"=",
"_split_consonants_and_vowels",
"(",
"word",
")",
"for",
"k",
",",
"v",
"in",
"WORD",
".",
"iteritems",
"(",
")",
":",
"if",
"len",
"(",
"v",
")",
">=",
"3",
"and",
"is_vowel",
"(",
"v",
"[",
... | If a (V)VVV-sequence contains a VV-sequence that could be an /i/-final
diphthong, there is a syllable boundary between it and the third vowel,
e.g., [raa.ois.sa], [huo.uim.me], [la.eis.sa], [sel.vi.äi.si], [tai.an],
[säi.e], [oi.om.me]. | [
"If",
"a",
"(",
"V",
")",
"VVV",
"-",
"sequence",
"contains",
"a",
"VV",
"-",
"sequence",
"that",
"could",
"be",
"an",
"/",
"i",
"/",
"-",
"final",
"diphthong",
"there",
"is",
"a",
"syllable",
"boundary",
"between",
"it",
"and",
"the",
"third",
"vowe... | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v01.py#L149-L172 | train |
tsnaomi/finnsyll | finnsyll/prev/v01.py | apply_T6 | def apply_T6(word):
'''If a VVV-sequence contains a long vowel, there is a syllable boundary
between it and the third vowel, e.g. [kor.ke.aa], [yh.ti.öön], [ruu.an],
[mää.yt.te].'''
WORD = _split_consonants_and_vowels(word)
for k, v in WORD.iteritems():
if len(v) == 3 and is_vowel(v[0]):
... | python | def apply_T6(word):
'''If a VVV-sequence contains a long vowel, there is a syllable boundary
between it and the third vowel, e.g. [kor.ke.aa], [yh.ti.öön], [ruu.an],
[mää.yt.te].'''
WORD = _split_consonants_and_vowels(word)
for k, v in WORD.iteritems():
if len(v) == 3 and is_vowel(v[0]):
... | [
"def",
"apply_T6",
"(",
"word",
")",
":",
"WORD",
"=",
"_split_consonants_and_vowels",
"(",
"word",
")",
"for",
"k",
",",
"v",
"in",
"WORD",
".",
"iteritems",
"(",
")",
":",
"if",
"len",
"(",
"v",
")",
"==",
"3",
"and",
"is_vowel",
"(",
"v",
"[",
... | If a VVV-sequence contains a long vowel, there is a syllable boundary
between it and the third vowel, e.g. [kor.ke.aa], [yh.ti.öön], [ruu.an],
[mää.yt.te]. | [
"If",
"a",
"VVV",
"-",
"sequence",
"contains",
"a",
"long",
"vowel",
"there",
"is",
"a",
"syllable",
"boundary",
"between",
"it",
"and",
"the",
"third",
"vowel",
"e",
".",
"g",
".",
"[",
"kor",
".",
"ke",
".",
"aa",
"]",
"[",
"yh",
".",
"ti",
"."... | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v01.py#L180-L202 | train |
tsnaomi/finnsyll | finnsyll/prev/v01.py | apply_T7 | def apply_T7(word):
'''If a VVV-sequence does not contain a potential /i/-final diphthong,
there is a syllable boundary between the second and third vowels, e.g.
[kau.an], [leu.an], [kiu.as].'''
WORD = _split_consonants_and_vowels(word)
for k, v in WORD.iteritems():
if len(v) == 3 and is_v... | python | def apply_T7(word):
'''If a VVV-sequence does not contain a potential /i/-final diphthong,
there is a syllable boundary between the second and third vowels, e.g.
[kau.an], [leu.an], [kiu.as].'''
WORD = _split_consonants_and_vowels(word)
for k, v in WORD.iteritems():
if len(v) == 3 and is_v... | [
"def",
"apply_T7",
"(",
"word",
")",
":",
"WORD",
"=",
"_split_consonants_and_vowels",
"(",
"word",
")",
"for",
"k",
",",
"v",
"in",
"WORD",
".",
"iteritems",
"(",
")",
":",
"if",
"len",
"(",
"v",
")",
"==",
"3",
"and",
"is_vowel",
"(",
"v",
"[",
... | If a VVV-sequence does not contain a potential /i/-final diphthong,
there is a syllable boundary between the second and third vowels, e.g.
[kau.an], [leu.an], [kiu.as]. | [
"If",
"a",
"VVV",
"-",
"sequence",
"does",
"not",
"contain",
"a",
"potential",
"/",
"i",
"/",
"-",
"final",
"diphthong",
"there",
"is",
"a",
"syllable",
"boundary",
"between",
"the",
"second",
"and",
"third",
"vowels",
"e",
".",
"g",
".",
"[",
"kau",
... | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v01.py#L207-L220 | train |
tsnaomi/finnsyll | finnsyll/prev/v12.py | syllabify | def syllabify(word):
'''Syllabify the given word, whether simplex or complex.'''
compound = not word.isalpha()
syllabify = _syllabify_complex if compound else _syllabify_simplex
syllabifications = list(syllabify(word))
# if variation, order variants from most preferred to least preferred
if len... | python | def syllabify(word):
'''Syllabify the given word, whether simplex or complex.'''
compound = not word.isalpha()
syllabify = _syllabify_complex if compound else _syllabify_simplex
syllabifications = list(syllabify(word))
# if variation, order variants from most preferred to least preferred
if len... | [
"def",
"syllabify",
"(",
"word",
")",
":",
"compound",
"=",
"not",
"word",
".",
"isalpha",
"(",
")",
"syllabify",
"=",
"_syllabify_complex",
"if",
"compound",
"else",
"_syllabify_simplex",
"syllabifications",
"=",
"list",
"(",
"syllabify",
"(",
"word",
")",
... | Syllabify the given word, whether simplex or complex. | [
"Syllabify",
"the",
"given",
"word",
"whether",
"simplex",
"or",
"complex",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v12.py#L17-L28 | train |
tsnaomi/finnsyll | finnsyll/prev/v12.py | wsp | def wsp(word):
'''Return the number of unstressed superheavy syllables.'''
violations = 0
unstressed = []
for w in extract_words(word):
unstressed += w.split('.')[1::2] # even syllables
# include extrametrical odd syllables as potential WSP violations
if w.count('.') % 2 == 0:... | python | def wsp(word):
'''Return the number of unstressed superheavy syllables.'''
violations = 0
unstressed = []
for w in extract_words(word):
unstressed += w.split('.')[1::2] # even syllables
# include extrametrical odd syllables as potential WSP violations
if w.count('.') % 2 == 0:... | [
"def",
"wsp",
"(",
"word",
")",
":",
"violations",
"=",
"0",
"unstressed",
"=",
"[",
"]",
"for",
"w",
"in",
"extract_words",
"(",
"word",
")",
":",
"unstressed",
"+=",
"w",
".",
"split",
"(",
"'.'",
")",
"[",
"1",
":",
":",
"2",
"]",
"# even syll... | Return the number of unstressed superheavy syllables. | [
"Return",
"the",
"number",
"of",
"unstressed",
"superheavy",
"syllables",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v12.py#L359-L383 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/data_model.py | abstractAcces.modifie | def modifie(self, key: str, value: Any) -> None:
"""Store the modification. `value` should be dumped in DB compatible format."""
if key in self.FIELDS_OPTIONS:
self.modifie_options(key, value)
else:
self.modifications[key] = value | python | def modifie(self, key: str, value: Any) -> None:
"""Store the modification. `value` should be dumped in DB compatible format."""
if key in self.FIELDS_OPTIONS:
self.modifie_options(key, value)
else:
self.modifications[key] = value | [
"def",
"modifie",
"(",
"self",
",",
"key",
":",
"str",
",",
"value",
":",
"Any",
")",
"->",
"None",
":",
"if",
"key",
"in",
"self",
".",
"FIELDS_OPTIONS",
":",
"self",
".",
"modifie_options",
"(",
"key",
",",
"value",
")",
"else",
":",
"self",
".",... | Store the modification. `value` should be dumped in DB compatible format. | [
"Store",
"the",
"modification",
".",
"value",
"should",
"be",
"dumped",
"in",
"DB",
"compatible",
"format",
"."
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L57-L62 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/data_model.py | abstractAcces.modifie_many | def modifie_many(self, dic: dict):
"""Convenience function which calls modifie on each element of dic"""
for i, v in dic.items():
self.modifie(i, v) | python | def modifie_many(self, dic: dict):
"""Convenience function which calls modifie on each element of dic"""
for i, v in dic.items():
self.modifie(i, v) | [
"def",
"modifie_many",
"(",
"self",
",",
"dic",
":",
"dict",
")",
":",
"for",
"i",
",",
"v",
"in",
"dic",
".",
"items",
"(",
")",
":",
"self",
".",
"modifie",
"(",
"i",
",",
"v",
")"
] | Convenience function which calls modifie on each element of dic | [
"Convenience",
"function",
"which",
"calls",
"modifie",
"on",
"each",
"element",
"of",
"dic"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L64-L67 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/data_model.py | abstractAcces.save | def save(self) -> sql.Executant:
"""Prepare a SQL request to save the current modifications.
Returns actually a LIST of requests (which may be of length one).
Note than it can include modifications on other part of the data.
After succes, the base should be updated.
"""
r... | python | def save(self) -> sql.Executant:
"""Prepare a SQL request to save the current modifications.
Returns actually a LIST of requests (which may be of length one).
Note than it can include modifications on other part of the data.
After succes, the base should be updated.
"""
r... | [
"def",
"save",
"(",
"self",
")",
"->",
"sql",
".",
"Executant",
":",
"r",
"=",
"self",
".",
"_dict_to_SQL",
"(",
"self",
".",
"modifications",
")",
"self",
".",
"modifications",
".",
"clear",
"(",
")",
"return",
"r"
] | Prepare a SQL request to save the current modifications.
Returns actually a LIST of requests (which may be of length one).
Note than it can include modifications on other part of the data.
After succes, the base should be updated. | [
"Prepare",
"a",
"SQL",
"request",
"to",
"save",
"the",
"current",
"modifications",
".",
"Returns",
"actually",
"a",
"LIST",
"of",
"requests",
"(",
"which",
"may",
"be",
"of",
"length",
"one",
")",
".",
"Note",
"than",
"it",
"can",
"include",
"modifications... | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L73-L81 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/data_model.py | abstractAcces.modifie_options | def modifie_options(self, field_option, value):
"""Set options in modifications.
All options will be stored since it should be grouped in the DB."""
options = dict(self["options"] or {}, **{field_option: value})
self.modifications["options"] = options | python | def modifie_options(self, field_option, value):
"""Set options in modifications.
All options will be stored since it should be grouped in the DB."""
options = dict(self["options"] or {}, **{field_option: value})
self.modifications["options"] = options | [
"def",
"modifie_options",
"(",
"self",
",",
"field_option",
",",
"value",
")",
":",
"options",
"=",
"dict",
"(",
"self",
"[",
"\"options\"",
"]",
"or",
"{",
"}",
",",
"*",
"*",
"{",
"field_option",
":",
"value",
"}",
")",
"self",
".",
"modifications",
... | Set options in modifications.
All options will be stored since it should be grouped in the DB. | [
"Set",
"options",
"in",
"modifications",
".",
"All",
"options",
"will",
"be",
"stored",
"since",
"it",
"should",
"be",
"grouped",
"in",
"the",
"DB",
"."
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L86-L90 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/data_model.py | abstractDictTable._from_dict_dict | def _from_dict_dict(cls, dic):
"""Takes a dict {id : dict_attributes} """
return cls({_convert_id(i): v for i, v in dic.items()}) | python | def _from_dict_dict(cls, dic):
"""Takes a dict {id : dict_attributes} """
return cls({_convert_id(i): v for i, v in dic.items()}) | [
"def",
"_from_dict_dict",
"(",
"cls",
",",
"dic",
")",
":",
"return",
"cls",
"(",
"{",
"_convert_id",
"(",
"i",
")",
":",
"v",
"for",
"i",
",",
"v",
"in",
"dic",
".",
"items",
"(",
")",
"}",
")"
] | Takes a dict {id : dict_attributes} | [
"Takes",
"a",
"dict",
"{",
"id",
":",
"dict_attributes",
"}"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L114-L116 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/data_model.py | abstractDictTable._from_list_dict | def _from_list_dict(cls, list_dic):
"""Takes a list of dict like objects and uses `champ_id` field as Id"""
return cls({_convert_id(dic[cls.CHAMP_ID]): dict(dic) for dic in list_dic}) | python | def _from_list_dict(cls, list_dic):
"""Takes a list of dict like objects and uses `champ_id` field as Id"""
return cls({_convert_id(dic[cls.CHAMP_ID]): dict(dic) for dic in list_dic}) | [
"def",
"_from_list_dict",
"(",
"cls",
",",
"list_dic",
")",
":",
"return",
"cls",
"(",
"{",
"_convert_id",
"(",
"dic",
"[",
"cls",
".",
"CHAMP_ID",
"]",
")",
":",
"dict",
"(",
"dic",
")",
"for",
"dic",
"in",
"list_dic",
"}",
")"
] | Takes a list of dict like objects and uses `champ_id` field as Id | [
"Takes",
"a",
"list",
"of",
"dict",
"like",
"objects",
"and",
"uses",
"champ_id",
"field",
"as",
"Id"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L119-L121 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/data_model.py | abstractDictTable.base_recherche_rapide | def base_recherche_rapide(self, base, pattern, to_string_hook=None):
"""
Return a collection of access matching `pattern`.
`to_string_hook` is an optionnal callable dict -> str to map record to string. Default to _record_to_string
"""
Ac = self.ACCES
if pattern == "*":
... | python | def base_recherche_rapide(self, base, pattern, to_string_hook=None):
"""
Return a collection of access matching `pattern`.
`to_string_hook` is an optionnal callable dict -> str to map record to string. Default to _record_to_string
"""
Ac = self.ACCES
if pattern == "*":
... | [
"def",
"base_recherche_rapide",
"(",
"self",
",",
"base",
",",
"pattern",
",",
"to_string_hook",
"=",
"None",
")",
":",
"Ac",
"=",
"self",
".",
"ACCES",
"if",
"pattern",
"==",
"\"*\"",
":",
"return",
"groups",
".",
"Collection",
"(",
"Ac",
"(",
"base",
... | Return a collection of access matching `pattern`.
`to_string_hook` is an optionnal callable dict -> str to map record to string. Default to _record_to_string | [
"Return",
"a",
"collection",
"of",
"access",
"matching",
"pattern",
".",
"to_string_hook",
"is",
"an",
"optionnal",
"callable",
"dict",
"-",
">",
"str",
"to",
"map",
"record",
"to",
"string",
".",
"Default",
"to",
"_record_to_string"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L141-L167 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/data_model.py | abstractDictTable.select_by_field | def select_by_field(self, base, field, value):
"""Return collection of acces whose field equal value"""
Ac = self.ACCES
return groups.Collection(Ac(base, i) for i, row in self.items() if row[field] == value) | python | def select_by_field(self, base, field, value):
"""Return collection of acces whose field equal value"""
Ac = self.ACCES
return groups.Collection(Ac(base, i) for i, row in self.items() if row[field] == value) | [
"def",
"select_by_field",
"(",
"self",
",",
"base",
",",
"field",
",",
"value",
")",
":",
"Ac",
"=",
"self",
".",
"ACCES",
"return",
"groups",
".",
"Collection",
"(",
"Ac",
"(",
"base",
",",
"i",
")",
"for",
"i",
",",
"row",
"in",
"self",
".",
"i... | Return collection of acces whose field equal value | [
"Return",
"collection",
"of",
"acces",
"whose",
"field",
"equal",
"value"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L169-L172 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/data_model.py | abstractDictTable.select_by_critere | def select_by_critere(self, base, criteria):
"""
:param base: Reference on whole base
:param criteria: Callable abstractAcces -> Bool, acting as filter
:return: Collection on acces passing the criteria
"""
Ac = self.ACCES
return groups.Collection(Ac(base, i) for i... | python | def select_by_critere(self, base, criteria):
"""
:param base: Reference on whole base
:param criteria: Callable abstractAcces -> Bool, acting as filter
:return: Collection on acces passing the criteria
"""
Ac = self.ACCES
return groups.Collection(Ac(base, i) for i... | [
"def",
"select_by_critere",
"(",
"self",
",",
"base",
",",
"criteria",
")",
":",
"Ac",
"=",
"self",
".",
"ACCES",
"return",
"groups",
".",
"Collection",
"(",
"Ac",
"(",
"base",
",",
"i",
")",
"for",
"i",
"in",
"self",
"if",
"criteria",
"(",
"Ac",
"... | :param base: Reference on whole base
:param criteria: Callable abstractAcces -> Bool, acting as filter
:return: Collection on acces passing the criteria | [
":",
"param",
"base",
":",
"Reference",
"on",
"whole",
"base",
":",
"param",
"criteria",
":",
"Callable",
"abstractAcces",
"-",
">",
"Bool",
"acting",
"as",
"filter",
":",
"return",
":",
"Collection",
"on",
"acces",
"passing",
"the",
"criteria"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L174-L181 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/data_model.py | abstractBase.load_from_db | def load_from_db(cls, callback_etat=print, out=None):
"""Launch data fetching then load data received.
The method _load_remote_db should be overridden.
If out is given, datas are set in it, instead of returning a new base object.
"""
dic = cls._load_remote_db(callback_etat)
... | python | def load_from_db(cls, callback_etat=print, out=None):
"""Launch data fetching then load data received.
The method _load_remote_db should be overridden.
If out is given, datas are set in it, instead of returning a new base object.
"""
dic = cls._load_remote_db(callback_etat)
... | [
"def",
"load_from_db",
"(",
"cls",
",",
"callback_etat",
"=",
"print",
",",
"out",
"=",
"None",
")",
":",
"dic",
"=",
"cls",
".",
"_load_remote_db",
"(",
"callback_etat",
")",
"callback_etat",
"(",
"\"Chargement...\"",
",",
"2",
",",
"3",
")",
"if",
"out... | Launch data fetching then load data received.
The method _load_remote_db should be overridden.
If out is given, datas are set in it, instead of returning a new base object. | [
"Launch",
"data",
"fetching",
"then",
"load",
"data",
"received",
".",
"The",
"method",
"_load_remote_db",
"should",
"be",
"overridden",
".",
"If",
"out",
"is",
"given",
"datas",
"are",
"set",
"in",
"it",
"instead",
"of",
"returning",
"a",
"new",
"base",
"... | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L214-L223 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/data_model.py | abstractBase._parse_text_DB | def _parse_text_DB(self, s):
"""Returns a dict of table interpreted from s.
s should be Json string encoding a dict { table_name : [fields_name,...] , [rows,... ] }"""
dic = self.decode_json_str(s)
new_dic = {}
for table_name, (header, rows) in dic.items():
newl = [{... | python | def _parse_text_DB(self, s):
"""Returns a dict of table interpreted from s.
s should be Json string encoding a dict { table_name : [fields_name,...] , [rows,... ] }"""
dic = self.decode_json_str(s)
new_dic = {}
for table_name, (header, rows) in dic.items():
newl = [{... | [
"def",
"_parse_text_DB",
"(",
"self",
",",
"s",
")",
":",
"dic",
"=",
"self",
".",
"decode_json_str",
"(",
"s",
")",
"new_dic",
"=",
"{",
"}",
"for",
"table_name",
",",
"(",
"header",
",",
"rows",
")",
"in",
"dic",
".",
"items",
"(",
")",
":",
"n... | Returns a dict of table interpreted from s.
s should be Json string encoding a dict { table_name : [fields_name,...] , [rows,... ] } | [
"Returns",
"a",
"dict",
"of",
"table",
"interpreted",
"from",
"s",
".",
"s",
"should",
"be",
"Json",
"string",
"encoding",
"a",
"dict",
"{",
"table_name",
":",
"[",
"fields_name",
"...",
"]",
"[",
"rows",
"...",
"]",
"}"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L235-L244 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/data_model.py | abstractBase.load_from_local | def load_from_local(cls):
"""Load datas from local file."""
try:
with open(cls.LOCAL_DB_PATH, 'rb') as f:
b = f.read()
s = security.protege_data(b, False)
except (FileNotFoundError, KeyError):
logging.exception(cls.__name__)
rai... | python | def load_from_local(cls):
"""Load datas from local file."""
try:
with open(cls.LOCAL_DB_PATH, 'rb') as f:
b = f.read()
s = security.protege_data(b, False)
except (FileNotFoundError, KeyError):
logging.exception(cls.__name__)
rai... | [
"def",
"load_from_local",
"(",
"cls",
")",
":",
"try",
":",
"with",
"open",
"(",
"cls",
".",
"LOCAL_DB_PATH",
",",
"'rb'",
")",
"as",
"f",
":",
"b",
"=",
"f",
".",
"read",
"(",
")",
"s",
"=",
"security",
".",
"protege_data",
"(",
"b",
",",
"False... | Load datas from local file. | [
"Load",
"datas",
"from",
"local",
"file",
"."
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L255-L266 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/data_model.py | abstractBase.dumps | def dumps(self):
"""Return a dictionnary of current tables"""
return {table_name: getattr(self, table_name).dumps() for table_name in self.TABLES} | python | def dumps(self):
"""Return a dictionnary of current tables"""
return {table_name: getattr(self, table_name).dumps() for table_name in self.TABLES} | [
"def",
"dumps",
"(",
"self",
")",
":",
"return",
"{",
"table_name",
":",
"getattr",
"(",
"self",
",",
"table_name",
")",
".",
"dumps",
"(",
")",
"for",
"table_name",
"in",
"self",
".",
"TABLES",
"}"
] | Return a dictionnary of current tables | [
"Return",
"a",
"dictionnary",
"of",
"current",
"tables"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L285-L287 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/data_model.py | abstractBase.save_to_local | def save_to_local(self, callback_etat=print):
"""
Saved current in memory base to local file.
It's a backup, not a convenient way to update datas
:param callback_etat: state callback, taking str,int,int as args
"""
callback_etat("Aquisition...", 0, 3)
d = self.d... | python | def save_to_local(self, callback_etat=print):
"""
Saved current in memory base to local file.
It's a backup, not a convenient way to update datas
:param callback_etat: state callback, taking str,int,int as args
"""
callback_etat("Aquisition...", 0, 3)
d = self.d... | [
"def",
"save_to_local",
"(",
"self",
",",
"callback_etat",
"=",
"print",
")",
":",
"callback_etat",
"(",
"\"Aquisition...\"",
",",
"0",
",",
"3",
")",
"d",
"=",
"self",
".",
"dumps",
"(",
")",
"s",
"=",
"json",
".",
"dumps",
"(",
"d",
",",
"indent",
... | Saved current in memory base to local file.
It's a backup, not a convenient way to update datas
:param callback_etat: state callback, taking str,int,int as args | [
"Saved",
"current",
"in",
"memory",
"base",
"to",
"local",
"file",
".",
"It",
"s",
"a",
"backup",
"not",
"a",
"convenient",
"way",
"to",
"update",
"datas"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L301-L319 | train |
kappius/pyheaderfile | pyheaderfile/excel.py | Xls.read_cell | def read_cell(self, x, y):
"""
reads the cell at position x and y; puts the default styles in xlwt
"""
cell = self._sheet.row(x)[y]
if self._file.xf_list[
cell.xf_index].background.pattern_colour_index == 64:
self._file.xf_list[
cell.xf... | python | def read_cell(self, x, y):
"""
reads the cell at position x and y; puts the default styles in xlwt
"""
cell = self._sheet.row(x)[y]
if self._file.xf_list[
cell.xf_index].background.pattern_colour_index == 64:
self._file.xf_list[
cell.xf... | [
"def",
"read_cell",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"cell",
"=",
"self",
".",
"_sheet",
".",
"row",
"(",
"x",
")",
"[",
"y",
"]",
"if",
"self",
".",
"_file",
".",
"xf_list",
"[",
"cell",
".",
"xf_index",
"]",
".",
"background",
".",
... | reads the cell at position x and y; puts the default styles in xlwt | [
"reads",
"the",
"cell",
"at",
"position",
"x",
"and",
"y",
";",
"puts",
"the",
"default",
"styles",
"in",
"xlwt"
] | 8d587dadae538adcec527fd8e74ad89ed5e2006a | https://github.com/kappius/pyheaderfile/blob/8d587dadae538adcec527fd8e74ad89ed5e2006a/pyheaderfile/excel.py#L20-L54 | train |
kappius/pyheaderfile | pyheaderfile/excel.py | Xls.write_cell | def write_cell(self, x, y, value, style=None):
"""
writing style and value in the cell of x and y position
"""
if isinstance(style, str):
style = self.xlwt.easyxf(style)
if style:
self._sheet.write(x, y, label=value, style=style)
else:
... | python | def write_cell(self, x, y, value, style=None):
"""
writing style and value in the cell of x and y position
"""
if isinstance(style, str):
style = self.xlwt.easyxf(style)
if style:
self._sheet.write(x, y, label=value, style=style)
else:
... | [
"def",
"write_cell",
"(",
"self",
",",
"x",
",",
"y",
",",
"value",
",",
"style",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"style",
",",
"str",
")",
":",
"style",
"=",
"self",
".",
"xlwt",
".",
"easyxf",
"(",
"style",
")",
"if",
"style",
... | writing style and value in the cell of x and y position | [
"writing",
"style",
"and",
"value",
"in",
"the",
"cell",
"of",
"x",
"and",
"y",
"position"
] | 8d587dadae538adcec527fd8e74ad89ed5e2006a | https://github.com/kappius/pyheaderfile/blob/8d587dadae538adcec527fd8e74ad89ed5e2006a/pyheaderfile/excel.py#L56-L65 | train |
OLC-Bioinformatics/sipprverse | cgecore/argumentparsing.py | get_string | def get_string(string):
""" This function checks if a path was given as string, and tries to read the
file and return the string.
"""
truestring = string
if string is not None:
if '/' in string:
if os.path.isfile(string):
try:
with open_(string,'r') as f:
... | python | def get_string(string):
""" This function checks if a path was given as string, and tries to read the
file and return the string.
"""
truestring = string
if string is not None:
if '/' in string:
if os.path.isfile(string):
try:
with open_(string,'r') as f:
... | [
"def",
"get_string",
"(",
"string",
")",
":",
"truestring",
"=",
"string",
"if",
"string",
"is",
"not",
"None",
":",
"if",
"'/'",
"in",
"string",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"string",
")",
":",
"try",
":",
"with",
"open_",
"("... | This function checks if a path was given as string, and tries to read the
file and return the string. | [
"This",
"function",
"checks",
"if",
"a",
"path",
"was",
"given",
"as",
"string",
"and",
"tries",
"to",
"read",
"the",
"file",
"and",
"return",
"the",
"string",
"."
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/argumentparsing.py#L14-L27 | train |
OLC-Bioinformatics/sipprverse | cgecore/argumentparsing.py | get_arguments | def get_arguments(options):
""" This function handles and validates the wrapper arguments. """
# These the next couple of lines defines the header of the Help output
parser = ArgumentParser(
formatter_class=RawDescriptionHelpFormatter,
usage=("""%(prog)s
--------------------------------------------... | python | def get_arguments(options):
""" This function handles and validates the wrapper arguments. """
# These the next couple of lines defines the header of the Help output
parser = ArgumentParser(
formatter_class=RawDescriptionHelpFormatter,
usage=("""%(prog)s
--------------------------------------------... | [
"def",
"get_arguments",
"(",
"options",
")",
":",
"# These the next couple of lines defines the header of the Help output",
"parser",
"=",
"ArgumentParser",
"(",
"formatter_class",
"=",
"RawDescriptionHelpFormatter",
",",
"usage",
"=",
"(",
"\"\"\"%(prog)s\n----------------------... | This function handles and validates the wrapper arguments. | [
"This",
"function",
"handles",
"and",
"validates",
"the",
"wrapper",
"arguments",
"."
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/argumentparsing.py#L29-L76 | train |
OLC-Bioinformatics/sipprverse | cgecore/argumentparsing.py | check_file_type | def check_file_type(files):
""" Check whether the input files are in fasta format, reads format or
other/mix formats.
"""
all_are_fasta = True
all_are_reads = True
all_are_empty = True
if sys.version_info < (3, 0):
if isinstance(files, (str, unicode)): files = [files]
else:
if is... | python | def check_file_type(files):
""" Check whether the input files are in fasta format, reads format or
other/mix formats.
"""
all_are_fasta = True
all_are_reads = True
all_are_empty = True
if sys.version_info < (3, 0):
if isinstance(files, (str, unicode)): files = [files]
else:
if is... | [
"def",
"check_file_type",
"(",
"files",
")",
":",
"all_are_fasta",
"=",
"True",
"all_are_reads",
"=",
"True",
"all_are_empty",
"=",
"True",
"if",
"sys",
".",
"version_info",
"<",
"(",
"3",
",",
"0",
")",
":",
"if",
"isinstance",
"(",
"files",
",",
"(",
... | Check whether the input files are in fasta format, reads format or
other/mix formats. | [
"Check",
"whether",
"the",
"input",
"files",
"are",
"in",
"fasta",
"format",
"reads",
"format",
"or",
"other",
"/",
"mix",
"formats",
"."
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/argumentparsing.py#L78-L101 | train |
OLC-Bioinformatics/sipprverse | cgecore/argumentparsing.py | make_file_list | def make_file_list(upload_path):
""" This function returns list of files in the given dir """
newlist = []
for el in sorted(os.listdir(upload_path)):
if ' ' in el:
raise Exception('Error: Spaces are not allowed in file names!\n')
newlist.append(os.path.normpath(upload_path+'/'+el))
debu... | python | def make_file_list(upload_path):
""" This function returns list of files in the given dir """
newlist = []
for el in sorted(os.listdir(upload_path)):
if ' ' in el:
raise Exception('Error: Spaces are not allowed in file names!\n')
newlist.append(os.path.normpath(upload_path+'/'+el))
debu... | [
"def",
"make_file_list",
"(",
"upload_path",
")",
":",
"newlist",
"=",
"[",
"]",
"for",
"el",
"in",
"sorted",
"(",
"os",
".",
"listdir",
"(",
"upload_path",
")",
")",
":",
"if",
"' '",
"in",
"el",
":",
"raise",
"Exception",
"(",
"'Error: Spaces are not a... | This function returns list of files in the given dir | [
"This",
"function",
"returns",
"list",
"of",
"files",
"in",
"the",
"given",
"dir"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/argumentparsing.py#L103-L111 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/rackspace.py | create_server_rackspace | def create_server_rackspace(connection,
distribution,
disk_name,
disk_size,
ami,
region,
key_pair,
instance_type,
... | python | def create_server_rackspace(connection,
distribution,
disk_name,
disk_size,
ami,
region,
key_pair,
instance_type,
... | [
"def",
"create_server_rackspace",
"(",
"connection",
",",
"distribution",
",",
"disk_name",
",",
"disk_size",
",",
"ami",
",",
"region",
",",
"key_pair",
",",
"instance_type",
",",
"instance_name",
",",
"tags",
"=",
"{",
"}",
",",
"security_groups",
"=",
"None... | Creates Rackspace Instance and saves it state in a local json file | [
"Creates",
"Rackspace",
"Instance",
"and",
"saves",
"it",
"state",
"in",
"a",
"local",
"json",
"file"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/rackspace.py#L47-L93 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/rackspace.py | destroy_rackspace | def destroy_rackspace(connection, region, instance_id):
""" terminates the instance """
server = connection.servers.get(instance_id)
log_yellow('deleting rackspace instance ...')
server.delete()
# wait for server to be deleted
try:
while True:
server = connection.servers.ge... | python | def destroy_rackspace(connection, region, instance_id):
""" terminates the instance """
server = connection.servers.get(instance_id)
log_yellow('deleting rackspace instance ...')
server.delete()
# wait for server to be deleted
try:
while True:
server = connection.servers.ge... | [
"def",
"destroy_rackspace",
"(",
"connection",
",",
"region",
",",
"instance_id",
")",
":",
"server",
"=",
"connection",
".",
"servers",
".",
"get",
"(",
"instance_id",
")",
"log_yellow",
"(",
"'deleting rackspace instance ...'",
")",
"server",
".",
"delete",
"(... | terminates the instance | [
"terminates",
"the",
"instance"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/rackspace.py#L96-L111 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/rackspace.py | get_rackspace_info | def get_rackspace_info(connection,
server_id):
""" queries Rackspace for details about a particular server id
"""
server = connection.servers.get(server_id)
data = {}
data['ip_address'] = server.accessIPv4
data['accessIPv4'] = server.accessIPv4
data['accessIPv6'] = se... | python | def get_rackspace_info(connection,
server_id):
""" queries Rackspace for details about a particular server id
"""
server = connection.servers.get(server_id)
data = {}
data['ip_address'] = server.accessIPv4
data['accessIPv4'] = server.accessIPv4
data['accessIPv6'] = se... | [
"def",
"get_rackspace_info",
"(",
"connection",
",",
"server_id",
")",
":",
"server",
"=",
"connection",
".",
"servers",
".",
"get",
"(",
"server_id",
")",
"data",
"=",
"{",
"}",
"data",
"[",
"'ip_address'",
"]",
"=",
"server",
".",
"accessIPv4",
"data",
... | queries Rackspace for details about a particular server id | [
"queries",
"Rackspace",
"for",
"details",
"about",
"a",
"particular",
"server",
"id"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/rackspace.py#L142-L166 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/formats.py | date_decoder | def date_decoder(dic):
"""Add python types decoding. See JsonEncoder"""
if '__date__' in dic:
try:
d = datetime.date(**{c: v for c, v in dic.items() if not c == "__date__"})
except (TypeError, ValueError):
raise json.JSONDecodeError("Corrupted date format !", str(dic), 1)... | python | def date_decoder(dic):
"""Add python types decoding. See JsonEncoder"""
if '__date__' in dic:
try:
d = datetime.date(**{c: v for c, v in dic.items() if not c == "__date__"})
except (TypeError, ValueError):
raise json.JSONDecodeError("Corrupted date format !", str(dic), 1)... | [
"def",
"date_decoder",
"(",
"dic",
")",
":",
"if",
"'__date__'",
"in",
"dic",
":",
"try",
":",
"d",
"=",
"datetime",
".",
"date",
"(",
"*",
"*",
"{",
"c",
":",
"v",
"for",
"c",
",",
"v",
"in",
"dic",
".",
"items",
"(",
")",
"if",
"not",
"c",
... | Add python types decoding. See JsonEncoder | [
"Add",
"python",
"types",
"decoding",
".",
"See",
"JsonEncoder"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/formats.py#L31-L45 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/formats.py | _type_string | def _type_string(label, case=None):
"""Shortcut for string like fields"""
return label, abstractSearch.in_string, lambda s: abstractRender.default(s, case=case), "" | python | def _type_string(label, case=None):
"""Shortcut for string like fields"""
return label, abstractSearch.in_string, lambda s: abstractRender.default(s, case=case), "" | [
"def",
"_type_string",
"(",
"label",
",",
"case",
"=",
"None",
")",
":",
"return",
"label",
",",
"abstractSearch",
".",
"in_string",
",",
"lambda",
"s",
":",
"abstractRender",
".",
"default",
"(",
"s",
",",
"case",
"=",
"case",
")",
",",
"\"\""
] | Shortcut for string like fields | [
"Shortcut",
"for",
"string",
"like",
"fields"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/formats.py#L301-L303 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/formats.py | _type_bool | def _type_bool(label,default=False):
"""Shortcut fot boolean like fields"""
return label, abstractSearch.nothing, abstractRender.boolen, default | python | def _type_bool(label,default=False):
"""Shortcut fot boolean like fields"""
return label, abstractSearch.nothing, abstractRender.boolen, default | [
"def",
"_type_bool",
"(",
"label",
",",
"default",
"=",
"False",
")",
":",
"return",
"label",
",",
"abstractSearch",
".",
"nothing",
",",
"abstractRender",
".",
"boolen",
",",
"default"
] | Shortcut fot boolean like fields | [
"Shortcut",
"fot",
"boolean",
"like",
"fields"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/formats.py#L316-L318 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/formats.py | abstractSearch.in_string | def in_string(objet, pattern):
""" abstractSearch dans une chaine, sans tenir compte de la casse. """
return bool(re.search(pattern, str(objet), flags=re.I)) if objet else False | python | def in_string(objet, pattern):
""" abstractSearch dans une chaine, sans tenir compte de la casse. """
return bool(re.search(pattern, str(objet), flags=re.I)) if objet else False | [
"def",
"in_string",
"(",
"objet",
",",
"pattern",
")",
":",
"return",
"bool",
"(",
"re",
".",
"search",
"(",
"pattern",
",",
"str",
"(",
"objet",
")",
",",
"flags",
"=",
"re",
".",
"I",
")",
")",
"if",
"objet",
"else",
"False"
] | abstractSearch dans une chaine, sans tenir compte de la casse. | [
"abstractSearch",
"dans",
"une",
"chaine",
"sans",
"tenir",
"compte",
"de",
"la",
"casse",
"."
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/formats.py#L199-L201 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/formats.py | abstractSearch.in_date | def in_date(objet, pattern):
""" abstractSearch dans une date datetime.date"""
if objet:
pattern = re.sub(" ", '', pattern)
objet_str = abstractRender.date(objet)
return bool(re.search(pattern, objet_str))
return False | python | def in_date(objet, pattern):
""" abstractSearch dans une date datetime.date"""
if objet:
pattern = re.sub(" ", '', pattern)
objet_str = abstractRender.date(objet)
return bool(re.search(pattern, objet_str))
return False | [
"def",
"in_date",
"(",
"objet",
",",
"pattern",
")",
":",
"if",
"objet",
":",
"pattern",
"=",
"re",
".",
"sub",
"(",
"\" \"",
",",
"''",
",",
"pattern",
")",
"objet_str",
"=",
"abstractRender",
".",
"date",
"(",
"objet",
")",
"return",
"bool",
"(",
... | abstractSearch dans une date datetime.date | [
"abstractSearch",
"dans",
"une",
"date",
"datetime",
".",
"date"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/formats.py#L204-L210 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/formats.py | abstractSearch.in_dateheure | def in_dateheure(objet, pattern):
""" abstractSearch dans une date-heure datetime.datetime (cf abstractRender.dateheure) """
if objet:
pattern = re.sub(" ", '', pattern)
objet_str = abstractRender.dateheure(objet)
return bool(re.search(pattern, objet_str))
ret... | python | def in_dateheure(objet, pattern):
""" abstractSearch dans une date-heure datetime.datetime (cf abstractRender.dateheure) """
if objet:
pattern = re.sub(" ", '', pattern)
objet_str = abstractRender.dateheure(objet)
return bool(re.search(pattern, objet_str))
ret... | [
"def",
"in_dateheure",
"(",
"objet",
",",
"pattern",
")",
":",
"if",
"objet",
":",
"pattern",
"=",
"re",
".",
"sub",
"(",
"\" \"",
",",
"''",
",",
"pattern",
")",
"objet_str",
"=",
"abstractRender",
".",
"dateheure",
"(",
"objet",
")",
"return",
"bool"... | abstractSearch dans une date-heure datetime.datetime (cf abstractRender.dateheure) | [
"abstractSearch",
"dans",
"une",
"date",
"-",
"heure",
"datetime",
".",
"datetime",
"(",
"cf",
"abstractRender",
".",
"dateheure",
")"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/formats.py#L213-L219 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/formats.py | abstractSearch.in_telephones | def in_telephones(objet, pattern):
""" abstractSearch dans une liste de téléphones."""
objet = objet or []
if pattern == '' or not objet:
return False
return max(bool(re.search(pattern, t)) for t in objet) | python | def in_telephones(objet, pattern):
""" abstractSearch dans une liste de téléphones."""
objet = objet or []
if pattern == '' or not objet:
return False
return max(bool(re.search(pattern, t)) for t in objet) | [
"def",
"in_telephones",
"(",
"objet",
",",
"pattern",
")",
":",
"objet",
"=",
"objet",
"or",
"[",
"]",
"if",
"pattern",
"==",
"''",
"or",
"not",
"objet",
":",
"return",
"False",
"return",
"max",
"(",
"bool",
"(",
"re",
".",
"search",
"(",
"pattern",
... | abstractSearch dans une liste de téléphones. | [
"abstractSearch",
"dans",
"une",
"liste",
"de",
"téléphones",
"."
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/formats.py#L222-L227 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/formats.py | abstractRender.date | def date(objet):
""" abstractRender d'une date datetime.date"""
if objet:
return "{}/{}/{}".format(objet.day, objet.month, objet.year)
return "" | python | def date(objet):
""" abstractRender d'une date datetime.date"""
if objet:
return "{}/{}/{}".format(objet.day, objet.month, objet.year)
return "" | [
"def",
"date",
"(",
"objet",
")",
":",
"if",
"objet",
":",
"return",
"\"{}/{}/{}\"",
".",
"format",
"(",
"objet",
".",
"day",
",",
"objet",
".",
"month",
",",
"objet",
".",
"year",
")",
"return",
"\"\""
] | abstractRender d'une date datetime.date | [
"abstractRender",
"d",
"une",
"date",
"datetime",
".",
"date"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/formats.py#L250-L254 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/formats.py | abstractRender.dateheure | def dateheure(objet):
""" abstractRender d'une date-heure datetime.datetime au format JJ/MM/AAAAàHH:mm """
if objet:
return "{}/{}/{} à {:02}:{:02}".format(objet.day, objet.month, objet.year, objet.hour, objet.minute)
return "" | python | def dateheure(objet):
""" abstractRender d'une date-heure datetime.datetime au format JJ/MM/AAAAàHH:mm """
if objet:
return "{}/{}/{} à {:02}:{:02}".format(objet.day, objet.month, objet.year, objet.hour, objet.minute)
return "" | [
"def",
"dateheure",
"(",
"objet",
")",
":",
"if",
"objet",
":",
"return",
"\"{}/{}/{} à {:02}:{:02}\".",
"f",
"ormat(",
"o",
"bjet.",
"d",
"ay,",
" ",
"bjet.",
"m",
"onth,",
" ",
"bjet.",
"y",
"ear,",
" ",
"bjet.",
"h",
"our,",
" ",
"bjet.",
"m",
"inut... | abstractRender d'une date-heure datetime.datetime au format JJ/MM/AAAAàHH:mm | [
"abstractRender",
"d",
"une",
"date",
"-",
"heure",
"datetime",
".",
"datetime",
"au",
"format",
"JJ",
"/",
"MM",
"/",
"AAAAàHH",
":",
"mm"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/formats.py#L257-L261 | train |
QunarOPS/qg.core | qg/core/gettextutils.py | install | def install(domain, lazy=False):
"""Install a _() function using the given translation domain.
Given a translation domain, install a _() function using gettext's
install() function.
The main difference from gettext.install() is that we allow
overriding the default localedir (e.g. /usr/share/locale... | python | def install(domain, lazy=False):
"""Install a _() function using the given translation domain.
Given a translation domain, install a _() function using gettext's
install() function.
The main difference from gettext.install() is that we allow
overriding the default localedir (e.g. /usr/share/locale... | [
"def",
"install",
"(",
"domain",
",",
"lazy",
"=",
"False",
")",
":",
"if",
"lazy",
":",
"# NOTE(mrodden): Lazy gettext functionality.",
"#",
"# The following introduces a deferred way to do translations on",
"# messages in OpenStack. We override the standard _() function",
"# and ... | Install a _() function using the given translation domain.
Given a translation domain, install a _() function using gettext's
install() function.
The main difference from gettext.install() is that we allow
overriding the default localedir (e.g. /usr/share/locale) using
a translation-domain-specifi... | [
"Install",
"a",
"_",
"()",
"function",
"using",
"the",
"given",
"translation",
"domain",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/gettextutils.py#L83-L130 | train |
QunarOPS/qg.core | qg/core/gettextutils.py | get_available_languages | def get_available_languages(domain):
"""Lists the available languages for the given translation domain.
:param domain: the domain to get languages for
"""
if domain in _AVAILABLE_LANGUAGES:
return copy.copy(_AVAILABLE_LANGUAGES[domain])
localedir = '%s_LOCALEDIR' % domain.upper()
find ... | python | def get_available_languages(domain):
"""Lists the available languages for the given translation domain.
:param domain: the domain to get languages for
"""
if domain in _AVAILABLE_LANGUAGES:
return copy.copy(_AVAILABLE_LANGUAGES[domain])
localedir = '%s_LOCALEDIR' % domain.upper()
find ... | [
"def",
"get_available_languages",
"(",
"domain",
")",
":",
"if",
"domain",
"in",
"_AVAILABLE_LANGUAGES",
":",
"return",
"copy",
".",
"copy",
"(",
"_AVAILABLE_LANGUAGES",
"[",
"domain",
"]",
")",
"localedir",
"=",
"'%s_LOCALEDIR'",
"%",
"domain",
".",
"upper",
... | Lists the available languages for the given translation domain.
:param domain: the domain to get languages for | [
"Lists",
"the",
"available",
"languages",
"for",
"the",
"given",
"translation",
"domain",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/gettextutils.py#L298-L343 | train |
QunarOPS/qg.core | qg/core/gettextutils.py | translate | def translate(obj, desired_locale=None):
"""Gets the translated unicode representation of the given object.
If the object is not translatable it is returned as-is.
If the locale is None the object is translated to the system locale.
:param obj: the object to translate
:param desired_locale: the lo... | python | def translate(obj, desired_locale=None):
"""Gets the translated unicode representation of the given object.
If the object is not translatable it is returned as-is.
If the locale is None the object is translated to the system locale.
:param obj: the object to translate
:param desired_locale: the lo... | [
"def",
"translate",
"(",
"obj",
",",
"desired_locale",
"=",
"None",
")",
":",
"message",
"=",
"obj",
"if",
"not",
"isinstance",
"(",
"message",
",",
"Message",
")",
":",
"# If the object to translate is not already translatable,",
"# let's first get its unicode represen... | Gets the translated unicode representation of the given object.
If the object is not translatable it is returned as-is.
If the locale is None the object is translated to the system locale.
:param obj: the object to translate
:param desired_locale: the locale to translate the message to, if None the
... | [
"Gets",
"the",
"translated",
"unicode",
"representation",
"of",
"the",
"given",
"object",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/gettextutils.py#L346-L367 | train |
QunarOPS/qg.core | qg/core/gettextutils.py | _translate_args | def _translate_args(args, desired_locale=None):
"""Translates all the translatable elements of the given arguments object.
This method is used for translating the translatable values in method
arguments which include values of tuples or dictionaries.
If the object is not a tuple or a dictionary the obj... | python | def _translate_args(args, desired_locale=None):
"""Translates all the translatable elements of the given arguments object.
This method is used for translating the translatable values in method
arguments which include values of tuples or dictionaries.
If the object is not a tuple or a dictionary the obj... | [
"def",
"_translate_args",
"(",
"args",
",",
"desired_locale",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"args",
",",
"tuple",
")",
":",
"return",
"tuple",
"(",
"translate",
"(",
"v",
",",
"desired_locale",
")",
"for",
"v",
"in",
"args",
")",
"if"... | Translates all the translatable elements of the given arguments object.
This method is used for translating the translatable values in method
arguments which include values of tuples or dictionaries.
If the object is not a tuple or a dictionary the object itself is
translated if it is translatable.
... | [
"Translates",
"all",
"the",
"translatable",
"elements",
"of",
"the",
"given",
"arguments",
"object",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/gettextutils.py#L370-L393 | train |
QunarOPS/qg.core | qg/core/gettextutils.py | Message.translate | def translate(self, desired_locale=None):
"""Translate this message to the desired locale.
:param desired_locale: The desired locale to translate the message to,
if no locale is provided the message will be
translated to the system's default... | python | def translate(self, desired_locale=None):
"""Translate this message to the desired locale.
:param desired_locale: The desired locale to translate the message to,
if no locale is provided the message will be
translated to the system's default... | [
"def",
"translate",
"(",
"self",
",",
"desired_locale",
"=",
"None",
")",
":",
"translated_message",
"=",
"Message",
".",
"_translate_msgid",
"(",
"self",
".",
"msgid",
",",
"self",
".",
"domain",
",",
"desired_locale",
")",
"if",
"self",
".",
"params",
"i... | Translate this message to the desired locale.
:param desired_locale: The desired locale to translate the message to,
if no locale is provided the message will be
translated to the system's default locale.
:returns: the translated message in... | [
"Translate",
"this",
"message",
"to",
"the",
"desired",
"locale",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/gettextutils.py#L163-L188 | train |
QunarOPS/qg.core | qg/core/gettextutils.py | Message._sanitize_mod_params | def _sanitize_mod_params(self, other):
"""Sanitize the object being modded with this Message.
- Add support for modding 'None' so translation supports it
- Trim the modded object, which can be a large dictionary, to only
those keys that would actually be used in a translation
- ... | python | def _sanitize_mod_params(self, other):
"""Sanitize the object being modded with this Message.
- Add support for modding 'None' so translation supports it
- Trim the modded object, which can be a large dictionary, to only
those keys that would actually be used in a translation
- ... | [
"def",
"_sanitize_mod_params",
"(",
"self",
",",
"other",
")",
":",
"if",
"other",
"is",
"None",
":",
"params",
"=",
"(",
"other",
",",
")",
"elif",
"isinstance",
"(",
"other",
",",
"dict",
")",
":",
"params",
"=",
"self",
".",
"_trim_dictionary_paramete... | Sanitize the object being modded with this Message.
- Add support for modding 'None' so translation supports it
- Trim the modded object, which can be a large dictionary, to only
those keys that would actually be used in a translation
- Snapshot the object being modded, in case the mess... | [
"Sanitize",
"the",
"object",
"being",
"modded",
"with",
"this",
"Message",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/gettextutils.py#L225-L240 | train |
QunarOPS/qg.core | qg/core/gettextutils.py | Message._trim_dictionary_parameters | def _trim_dictionary_parameters(self, dict_param):
"""Return a dict that only has matching entries in the msgid."""
# NOTE(luisg): Here we trim down the dictionary passed as parameters
# to avoid carrying a lot of unnecessary weight around in the message
# object, for example if someone ... | python | def _trim_dictionary_parameters(self, dict_param):
"""Return a dict that only has matching entries in the msgid."""
# NOTE(luisg): Here we trim down the dictionary passed as parameters
# to avoid carrying a lot of unnecessary weight around in the message
# object, for example if someone ... | [
"def",
"_trim_dictionary_parameters",
"(",
"self",
",",
"dict_param",
")",
":",
"# NOTE(luisg): Here we trim down the dictionary passed as parameters",
"# to avoid carrying a lot of unnecessary weight around in the message",
"# object, for example if someone passes in Message() % locals() but",
... | Return a dict that only has matching entries in the msgid. | [
"Return",
"a",
"dict",
"that",
"only",
"has",
"matching",
"entries",
"in",
"the",
"msgid",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/gettextutils.py#L242-L272 | train |
OnroerendErfgoed/pyramid_urireferencer | pyramid_urireferencer/renderers.py | registry_adapter | def registry_adapter(obj, request):
"""
Adapter for rendering a :class:`pyramid_urireferencer.models.RegistryResponse` to json.
:param pyramid_urireferencer.models.RegistryResponse obj: The response to be rendered.
:rtype: :class:`dict`
"""
return {
'query_uri': obj.query_uri,
'... | python | def registry_adapter(obj, request):
"""
Adapter for rendering a :class:`pyramid_urireferencer.models.RegistryResponse` to json.
:param pyramid_urireferencer.models.RegistryResponse obj: The response to be rendered.
:rtype: :class:`dict`
"""
return {
'query_uri': obj.query_uri,
'... | [
"def",
"registry_adapter",
"(",
"obj",
",",
"request",
")",
":",
"return",
"{",
"'query_uri'",
":",
"obj",
".",
"query_uri",
",",
"'success'",
":",
"obj",
".",
"success",
",",
"'has_references'",
":",
"obj",
".",
"has_references",
",",
"'count'",
":",
"obj... | Adapter for rendering a :class:`pyramid_urireferencer.models.RegistryResponse` to json.
:param pyramid_urireferencer.models.RegistryResponse obj: The response to be rendered.
:rtype: :class:`dict` | [
"Adapter",
"for",
"rendering",
"a",
":",
"class",
":",
"pyramid_urireferencer",
".",
"models",
".",
"RegistryResponse",
"to",
"json",
"."
] | c6ee4ba863e32ced304b9cf00f3f5b450757a29a | https://github.com/OnroerendErfgoed/pyramid_urireferencer/blob/c6ee4ba863e32ced304b9cf00f3f5b450757a29a/pyramid_urireferencer/renderers.py#L14-L38 | train |
OnroerendErfgoed/pyramid_urireferencer | pyramid_urireferencer/renderers.py | application_adapter | def application_adapter(obj, request):
"""
Adapter for rendering a :class:`pyramid_urireferencer.models.ApplicationResponse` to json.
:param pyramid_urireferencer.models.ApplicationResponse obj: The response to be rendered.
:rtype: :class:`dict`
"""
return {
'title': obj.title,
... | python | def application_adapter(obj, request):
"""
Adapter for rendering a :class:`pyramid_urireferencer.models.ApplicationResponse` to json.
:param pyramid_urireferencer.models.ApplicationResponse obj: The response to be rendered.
:rtype: :class:`dict`
"""
return {
'title': obj.title,
... | [
"def",
"application_adapter",
"(",
"obj",
",",
"request",
")",
":",
"return",
"{",
"'title'",
":",
"obj",
".",
"title",
",",
"'uri'",
":",
"obj",
".",
"uri",
",",
"'service_url'",
":",
"obj",
".",
"service_url",
",",
"'success'",
":",
"obj",
".",
"succ... | Adapter for rendering a :class:`pyramid_urireferencer.models.ApplicationResponse` to json.
:param pyramid_urireferencer.models.ApplicationResponse obj: The response to be rendered.
:rtype: :class:`dict` | [
"Adapter",
"for",
"rendering",
"a",
":",
"class",
":",
"pyramid_urireferencer",
".",
"models",
".",
"ApplicationResponse",
"to",
"json",
"."
] | c6ee4ba863e32ced304b9cf00f3f5b450757a29a | https://github.com/OnroerendErfgoed/pyramid_urireferencer/blob/c6ee4ba863e32ced304b9cf00f3f5b450757a29a/pyramid_urireferencer/renderers.py#L41-L59 | train |
tsnaomi/finnsyll | finnsyll/prev/phonology.py | replace_umlauts | def replace_umlauts(word, put_back=False): # use translate()
'''If put_back is True, put in umlauts; else, take them out!'''
if put_back:
word = word.replace('A', 'ä')
word = word.replace('O', 'ö')
else:
word = word.replace('ä', 'A').replace('\xc3\xa4', 'A')
word = word.rep... | python | def replace_umlauts(word, put_back=False): # use translate()
'''If put_back is True, put in umlauts; else, take them out!'''
if put_back:
word = word.replace('A', 'ä')
word = word.replace('O', 'ö')
else:
word = word.replace('ä', 'A').replace('\xc3\xa4', 'A')
word = word.rep... | [
"def",
"replace_umlauts",
"(",
"word",
",",
"put_back",
"=",
"False",
")",
":",
"# use translate()",
"if",
"put_back",
":",
"word",
"=",
"word",
".",
"replace",
"(",
"'A'",
",",
"'ä')",
"",
"word",
"=",
"word",
".",
"replace",
"(",
"'O'",
",",
"'ö')",
... | If put_back is True, put in umlauts; else, take them out! | [
"If",
"put_back",
"is",
"True",
"put",
"in",
"umlauts",
";",
"else",
"take",
"them",
"out!"
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/phonology.py#L203-L213 | train |
OLC-Bioinformatics/sipprverse | cgecore/blaster/blaster.py | Blaster.get_query_align | def get_query_align(hit, contig):
"""
Function for extracting extra seqeunce data to the query
alignment if the full reference length are not covered
"""
# Getting data needed to extract sequences
query_seq = hit['query_string']
homo_seq = hit['homo_string']
sbjct_... | python | def get_query_align(hit, contig):
"""
Function for extracting extra seqeunce data to the query
alignment if the full reference length are not covered
"""
# Getting data needed to extract sequences
query_seq = hit['query_string']
homo_seq = hit['homo_string']
sbjct_... | [
"def",
"get_query_align",
"(",
"hit",
",",
"contig",
")",
":",
"# Getting data needed to extract sequences",
"query_seq",
"=",
"hit",
"[",
"'query_string'",
"]",
"homo_seq",
"=",
"hit",
"[",
"'homo_string'",
"]",
"sbjct_start",
"=",
"int",
"(",
"hit",
"[",
"'sbj... | Function for extracting extra seqeunce data to the query
alignment if the full reference length are not covered | [
"Function",
"for",
"extracting",
"extra",
"seqeunce",
"data",
"to",
"the",
"query",
"alignment",
"if",
"the",
"full",
"reference",
"length",
"are",
"not",
"covered"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/blaster/blaster.py#L465-L575 | train |
BertrandBordage/django-tablature | tablature/views.py | TableDataViewMixin.get_ordering_for_column | def get_ordering_for_column(self, column, direction):
"""
Returns a tuple of lookups to order by for the given column
and direction. Direction is an integer, either -1, 0 or 1.
"""
if direction == 0:
return ()
if column in self.orderings:
ordering ... | python | def get_ordering_for_column(self, column, direction):
"""
Returns a tuple of lookups to order by for the given column
and direction. Direction is an integer, either -1, 0 or 1.
"""
if direction == 0:
return ()
if column in self.orderings:
ordering ... | [
"def",
"get_ordering_for_column",
"(",
"self",
",",
"column",
",",
"direction",
")",
":",
"if",
"direction",
"==",
"0",
":",
"return",
"(",
")",
"if",
"column",
"in",
"self",
".",
"orderings",
":",
"ordering",
"=",
"self",
".",
"orderings",
"[",
"column"... | Returns a tuple of lookups to order by for the given column
and direction. Direction is an integer, either -1, 0 or 1. | [
"Returns",
"a",
"tuple",
"of",
"lookups",
"to",
"order",
"by",
"for",
"the",
"given",
"column",
"and",
"direction",
".",
"Direction",
"is",
"an",
"integer",
"either",
"-",
"1",
"0",
"or",
"1",
"."
] | f5198b3fb1ebf7f5dfd8ebfd4bf977468e4f0390 | https://github.com/BertrandBordage/django-tablature/blob/f5198b3fb1ebf7f5dfd8ebfd4bf977468e4f0390/tablature/views.py#L116-L135 | train |
pymacaron/pymacaron-core | pymacaron_core/swagger/spec.py | ApiSpec.model_to_json | def model_to_json(self, object, cleanup=True):
"""Take a model instance and return it as a json struct"""
model_name = type(object).__name__
if model_name not in self.swagger_dict['definitions']:
raise ValidationError("Swagger spec has no definition for model %s" % model_name)
... | python | def model_to_json(self, object, cleanup=True):
"""Take a model instance and return it as a json struct"""
model_name = type(object).__name__
if model_name not in self.swagger_dict['definitions']:
raise ValidationError("Swagger spec has no definition for model %s" % model_name)
... | [
"def",
"model_to_json",
"(",
"self",
",",
"object",
",",
"cleanup",
"=",
"True",
")",
":",
"model_name",
"=",
"type",
"(",
"object",
")",
".",
"__name__",
"if",
"model_name",
"not",
"in",
"self",
".",
"swagger_dict",
"[",
"'definitions'",
"]",
":",
"rais... | Take a model instance and return it as a json struct | [
"Take",
"a",
"model",
"instance",
"and",
"return",
"it",
"as",
"a",
"json",
"struct"
] | 95070a39ed7065a84244ff5601fea4d54cc72b66 | https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/swagger/spec.py#L95-L105 | train |
pymacaron/pymacaron-core | pymacaron_core/swagger/spec.py | ApiSpec.json_to_model | def json_to_model(self, model_name, j):
"""Take a json strust and a model name, and return a model instance"""
if model_name not in self.swagger_dict['definitions']:
raise ValidationError("Swagger spec has no definition for model %s" % model_name)
model_def = self.swagger_dict['defin... | python | def json_to_model(self, model_name, j):
"""Take a json strust and a model name, and return a model instance"""
if model_name not in self.swagger_dict['definitions']:
raise ValidationError("Swagger spec has no definition for model %s" % model_name)
model_def = self.swagger_dict['defin... | [
"def",
"json_to_model",
"(",
"self",
",",
"model_name",
",",
"j",
")",
":",
"if",
"model_name",
"not",
"in",
"self",
".",
"swagger_dict",
"[",
"'definitions'",
"]",
":",
"raise",
"ValidationError",
"(",
"\"Swagger spec has no definition for model %s\"",
"%",
"mode... | Take a json strust and a model name, and return a model instance | [
"Take",
"a",
"json",
"strust",
"and",
"a",
"model",
"name",
"and",
"return",
"a",
"model",
"instance"
] | 95070a39ed7065a84244ff5601fea4d54cc72b66 | https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/swagger/spec.py#L124-L130 | train |
pymacaron/pymacaron-core | pymacaron_core/swagger/spec.py | ApiSpec.validate | def validate(self, model_name, object):
"""Validate an object against its swagger model"""
if model_name not in self.swagger_dict['definitions']:
raise ValidationError("Swagger spec has no definition for model %s" % model_name)
model_def = self.swagger_dict['definitions'][model_name]... | python | def validate(self, model_name, object):
"""Validate an object against its swagger model"""
if model_name not in self.swagger_dict['definitions']:
raise ValidationError("Swagger spec has no definition for model %s" % model_name)
model_def = self.swagger_dict['definitions'][model_name]... | [
"def",
"validate",
"(",
"self",
",",
"model_name",
",",
"object",
")",
":",
"if",
"model_name",
"not",
"in",
"self",
".",
"swagger_dict",
"[",
"'definitions'",
"]",
":",
"raise",
"ValidationError",
"(",
"\"Swagger spec has no definition for model %s\"",
"%",
"mode... | Validate an object against its swagger model | [
"Validate",
"an",
"object",
"against",
"its",
"swagger",
"model"
] | 95070a39ed7065a84244ff5601fea4d54cc72b66 | https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/swagger/spec.py#L133-L139 | train |
pymacaron/pymacaron-core | pymacaron_core/swagger/spec.py | ApiSpec.call_on_each_endpoint | def call_on_each_endpoint(self, callback):
"""Find all server endpoints defined in the swagger spec and calls 'callback' for each,
with an instance of EndpointData as argument.
"""
if 'paths' not in self.swagger_dict:
return
for path, d in list(self.swagger_dict['pa... | python | def call_on_each_endpoint(self, callback):
"""Find all server endpoints defined in the swagger spec and calls 'callback' for each,
with an instance of EndpointData as argument.
"""
if 'paths' not in self.swagger_dict:
return
for path, d in list(self.swagger_dict['pa... | [
"def",
"call_on_each_endpoint",
"(",
"self",
",",
"callback",
")",
":",
"if",
"'paths'",
"not",
"in",
"self",
".",
"swagger_dict",
":",
"return",
"for",
"path",
",",
"d",
"in",
"list",
"(",
"self",
".",
"swagger_dict",
"[",
"'paths'",
"]",
".",
"items",
... | Find all server endpoints defined in the swagger spec and calls 'callback' for each,
with an instance of EndpointData as argument. | [
"Find",
"all",
"server",
"endpoints",
"defined",
"in",
"the",
"swagger",
"spec",
"and",
"calls",
"callback",
"for",
"each",
"with",
"an",
"instance",
"of",
"EndpointData",
"as",
"argument",
"."
] | 95070a39ed7065a84244ff5601fea4d54cc72b66 | https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/swagger/spec.py#L142-L213 | train |
andrewguy9/safeoutput | safeoutput/__init__.py | main | def main(args=None):
"""Buffer stdin and flush, and avoid incomplete files."""
parser = argparse.ArgumentParser(description=main.__doc__)
parser.add_argument(
'--binary',
dest='mode',
action='store_const',
const="wb",
default="w",
help='write in binary mode')
... | python | def main(args=None):
"""Buffer stdin and flush, and avoid incomplete files."""
parser = argparse.ArgumentParser(description=main.__doc__)
parser.add_argument(
'--binary',
dest='mode',
action='store_const',
const="wb",
default="w",
help='write in binary mode')
... | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"main",
".",
"__doc__",
")",
"parser",
".",
"add_argument",
"(",
"'--binary'",
",",
"dest",
"=",
"'mode'",
",",
"action",
"=",
... | Buffer stdin and flush, and avoid incomplete files. | [
"Buffer",
"stdin",
"and",
"flush",
"and",
"avoid",
"incomplete",
"files",
"."
] | e48fa1f691b57ea81c8faf7539f0bdd28ab59be5 | https://github.com/andrewguy9/safeoutput/blob/e48fa1f691b57ea81c8faf7539f0bdd28ab59be5/safeoutput/__init__.py#L64-L86 | train |
hid-io/layouts-python | layouts/emitter.py | basic_c_defines | def basic_c_defines(
layout,
keyboard_prefix="KEY_",
led_prefix="LED_",
sysctrl_prefix="SYS_",
cons_prefix="CONS_",
code_suffix=True,
all_caps=True,
space_char="_"
):
'''
Generates a list of C defines that can be used to generate a header file
@param layout: Layout object
... | python | def basic_c_defines(
layout,
keyboard_prefix="KEY_",
led_prefix="LED_",
sysctrl_prefix="SYS_",
cons_prefix="CONS_",
code_suffix=True,
all_caps=True,
space_char="_"
):
'''
Generates a list of C defines that can be used to generate a header file
@param layout: Layout object
... | [
"def",
"basic_c_defines",
"(",
"layout",
",",
"keyboard_prefix",
"=",
"\"KEY_\"",
",",
"led_prefix",
"=",
"\"LED_\"",
",",
"sysctrl_prefix",
"=",
"\"SYS_\"",
",",
"cons_prefix",
"=",
"\"CONS_\"",
",",
"code_suffix",
"=",
"True",
",",
"all_caps",
"=",
"True",
"... | Generates a list of C defines that can be used to generate a header file
@param layout: Layout object
@keyboard_prefix: Prefix used for to_hid_keyboard
@led_prefix: Prefix used for to_hid_led
@sysctrl_prefix: Prefix used for to_hid_sysctrl
@cons_prefix: Prefix used for to_hid_consumer
@code_suf... | [
"Generates",
"a",
"list",
"of",
"C",
"defines",
"that",
"can",
"be",
"used",
"to",
"generate",
"a",
"header",
"file"
] | b347578bfb4198fd812ecd7a2d9c7e551a856280 | https://github.com/hid-io/layouts-python/blob/b347578bfb4198fd812ecd7a2d9c7e551a856280/layouts/emitter.py#L11-L81 | train |
AASHE/django-constant-contact | django_constant_contact/models.py | ConstantContact.new_email_marketing_campaign | def new_email_marketing_campaign(self, name, email_content, from_email,
from_name, reply_to_email, subject,
text_content, address,
is_view_as_webpage_enabled=False,
view_as... | python | def new_email_marketing_campaign(self, name, email_content, from_email,
from_name, reply_to_email, subject,
text_content, address,
is_view_as_webpage_enabled=False,
view_as... | [
"def",
"new_email_marketing_campaign",
"(",
"self",
",",
"name",
",",
"email_content",
",",
"from_email",
",",
"from_name",
",",
"reply_to_email",
",",
"subject",
",",
"text_content",
",",
"address",
",",
"is_view_as_webpage_enabled",
"=",
"False",
",",
"view_as_web... | Create a Constant Contact email marketing campaign.
Returns an EmailMarketingCampaign object. | [
"Create",
"a",
"Constant",
"Contact",
"email",
"marketing",
"campaign",
".",
"Returns",
"an",
"EmailMarketingCampaign",
"object",
"."
] | 2a37f00ee62531804414b35637d0dad5992d5822 | https://github.com/AASHE/django-constant-contact/blob/2a37f00ee62531804414b35637d0dad5992d5822/django_constant_contact/models.py#L56-L105 | train |
AASHE/django-constant-contact | django_constant_contact/models.py | ConstantContact.update_email_marketing_campaign | def update_email_marketing_campaign(self, email_marketing_campaign,
name, email_content, from_email,
from_name, reply_to_email, subject,
text_content, address,
... | python | def update_email_marketing_campaign(self, email_marketing_campaign,
name, email_content, from_email,
from_name, reply_to_email, subject,
text_content, address,
... | [
"def",
"update_email_marketing_campaign",
"(",
"self",
",",
"email_marketing_campaign",
",",
"name",
",",
"email_content",
",",
"from_email",
",",
"from_name",
",",
"reply_to_email",
",",
"subject",
",",
"text_content",
",",
"address",
",",
"is_view_as_webpage_enabled",... | Update a Constant Contact email marketing campaign.
Returns the updated EmailMarketingCampaign object. | [
"Update",
"a",
"Constant",
"Contact",
"email",
"marketing",
"campaign",
".",
"Returns",
"the",
"updated",
"EmailMarketingCampaign",
"object",
"."
] | 2a37f00ee62531804414b35637d0dad5992d5822 | https://github.com/AASHE/django-constant-contact/blob/2a37f00ee62531804414b35637d0dad5992d5822/django_constant_contact/models.py#L107-L162 | train |
AASHE/django-constant-contact | django_constant_contact/models.py | ConstantContact.delete_email_marketing_campaign | def delete_email_marketing_campaign(self, email_marketing_campaign):
"""Deletes a Constant Contact email marketing campaign.
"""
url = self.api.join('/'.join([
self.EMAIL_MARKETING_CAMPAIGN_URL,
str(email_marketing_campaign.constant_contact_id)]))
response = url.d... | python | def delete_email_marketing_campaign(self, email_marketing_campaign):
"""Deletes a Constant Contact email marketing campaign.
"""
url = self.api.join('/'.join([
self.EMAIL_MARKETING_CAMPAIGN_URL,
str(email_marketing_campaign.constant_contact_id)]))
response = url.d... | [
"def",
"delete_email_marketing_campaign",
"(",
"self",
",",
"email_marketing_campaign",
")",
":",
"url",
"=",
"self",
".",
"api",
".",
"join",
"(",
"'/'",
".",
"join",
"(",
"[",
"self",
".",
"EMAIL_MARKETING_CAMPAIGN_URL",
",",
"str",
"(",
"email_marketing_campa... | Deletes a Constant Contact email marketing campaign. | [
"Deletes",
"a",
"Constant",
"Contact",
"email",
"marketing",
"campaign",
"."
] | 2a37f00ee62531804414b35637d0dad5992d5822 | https://github.com/AASHE/django-constant-contact/blob/2a37f00ee62531804414b35637d0dad5992d5822/django_constant_contact/models.py#L164-L172 | train |
AASHE/django-constant-contact | django_constant_contact/models.py | ConstantContact.inline_css | def inline_css(self, html):
"""Inlines CSS defined in external style sheets.
"""
premailer = Premailer(html)
inlined_html = premailer.transform(pretty_print=True)
return inlined_html | python | def inline_css(self, html):
"""Inlines CSS defined in external style sheets.
"""
premailer = Premailer(html)
inlined_html = premailer.transform(pretty_print=True)
return inlined_html | [
"def",
"inline_css",
"(",
"self",
",",
"html",
")",
":",
"premailer",
"=",
"Premailer",
"(",
"html",
")",
"inlined_html",
"=",
"premailer",
".",
"transform",
"(",
"pretty_print",
"=",
"True",
")",
"return",
"inlined_html"
] | Inlines CSS defined in external style sheets. | [
"Inlines",
"CSS",
"defined",
"in",
"external",
"style",
"sheets",
"."
] | 2a37f00ee62531804414b35637d0dad5992d5822 | https://github.com/AASHE/django-constant-contact/blob/2a37f00ee62531804414b35637d0dad5992d5822/django_constant_contact/models.py#L174-L179 | train |
AASHE/django-constant-contact | django_constant_contact/models.py | ConstantContact.preview_email_marketing_campaign | def preview_email_marketing_campaign(self, email_marketing_campaign):
"""Returns HTML and text previews of an EmailMarketingCampaign.
"""
url = self.api.join('/'.join([
self.EMAIL_MARKETING_CAMPAIGN_URL,
str(email_marketing_campaign.constant_contact_id),
'prev... | python | def preview_email_marketing_campaign(self, email_marketing_campaign):
"""Returns HTML and text previews of an EmailMarketingCampaign.
"""
url = self.api.join('/'.join([
self.EMAIL_MARKETING_CAMPAIGN_URL,
str(email_marketing_campaign.constant_contact_id),
'prev... | [
"def",
"preview_email_marketing_campaign",
"(",
"self",
",",
"email_marketing_campaign",
")",
":",
"url",
"=",
"self",
".",
"api",
".",
"join",
"(",
"'/'",
".",
"join",
"(",
"[",
"self",
".",
"EMAIL_MARKETING_CAMPAIGN_URL",
",",
"str",
"(",
"email_marketing_camp... | Returns HTML and text previews of an EmailMarketingCampaign. | [
"Returns",
"HTML",
"and",
"text",
"previews",
"of",
"an",
"EmailMarketingCampaign",
"."
] | 2a37f00ee62531804414b35637d0dad5992d5822 | https://github.com/AASHE/django-constant-contact/blob/2a37f00ee62531804414b35637d0dad5992d5822/django_constant_contact/models.py#L181-L191 | train |
AASHE/django-constant-contact | django_constant_contact/models.py | EmailMarketingCampaign.pre_save | def pre_save(cls, sender, instance, *args, **kwargs):
"""Pull constant_contact_id out of data.
"""
instance.constant_contact_id = str(instance.data['id']) | python | def pre_save(cls, sender, instance, *args, **kwargs):
"""Pull constant_contact_id out of data.
"""
instance.constant_contact_id = str(instance.data['id']) | [
"def",
"pre_save",
"(",
"cls",
",",
"sender",
",",
"instance",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"instance",
".",
"constant_contact_id",
"=",
"str",
"(",
"instance",
".",
"data",
"[",
"'id'",
"]",
")"
] | Pull constant_contact_id out of data. | [
"Pull",
"constant_contact_id",
"out",
"of",
"data",
"."
] | 2a37f00ee62531804414b35637d0dad5992d5822 | https://github.com/AASHE/django-constant-contact/blob/2a37f00ee62531804414b35637d0dad5992d5822/django_constant_contact/models.py#L216-L219 | train |
AASHE/django-constant-contact | django_constant_contact/models.py | EmailMarketingCampaign.pre_delete | def pre_delete(cls, sender, instance, *args, **kwargs):
"""Deletes the CC email marketing campaign associated with me.
"""
cc = ConstantContact()
response = cc.delete_email_marketing_campaign(instance)
response.raise_for_status() | python | def pre_delete(cls, sender, instance, *args, **kwargs):
"""Deletes the CC email marketing campaign associated with me.
"""
cc = ConstantContact()
response = cc.delete_email_marketing_campaign(instance)
response.raise_for_status() | [
"def",
"pre_delete",
"(",
"cls",
",",
"sender",
",",
"instance",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cc",
"=",
"ConstantContact",
"(",
")",
"response",
"=",
"cc",
".",
"delete_email_marketing_campaign",
"(",
"instance",
")",
"response",
... | Deletes the CC email marketing campaign associated with me. | [
"Deletes",
"the",
"CC",
"email",
"marketing",
"campaign",
"associated",
"with",
"me",
"."
] | 2a37f00ee62531804414b35637d0dad5992d5822 | https://github.com/AASHE/django-constant-contact/blob/2a37f00ee62531804414b35637d0dad5992d5822/django_constant_contact/models.py#L222-L227 | train |
OLC-Bioinformatics/sipprverse | sixteenS/sixteenS_probes.py | SixteenS.runner | def runner(self):
"""
Run the necessary methods in the correct order
"""
printtime('Starting {} analysis pipeline'.format(self.analysistype), self.starttime)
if not self.pipeline:
# If the metadata has been passed from the method script, self.pipeline must still be fa... | python | def runner(self):
"""
Run the necessary methods in the correct order
"""
printtime('Starting {} analysis pipeline'.format(self.analysistype), self.starttime)
if not self.pipeline:
# If the metadata has been passed from the method script, self.pipeline must still be fa... | [
"def",
"runner",
"(",
"self",
")",
":",
"printtime",
"(",
"'Starting {} analysis pipeline'",
".",
"format",
"(",
"self",
".",
"analysistype",
")",
",",
"self",
".",
"starttime",
")",
"if",
"not",
"self",
".",
"pipeline",
":",
"# If the metadata has been passed f... | Run the necessary methods in the correct order | [
"Run",
"the",
"necessary",
"methods",
"in",
"the",
"correct",
"order"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteenS_probes.py#L418-L443 | train |
JeromeParadis/django-mailing | mailing/mail.py | send_email | def send_email(recipients, subject, text_content=None, html_content=None, from_email=None, use_base_template=True, category=None, fail_silently=False, language=None, cc=None, bcc=None, attachments=None, headers=None, bypass_queue=False, bypass_hijacking=False, attach_files=None):
"""
Will send a multi-format ... | python | def send_email(recipients, subject, text_content=None, html_content=None, from_email=None, use_base_template=True, category=None, fail_silently=False, language=None, cc=None, bcc=None, attachments=None, headers=None, bypass_queue=False, bypass_hijacking=False, attach_files=None):
"""
Will send a multi-format ... | [
"def",
"send_email",
"(",
"recipients",
",",
"subject",
",",
"text_content",
"=",
"None",
",",
"html_content",
"=",
"None",
",",
"from_email",
"=",
"None",
",",
"use_base_template",
"=",
"True",
",",
"category",
"=",
"None",
",",
"fail_silently",
"=",
"False... | Will send a multi-format email to recipients. Email may be queued through celery | [
"Will",
"send",
"a",
"multi",
"-",
"format",
"email",
"to",
"recipients",
".",
"Email",
"may",
"be",
"queued",
"through",
"celery"
] | e1773410ab8ab946caf2847c46e025ba43c1ba6c | https://github.com/JeromeParadis/django-mailing/blob/e1773410ab8ab946caf2847c46e025ba43c1ba6c/mailing/mail.py#L23-L103 | train |
Riffstation/Flask-Philo-SQLAlchemy | flask_philo_sqlalchemy/connection.py | ConnectionPool.initialize_connections | def initialize_connections(self, scopefunc=None):
"""
Initialize a database connection by each connection string
defined in the configuration file
"""
for connection_name, connection_string in\
self.app.config['FLASK_PHILO_SQLALCHEMY'].items():
engine ... | python | def initialize_connections(self, scopefunc=None):
"""
Initialize a database connection by each connection string
defined in the configuration file
"""
for connection_name, connection_string in\
self.app.config['FLASK_PHILO_SQLALCHEMY'].items():
engine ... | [
"def",
"initialize_connections",
"(",
"self",
",",
"scopefunc",
"=",
"None",
")",
":",
"for",
"connection_name",
",",
"connection_string",
"in",
"self",
".",
"app",
".",
"config",
"[",
"'FLASK_PHILO_SQLALCHEMY'",
"]",
".",
"items",
"(",
")",
":",
"engine",
"... | Initialize a database connection by each connection string
defined in the configuration file | [
"Initialize",
"a",
"database",
"connection",
"by",
"each",
"connection",
"string",
"defined",
"in",
"the",
"configuration",
"file"
] | 71598bb603b8458a2cf9f7989f71d8f1c77fafb9 | https://github.com/Riffstation/Flask-Philo-SQLAlchemy/blob/71598bb603b8458a2cf9f7989f71d8f1c77fafb9/flask_philo_sqlalchemy/connection.py#L26-L36 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/groups.py | sortableListe.sort | def sort(self, attribut, order=False):
"""
Implément un tri par attrbut.
:param str attribut: Nom du champ concerné
:param bool order: Ordre croissant ou décroissant
"""
value_default = formats.ASSOCIATION[attribut][3]
if type(value_default) is str: # case inse... | python | def sort(self, attribut, order=False):
"""
Implément un tri par attrbut.
:param str attribut: Nom du champ concerné
:param bool order: Ordre croissant ou décroissant
"""
value_default = formats.ASSOCIATION[attribut][3]
if type(value_default) is str: # case inse... | [
"def",
"sort",
"(",
"self",
",",
"attribut",
",",
"order",
"=",
"False",
")",
":",
"value_default",
"=",
"formats",
".",
"ASSOCIATION",
"[",
"attribut",
"]",
"[",
"3",
"]",
"if",
"type",
"(",
"value_default",
")",
"is",
"str",
":",
"# case insensitive so... | Implément un tri par attrbut.
:param str attribut: Nom du champ concerné
:param bool order: Ordre croissant ou décroissant | [
"Implément",
"un",
"tri",
"par",
"attrbut",
"."
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/groups.py#L9-L27 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/groups.py | sortableListe.index_from_id | def index_from_id(self,Id):
"""Return the row of given Id if it'exists, otherwise None. Only works with pseudo-acces"""
try:
return [a.Id for a in self].index(Id)
except IndexError:
return | python | def index_from_id(self,Id):
"""Return the row of given Id if it'exists, otherwise None. Only works with pseudo-acces"""
try:
return [a.Id for a in self].index(Id)
except IndexError:
return | [
"def",
"index_from_id",
"(",
"self",
",",
"Id",
")",
":",
"try",
":",
"return",
"[",
"a",
".",
"Id",
"for",
"a",
"in",
"self",
"]",
".",
"index",
"(",
"Id",
")",
"except",
"IndexError",
":",
"return"
] | Return the row of given Id if it'exists, otherwise None. Only works with pseudo-acces | [
"Return",
"the",
"row",
"of",
"given",
"Id",
"if",
"it",
"exists",
"otherwise",
"None",
".",
"Only",
"works",
"with",
"pseudo",
"-",
"acces"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/groups.py#L38-L43 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/groups.py | Collection.append | def append(self, acces, **kwargs):
"""Append acces to list. Quite slow since it checks uniqueness.
kwargs may set `info` for this acces.
"""
if acces.Id in set(ac.Id for ac in self):
raise ValueError("Acces id already in list !")
list.append(self, acces)
if kw... | python | def append(self, acces, **kwargs):
"""Append acces to list. Quite slow since it checks uniqueness.
kwargs may set `info` for this acces.
"""
if acces.Id in set(ac.Id for ac in self):
raise ValueError("Acces id already in list !")
list.append(self, acces)
if kw... | [
"def",
"append",
"(",
"self",
",",
"acces",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"acces",
".",
"Id",
"in",
"set",
"(",
"ac",
".",
"Id",
"for",
"ac",
"in",
"self",
")",
":",
"raise",
"ValueError",
"(",
"\"Acces id already in list !\"",
")",
"list"... | Append acces to list. Quite slow since it checks uniqueness.
kwargs may set `info` for this acces. | [
"Append",
"acces",
"to",
"list",
".",
"Quite",
"slow",
"since",
"it",
"checks",
"uniqueness",
".",
"kwargs",
"may",
"set",
"info",
"for",
"this",
"acces",
"."
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/groups.py#L65-L73 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/groups.py | Collection.remove_id | def remove_id(self,key):
"""Suppress acces with id = key"""
self.infos.pop(key, "")
new_l = [a for a in self if not (a.Id == key)]
list.__init__(self, new_l) | python | def remove_id(self,key):
"""Suppress acces with id = key"""
self.infos.pop(key, "")
new_l = [a for a in self if not (a.Id == key)]
list.__init__(self, new_l) | [
"def",
"remove_id",
"(",
"self",
",",
"key",
")",
":",
"self",
".",
"infos",
".",
"pop",
"(",
"key",
",",
"\"\"",
")",
"new_l",
"=",
"[",
"a",
"for",
"a",
"in",
"self",
"if",
"not",
"(",
"a",
".",
"Id",
"==",
"key",
")",
"]",
"list",
".",
"... | Suppress acces with id = key | [
"Suppress",
"acces",
"with",
"id",
"=",
"key"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/groups.py#L75-L79 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/groups.py | Collection.get_info | def get_info(self, key=None, Id=None) -> dict:
"""Returns information associated with Id or list index"""
if key is not None:
Id = self[key].Id
return self.infos.get(Id,{}) | python | def get_info(self, key=None, Id=None) -> dict:
"""Returns information associated with Id or list index"""
if key is not None:
Id = self[key].Id
return self.infos.get(Id,{}) | [
"def",
"get_info",
"(",
"self",
",",
"key",
"=",
"None",
",",
"Id",
"=",
"None",
")",
"->",
"dict",
":",
"if",
"key",
"is",
"not",
"None",
":",
"Id",
"=",
"self",
"[",
"key",
"]",
".",
"Id",
"return",
"self",
".",
"infos",
".",
"get",
"(",
"I... | Returns information associated with Id or list index | [
"Returns",
"information",
"associated",
"with",
"Id",
"or",
"list",
"index"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/groups.py#L91-L95 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/groups.py | Collection.recherche | def recherche(self, pattern, entete):
"""Performs a search field by field, using functions defined in formats.
Matchs are marked with info[`font`]
:param pattern: String to look for
:param entete: Fields to look into
:return: Nothing. The collection is changed in place
"... | python | def recherche(self, pattern, entete):
"""Performs a search field by field, using functions defined in formats.
Matchs are marked with info[`font`]
:param pattern: String to look for
:param entete: Fields to look into
:return: Nothing. The collection is changed in place
"... | [
"def",
"recherche",
"(",
"self",
",",
"pattern",
",",
"entete",
")",
":",
"new_liste",
"=",
"[",
"]",
"sub_patterns",
"=",
"pattern",
".",
"split",
"(",
"\" \"",
")",
"for",
"p",
"in",
"self",
":",
"d_font",
"=",
"{",
"att",
":",
"False",
"for",
"a... | Performs a search field by field, using functions defined in formats.
Matchs are marked with info[`font`]
:param pattern: String to look for
:param entete: Fields to look into
:return: Nothing. The collection is changed in place | [
"Performs",
"a",
"search",
"field",
"by",
"field",
"using",
"functions",
"defined",
"in",
"formats",
".",
"Matchs",
"are",
"marked",
"with",
"info",
"[",
"font",
"]"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/groups.py#L102-L132 | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/groups.py | Collection.extend | def extend(self, collection):
"""Merges collections. Ensure uniqueness of ids"""
l_ids = set([a.Id for a in self])
for acces in collection:
if not acces.Id in l_ids:
list.append(self,acces)
info = collection.get_info(Id=acces.Id)
if inf... | python | def extend(self, collection):
"""Merges collections. Ensure uniqueness of ids"""
l_ids = set([a.Id for a in self])
for acces in collection:
if not acces.Id in l_ids:
list.append(self,acces)
info = collection.get_info(Id=acces.Id)
if inf... | [
"def",
"extend",
"(",
"self",
",",
"collection",
")",
":",
"l_ids",
"=",
"set",
"(",
"[",
"a",
".",
"Id",
"for",
"a",
"in",
"self",
"]",
")",
"for",
"acces",
"in",
"collection",
":",
"if",
"not",
"acces",
".",
"Id",
"in",
"l_ids",
":",
"list",
... | Merges collections. Ensure uniqueness of ids | [
"Merges",
"collections",
".",
"Ensure",
"uniqueness",
"of",
"ids"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/groups.py#L135-L143 | train |
QunarOPS/qg.core | qg/core/timeutils.py | isotime | def isotime(at=None, subsecond=False):
"""Stringify time in ISO 8601 format."""
if not at:
at = utcnow()
st = at.strftime(_ISO8601_TIME_FORMAT
if not subsecond
else _ISO8601_TIME_FORMAT_SUBSECOND)
tz = at.tzinfo.tzname(None) if at.tzinfo else 'UTC'
s... | python | def isotime(at=None, subsecond=False):
"""Stringify time in ISO 8601 format."""
if not at:
at = utcnow()
st = at.strftime(_ISO8601_TIME_FORMAT
if not subsecond
else _ISO8601_TIME_FORMAT_SUBSECOND)
tz = at.tzinfo.tzname(None) if at.tzinfo else 'UTC'
s... | [
"def",
"isotime",
"(",
"at",
"=",
"None",
",",
"subsecond",
"=",
"False",
")",
":",
"if",
"not",
"at",
":",
"at",
"=",
"utcnow",
"(",
")",
"st",
"=",
"at",
".",
"strftime",
"(",
"_ISO8601_TIME_FORMAT",
"if",
"not",
"subsecond",
"else",
"_ISO8601_TIME_F... | Stringify time in ISO 8601 format. | [
"Stringify",
"time",
"in",
"ISO",
"8601",
"format",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L34-L43 | train |
QunarOPS/qg.core | qg/core/timeutils.py | parse_isotime | def parse_isotime(timestr):
"""Parse time from ISO 8601 format."""
try:
return iso8601.parse_date(timestr)
except iso8601.ParseError as e:
raise ValueError(six.text_type(e))
except TypeError as e:
raise ValueError(six.text_type(e)) | python | def parse_isotime(timestr):
"""Parse time from ISO 8601 format."""
try:
return iso8601.parse_date(timestr)
except iso8601.ParseError as e:
raise ValueError(six.text_type(e))
except TypeError as e:
raise ValueError(six.text_type(e)) | [
"def",
"parse_isotime",
"(",
"timestr",
")",
":",
"try",
":",
"return",
"iso8601",
".",
"parse_date",
"(",
"timestr",
")",
"except",
"iso8601",
".",
"ParseError",
"as",
"e",
":",
"raise",
"ValueError",
"(",
"six",
".",
"text_type",
"(",
"e",
")",
")",
... | Parse time from ISO 8601 format. | [
"Parse",
"time",
"from",
"ISO",
"8601",
"format",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L46-L53 | train |
QunarOPS/qg.core | qg/core/timeutils.py | strtime | def strtime(at=None, fmt=PERFECT_TIME_FORMAT):
"""Returns formatted utcnow."""
if not at:
at = utcnow()
return at.strftime(fmt) | python | def strtime(at=None, fmt=PERFECT_TIME_FORMAT):
"""Returns formatted utcnow."""
if not at:
at = utcnow()
return at.strftime(fmt) | [
"def",
"strtime",
"(",
"at",
"=",
"None",
",",
"fmt",
"=",
"PERFECT_TIME_FORMAT",
")",
":",
"if",
"not",
"at",
":",
"at",
"=",
"utcnow",
"(",
")",
"return",
"at",
".",
"strftime",
"(",
"fmt",
")"
] | Returns formatted utcnow. | [
"Returns",
"formatted",
"utcnow",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L56-L60 | train |
QunarOPS/qg.core | qg/core/timeutils.py | normalize_time | def normalize_time(timestamp):
"""Normalize time in arbitrary timezone to UTC naive object."""
offset = timestamp.utcoffset()
if offset is None:
return timestamp
return timestamp.replace(tzinfo=None) - offset | python | def normalize_time(timestamp):
"""Normalize time in arbitrary timezone to UTC naive object."""
offset = timestamp.utcoffset()
if offset is None:
return timestamp
return timestamp.replace(tzinfo=None) - offset | [
"def",
"normalize_time",
"(",
"timestamp",
")",
":",
"offset",
"=",
"timestamp",
".",
"utcoffset",
"(",
")",
"if",
"offset",
"is",
"None",
":",
"return",
"timestamp",
"return",
"timestamp",
".",
"replace",
"(",
"tzinfo",
"=",
"None",
")",
"-",
"offset"
] | Normalize time in arbitrary timezone to UTC naive object. | [
"Normalize",
"time",
"in",
"arbitrary",
"timezone",
"to",
"UTC",
"naive",
"object",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L68-L73 | train |
QunarOPS/qg.core | qg/core/timeutils.py | is_older_than | def is_older_than(before, seconds):
"""Return True if before is older than seconds."""
if isinstance(before, six.string_types):
before = parse_strtime(before).replace(tzinfo=None)
else:
before = before.replace(tzinfo=None)
return utcnow() - before > datetime.timedelta(seconds=seconds) | python | def is_older_than(before, seconds):
"""Return True if before is older than seconds."""
if isinstance(before, six.string_types):
before = parse_strtime(before).replace(tzinfo=None)
else:
before = before.replace(tzinfo=None)
return utcnow() - before > datetime.timedelta(seconds=seconds) | [
"def",
"is_older_than",
"(",
"before",
",",
"seconds",
")",
":",
"if",
"isinstance",
"(",
"before",
",",
"six",
".",
"string_types",
")",
":",
"before",
"=",
"parse_strtime",
"(",
"before",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"None",
")",
"else",
... | Return True if before is older than seconds. | [
"Return",
"True",
"if",
"before",
"is",
"older",
"than",
"seconds",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L76-L83 | train |
QunarOPS/qg.core | qg/core/timeutils.py | is_newer_than | def is_newer_than(after, seconds):
"""Return True if after is newer than seconds."""
if isinstance(after, six.string_types):
after = parse_strtime(after).replace(tzinfo=None)
else:
after = after.replace(tzinfo=None)
return after - utcnow() > datetime.timedelta(seconds=seconds) | python | def is_newer_than(after, seconds):
"""Return True if after is newer than seconds."""
if isinstance(after, six.string_types):
after = parse_strtime(after).replace(tzinfo=None)
else:
after = after.replace(tzinfo=None)
return after - utcnow() > datetime.timedelta(seconds=seconds) | [
"def",
"is_newer_than",
"(",
"after",
",",
"seconds",
")",
":",
"if",
"isinstance",
"(",
"after",
",",
"six",
".",
"string_types",
")",
":",
"after",
"=",
"parse_strtime",
"(",
"after",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"None",
")",
"else",
":",... | Return True if after is newer than seconds. | [
"Return",
"True",
"if",
"after",
"is",
"newer",
"than",
"seconds",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L86-L93 | train |
QunarOPS/qg.core | qg/core/timeutils.py | utcnow_ts | def utcnow_ts():
"""Timestamp version of our utcnow function."""
if utcnow.override_time is None:
# NOTE(kgriffs): This is several times faster
# than going through calendar.timegm(...)
return int(time.time())
return calendar.timegm(utcnow().timetuple()) | python | def utcnow_ts():
"""Timestamp version of our utcnow function."""
if utcnow.override_time is None:
# NOTE(kgriffs): This is several times faster
# than going through calendar.timegm(...)
return int(time.time())
return calendar.timegm(utcnow().timetuple()) | [
"def",
"utcnow_ts",
"(",
")",
":",
"if",
"utcnow",
".",
"override_time",
"is",
"None",
":",
"# NOTE(kgriffs): This is several times faster",
"# than going through calendar.timegm(...)",
"return",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
"return",
"calendar",
... | Timestamp version of our utcnow function. | [
"Timestamp",
"version",
"of",
"our",
"utcnow",
"function",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L96-L103 | train |
QunarOPS/qg.core | qg/core/timeutils.py | utcnow | def utcnow():
"""Overridable version of utils.utcnow."""
if utcnow.override_time:
try:
return utcnow.override_time.pop(0)
except AttributeError:
return utcnow.override_time
return datetime.datetime.utcnow() | python | def utcnow():
"""Overridable version of utils.utcnow."""
if utcnow.override_time:
try:
return utcnow.override_time.pop(0)
except AttributeError:
return utcnow.override_time
return datetime.datetime.utcnow() | [
"def",
"utcnow",
"(",
")",
":",
"if",
"utcnow",
".",
"override_time",
":",
"try",
":",
"return",
"utcnow",
".",
"override_time",
".",
"pop",
"(",
"0",
")",
"except",
"AttributeError",
":",
"return",
"utcnow",
".",
"override_time",
"return",
"datetime",
"."... | Overridable version of utils.utcnow. | [
"Overridable",
"version",
"of",
"utils",
".",
"utcnow",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L106-L113 | train |
QunarOPS/qg.core | qg/core/timeutils.py | advance_time_delta | def advance_time_delta(timedelta):
"""Advance overridden time using a datetime.timedelta."""
assert(utcnow.override_time is not None)
try:
for dt in utcnow.override_time:
dt += timedelta
except TypeError:
utcnow.override_time += timedelta | python | def advance_time_delta(timedelta):
"""Advance overridden time using a datetime.timedelta."""
assert(utcnow.override_time is not None)
try:
for dt in utcnow.override_time:
dt += timedelta
except TypeError:
utcnow.override_time += timedelta | [
"def",
"advance_time_delta",
"(",
"timedelta",
")",
":",
"assert",
"(",
"utcnow",
".",
"override_time",
"is",
"not",
"None",
")",
"try",
":",
"for",
"dt",
"in",
"utcnow",
".",
"override_time",
":",
"dt",
"+=",
"timedelta",
"except",
"TypeError",
":",
"utcn... | Advance overridden time using a datetime.timedelta. | [
"Advance",
"overridden",
"time",
"using",
"a",
"datetime",
".",
"timedelta",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L135-L142 | train |
QunarOPS/qg.core | qg/core/timeutils.py | marshall_now | def marshall_now(now=None):
"""Make an rpc-safe datetime with microseconds.
Note: tzinfo is stripped, but not required for relative times.
"""
if not now:
now = utcnow()
return dict(day=now.day, month=now.month, year=now.year, hour=now.hour,
minute=now.minute, second=now.sec... | python | def marshall_now(now=None):
"""Make an rpc-safe datetime with microseconds.
Note: tzinfo is stripped, but not required for relative times.
"""
if not now:
now = utcnow()
return dict(day=now.day, month=now.month, year=now.year, hour=now.hour,
minute=now.minute, second=now.sec... | [
"def",
"marshall_now",
"(",
"now",
"=",
"None",
")",
":",
"if",
"not",
"now",
":",
"now",
"=",
"utcnow",
"(",
")",
"return",
"dict",
"(",
"day",
"=",
"now",
".",
"day",
",",
"month",
"=",
"now",
".",
"month",
",",
"year",
"=",
"now",
".",
"year... | Make an rpc-safe datetime with microseconds.
Note: tzinfo is stripped, but not required for relative times. | [
"Make",
"an",
"rpc",
"-",
"safe",
"datetime",
"with",
"microseconds",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L155-L164 | train |
QunarOPS/qg.core | qg/core/timeutils.py | unmarshall_time | def unmarshall_time(tyme):
"""Unmarshall a datetime dict."""
return datetime.datetime(day=tyme['day'],
month=tyme['month'],
year=tyme['year'],
hour=tyme['hour'],
minute=tyme['minute'],
... | python | def unmarshall_time(tyme):
"""Unmarshall a datetime dict."""
return datetime.datetime(day=tyme['day'],
month=tyme['month'],
year=tyme['year'],
hour=tyme['hour'],
minute=tyme['minute'],
... | [
"def",
"unmarshall_time",
"(",
"tyme",
")",
":",
"return",
"datetime",
".",
"datetime",
"(",
"day",
"=",
"tyme",
"[",
"'day'",
"]",
",",
"month",
"=",
"tyme",
"[",
"'month'",
"]",
",",
"year",
"=",
"tyme",
"[",
"'year'",
"]",
",",
"hour",
"=",
"tym... | Unmarshall a datetime dict. | [
"Unmarshall",
"a",
"datetime",
"dict",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L167-L175 | train |
QunarOPS/qg.core | qg/core/timeutils.py | total_seconds | def total_seconds(delta):
"""Return the total seconds of datetime.timedelta object.
Compute total seconds of datetime.timedelta, datetime.timedelta
doesn't have method total_seconds in Python2.6, calculate it manually.
"""
try:
return delta.total_seconds()
except AttributeError:
... | python | def total_seconds(delta):
"""Return the total seconds of datetime.timedelta object.
Compute total seconds of datetime.timedelta, datetime.timedelta
doesn't have method total_seconds in Python2.6, calculate it manually.
"""
try:
return delta.total_seconds()
except AttributeError:
... | [
"def",
"total_seconds",
"(",
"delta",
")",
":",
"try",
":",
"return",
"delta",
".",
"total_seconds",
"(",
")",
"except",
"AttributeError",
":",
"return",
"(",
"(",
"delta",
".",
"days",
"*",
"24",
"*",
"3600",
")",
"+",
"delta",
".",
"seconds",
"+",
... | Return the total seconds of datetime.timedelta object.
Compute total seconds of datetime.timedelta, datetime.timedelta
doesn't have method total_seconds in Python2.6, calculate it manually. | [
"Return",
"the",
"total",
"seconds",
"of",
"datetime",
".",
"timedelta",
"object",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L188-L198 | train |
QunarOPS/qg.core | qg/core/timeutils.py | is_soon | def is_soon(dt, window):
"""Determines if time is going to happen in the next window seconds.
:params dt: the time
:params window: minimum seconds to remain to consider the time not soon
:return: True if expiration is within the given duration
"""
soon = (utcnow() + datetime.timedelta(seconds=... | python | def is_soon(dt, window):
"""Determines if time is going to happen in the next window seconds.
:params dt: the time
:params window: minimum seconds to remain to consider the time not soon
:return: True if expiration is within the given duration
"""
soon = (utcnow() + datetime.timedelta(seconds=... | [
"def",
"is_soon",
"(",
"dt",
",",
"window",
")",
":",
"soon",
"=",
"(",
"utcnow",
"(",
")",
"+",
"datetime",
".",
"timedelta",
"(",
"seconds",
"=",
"window",
")",
")",
"return",
"normalize_time",
"(",
"dt",
")",
"<=",
"soon"
] | Determines if time is going to happen in the next window seconds.
:params dt: the time
:params window: minimum seconds to remain to consider the time not soon
:return: True if expiration is within the given duration | [
"Determines",
"if",
"time",
"is",
"going",
"to",
"happen",
"in",
"the",
"next",
"window",
"seconds",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L201-L210 | train |
tsnaomi/finnsyll | ez_setup.py | download_file_powershell | def download_file_powershell(url, target):
'''
Download the file at url to target using Powershell (which will validate
trust). Raise an exception if the command cannot complete.
'''
target = os.path.abspath(target)
cmd = [
'powershell',
'-Command',
'(new-object System.Ne... | python | def download_file_powershell(url, target):
'''
Download the file at url to target using Powershell (which will validate
trust). Raise an exception if the command cannot complete.
'''
target = os.path.abspath(target)
cmd = [
'powershell',
'-Command',
'(new-object System.Ne... | [
"def",
"download_file_powershell",
"(",
"url",
",",
"target",
")",
":",
"target",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"target",
")",
"cmd",
"=",
"[",
"'powershell'",
",",
"'-Command'",
",",
"'(new-object System.Net.WebClient).DownloadFile(%(url)r, %(target)... | Download the file at url to target using Powershell (which will validate
trust). Raise an exception if the command cannot complete. | [
"Download",
"the",
"file",
"at",
"url",
"to",
"target",
"using",
"Powershell",
"(",
"which",
"will",
"validate",
"trust",
")",
".",
"Raise",
"an",
"exception",
"if",
"the",
"command",
"cannot",
"complete",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/ez_setup.py#L162-L173 | train |
tsnaomi/finnsyll | ez_setup.py | download_file_insecure | def download_file_insecure(url, target):
'''
Use Python to download the file, even though it cannot authenticate the
connection.
'''
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
src = dst = None
try:
src = urlopen(url)
... | python | def download_file_insecure(url, target):
'''
Use Python to download the file, even though it cannot authenticate the
connection.
'''
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
src = dst = None
try:
src = urlopen(url)
... | [
"def",
"download_file_insecure",
"(",
"url",
",",
"target",
")",
":",
"try",
":",
"from",
"urllib",
".",
"request",
"import",
"urlopen",
"except",
"ImportError",
":",
"from",
"urllib2",
"import",
"urlopen",
"src",
"=",
"dst",
"=",
"None",
"try",
":",
"src"... | Use Python to download the file, even though it cannot authenticate the
connection. | [
"Use",
"Python",
"to",
"download",
"the",
"file",
"even",
"though",
"it",
"cannot",
"authenticate",
"the",
"connection",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/ez_setup.py#L233-L254 | train |
tsnaomi/finnsyll | ez_setup.py | _build_install_args | def _build_install_args(options):
'''
Build the arguments to 'python setup.py install' on the setuptools package
'''
install_args = []
if options.user_install:
if sys.version_info < (2, 6):
log.warn('--user requires Python 2.6 or later')
raise SystemExit(1)
in... | python | def _build_install_args(options):
'''
Build the arguments to 'python setup.py install' on the setuptools package
'''
install_args = []
if options.user_install:
if sys.version_info < (2, 6):
log.warn('--user requires Python 2.6 or later')
raise SystemExit(1)
in... | [
"def",
"_build_install_args",
"(",
"options",
")",
":",
"install_args",
"=",
"[",
"]",
"if",
"options",
".",
"user_install",
":",
"if",
"sys",
".",
"version_info",
"<",
"(",
"2",
",",
"6",
")",
":",
"log",
".",
"warn",
"(",
"'--user requires Python 2.6 or ... | Build the arguments to 'python setup.py install' on the setuptools package | [
"Build",
"the",
"arguments",
"to",
"python",
"setup",
".",
"py",
"install",
"on",
"the",
"setuptools",
"package"
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/ez_setup.py#L345-L355 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.