repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
Ezhil-Language-Foundation/open-tamil | tamil/utf8.py | joinMeiUyir | def joinMeiUyir(mei_char, uyir_char):
"""
This function join mei character and uyir character, and retuns as
compound uyirmei unicode character.
Inputs:
mei_char : It must be unicode tamil mei char.
uyir_char : It must be unicode tamil uyir char.
Written By : Arulalan.T
Date : ... | python | def joinMeiUyir(mei_char, uyir_char):
"""
This function join mei character and uyir character, and retuns as
compound uyirmei unicode character.
Inputs:
mei_char : It must be unicode tamil mei char.
uyir_char : It must be unicode tamil uyir char.
Written By : Arulalan.T
Date : ... | [
"def",
"joinMeiUyir",
"(",
"mei_char",
",",
"uyir_char",
")",
":",
"if",
"not",
"mei_char",
":",
"return",
"uyir_char",
"if",
"not",
"uyir_char",
":",
"return",
"mei_char",
"if",
"not",
"isinstance",
"(",
"mei_char",
",",
"PYTHON3",
"and",
"str",
"or",
"un... | This function join mei character and uyir character, and retuns as
compound uyirmei unicode character.
Inputs:
mei_char : It must be unicode tamil mei char.
uyir_char : It must be unicode tamil uyir char.
Written By : Arulalan.T
Date : 22.09.2014 | [
"This",
"function",
"join",
"mei",
"character",
"and",
"uyir",
"character",
"and",
"retuns",
"as",
"compound",
"uyirmei",
"unicode",
"character",
"."
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/tamil/utf8.py#L622-L652 |
Ezhil-Language-Foundation/open-tamil | tamil/regexp.py | expand_tamil | def expand_tamil(start,end):
""" expand uyir or mei-letter range etc.
i.e. அ-ஔ gets converted to அ,ஆ,இ,ஈ,உ,ஊ,எ,ஏ,ஐ,ஒ,ஓ,ஔ etc.
"""
# few sequences
for seq in [utf8.uyir_letters, utf8.grantha_mei_letters, \
utf8.grantha_agaram_letters]:
if is_containing_seq(start,end,seq):... | python | def expand_tamil(start,end):
""" expand uyir or mei-letter range etc.
i.e. அ-ஔ gets converted to அ,ஆ,இ,ஈ,உ,ஊ,எ,ஏ,ஐ,ஒ,ஓ,ஔ etc.
"""
# few sequences
for seq in [utf8.uyir_letters, utf8.grantha_mei_letters, \
utf8.grantha_agaram_letters]:
if is_containing_seq(start,end,seq):... | [
"def",
"expand_tamil",
"(",
"start",
",",
"end",
")",
":",
"# few sequences",
"for",
"seq",
"in",
"[",
"utf8",
".",
"uyir_letters",
",",
"utf8",
".",
"grantha_mei_letters",
",",
"utf8",
".",
"grantha_agaram_letters",
"]",
":",
"if",
"is_containing_seq",
"(",
... | expand uyir or mei-letter range etc.
i.e. அ-ஔ gets converted to அ,ஆ,இ,ஈ,உ,ஊ,எ,ஏ,ஐ,ஒ,ஓ,ஔ etc. | [
"expand",
"uyir",
"or",
"mei",
"-",
"letter",
"range",
"etc",
".",
"i",
".",
"e",
".",
"அ",
"-",
"ஔ",
"gets",
"converted",
"to",
"அ",
"ஆ",
"இ",
"ஈ",
"உ",
"ஊ",
"எ",
"ஏ",
"ஐ",
"ஒ",
"ஓ",
"ஔ",
"etc",
"."
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/tamil/regexp.py#L20-L34 |
Ezhil-Language-Foundation/open-tamil | tamil/regexp.py | make_pattern | def make_pattern( patt, flags=0 ):
"""
returns a compile regular expression object
"""
# print('input',len(patt))
patt_letters = utf8.get_letters( patt )
patt_out = list()
idx = 0
# print('output',len(patt_letters))
patt = [None,None]
prev = None
LEN_PATT = len(patt_lette... | python | def make_pattern( patt, flags=0 ):
"""
returns a compile regular expression object
"""
# print('input',len(patt))
patt_letters = utf8.get_letters( patt )
patt_out = list()
idx = 0
# print('output',len(patt_letters))
patt = [None,None]
prev = None
LEN_PATT = len(patt_lette... | [
"def",
"make_pattern",
"(",
"patt",
",",
"flags",
"=",
"0",
")",
":",
"# print('input',len(patt))",
"patt_letters",
"=",
"utf8",
".",
"get_letters",
"(",
"patt",
")",
"patt_out",
"=",
"list",
"(",
")",
"idx",
"=",
"0",
"# print('output',len(patt_letters))",
"p... | returns a compile regular expression object | [
"returns",
"a",
"compile",
"regular",
"expression",
"object"
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/tamil/regexp.py#L36-L65 |
Ezhil-Language-Foundation/open-tamil | examples/speller/ta_data.py | BigramHash.frequency_model | def frequency_model( self ):
""" build a letter frequency model for Tamil letters from a corpus """
prev_letter = None
# use a generator in corpus
prev_letter = list(self.corpus.next_tamil_letter())[0]
for next_letter in self.corpus.next_tamil_letter():
# update frequ... | python | def frequency_model( self ):
""" build a letter frequency model for Tamil letters from a corpus """
prev_letter = None
# use a generator in corpus
prev_letter = list(self.corpus.next_tamil_letter())[0]
for next_letter in self.corpus.next_tamil_letter():
# update frequ... | [
"def",
"frequency_model",
"(",
"self",
")",
":",
"prev_letter",
"=",
"None",
"# use a generator in corpus",
"prev_letter",
"=",
"list",
"(",
"self",
".",
"corpus",
".",
"next_tamil_letter",
"(",
")",
")",
"[",
"0",
"]",
"for",
"next_letter",
"in",
"self",
".... | build a letter frequency model for Tamil letters from a corpus | [
"build",
"a",
"letter",
"frequency",
"model",
"for",
"Tamil",
"letters",
"from",
"a",
"corpus"
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/examples/speller/ta_data.py#L81-L95 |
Ezhil-Language-Foundation/open-tamil | tamil/iscii.py | convert_to_unicode | def convert_to_unicode( tscii_input ):
""" convert a byte-ASCII encoded string into equivalent Unicode string
in the UTF-8 notation."""
output = list()
prev = None
prev2x = None
# need a look ahead of 2 tokens atleast
for char in tscii_input:
## print "%2x"%ord(char) # debugging
... | python | def convert_to_unicode( tscii_input ):
""" convert a byte-ASCII encoded string into equivalent Unicode string
in the UTF-8 notation."""
output = list()
prev = None
prev2x = None
# need a look ahead of 2 tokens atleast
for char in tscii_input:
## print "%2x"%ord(char) # debugging
... | [
"def",
"convert_to_unicode",
"(",
"tscii_input",
")",
":",
"output",
"=",
"list",
"(",
")",
"prev",
"=",
"None",
"prev2x",
"=",
"None",
"# need a look ahead of 2 tokens atleast",
"for",
"char",
"in",
"tscii_input",
":",
"## print \"%2x\"%ord(char) # debugging",
"if",
... | convert a byte-ASCII encoded string into equivalent Unicode string
in the UTF-8 notation. | [
"convert",
"a",
"byte",
"-",
"ASCII",
"encoded",
"string",
"into",
"equivalent",
"Unicode",
"string",
"in",
"the",
"UTF",
"-",
"8",
"notation",
"."
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/tamil/iscii.py#L151-L201 |
Ezhil-Language-Foundation/open-tamil | examples/wordxsec.py | WordXSec.compute | def compute( self ):
# compute the intersection graph into @xsections dictionary
wordlist = self.wordlist
""" build a dictionary of words, and their intersections """
xsections = {}
for i in range(len(wordlist)):
word_i = wordlist[i]
for j in range(... | python | def compute( self ):
# compute the intersection graph into @xsections dictionary
wordlist = self.wordlist
""" build a dictionary of words, and their intersections """
xsections = {}
for i in range(len(wordlist)):
word_i = wordlist[i]
for j in range(... | [
"def",
"compute",
"(",
"self",
")",
":",
"# compute the intersection graph into @xsections dictionary\r",
"wordlist",
"=",
"self",
".",
"wordlist",
"xsections",
"=",
"{",
"}",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"wordlist",
")",
")",
":",
"word_i",
"="... | build a dictionary of words, and their intersections | [
"build",
"a",
"dictionary",
"of",
"words",
"and",
"their",
"intersections"
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/examples/wordxsec.py#L26-L51 |
Ezhil-Language-Foundation/open-tamil | solthiruthi/heuristics.py | Sequential.in_sequence | def in_sequence( word, ref_set, ref_reason, freq_threshold = 2 ):
""" ignore ctx information right now. If repetition/match length >= @freq_threshold then we flag-it """
chars = get_letters(word)
flag = True #no error assumed
reason = None #no reason
freq_count = 0
for ch... | python | def in_sequence( word, ref_set, ref_reason, freq_threshold = 2 ):
""" ignore ctx information right now. If repetition/match length >= @freq_threshold then we flag-it """
chars = get_letters(word)
flag = True #no error assumed
reason = None #no reason
freq_count = 0
for ch... | [
"def",
"in_sequence",
"(",
"word",
",",
"ref_set",
",",
"ref_reason",
",",
"freq_threshold",
"=",
"2",
")",
":",
"chars",
"=",
"get_letters",
"(",
"word",
")",
"flag",
"=",
"True",
"#no error assumed",
"reason",
"=",
"None",
"#no reason",
"freq_count",
"=",
... | ignore ctx information right now. If repetition/match length >= @freq_threshold then we flag-it | [
"ignore",
"ctx",
"information",
"right",
"now",
".",
"If",
"repetition",
"/",
"match",
"length",
">",
"="
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/solthiruthi/heuristics.py#L34-L50 |
Ezhil-Language-Foundation/open-tamil | solthiruthi/heuristics.py | AdjacentVowels.apply | def apply(self, word, ctx=None):
""" ignore ctx information right now """
return Sequential.in_sequence(word,AdjacentVowels.uyir_letters,AdjacentVowels.reason) | python | def apply(self, word, ctx=None):
""" ignore ctx information right now """
return Sequential.in_sequence(word,AdjacentVowels.uyir_letters,AdjacentVowels.reason) | [
"def",
"apply",
"(",
"self",
",",
"word",
",",
"ctx",
"=",
"None",
")",
":",
"return",
"Sequential",
".",
"in_sequence",
"(",
"word",
",",
"AdjacentVowels",
".",
"uyir_letters",
",",
"AdjacentVowels",
".",
"reason",
")"
] | ignore ctx information right now | [
"ignore",
"ctx",
"information",
"right",
"now"
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/solthiruthi/heuristics.py#L59-L61 |
Ezhil-Language-Foundation/open-tamil | solthiruthi/heuristics.py | AdjacentConsonants.apply | def apply(self, word, ctx=None):
""" ignore ctx information right now """
flag,reason = Sequential.in_sequence(word,AdjacentConsonants.mei_letters,AdjacentConsonants.reason,self.freq_threshold)
if flag:
flag,reason = Sequential.in_sequence(word,AdjacentConsonants.agaram_letters,Adjac... | python | def apply(self, word, ctx=None):
""" ignore ctx information right now """
flag,reason = Sequential.in_sequence(word,AdjacentConsonants.mei_letters,AdjacentConsonants.reason,self.freq_threshold)
if flag:
flag,reason = Sequential.in_sequence(word,AdjacentConsonants.agaram_letters,Adjac... | [
"def",
"apply",
"(",
"self",
",",
"word",
",",
"ctx",
"=",
"None",
")",
":",
"flag",
",",
"reason",
"=",
"Sequential",
".",
"in_sequence",
"(",
"word",
",",
"AdjacentConsonants",
".",
"mei_letters",
",",
"AdjacentConsonants",
".",
"reason",
",",
"self",
... | ignore ctx information right now | [
"ignore",
"ctx",
"information",
"right",
"now"
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/solthiruthi/heuristics.py#L74-L79 |
Ezhil-Language-Foundation/open-tamil | solthiruthi/heuristics.py | RepeatedLetters.apply | def apply(self,word,ctx=None):
""" ignore ctx information right now """
chars = get_letters(word)
flag = True #no error assumed
reason = None #no reason
prev_letter = None
for char in chars:
if prev_letter == char:
flag = False
... | python | def apply(self,word,ctx=None):
""" ignore ctx information right now """
chars = get_letters(word)
flag = True #no error assumed
reason = None #no reason
prev_letter = None
for char in chars:
if prev_letter == char:
flag = False
... | [
"def",
"apply",
"(",
"self",
",",
"word",
",",
"ctx",
"=",
"None",
")",
":",
"chars",
"=",
"get_letters",
"(",
"word",
")",
"flag",
"=",
"True",
"#no error assumed",
"reason",
"=",
"None",
"#no reason",
"prev_letter",
"=",
"None",
"for",
"char",
"in",
... | ignore ctx information right now | [
"ignore",
"ctx",
"information",
"right",
"now"
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/solthiruthi/heuristics.py#L85-L98 |
Ezhil-Language-Foundation/open-tamil | solthiruthi/heuristics.py | BadIME.apply | def apply(self, word, ctx=None):
""" ignore ctx information right now """
chars = get_letters(word)
flag = True #no error assumed
reason = None #no reason
prev_char = None
for char in chars:
rule1,rule2,rule3 = False,False,False
# rule 1 : uyir fo... | python | def apply(self, word, ctx=None):
""" ignore ctx information right now """
chars = get_letters(word)
flag = True #no error assumed
reason = None #no reason
prev_char = None
for char in chars:
rule1,rule2,rule3 = False,False,False
# rule 1 : uyir fo... | [
"def",
"apply",
"(",
"self",
",",
"word",
",",
"ctx",
"=",
"None",
")",
":",
"chars",
"=",
"get_letters",
"(",
"word",
")",
"flag",
"=",
"True",
"#no error assumed",
"reason",
"=",
"None",
"#no reason",
"prev_char",
"=",
"None",
"for",
"char",
"in",
"c... | ignore ctx information right now | [
"ignore",
"ctx",
"information",
"right",
"now"
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/solthiruthi/heuristics.py#L107-L133 |
Ezhil-Language-Foundation/open-tamil | tamilstemmer/basestemmer.py | BaseStemmer.set_current | def set_current(self, value):
'''
Set the self.current string.
'''
self.current = value
self.cursor = 0
self.limit = len(self.current)
self.limit_backward = 0
self.bra = self.cursor
self.ket = self.limit | python | def set_current(self, value):
'''
Set the self.current string.
'''
self.current = value
self.cursor = 0
self.limit = len(self.current)
self.limit_backward = 0
self.bra = self.cursor
self.ket = self.limit | [
"def",
"set_current",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"current",
"=",
"value",
"self",
".",
"cursor",
"=",
"0",
"self",
".",
"limit",
"=",
"len",
"(",
"self",
".",
"current",
")",
"self",
".",
"limit_backward",
"=",
"0",
"self",
"... | Set the self.current string. | [
"Set",
"the",
"self",
".",
"current",
"string",
"."
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/tamilstemmer/basestemmer.py#L12-L21 |
Ezhil-Language-Foundation/open-tamil | tamilstemmer/basestemmer.py | BaseStemmer.replace_s | def replace_s(self, c_bra, c_ket, s):
'''
to replace chars between c_bra and c_ket in self.current by the
chars in s.
@type c_bra int
@type c_ket int
@type s: string
'''
adjustment = len(s) - (c_ket - c_bra)
self.current = self.current[0:c_bra] + ... | python | def replace_s(self, c_bra, c_ket, s):
'''
to replace chars between c_bra and c_ket in self.current by the
chars in s.
@type c_bra int
@type c_ket int
@type s: string
'''
adjustment = len(s) - (c_ket - c_bra)
self.current = self.current[0:c_bra] + ... | [
"def",
"replace_s",
"(",
"self",
",",
"c_bra",
",",
"c_ket",
",",
"s",
")",
":",
"adjustment",
"=",
"len",
"(",
"s",
")",
"-",
"(",
"c_ket",
"-",
"c_bra",
")",
"self",
".",
"current",
"=",
"self",
".",
"current",
"[",
"0",
":",
"c_bra",
"]",
"+... | to replace chars between c_bra and c_ket in self.current by the
chars in s.
@type c_bra int
@type c_ket int
@type s: string | [
"to",
"replace",
"chars",
"between",
"c_bra",
"and",
"c_ket",
"in",
"self",
".",
"current",
"by",
"the",
"chars",
"in",
"s",
"."
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/tamilstemmer/basestemmer.py#L261-L277 |
Ezhil-Language-Foundation/open-tamil | tamilstemmer/basestemmer.py | BaseStemmer.slice_to | def slice_to(self, s):
'''
Copy the slice into the supplied StringBuffer
@type s: string
'''
result = ''
if self.slice_check():
result = self.current[self.bra:self.ket]
return result | python | def slice_to(self, s):
'''
Copy the slice into the supplied StringBuffer
@type s: string
'''
result = ''
if self.slice_check():
result = self.current[self.bra:self.ket]
return result | [
"def",
"slice_to",
"(",
"self",
",",
"s",
")",
":",
"result",
"=",
"''",
"if",
"self",
".",
"slice_check",
"(",
")",
":",
"result",
"=",
"self",
".",
"current",
"[",
"self",
".",
"bra",
":",
"self",
".",
"ket",
"]",
"return",
"result"
] | Copy the slice into the supplied StringBuffer
@type s: string | [
"Copy",
"the",
"slice",
"into",
"the",
"supplied",
"StringBuffer"
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/tamilstemmer/basestemmer.py#L309-L318 |
Ezhil-Language-Foundation/open-tamil | tamil/tweetparser.py | TamilTweetParser.isTamilPredicate | def isTamilPredicate(word):
""" is Tamil word : boolean True/False"""
for c in word:
if unicodedata.name(c).split()[0] != u'TAMIL' :
return False
return True | python | def isTamilPredicate(word):
""" is Tamil word : boolean True/False"""
for c in word:
if unicodedata.name(c).split()[0] != u'TAMIL' :
return False
return True | [
"def",
"isTamilPredicate",
"(",
"word",
")",
":",
"for",
"c",
"in",
"word",
":",
"if",
"unicodedata",
".",
"name",
"(",
"c",
")",
".",
"split",
"(",
")",
"[",
"0",
"]",
"!=",
"u'TAMIL'",
":",
"return",
"False",
"return",
"True"
] | is Tamil word : boolean True/False | [
"is",
"Tamil",
"word",
":",
"boolean",
"True",
"/",
"False"
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/tamil/tweetparser.py#L71-L76 |
Ezhil-Language-Foundation/open-tamil | tamil/tweetparser.py | TamilTweetParser.cleanupPunct | def cleanupPunct( tweet ):
""" NonEnglishOrTamilOr """
tweet = ''.join( map( lambda c: (unicodedata.name(c).split()[0] in [u'TAMIL',u'LATIN']) and c or u' ', tweet) )
return tweet | python | def cleanupPunct( tweet ):
""" NonEnglishOrTamilOr """
tweet = ''.join( map( lambda c: (unicodedata.name(c).split()[0] in [u'TAMIL',u'LATIN']) and c or u' ', tweet) )
return tweet | [
"def",
"cleanupPunct",
"(",
"tweet",
")",
":",
"tweet",
"=",
"''",
".",
"join",
"(",
"map",
"(",
"lambda",
"c",
":",
"(",
"unicodedata",
".",
"name",
"(",
"c",
")",
".",
"split",
"(",
")",
"[",
"0",
"]",
"in",
"[",
"u'TAMIL'",
",",
"u'LATIN'",
... | NonEnglishOrTamilOr | [
"NonEnglishOrTamilOr"
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/tamil/tweetparser.py#L79-L82 |
Ezhil-Language-Foundation/open-tamil | tamil/tweetparser.py | TamilTweetParser.getTamilWords | def getTamilWords( tweet ):
"""" word needs to all be in the same tamil language """
tweet = TamilTweetParser.cleanupPunct( tweet );
nonETwords = filter( lambda x: len(x) > 0 , re.split(r'\s+',tweet) );#|"+|\'+|#+
tamilWords = filter( TamilTweetParser.isTamilPredicate, nonETwords );
... | python | def getTamilWords( tweet ):
"""" word needs to all be in the same tamil language """
tweet = TamilTweetParser.cleanupPunct( tweet );
nonETwords = filter( lambda x: len(x) > 0 , re.split(r'\s+',tweet) );#|"+|\'+|#+
tamilWords = filter( TamilTweetParser.isTamilPredicate, nonETwords );
... | [
"def",
"getTamilWords",
"(",
"tweet",
")",
":",
"tweet",
"=",
"TamilTweetParser",
".",
"cleanupPunct",
"(",
"tweet",
")",
"nonETwords",
"=",
"filter",
"(",
"lambda",
"x",
":",
"len",
"(",
"x",
")",
">",
"0",
",",
"re",
".",
"split",
"(",
"r'\\s+'",
"... | word needs to all be in the same tamil language | [
"word",
"needs",
"to",
"all",
"be",
"in",
"the",
"same",
"tamil",
"language"
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/tamil/tweetparser.py#L85-L90 |
Ezhil-Language-Foundation/open-tamil | tamil/tscii.py | convert_to_unicode | def convert_to_unicode( tscii_input ):
""" convert a byte-ASCII encoded string into equivalent Unicode string
in the UTF-8 notation."""
output = list()
prev = None
prev2x = None
# need a look ahead of 2 tokens atleast
for char in tscii_input:
## print "%2x"%ord(char) # debugging
... | python | def convert_to_unicode( tscii_input ):
""" convert a byte-ASCII encoded string into equivalent Unicode string
in the UTF-8 notation."""
output = list()
prev = None
prev2x = None
# need a look ahead of 2 tokens atleast
for char in tscii_input:
## print "%2x"%ord(char) # debugging
... | [
"def",
"convert_to_unicode",
"(",
"tscii_input",
")",
":",
"output",
"=",
"list",
"(",
")",
"prev",
"=",
"None",
"prev2x",
"=",
"None",
"# need a look ahead of 2 tokens atleast",
"for",
"char",
"in",
"tscii_input",
":",
"## print \"%2x\"%ord(char) # debugging",
"if",
... | convert a byte-ASCII encoded string into equivalent Unicode string
in the UTF-8 notation. | [
"convert",
"a",
"byte",
"-",
"ASCII",
"encoded",
"string",
"into",
"equivalent",
"Unicode",
"string",
"in",
"the",
"UTF",
"-",
"8",
"notation",
"."
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/tamil/tscii.py#L151-L201 |
Ezhil-Language-Foundation/open-tamil | tamil/txt2unicode/encode2unicode.py | _get_unique_ch | def _get_unique_ch(text, all_common_encodes):
"""
text : encode sample strings
returns unique word / characters from input text encode strings.
"""
unique_chars = ''
if isinstance(text, str):
text = text.split("\n")
elif isinstance(text, (list, tuple)):
p... | python | def _get_unique_ch(text, all_common_encodes):
"""
text : encode sample strings
returns unique word / characters from input text encode strings.
"""
unique_chars = ''
if isinstance(text, str):
text = text.split("\n")
elif isinstance(text, (list, tuple)):
p... | [
"def",
"_get_unique_ch",
"(",
"text",
",",
"all_common_encodes",
")",
":",
"unique_chars",
"=",
"''",
"if",
"isinstance",
"(",
"text",
",",
"str",
")",
":",
"text",
"=",
"text",
".",
"split",
"(",
"\"\\n\"",
")",
"elif",
"isinstance",
"(",
"text",
",",
... | text : encode sample strings
returns unique word / characters from input text encode strings. | [
"text",
":",
"encode",
"sample",
"strings",
"returns",
"unique",
"word",
"/",
"characters",
"from",
"input",
"text",
"encode",
"strings",
"."
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/tamil/txt2unicode/encode2unicode.py#L179-L213 |
Ezhil-Language-Foundation/open-tamil | tamil/txt2unicode/encode2unicode.py | _get_unique_common_encodes | def _get_unique_common_encodes():
"""
This function will return both unique_encodes and common_encodes as tuple.
unique_encodes : In dictionary with encodes name as key and its
corresponding encode's unique characters among other available encodes.
common_encodes : In set type which has al... | python | def _get_unique_common_encodes():
"""
This function will return both unique_encodes and common_encodes as tuple.
unique_encodes : In dictionary with encodes name as key and its
corresponding encode's unique characters among other available encodes.
common_encodes : In set type which has al... | [
"def",
"_get_unique_common_encodes",
"(",
")",
":",
"_all_unique_encodes_",
"=",
"[",
"]",
"_all_unicode_encodes_",
"=",
"{",
"}",
"_all_common_encodes_",
"=",
"set",
"(",
"[",
"]",
")",
"_all_common_encodes_single_char_",
"=",
"set",
"(",
"[",
"]",
")",
"for",
... | This function will return both unique_encodes and common_encodes as tuple.
unique_encodes : In dictionary with encodes name as key and its
corresponding encode's unique characters among other available encodes.
common_encodes : In set type which has all common encode compound
characters from... | [
"This",
"function",
"will",
"return",
"both",
"unique_encodes",
"and",
"common_encodes",
"as",
"tuple",
".",
"unique_encodes",
":",
"In",
"dictionary",
"with",
"encodes",
"name",
"as",
"key",
"and",
"its",
"corresponding",
"encode",
"s",
"unique",
"characters",
... | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/tamil/txt2unicode/encode2unicode.py#L216-L288 |
Ezhil-Language-Foundation/open-tamil | tamil/txt2unicode/encode2unicode.py | auto2unicode | def auto2unicode(text):
"""
This function tries to identify encode in available encodings.
If it finds, then it will convert text into unicode string.
Author : Arulalan.T
04.08.2014
"""
_all_unique_encodes_, _all_common_encodes_ = _get_unique_common_encodes()
# get unique... | python | def auto2unicode(text):
"""
This function tries to identify encode in available encodings.
If it finds, then it will convert text into unicode string.
Author : Arulalan.T
04.08.2014
"""
_all_unique_encodes_, _all_common_encodes_ = _get_unique_common_encodes()
# get unique... | [
"def",
"auto2unicode",
"(",
"text",
")",
":",
"_all_unique_encodes_",
",",
"_all_common_encodes_",
"=",
"_get_unique_common_encodes",
"(",
")",
"# get unique word which falls under any one of available encodes from\r",
"# user passed text lines\r",
"unique_chars",
"=",
"_get_unique... | This function tries to identify encode in available encodings.
If it finds, then it will convert text into unicode string.
Author : Arulalan.T
04.08.2014 | [
"This",
"function",
"tries",
"to",
"identify",
"encode",
"in",
"available",
"encodings",
".",
"If",
"it",
"finds",
"then",
"it",
"will",
"convert",
"text",
"into",
"unicode",
"string",
".",
"Author",
":",
"Arulalan",
".",
"T",
"04",
".",
"08",
".",
"2014... | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/tamil/txt2unicode/encode2unicode.py#L292-L330 |
Ezhil-Language-Foundation/open-tamil | ngram/LetterModels.py | Unigram.frequency_model | def frequency_model( self ):
""" build a letter frequency model for Tamil letters from a corpus """
# use a generator in corpus
for next_letter in self.corpus.next_tamil_letter():
# update frequency from corpus
self.letter[next_letter] = self.letter[next_letter] + 1 | python | def frequency_model( self ):
""" build a letter frequency model for Tamil letters from a corpus """
# use a generator in corpus
for next_letter in self.corpus.next_tamil_letter():
# update frequency from corpus
self.letter[next_letter] = self.letter[next_letter] + 1 | [
"def",
"frequency_model",
"(",
"self",
")",
":",
"# use a generator in corpus",
"for",
"next_letter",
"in",
"self",
".",
"corpus",
".",
"next_tamil_letter",
"(",
")",
":",
"# update frequency from corpus",
"self",
".",
"letter",
"[",
"next_letter",
"]",
"=",
"self... | build a letter frequency model for Tamil letters from a corpus | [
"build",
"a",
"letter",
"frequency",
"model",
"for",
"Tamil",
"letters",
"from",
"a",
"corpus"
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/ngram/LetterModels.py#L43-L48 |
Ezhil-Language-Foundation/open-tamil | ngram/LetterModels.py | Bigram.language_model | def language_model(self,verbose=True):
""" builds a Tamil bigram letter model """
# use a generator in corpus
prev = None
for next_letter in self.corpus.next_tamil_letter():
# update frequency from corpus
if prev:
self.letter2[prev][next_letter] +=... | python | def language_model(self,verbose=True):
""" builds a Tamil bigram letter model """
# use a generator in corpus
prev = None
for next_letter in self.corpus.next_tamil_letter():
# update frequency from corpus
if prev:
self.letter2[prev][next_letter] +=... | [
"def",
"language_model",
"(",
"self",
",",
"verbose",
"=",
"True",
")",
":",
"# use a generator in corpus",
"prev",
"=",
"None",
"for",
"next_letter",
"in",
"self",
".",
"corpus",
".",
"next_tamil_letter",
"(",
")",
":",
"# update frequency from corpus",
"if",
"... | builds a Tamil bigram letter model | [
"builds",
"a",
"Tamil",
"bigram",
"letter",
"model"
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/ngram/LetterModels.py#L65-L78 |
Ezhil-Language-Foundation/open-tamil | ngram/LetterModels.py | Trigram.language_model | def language_model(self,verbose=True):
""" builds a Tamil bigram letter model """
# use a generator in corpus
p2 = None
p1 = None
for next_letter in self.corpus.next_tamil_letter():
# update frequency from corpus
if p2:
trig = p2+p1+next_le... | python | def language_model(self,verbose=True):
""" builds a Tamil bigram letter model """
# use a generator in corpus
p2 = None
p1 = None
for next_letter in self.corpus.next_tamil_letter():
# update frequency from corpus
if p2:
trig = p2+p1+next_le... | [
"def",
"language_model",
"(",
"self",
",",
"verbose",
"=",
"True",
")",
":",
"# use a generator in corpus",
"p2",
"=",
"None",
"p1",
"=",
"None",
"for",
"next_letter",
"in",
"self",
".",
"corpus",
".",
"next_tamil_letter",
"(",
")",
":",
"# update frequency fr... | builds a Tamil bigram letter model | [
"builds",
"a",
"Tamil",
"bigram",
"letter",
"model"
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/ngram/LetterModels.py#L97-L109 |
Ezhil-Language-Foundation/open-tamil | tamil/numeral.py | num2tamilstr | def num2tamilstr( *args ):
""" work till one lakh crore - i.e 1e5*1e7 = 1e12.
turn number into a numeral, Indian style. Fractions upto 1e-30"""
number = args[0]
if len(args) < 2:
filenames = []
else:
filenames = args[1]
if len(args) ==3:
tensSpecial = args[2]
else... | python | def num2tamilstr( *args ):
""" work till one lakh crore - i.e 1e5*1e7 = 1e12.
turn number into a numeral, Indian style. Fractions upto 1e-30"""
number = args[0]
if len(args) < 2:
filenames = []
else:
filenames = args[1]
if len(args) ==3:
tensSpecial = args[2]
else... | [
"def",
"num2tamilstr",
"(",
"*",
"args",
")",
":",
"number",
"=",
"args",
"[",
"0",
"]",
"if",
"len",
"(",
"args",
")",
"<",
"2",
":",
"filenames",
"=",
"[",
"]",
"else",
":",
"filenames",
"=",
"args",
"[",
"1",
"]",
"if",
"len",
"(",
"args",
... | work till one lakh crore - i.e 1e5*1e7 = 1e12.
turn number into a numeral, Indian style. Fractions upto 1e-30 | [
"work",
"till",
"one",
"lakh",
"crore",
"-",
"i",
".",
"e",
"1e5",
"*",
"1e7",
"=",
"1e12",
".",
"turn",
"number",
"into",
"a",
"numeral",
"Indian",
"style",
".",
"Fractions",
"upto",
"1e",
"-",
"30"
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/tamil/numeral.py#L14-L214 |
Ezhil-Language-Foundation/open-tamil | tamil/numeral.py | num2tamilstr_american | def num2tamilstr_american( *args ):
number = args[0]
""" work till 1000 trillion - 1 - i.e = 1e12*1e3 - 1.
turn number into a numeral, American style. Fractions upto 1e-30. """
if not any( filter( lambda T: isinstance( number, T), [int, str, unicode, long, float]) ) or isinstance(number,complex):... | python | def num2tamilstr_american( *args ):
number = args[0]
""" work till 1000 trillion - 1 - i.e = 1e12*1e3 - 1.
turn number into a numeral, American style. Fractions upto 1e-30. """
if not any( filter( lambda T: isinstance( number, T), [int, str, unicode, long, float]) ) or isinstance(number,complex):... | [
"def",
"num2tamilstr_american",
"(",
"*",
"args",
")",
":",
"number",
"=",
"args",
"[",
"0",
"]",
"if",
"not",
"any",
"(",
"filter",
"(",
"lambda",
"T",
":",
"isinstance",
"(",
"number",
",",
"T",
")",
",",
"[",
"int",
",",
"str",
",",
"unicode",
... | work till 1000 trillion - 1 - i.e = 1e12*1e3 - 1.
turn number into a numeral, American style. Fractions upto 1e-30. | [
"work",
"till",
"1000",
"trillion",
"-",
"1",
"-",
"i",
".",
"e",
"=",
"1e12",
"*",
"1e3",
"-",
"1",
".",
"turn",
"number",
"into",
"a",
"numeral",
"American",
"style",
".",
"Fractions",
"upto",
"1e",
"-",
"30",
"."
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/tamil/numeral.py#L216-L317 |
Ezhil-Language-Foundation/open-tamil | examples/solpattiyal.py | WordFrequency.get_tamil_words_iterable | def get_tamil_words_iterable( letters ):
""" given a list of UTF-8 letters section them into words, grouping them at spaces """
#punctuations = u'-,+,/,*,>,<,_,],[,{,},(,)'.split(',')+[',']
#isspace_or_tamil = lambda x: not x in punctuations and tamil.utf8.istamil(x)
# correct... | python | def get_tamil_words_iterable( letters ):
""" given a list of UTF-8 letters section them into words, grouping them at spaces """
#punctuations = u'-,+,/,*,>,<,_,],[,{,},(,)'.split(',')+[',']
#isspace_or_tamil = lambda x: not x in punctuations and tamil.utf8.istamil(x)
# correct... | [
"def",
"get_tamil_words_iterable",
"(",
"letters",
")",
":",
"#punctuations = u'-,+,/,*,>,<,_,],[,{,},(,)'.split(',')+[',']",
"#isspace_or_tamil = lambda x: not x in punctuations and tamil.utf8.istamil(x)",
"# correct algorithm for get-tamil-words",
"buf",
"=",
"[",
"]",
"for",
"idx",
... | given a list of UTF-8 letters section them into words, grouping them at spaces | [
"given",
"a",
"list",
"of",
"UTF",
"-",
"8",
"letters",
"section",
"them",
"into",
"words",
"grouping",
"them",
"at",
"spaces"
] | train | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/examples/solpattiyal.py#L30-L45 |
wdecoster/nanocomp | nanocomp/NanoComp.py | main | def main():
'''
Organization function
-setups logging
-gets inputdata
-calls plotting function
'''
args = get_args()
try:
utils.make_output_dir(args.outdir)
utils.init_logs(args, tool="NanoComp")
args.format = nanoplotter.check_valid_format(args.format)
se... | python | def main():
'''
Organization function
-setups logging
-gets inputdata
-calls plotting function
'''
args = get_args()
try:
utils.make_output_dir(args.outdir)
utils.init_logs(args, tool="NanoComp")
args.format = nanoplotter.check_valid_format(args.format)
se... | [
"def",
"main",
"(",
")",
":",
"args",
"=",
"get_args",
"(",
")",
"try",
":",
"utils",
".",
"make_output_dir",
"(",
"args",
".",
"outdir",
")",
"utils",
".",
"init_logs",
"(",
"args",
",",
"tool",
"=",
"\"NanoComp\"",
")",
"args",
".",
"format",
"=",
... | Organization function
-setups logging
-gets inputdata
-calls plotting function | [
"Organization",
"function",
"-",
"setups",
"logging",
"-",
"gets",
"inputdata",
"-",
"calls",
"plotting",
"function"
] | train | https://github.com/wdecoster/nanocomp/blob/0533f258201263858ac0467da37c855880560d2d/nanocomp/NanoComp.py#L16-L64 |
wdecoster/nanocomp | nanocomp/NanoComp.py | validate_split_runs_file | def validate_split_runs_file(split_runs_file):
"""Check if structure of file is as expected and return dictionary linking names to run_IDs."""
try:
content = [l.strip() for l in split_runs_file.readlines()]
if content[0].upper().split('\t') == ['NAME', 'RUN_ID']:
return {c.split('\t'... | python | def validate_split_runs_file(split_runs_file):
"""Check if structure of file is as expected and return dictionary linking names to run_IDs."""
try:
content = [l.strip() for l in split_runs_file.readlines()]
if content[0].upper().split('\t') == ['NAME', 'RUN_ID']:
return {c.split('\t'... | [
"def",
"validate_split_runs_file",
"(",
"split_runs_file",
")",
":",
"try",
":",
"content",
"=",
"[",
"l",
".",
"strip",
"(",
")",
"for",
"l",
"in",
"split_runs_file",
".",
"readlines",
"(",
")",
"]",
"if",
"content",
"[",
"0",
"]",
".",
"upper",
"(",
... | Check if structure of file is as expected and return dictionary linking names to run_IDs. | [
"Check",
"if",
"structure",
"of",
"file",
"is",
"as",
"expected",
"and",
"return",
"dictionary",
"linking",
"names",
"to",
"run_IDs",
"."
] | train | https://github.com/wdecoster/nanocomp/blob/0533f258201263858ac0467da37c855880560d2d/nanocomp/NanoComp.py#L195-L206 |
wdecoster/nanocomp | nanocomp/NanoComp.py | change_identifiers | def change_identifiers(datadf, split_dict):
"""Change the dataset identifiers based on the names in the dictionary."""
for rid, name in split_dict.items():
datadf.loc[datadf["runIDs"] == rid, "dataset"] = name | python | def change_identifiers(datadf, split_dict):
"""Change the dataset identifiers based on the names in the dictionary."""
for rid, name in split_dict.items():
datadf.loc[datadf["runIDs"] == rid, "dataset"] = name | [
"def",
"change_identifiers",
"(",
"datadf",
",",
"split_dict",
")",
":",
"for",
"rid",
",",
"name",
"in",
"split_dict",
".",
"items",
"(",
")",
":",
"datadf",
".",
"loc",
"[",
"datadf",
"[",
"\"runIDs\"",
"]",
"==",
"rid",
",",
"\"dataset\"",
"]",
"=",... | Change the dataset identifiers based on the names in the dictionary. | [
"Change",
"the",
"dataset",
"identifiers",
"based",
"on",
"the",
"names",
"in",
"the",
"dictionary",
"."
] | train | https://github.com/wdecoster/nanocomp/blob/0533f258201263858ac0467da37c855880560d2d/nanocomp/NanoComp.py#L209-L212 |
wdecoster/nanocomp | nanocomp/NanoComp.py | make_report | def make_report(plots, path):
'''
Creates a fat html report based on the previously created files
plots is a list of Plot objects defined by a path and title
statsfile is the file to which the stats have been saved,
which is parsed to a table (rather dodgy)
'''
logging.info("Writing html rep... | python | def make_report(plots, path):
'''
Creates a fat html report based on the previously created files
plots is a list of Plot objects defined by a path and title
statsfile is the file to which the stats have been saved,
which is parsed to a table (rather dodgy)
'''
logging.info("Writing html rep... | [
"def",
"make_report",
"(",
"plots",
",",
"path",
")",
":",
"logging",
".",
"info",
"(",
"\"Writing html report.\"",
")",
"html_head",
"=",
"\"\"\"<!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"UTF-8\">\n <style>\n table, th, td {\n ... | Creates a fat html report based on the previously created files
plots is a list of Plot objects defined by a path and title
statsfile is the file to which the stats have been saved,
which is parsed to a table (rather dodgy) | [
"Creates",
"a",
"fat",
"html",
"report",
"based",
"on",
"the",
"previously",
"created",
"files",
"plots",
"is",
"a",
"list",
"of",
"Plot",
"objects",
"defined",
"by",
"a",
"path",
"and",
"title",
"statsfile",
"is",
"the",
"file",
"to",
"which",
"the",
"s... | train | https://github.com/wdecoster/nanocomp/blob/0533f258201263858ac0467da37c855880560d2d/nanocomp/NanoComp.py#L309-L346 |
six8/pytailer | src/tailer/__init__.py | Tailer.follow | def follow(self, delay=1.0):
"""\
Iterator generator that returns lines as data is added to the file.
Based on: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/157035
"""
trailing = True
while 1:
where = self.file.tell()
line = self.file.... | python | def follow(self, delay=1.0):
"""\
Iterator generator that returns lines as data is added to the file.
Based on: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/157035
"""
trailing = True
while 1:
where = self.file.tell()
line = self.file.... | [
"def",
"follow",
"(",
"self",
",",
"delay",
"=",
"1.0",
")",
":",
"trailing",
"=",
"True",
"while",
"1",
":",
"where",
"=",
"self",
".",
"file",
".",
"tell",
"(",
")",
"line",
"=",
"self",
".",
"file",
".",
"readline",
"(",
")",
"if",
"line",
"... | \
Iterator generator that returns lines as data is added to the file.
Based on: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/157035 | [
"\\",
"Iterator",
"generator",
"that",
"returns",
"lines",
"as",
"data",
"is",
"added",
"to",
"the",
"file",
"."
] | train | https://github.com/six8/pytailer/blob/8f78431b9d2e63077d7f7150264869506c890024/src/tailer/__init__.py#L153-L182 |
yodle/docker-registry-client | docker_registry_client/_BaseClient.py | CommonBaseClient._http_response | def _http_response(self, url, method, data=None, **kwargs):
"""url -> full target url
method -> method from requests
data -> request body
kwargs -> url formatting args
"""
header = {'content-type': 'application/json'}
if data:
data = json.dum... | python | def _http_response(self, url, method, data=None, **kwargs):
"""url -> full target url
method -> method from requests
data -> request body
kwargs -> url formatting args
"""
header = {'content-type': 'application/json'}
if data:
data = json.dum... | [
"def",
"_http_response",
"(",
"self",
",",
"url",
",",
"method",
",",
"data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"header",
"=",
"{",
"'content-type'",
":",
"'application/json'",
"}",
"if",
"data",
":",
"data",
"=",
"json",
".",
"dumps",
... | url -> full target url
method -> method from requests
data -> request body
kwargs -> url formatting args | [
"url",
"-",
">",
"full",
"target",
"url",
"method",
"-",
">",
"method",
"from",
"requests",
"data",
"-",
">",
"request",
"body",
"kwargs",
"-",
">",
"url",
"formatting",
"args"
] | train | https://github.com/yodle/docker-registry-client/blob/8abf6b0200a68bed986f698dcbf02d444257b75c/docker_registry_client/_BaseClient.py#L30-L47 |
yodle/docker-registry-client | docker_registry_client/_BaseClient.py | CommonBaseClient._http_call | def _http_call(self, url, method, data=None, **kwargs):
"""url -> full target url
method -> method from requests
data -> request body
kwargs -> url formatting args
"""
response = self._http_response(url, method, data=data, **kwargs)
if not response.conten... | python | def _http_call(self, url, method, data=None, **kwargs):
"""url -> full target url
method -> method from requests
data -> request body
kwargs -> url formatting args
"""
response = self._http_response(url, method, data=data, **kwargs)
if not response.conten... | [
"def",
"_http_call",
"(",
"self",
",",
"url",
",",
"method",
",",
"data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"self",
".",
"_http_response",
"(",
"url",
",",
"method",
",",
"data",
"=",
"data",
",",
"*",
"*",
"kwargs",
... | url -> full target url
method -> method from requests
data -> request body
kwargs -> url formatting args | [
"url",
"-",
">",
"full",
"target",
"url",
"method",
"-",
">",
"method",
"from",
"requests",
"data",
"-",
">",
"request",
"body",
"kwargs",
"-",
">",
"url",
"formatting",
"args"
] | train | https://github.com/yodle/docker-registry-client/blob/8abf6b0200a68bed986f698dcbf02d444257b75c/docker_registry_client/_BaseClient.py#L49-L59 |
yodle/docker-registry-client | docker_registry_client/_BaseClient.py | BaseClientV1.search | def search(self, q=''):
"""GET /v1/search"""
if q:
q = '?q=' + q
return self._http_call('/v1/search' + q, get) | python | def search(self, q=''):
"""GET /v1/search"""
if q:
q = '?q=' + q
return self._http_call('/v1/search' + q, get) | [
"def",
"search",
"(",
"self",
",",
"q",
"=",
"''",
")",
":",
"if",
"q",
":",
"q",
"=",
"'?q='",
"+",
"q",
"return",
"self",
".",
"_http_call",
"(",
"'/v1/search'",
"+",
"q",
",",
"get",
")"
] | GET /v1/search | [
"GET",
"/",
"v1",
"/",
"search"
] | train | https://github.com/yodle/docker-registry-client/blob/8abf6b0200a68bed986f698dcbf02d444257b75c/docker_registry_client/_BaseClient.py#L73-L77 |
yodle/docker-registry-client | docker_registry_client/_BaseClient.py | BaseClientV1.get_images_layer | def get_images_layer(self, image_id):
"""GET /v1/images/{image_id}/layer"""
return self._http_call(self.IMAGE_LAYER, get, image_id=image_id) | python | def get_images_layer(self, image_id):
"""GET /v1/images/{image_id}/layer"""
return self._http_call(self.IMAGE_LAYER, get, image_id=image_id) | [
"def",
"get_images_layer",
"(",
"self",
",",
"image_id",
")",
":",
"return",
"self",
".",
"_http_call",
"(",
"self",
".",
"IMAGE_LAYER",
",",
"get",
",",
"image_id",
"=",
"image_id",
")"
] | GET /v1/images/{image_id}/layer | [
"GET",
"/",
"v1",
"/",
"images",
"/",
"{",
"image_id",
"}",
"/",
"layer"
] | train | https://github.com/yodle/docker-registry-client/blob/8abf6b0200a68bed986f698dcbf02d444257b75c/docker_registry_client/_BaseClient.py#L83-L85 |
yodle/docker-registry-client | docker_registry_client/_BaseClient.py | BaseClientV1.put_images_layer | def put_images_layer(self, image_id, data):
"""PUT /v1/images/(image_id)/layer"""
return self._http_call(self.IMAGE_LAYER, put,
image_id=image_id, data=data) | python | def put_images_layer(self, image_id, data):
"""PUT /v1/images/(image_id)/layer"""
return self._http_call(self.IMAGE_LAYER, put,
image_id=image_id, data=data) | [
"def",
"put_images_layer",
"(",
"self",
",",
"image_id",
",",
"data",
")",
":",
"return",
"self",
".",
"_http_call",
"(",
"self",
".",
"IMAGE_LAYER",
",",
"put",
",",
"image_id",
"=",
"image_id",
",",
"data",
"=",
"data",
")"
] | PUT /v1/images/(image_id)/layer | [
"PUT",
"/",
"v1",
"/",
"images",
"/",
"(",
"image_id",
")",
"/",
"layer"
] | train | https://github.com/yodle/docker-registry-client/blob/8abf6b0200a68bed986f698dcbf02d444257b75c/docker_registry_client/_BaseClient.py#L87-L90 |
yodle/docker-registry-client | docker_registry_client/_BaseClient.py | BaseClientV1.put_image_layer | def put_image_layer(self, image_id, data):
"""PUT /v1/images/(image_id)/json"""
return self._http_call(self.IMAGE_JSON, put,
data=data, image_id=image_id) | python | def put_image_layer(self, image_id, data):
"""PUT /v1/images/(image_id)/json"""
return self._http_call(self.IMAGE_JSON, put,
data=data, image_id=image_id) | [
"def",
"put_image_layer",
"(",
"self",
",",
"image_id",
",",
"data",
")",
":",
"return",
"self",
".",
"_http_call",
"(",
"self",
".",
"IMAGE_JSON",
",",
"put",
",",
"data",
"=",
"data",
",",
"image_id",
"=",
"image_id",
")"
] | PUT /v1/images/(image_id)/json | [
"PUT",
"/",
"v1",
"/",
"images",
"/",
"(",
"image_id",
")",
"/",
"json"
] | train | https://github.com/yodle/docker-registry-client/blob/8abf6b0200a68bed986f698dcbf02d444257b75c/docker_registry_client/_BaseClient.py#L92-L95 |
yodle/docker-registry-client | docker_registry_client/_BaseClient.py | BaseClientV1.get_image_layer | def get_image_layer(self, image_id):
"""GET /v1/images/(image_id)/json"""
return self._http_call(self.IMAGE_JSON, get, image_id=image_id) | python | def get_image_layer(self, image_id):
"""GET /v1/images/(image_id)/json"""
return self._http_call(self.IMAGE_JSON, get, image_id=image_id) | [
"def",
"get_image_layer",
"(",
"self",
",",
"image_id",
")",
":",
"return",
"self",
".",
"_http_call",
"(",
"self",
".",
"IMAGE_JSON",
",",
"get",
",",
"image_id",
"=",
"image_id",
")"
] | GET /v1/images/(image_id)/json | [
"GET",
"/",
"v1",
"/",
"images",
"/",
"(",
"image_id",
")",
"/",
"json"
] | train | https://github.com/yodle/docker-registry-client/blob/8abf6b0200a68bed986f698dcbf02d444257b75c/docker_registry_client/_BaseClient.py#L97-L99 |
yodle/docker-registry-client | docker_registry_client/_BaseClient.py | BaseClientV1.get_image_ancestry | def get_image_ancestry(self, image_id):
"""GET /v1/images/(image_id)/ancestry"""
return self._http_call(self.IMAGE_ANCESTRY, get, image_id=image_id) | python | def get_image_ancestry(self, image_id):
"""GET /v1/images/(image_id)/ancestry"""
return self._http_call(self.IMAGE_ANCESTRY, get, image_id=image_id) | [
"def",
"get_image_ancestry",
"(",
"self",
",",
"image_id",
")",
":",
"return",
"self",
".",
"_http_call",
"(",
"self",
".",
"IMAGE_ANCESTRY",
",",
"get",
",",
"image_id",
"=",
"image_id",
")"
] | GET /v1/images/(image_id)/ancestry | [
"GET",
"/",
"v1",
"/",
"images",
"/",
"(",
"image_id",
")",
"/",
"ancestry"
] | train | https://github.com/yodle/docker-registry-client/blob/8abf6b0200a68bed986f698dcbf02d444257b75c/docker_registry_client/_BaseClient.py#L101-L103 |
yodle/docker-registry-client | docker_registry_client/_BaseClient.py | BaseClientV1.get_repository_tags | def get_repository_tags(self, namespace, repository):
"""GET /v1/repositories/(namespace)/(repository)/tags"""
return self._http_call(self.TAGS, get,
namespace=namespace, repository=repository) | python | def get_repository_tags(self, namespace, repository):
"""GET /v1/repositories/(namespace)/(repository)/tags"""
return self._http_call(self.TAGS, get,
namespace=namespace, repository=repository) | [
"def",
"get_repository_tags",
"(",
"self",
",",
"namespace",
",",
"repository",
")",
":",
"return",
"self",
".",
"_http_call",
"(",
"self",
".",
"TAGS",
",",
"get",
",",
"namespace",
"=",
"namespace",
",",
"repository",
"=",
"repository",
")"
] | GET /v1/repositories/(namespace)/(repository)/tags | [
"GET",
"/",
"v1",
"/",
"repositories",
"/",
"(",
"namespace",
")",
"/",
"(",
"repository",
")",
"/",
"tags"
] | train | https://github.com/yodle/docker-registry-client/blob/8abf6b0200a68bed986f698dcbf02d444257b75c/docker_registry_client/_BaseClient.py#L105-L108 |
yodle/docker-registry-client | docker_registry_client/_BaseClient.py | BaseClientV1.get_image_id | def get_image_id(self, namespace, respository, tag):
"""GET /v1/repositories/(namespace)/(repository)/tags/(tag*)"""
return self._http_call(self.TAGS + '/' + tag, get,
namespace=namespace, repository=respository) | python | def get_image_id(self, namespace, respository, tag):
"""GET /v1/repositories/(namespace)/(repository)/tags/(tag*)"""
return self._http_call(self.TAGS + '/' + tag, get,
namespace=namespace, repository=respository) | [
"def",
"get_image_id",
"(",
"self",
",",
"namespace",
",",
"respository",
",",
"tag",
")",
":",
"return",
"self",
".",
"_http_call",
"(",
"self",
".",
"TAGS",
"+",
"'/'",
"+",
"tag",
",",
"get",
",",
"namespace",
"=",
"namespace",
",",
"repository",
"=... | GET /v1/repositories/(namespace)/(repository)/tags/(tag*) | [
"GET",
"/",
"v1",
"/",
"repositories",
"/",
"(",
"namespace",
")",
"/",
"(",
"repository",
")",
"/",
"tags",
"/",
"(",
"tag",
"*",
")"
] | train | https://github.com/yodle/docker-registry-client/blob/8abf6b0200a68bed986f698dcbf02d444257b75c/docker_registry_client/_BaseClient.py#L110-L113 |
yodle/docker-registry-client | docker_registry_client/_BaseClient.py | BaseClientV1.get_tag_json | def get_tag_json(self, namespace, repository, tag):
"""GET /v1/repositories(namespace)/(repository)tags(tag*)/json"""
return self._http_call(self.TAGS + '/' + tag + '/json', get,
namespace=namespace, repository=repository) | python | def get_tag_json(self, namespace, repository, tag):
"""GET /v1/repositories(namespace)/(repository)tags(tag*)/json"""
return self._http_call(self.TAGS + '/' + tag + '/json', get,
namespace=namespace, repository=repository) | [
"def",
"get_tag_json",
"(",
"self",
",",
"namespace",
",",
"repository",
",",
"tag",
")",
":",
"return",
"self",
".",
"_http_call",
"(",
"self",
".",
"TAGS",
"+",
"'/'",
"+",
"tag",
"+",
"'/json'",
",",
"get",
",",
"namespace",
"=",
"namespace",
",",
... | GET /v1/repositories(namespace)/(repository)tags(tag*)/json | [
"GET",
"/",
"v1",
"/",
"repositories",
"(",
"namespace",
")",
"/",
"(",
"repository",
")",
"tags",
"(",
"tag",
"*",
")",
"/",
"json"
] | train | https://github.com/yodle/docker-registry-client/blob/8abf6b0200a68bed986f698dcbf02d444257b75c/docker_registry_client/_BaseClient.py#L115-L118 |
yodle/docker-registry-client | docker_registry_client/_BaseClient.py | BaseClientV1.delete_repository_tag | def delete_repository_tag(self, namespace, repository, tag):
"""DELETE /v1/repositories/(namespace)/(repository)/tags/(tag*)"""
return self._http_call(self.TAGS + '/' + tag, delete,
namespace=namespace, repository=repository) | python | def delete_repository_tag(self, namespace, repository, tag):
"""DELETE /v1/repositories/(namespace)/(repository)/tags/(tag*)"""
return self._http_call(self.TAGS + '/' + tag, delete,
namespace=namespace, repository=repository) | [
"def",
"delete_repository_tag",
"(",
"self",
",",
"namespace",
",",
"repository",
",",
"tag",
")",
":",
"return",
"self",
".",
"_http_call",
"(",
"self",
".",
"TAGS",
"+",
"'/'",
"+",
"tag",
",",
"delete",
",",
"namespace",
"=",
"namespace",
",",
"reposi... | DELETE /v1/repositories/(namespace)/(repository)/tags/(tag*) | [
"DELETE",
"/",
"v1",
"/",
"repositories",
"/",
"(",
"namespace",
")",
"/",
"(",
"repository",
")",
"/",
"tags",
"/",
"(",
"tag",
"*",
")"
] | train | https://github.com/yodle/docker-registry-client/blob/8abf6b0200a68bed986f698dcbf02d444257b75c/docker_registry_client/_BaseClient.py#L120-L123 |
yodle/docker-registry-client | docker_registry_client/_BaseClient.py | BaseClientV1.set_tag | def set_tag(self, namespace, repository, tag, image_id):
"""PUT /v1/repositories/(namespace)/(repository)/tags/(tag*)"""
return self._http_call(self.TAGS + '/' + tag, put, data=image_id,
namespace=namespace, repository=repository) | python | def set_tag(self, namespace, repository, tag, image_id):
"""PUT /v1/repositories/(namespace)/(repository)/tags/(tag*)"""
return self._http_call(self.TAGS + '/' + tag, put, data=image_id,
namespace=namespace, repository=repository) | [
"def",
"set_tag",
"(",
"self",
",",
"namespace",
",",
"repository",
",",
"tag",
",",
"image_id",
")",
":",
"return",
"self",
".",
"_http_call",
"(",
"self",
".",
"TAGS",
"+",
"'/'",
"+",
"tag",
",",
"put",
",",
"data",
"=",
"image_id",
",",
"namespac... | PUT /v1/repositories/(namespace)/(repository)/tags/(tag*) | [
"PUT",
"/",
"v1",
"/",
"repositories",
"/",
"(",
"namespace",
")",
"/",
"(",
"repository",
")",
"/",
"tags",
"/",
"(",
"tag",
"*",
")"
] | train | https://github.com/yodle/docker-registry-client/blob/8abf6b0200a68bed986f698dcbf02d444257b75c/docker_registry_client/_BaseClient.py#L125-L128 |
yodle/docker-registry-client | docker_registry_client/_BaseClient.py | BaseClientV1.delete_repository | def delete_repository(self, namespace, repository):
"""DELETE /v1/repositories/(namespace)/(repository)/"""
return self._http_call(self.REPO, delete,
namespace=namespace, repository=repository) | python | def delete_repository(self, namespace, repository):
"""DELETE /v1/repositories/(namespace)/(repository)/"""
return self._http_call(self.REPO, delete,
namespace=namespace, repository=repository) | [
"def",
"delete_repository",
"(",
"self",
",",
"namespace",
",",
"repository",
")",
":",
"return",
"self",
".",
"_http_call",
"(",
"self",
".",
"REPO",
",",
"delete",
",",
"namespace",
"=",
"namespace",
",",
"repository",
"=",
"repository",
")"
] | DELETE /v1/repositories/(namespace)/(repository)/ | [
"DELETE",
"/",
"v1",
"/",
"repositories",
"/",
"(",
"namespace",
")",
"/",
"(",
"repository",
")",
"/"
] | train | https://github.com/yodle/docker-registry-client/blob/8abf6b0200a68bed986f698dcbf02d444257b75c/docker_registry_client/_BaseClient.py#L130-L133 |
yodle/docker-registry-client | docker_registry_client/_BaseClient.py | BaseClientV2._http_response | def _http_response(self, url, method, data=None, content_type=None,
schema=None, **kwargs):
"""url -> full target url
method -> method from requests
data -> request body
kwargs -> url formatting args
"""
if schema is None:
sche... | python | def _http_response(self, url, method, data=None, content_type=None,
schema=None, **kwargs):
"""url -> full target url
method -> method from requests
data -> request body
kwargs -> url formatting args
"""
if schema is None:
sche... | [
"def",
"_http_response",
"(",
"self",
",",
"url",
",",
"method",
",",
"data",
"=",
"None",
",",
"content_type",
"=",
"None",
",",
"schema",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"schema",
"is",
"None",
":",
"schema",
"=",
"self",
".... | url -> full target url
method -> method from requests
data -> request body
kwargs -> url formatting args | [
"url",
"-",
">",
"full",
"target",
"url",
"method",
"-",
">",
"method",
"from",
"requests",
"data",
"-",
">",
"request",
"body",
"kwargs",
"-",
">",
"url",
"formatting",
"args"
] | train | https://github.com/yodle/docker-registry-client/blob/8abf6b0200a68bed986f698dcbf02d444257b75c/docker_registry_client/_BaseClient.py#L229-L269 |
adafruit/Adafruit_Python_MCP9808 | Adafruit_MCP9808/MCP9808.py | MCP9808.begin | def begin(self):
"""Start taking temperature measurements. Returns True if the device is
intialized, False otherwise.
"""
# Check manufacturer and device ID match expected values.
mid = self._device.readU16BE(MCP9808_REG_MANUF_ID)
did = self._device.readU16BE(MCP9808_REG_DEVICE_ID)
self._logger.debug('Re... | python | def begin(self):
"""Start taking temperature measurements. Returns True if the device is
intialized, False otherwise.
"""
# Check manufacturer and device ID match expected values.
mid = self._device.readU16BE(MCP9808_REG_MANUF_ID)
did = self._device.readU16BE(MCP9808_REG_DEVICE_ID)
self._logger.debug('Re... | [
"def",
"begin",
"(",
"self",
")",
":",
"# Check manufacturer and device ID match expected values.",
"mid",
"=",
"self",
".",
"_device",
".",
"readU16BE",
"(",
"MCP9808_REG_MANUF_ID",
")",
"did",
"=",
"self",
".",
"_device",
".",
"readU16BE",
"(",
"MCP9808_REG_DEVICE... | Start taking temperature measurements. Returns True if the device is
intialized, False otherwise. | [
"Start",
"taking",
"temperature",
"measurements",
".",
"Returns",
"True",
"if",
"the",
"device",
"is",
"intialized",
"False",
"otherwise",
"."
] | train | https://github.com/adafruit/Adafruit_Python_MCP9808/blob/5524605a15cfce5668f259de72c88d5be74565f4/Adafruit_MCP9808/MCP9808.py#L67-L76 |
adafruit/Adafruit_Python_MCP9808 | Adafruit_MCP9808/MCP9808.py | MCP9808.readTempC | def readTempC(self):
"""Read sensor and return its value in degrees celsius."""
# Read temperature register value.
t = self._device.readU16BE(MCP9808_REG_AMBIENT_TEMP)
self._logger.debug('Raw ambient temp register value: 0x{0:04X}'.format(t & 0xFFFF))
# Scale and convert to signed value.
temp = (t & 0x0FFF)... | python | def readTempC(self):
"""Read sensor and return its value in degrees celsius."""
# Read temperature register value.
t = self._device.readU16BE(MCP9808_REG_AMBIENT_TEMP)
self._logger.debug('Raw ambient temp register value: 0x{0:04X}'.format(t & 0xFFFF))
# Scale and convert to signed value.
temp = (t & 0x0FFF)... | [
"def",
"readTempC",
"(",
"self",
")",
":",
"# Read temperature register value.",
"t",
"=",
"self",
".",
"_device",
".",
"readU16BE",
"(",
"MCP9808_REG_AMBIENT_TEMP",
")",
"self",
".",
"_logger",
".",
"debug",
"(",
"'Raw ambient temp register value: 0x{0:04X}'",
".",
... | Read sensor and return its value in degrees celsius. | [
"Read",
"sensor",
"and",
"return",
"its",
"value",
"in",
"degrees",
"celsius",
"."
] | train | https://github.com/adafruit/Adafruit_Python_MCP9808/blob/5524605a15cfce5668f259de72c88d5be74565f4/Adafruit_MCP9808/MCP9808.py#L78-L87 |
bmihelac/django-cruds | cruds/utils.py | crud_url_name | def crud_url_name(model, action, prefix=None):
"""
Returns url name for given model and action.
"""
if prefix is None:
prefix = ""
app_label = model._meta.app_label
model_lower = model.__name__.lower()
return '%s%s_%s_%s' % (prefix, app_label, model_lower, action) | python | def crud_url_name(model, action, prefix=None):
"""
Returns url name for given model and action.
"""
if prefix is None:
prefix = ""
app_label = model._meta.app_label
model_lower = model.__name__.lower()
return '%s%s_%s_%s' % (prefix, app_label, model_lower, action) | [
"def",
"crud_url_name",
"(",
"model",
",",
"action",
",",
"prefix",
"=",
"None",
")",
":",
"if",
"prefix",
"is",
"None",
":",
"prefix",
"=",
"\"\"",
"app_label",
"=",
"model",
".",
"_meta",
".",
"app_label",
"model_lower",
"=",
"model",
".",
"__name__",
... | Returns url name for given model and action. | [
"Returns",
"url",
"name",
"for",
"given",
"model",
"and",
"action",
"."
] | train | https://github.com/bmihelac/django-cruds/blob/7828aac3eb2b4c02e5f3843c4cbff654d57cf1e7/cruds/utils.py#L34-L42 |
bmihelac/django-cruds | cruds/utils.py | get_fields | def get_fields(model, include=None):
"""
Returns ordered dict in format 'field': 'verbose_name'
"""
fields = OrderedDict()
info = model._meta
if include:
selected = [info.get_field(name) for name in include]
else:
selected = [field for field in info.fields if field.editable]
... | python | def get_fields(model, include=None):
"""
Returns ordered dict in format 'field': 'verbose_name'
"""
fields = OrderedDict()
info = model._meta
if include:
selected = [info.get_field(name) for name in include]
else:
selected = [field for field in info.fields if field.editable]
... | [
"def",
"get_fields",
"(",
"model",
",",
"include",
"=",
"None",
")",
":",
"fields",
"=",
"OrderedDict",
"(",
")",
"info",
"=",
"model",
".",
"_meta",
"if",
"include",
":",
"selected",
"=",
"[",
"info",
".",
"get_field",
"(",
"name",
")",
"for",
"name... | Returns ordered dict in format 'field': 'verbose_name' | [
"Returns",
"ordered",
"dict",
"in",
"format",
"field",
":",
"verbose_name"
] | train | https://github.com/bmihelac/django-cruds/blob/7828aac3eb2b4c02e5f3843c4cbff654d57cf1e7/cruds/utils.py#L45-L57 |
bmihelac/django-cruds | cruds/utils.py | crud_url | def crud_url(instance_or_model, action, prefix=None, additional_kwargs=None):
"""Shortcut function returns URL for instance or model and action.
Example::
crud_url(author, 'update')
Is same as:
reverse('testapp_author_update', kwargs={'pk': author.pk})
Example::
crud_url(Au... | python | def crud_url(instance_or_model, action, prefix=None, additional_kwargs=None):
"""Shortcut function returns URL for instance or model and action.
Example::
crud_url(author, 'update')
Is same as:
reverse('testapp_author_update', kwargs={'pk': author.pk})
Example::
crud_url(Au... | [
"def",
"crud_url",
"(",
"instance_or_model",
",",
"action",
",",
"prefix",
"=",
"None",
",",
"additional_kwargs",
"=",
"None",
")",
":",
"if",
"additional_kwargs",
"is",
"None",
":",
"additional_kwargs",
"=",
"{",
"}",
"if",
"isinstance",
"(",
"instance_or_mod... | Shortcut function returns URL for instance or model and action.
Example::
crud_url(author, 'update')
Is same as:
reverse('testapp_author_update', kwargs={'pk': author.pk})
Example::
crud_url(Author, 'update')
Is same as:
reverse('testapp_author_list') | [
"Shortcut",
"function",
"returns",
"URL",
"for",
"instance",
"or",
"model",
"and",
"action",
"."
] | train | https://github.com/bmihelac/django-cruds/blob/7828aac3eb2b4c02e5f3843c4cbff654d57cf1e7/cruds/utils.py#L60-L89 |
bmihelac/django-cruds | cruds/utils.py | crud_permission_name | def crud_permission_name(model, action, convert=True):
"""Returns permission name using Django naming convention: app_label.action_object.
If `convert` is True, `create` and `update` actions would be renamed
to `add` and `change`.
"""
app_label = model._meta.app_label
model_lower = model.__name... | python | def crud_permission_name(model, action, convert=True):
"""Returns permission name using Django naming convention: app_label.action_object.
If `convert` is True, `create` and `update` actions would be renamed
to `add` and `change`.
"""
app_label = model._meta.app_label
model_lower = model.__name... | [
"def",
"crud_permission_name",
"(",
"model",
",",
"action",
",",
"convert",
"=",
"True",
")",
":",
"app_label",
"=",
"model",
".",
"_meta",
".",
"app_label",
"model_lower",
"=",
"model",
".",
"__name__",
".",
"lower",
"(",
")",
"if",
"convert",
":",
"act... | Returns permission name using Django naming convention: app_label.action_object.
If `convert` is True, `create` and `update` actions would be renamed
to `add` and `change`. | [
"Returns",
"permission",
"name",
"using",
"Django",
"naming",
"convention",
":",
"app_label",
".",
"action_object",
"."
] | train | https://github.com/bmihelac/django-cruds/blob/7828aac3eb2b4c02e5f3843c4cbff654d57cf1e7/cruds/utils.py#L112-L126 |
bmihelac/django-cruds | cruds/templatetags/crud_tags.py | format_value | def format_value(obj, field_name):
"""
Simple value formatting.
If value is model instance returns link to detail view if exists.
"""
display_func = getattr(obj, 'get_%s_display' % field_name, None)
if display_func:
return display_func()
value = getattr(obj, field_name)
if isin... | python | def format_value(obj, field_name):
"""
Simple value formatting.
If value is model instance returns link to detail view if exists.
"""
display_func = getattr(obj, 'get_%s_display' % field_name, None)
if display_func:
return display_func()
value = getattr(obj, field_name)
if isin... | [
"def",
"format_value",
"(",
"obj",
",",
"field_name",
")",
":",
"display_func",
"=",
"getattr",
"(",
"obj",
",",
"'get_%s_display'",
"%",
"field_name",
",",
"None",
")",
"if",
"display_func",
":",
"return",
"display_func",
"(",
")",
"value",
"=",
"getattr",
... | Simple value formatting.
If value is model instance returns link to detail view if exists. | [
"Simple",
"value",
"formatting",
"."
] | train | https://github.com/bmihelac/django-cruds/blob/7828aac3eb2b4c02e5f3843c4cbff654d57cf1e7/cruds/templatetags/crud_tags.py#L52-L81 |
bmihelac/django-cruds | cruds/templatetags/crud_tags.py | crud_fields | def crud_fields(obj, fields=None):
"""
Display object fields in table rows::
<table>
{% crud_fields object 'id, %}
</table>
* ``fields`` fields to include
If fields is ``None`` all fields will be displayed.
If fields is ``string`` comma separated field names wi... | python | def crud_fields(obj, fields=None):
"""
Display object fields in table rows::
<table>
{% crud_fields object 'id, %}
</table>
* ``fields`` fields to include
If fields is ``None`` all fields will be displayed.
If fields is ``string`` comma separated field names wi... | [
"def",
"crud_fields",
"(",
"obj",
",",
"fields",
"=",
"None",
")",
":",
"if",
"fields",
"is",
"None",
":",
"fields",
"=",
"utils",
".",
"get_fields",
"(",
"type",
"(",
"obj",
")",
")",
"elif",
"isinstance",
"(",
"fields",
",",
"six",
".",
"string_typ... | Display object fields in table rows::
<table>
{% crud_fields object 'id, %}
</table>
* ``fields`` fields to include
If fields is ``None`` all fields will be displayed.
If fields is ``string`` comma separated field names will be
displayed.
if field is di... | [
"Display",
"object",
"fields",
"in",
"table",
"rows",
"::"
] | train | https://github.com/bmihelac/django-cruds/blob/7828aac3eb2b4c02e5f3843c4cbff654d57cf1e7/cruds/templatetags/crud_tags.py#L85-L109 |
bmihelac/django-cruds | cruds/templatetags/crud_tags.py | get_fields | def get_fields(model, fields=None):
"""
Assigns fields for model.
"""
include = [f.strip() for f in fields.split(',')] if fields else None
return utils.get_fields(
model,
include
) | python | def get_fields(model, fields=None):
"""
Assigns fields for model.
"""
include = [f.strip() for f in fields.split(',')] if fields else None
return utils.get_fields(
model,
include
) | [
"def",
"get_fields",
"(",
"model",
",",
"fields",
"=",
"None",
")",
":",
"include",
"=",
"[",
"f",
".",
"strip",
"(",
")",
"for",
"f",
"in",
"fields",
".",
"split",
"(",
"','",
")",
"]",
"if",
"fields",
"else",
"None",
"return",
"utils",
".",
"ge... | Assigns fields for model. | [
"Assigns",
"fields",
"for",
"model",
"."
] | train | https://github.com/bmihelac/django-cruds/blob/7828aac3eb2b4c02e5f3843c4cbff654d57cf1e7/cruds/templatetags/crud_tags.py#L113-L121 |
bmihelac/django-cruds | cruds/urls.py | crud_urls | def crud_urls(model,
list_view=None,
create_view=None,
update_view=None,
detail_view=None,
delete_view=None,
url_prefix=None,
name_prefix=None,
list_views=None,
**kwargs):
"""Returns a list ... | python | def crud_urls(model,
list_view=None,
create_view=None,
update_view=None,
detail_view=None,
delete_view=None,
url_prefix=None,
name_prefix=None,
list_views=None,
**kwargs):
"""Returns a list ... | [
"def",
"crud_urls",
"(",
"model",
",",
"list_view",
"=",
"None",
",",
"create_view",
"=",
"None",
",",
"update_view",
"=",
"None",
",",
"detail_view",
"=",
"None",
",",
"delete_view",
"=",
"None",
",",
"url_prefix",
"=",
"None",
",",
"name_prefix",
"=",
... | Returns a list of url patterns for model.
:param list_view:
:param create_view:
:param update_view:
:param detail_view:
:param delete_view:
:param url_prefix: prefix to prepend, default is `'$'`
:param name_prefix: prefix to prepend to name, default is empty string
:param list_views(dic... | [
"Returns",
"a",
"list",
"of",
"url",
"patterns",
"for",
"model",
"."
] | train | https://github.com/bmihelac/django-cruds/blob/7828aac3eb2b4c02e5f3843c4cbff654d57cf1e7/cruds/urls.py#L17-L88 |
bmihelac/django-cruds | cruds/urls.py | crud_for_model | def crud_for_model(model, urlprefix=None):
"""Returns list of ``url`` items to CRUD a model.
"""
model_lower = model.__name__.lower()
if urlprefix is None:
urlprefix = ''
urlprefix += model_lower + '/'
urls = crud_urls(
model,
list_view=CRUDListView.as_view(model=model)... | python | def crud_for_model(model, urlprefix=None):
"""Returns list of ``url`` items to CRUD a model.
"""
model_lower = model.__name__.lower()
if urlprefix is None:
urlprefix = ''
urlprefix += model_lower + '/'
urls = crud_urls(
model,
list_view=CRUDListView.as_view(model=model)... | [
"def",
"crud_for_model",
"(",
"model",
",",
"urlprefix",
"=",
"None",
")",
":",
"model_lower",
"=",
"model",
".",
"__name__",
".",
"lower",
"(",
")",
"if",
"urlprefix",
"is",
"None",
":",
"urlprefix",
"=",
"''",
"urlprefix",
"+=",
"model_lower",
"+",
"'/... | Returns list of ``url`` items to CRUD a model. | [
"Returns",
"list",
"of",
"url",
"items",
"to",
"CRUD",
"a",
"model",
"."
] | train | https://github.com/bmihelac/django-cruds/blob/7828aac3eb2b4c02e5f3843c4cbff654d57cf1e7/cruds/urls.py#L91-L109 |
bmihelac/django-cruds | cruds/urls.py | crud_for_app | def crud_for_app(app_label, urlprefix=None):
"""
Returns list of ``url`` items to CRUD an app.
"""
if urlprefix is None:
urlprefix = app_label + '/'
app = apps.get_app_config(app_label)
urls = []
for model in app.get_models():
urls += crud_for_model(model, urlprefix)
retu... | python | def crud_for_app(app_label, urlprefix=None):
"""
Returns list of ``url`` items to CRUD an app.
"""
if urlprefix is None:
urlprefix = app_label + '/'
app = apps.get_app_config(app_label)
urls = []
for model in app.get_models():
urls += crud_for_model(model, urlprefix)
retu... | [
"def",
"crud_for_app",
"(",
"app_label",
",",
"urlprefix",
"=",
"None",
")",
":",
"if",
"urlprefix",
"is",
"None",
":",
"urlprefix",
"=",
"app_label",
"+",
"'/'",
"app",
"=",
"apps",
".",
"get_app_config",
"(",
"app_label",
")",
"urls",
"=",
"[",
"]",
... | Returns list of ``url`` items to CRUD an app. | [
"Returns",
"list",
"of",
"url",
"items",
"to",
"CRUD",
"an",
"app",
"."
] | train | https://github.com/bmihelac/django-cruds/blob/7828aac3eb2b4c02e5f3843c4cbff654d57cf1e7/cruds/urls.py#L112-L122 |
bmihelac/django-cruds | cruds/views.py | CRUDMixin.get_context_data | def get_context_data(self, **kwargs):
"""
Adds available urls and names.
"""
context = super(CRUDMixin, self).get_context_data(**kwargs)
context.update({
'model_verbose_name': self.model._meta.verbose_name,
'model_verbose_name_plural': self.model._meta.ver... | python | def get_context_data(self, **kwargs):
"""
Adds available urls and names.
"""
context = super(CRUDMixin, self).get_context_data(**kwargs)
context.update({
'model_verbose_name': self.model._meta.verbose_name,
'model_verbose_name_plural': self.model._meta.ver... | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"context",
"=",
"super",
"(",
"CRUDMixin",
",",
"self",
")",
".",
"get_context_data",
"(",
"*",
"*",
"kwargs",
")",
"context",
".",
"update",
"(",
"{",
"'model_verbose_name'",
":"... | Adds available urls and names. | [
"Adds",
"available",
"urls",
"and",
"names",
"."
] | train | https://github.com/bmihelac/django-cruds/blob/7828aac3eb2b4c02e5f3843c4cbff654d57cf1e7/cruds/views.py#L23-L52 |
bmihelac/django-cruds | cruds/views.py | CRUDMixin.get_template_names | def get_template_names(self):
"""
Adds crud_template_name to default template names.
"""
names = super(CRUDMixin, self).get_template_names()
if self.crud_template_name:
names.append(self.crud_template_name)
return names | python | def get_template_names(self):
"""
Adds crud_template_name to default template names.
"""
names = super(CRUDMixin, self).get_template_names()
if self.crud_template_name:
names.append(self.crud_template_name)
return names | [
"def",
"get_template_names",
"(",
"self",
")",
":",
"names",
"=",
"super",
"(",
"CRUDMixin",
",",
"self",
")",
".",
"get_template_names",
"(",
")",
"if",
"self",
".",
"crud_template_name",
":",
"names",
".",
"append",
"(",
"self",
".",
"crud_template_name",
... | Adds crud_template_name to default template names. | [
"Adds",
"crud_template_name",
"to",
"default",
"template",
"names",
"."
] | train | https://github.com/bmihelac/django-cruds/blob/7828aac3eb2b4c02e5f3843c4cbff654d57cf1e7/cruds/views.py#L54-L61 |
croscon/fleaker | setup.py | install | def install():
"""Install Fleaker.
In a function so we can protect this file so it's only run when we
explicitly invoke it and not, say, when py.test collects all Python
modules.
"""
_version_re = re.compile(r"__version__\s+=\s+(.*)") # pylint: disable=invalid-name
with open('./fleaker/__... | python | def install():
"""Install Fleaker.
In a function so we can protect this file so it's only run when we
explicitly invoke it and not, say, when py.test collects all Python
modules.
"""
_version_re = re.compile(r"__version__\s+=\s+(.*)") # pylint: disable=invalid-name
with open('./fleaker/__... | [
"def",
"install",
"(",
")",
":",
"_version_re",
"=",
"re",
".",
"compile",
"(",
"r\"__version__\\s+=\\s+(.*)\"",
")",
"# pylint: disable=invalid-name",
"with",
"open",
"(",
"'./fleaker/__init__.py'",
",",
"'rb'",
")",
"as",
"file_",
":",
"version",
"=",
"ast",
"... | Install Fleaker.
In a function so we can protect this file so it's only run when we
explicitly invoke it and not, say, when py.test collects all Python
modules. | [
"Install",
"Fleaker",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/setup.py#L50-L120 |
croscon/fleaker | fleaker/peewee/fields/json.py | JSONField.python_value | def python_value(self, value):
"""Return the JSON in the database as a ``dict``.
Returns:
dict: The field run through json.loads
"""
value = super(JSONField, self).python_value(value)
if value is not None:
return flask.json.loads(value, **self._load_kwar... | python | def python_value(self, value):
"""Return the JSON in the database as a ``dict``.
Returns:
dict: The field run through json.loads
"""
value = super(JSONField, self).python_value(value)
if value is not None:
return flask.json.loads(value, **self._load_kwar... | [
"def",
"python_value",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"super",
"(",
"JSONField",
",",
"self",
")",
".",
"python_value",
"(",
"value",
")",
"if",
"value",
"is",
"not",
"None",
":",
"return",
"flask",
".",
"json",
".",
"loads",
"(",... | Return the JSON in the database as a ``dict``.
Returns:
dict: The field run through json.loads | [
"Return",
"the",
"JSON",
"in",
"the",
"database",
"as",
"a",
"dict",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/peewee/fields/json.py#L101-L110 |
croscon/fleaker | fleaker/peewee/fields/json.py | JSONField.db_value | def db_value(self, value):
"""Store the value in the database.
If the value is a dict like object, it is converted to a string before
storing.
"""
# Everything is encoded being before being surfaced
value = flask.json.dumps(value)
return super(JSONField, self).d... | python | def db_value(self, value):
"""Store the value in the database.
If the value is a dict like object, it is converted to a string before
storing.
"""
# Everything is encoded being before being surfaced
value = flask.json.dumps(value)
return super(JSONField, self).d... | [
"def",
"db_value",
"(",
"self",
",",
"value",
")",
":",
"# Everything is encoded being before being surfaced",
"value",
"=",
"flask",
".",
"json",
".",
"dumps",
"(",
"value",
")",
"return",
"super",
"(",
"JSONField",
",",
"self",
")",
".",
"db_value",
"(",
"... | Store the value in the database.
If the value is a dict like object, it is converted to a string before
storing. | [
"Store",
"the",
"value",
"in",
"the",
"database",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/peewee/fields/json.py#L112-L121 |
croscon/fleaker | fleaker/peewee/mixins/search.py | SearchMixin.search | def search(cls, term, fields=()):
"""Generic SQL search function that uses SQL ``LIKE`` to search the
database for matching records. The records are sorted by their
relavancey to the search term.
The query searches and sorts on the folling criteria, in order, where
the target st... | python | def search(cls, term, fields=()):
"""Generic SQL search function that uses SQL ``LIKE`` to search the
database for matching records. The records are sorted by their
relavancey to the search term.
The query searches and sorts on the folling criteria, in order, where
the target st... | [
"def",
"search",
"(",
"cls",
",",
"term",
",",
"fields",
"=",
"(",
")",
")",
":",
"if",
"not",
"any",
"(",
"(",
"cls",
".",
"_meta",
".",
"search_fields",
",",
"fields",
")",
")",
":",
"raise",
"AttributeError",
"(",
"\"A list of searchable fields must b... | Generic SQL search function that uses SQL ``LIKE`` to search the
database for matching records. The records are sorted by their
relavancey to the search term.
The query searches and sorts on the folling criteria, in order, where
the target string is ``exactly``:
1. Straight equ... | [
"Generic",
"SQL",
"search",
"function",
"that",
"uses",
"SQL",
"LIKE",
"to",
"search",
"the",
"database",
"for",
"matching",
"records",
".",
"The",
"records",
"are",
"sorted",
"by",
"their",
"relavancey",
"to",
"the",
"search",
"term",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/peewee/mixins/search.py#L97-L180 |
croscon/fleaker | fleaker/marshmallow/fields/foreign_key.py | ForeignKeyField._add_to_schema | def _add_to_schema(self, field_name, schema):
"""Set the ``attribute`` attr to the field in question so this always
gets deserialzed into the field name without ``_id``.
Args:
field_name (str): The name of the field (the attribute name being
set in the schema).
... | python | def _add_to_schema(self, field_name, schema):
"""Set the ``attribute`` attr to the field in question so this always
gets deserialzed into the field name without ``_id``.
Args:
field_name (str): The name of the field (the attribute name being
set in the schema).
... | [
"def",
"_add_to_schema",
"(",
"self",
",",
"field_name",
",",
"schema",
")",
":",
"super",
"(",
"ForeignKeyField",
",",
"self",
")",
".",
"_add_to_schema",
"(",
"field_name",
",",
"schema",
")",
"if",
"self",
".",
"get_field_value",
"(",
"'convert_fks'",
","... | Set the ``attribute`` attr to the field in question so this always
gets deserialzed into the field name without ``_id``.
Args:
field_name (str): The name of the field (the attribute name being
set in the schema).
schema (marshmallow.Schema): The actual parent sch... | [
"Set",
"the",
"attribute",
"attr",
"to",
"the",
"field",
"in",
"question",
"so",
"this",
"always",
"gets",
"deserialzed",
"into",
"the",
"field",
"name",
"without",
"_id",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/marshmallow/fields/foreign_key.py#L36-L49 |
croscon/fleaker | fleaker/marshmallow/fields/foreign_key.py | ForeignKeyField._serialize | def _serialize(self, value, attr, obj):
"""Grab the ID value off the Peewee model so we serialize an ID back.
"""
# this might be an optional field
if value:
value = value.id
return super(ForeignKeyField, self)._serialize(value, attr, obj) | python | def _serialize(self, value, attr, obj):
"""Grab the ID value off the Peewee model so we serialize an ID back.
"""
# this might be an optional field
if value:
value = value.id
return super(ForeignKeyField, self)._serialize(value, attr, obj) | [
"def",
"_serialize",
"(",
"self",
",",
"value",
",",
"attr",
",",
"obj",
")",
":",
"# this might be an optional field",
"if",
"value",
":",
"value",
"=",
"value",
".",
"id",
"return",
"super",
"(",
"ForeignKeyField",
",",
"self",
")",
".",
"_serialize",
"(... | Grab the ID value off the Peewee model so we serialize an ID back. | [
"Grab",
"the",
"ID",
"value",
"off",
"the",
"Peewee",
"model",
"so",
"we",
"serialize",
"an",
"ID",
"back",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/marshmallow/fields/foreign_key.py#L51-L58 |
croscon/fleaker | fleaker/orm.py | _discover_ideal_backend | def _discover_ideal_backend(orm_backend):
"""Auto-discover the ideal backend based on what is installed.
Right now, handles discovery of:
* PeeWee
* SQLAlchemy
Args:
orm_backend (str): The ``orm_backend`` value that was passed to the
``create_app`` function. That is, the OR... | python | def _discover_ideal_backend(orm_backend):
"""Auto-discover the ideal backend based on what is installed.
Right now, handles discovery of:
* PeeWee
* SQLAlchemy
Args:
orm_backend (str): The ``orm_backend`` value that was passed to the
``create_app`` function. That is, the OR... | [
"def",
"_discover_ideal_backend",
"(",
"orm_backend",
")",
":",
"if",
"orm_backend",
":",
"return",
"orm_backend",
"if",
"peewee",
"is",
"not",
"MISSING",
"and",
"sqlalchemy",
"is",
"not",
"MISSING",
":",
"raise",
"RuntimeError",
"(",
"'Both PeeWee and SQLAlchemy de... | Auto-discover the ideal backend based on what is installed.
Right now, handles discovery of:
* PeeWee
* SQLAlchemy
Args:
orm_backend (str): The ``orm_backend`` value that was passed to the
``create_app`` function. That is, the ORM Backend the User
indicated they wan... | [
"Auto",
"-",
"discover",
"the",
"ideal",
"backend",
"based",
"on",
"what",
"is",
"installed",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/orm.py#L83-L116 |
croscon/fleaker | fleaker/orm.py | ORMAwareApp.post_create_app | def post_create_app(cls, app, **settings):
"""Init the extension for our chosen ORM Backend, if possible.
This method will ensure that the ``db`` proxy is set to the right
extension and that that extension is properly created and configured.
Since it needs to call ``init_app`` it MUST b... | python | def post_create_app(cls, app, **settings):
"""Init the extension for our chosen ORM Backend, if possible.
This method will ensure that the ``db`` proxy is set to the right
extension and that that extension is properly created and configured.
Since it needs to call ``init_app`` it MUST b... | [
"def",
"post_create_app",
"(",
"cls",
",",
"app",
",",
"*",
"*",
"settings",
")",
":",
"global",
"_SELECTED_BACKEND",
"backend",
"=",
"settings",
".",
"pop",
"(",
"'orm_backend'",
",",
"None",
")",
"backend",
"=",
"_discover_ideal_backend",
"(",
"backend",
"... | Init the extension for our chosen ORM Backend, if possible.
This method will ensure that the ``db`` proxy is set to the right
extension and that that extension is properly created and configured.
Since it needs to call ``init_app`` it MUST be a Post Create Hook.
If the chosen backend i... | [
"Init",
"the",
"extension",
"for",
"our",
"chosen",
"ORM",
"Backend",
"if",
"possible",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/orm.py#L193-L300 |
croscon/fleaker | fleaker/orm.py | ORMAwareApp._init_peewee_ext | def _init_peewee_ext(cls, app, dummy_configuration=None,
dummy_configure_args=None):
"""Init the actual PeeWee extension with the app that was created.
Since PeeWee requires the ``DATABASE`` config parameter to be present
IMMEDIATELY upon initializing the application, w... | python | def _init_peewee_ext(cls, app, dummy_configuration=None,
dummy_configure_args=None):
"""Init the actual PeeWee extension with the app that was created.
Since PeeWee requires the ``DATABASE`` config parameter to be present
IMMEDIATELY upon initializing the application, w... | [
"def",
"_init_peewee_ext",
"(",
"cls",
",",
"app",
",",
"dummy_configuration",
"=",
"None",
",",
"dummy_configure_args",
"=",
"None",
")",
":",
"# the database still isn't present, go ahead and register the callback",
"# again, so we can try later.",
"if",
"'DATABASE'",
"not"... | Init the actual PeeWee extension with the app that was created.
Since PeeWee requires the ``DATABASE`` config parameter to be present
IMMEDIATELY upon initializing the application, we need to delay this
construction. This is because, in standard use, we will create the app
and attempt t... | [
"Init",
"the",
"actual",
"PeeWee",
"extension",
"with",
"the",
"app",
"that",
"was",
"created",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/orm.py#L303-L338 |
croscon/fleaker | fleaker/config.py | MultiStageConfigurableApp.configure | def configure(self, *args, **kwargs):
"""Configure the Application through a varied number of sources of
different types.
This function chains multiple possible configuration methods together
in order to just "make it work". You can pass multiple configuration
sources in to the ... | python | def configure(self, *args, **kwargs):
"""Configure the Application through a varied number of sources of
different types.
This function chains multiple possible configuration methods together
in order to just "make it work". You can pass multiple configuration
sources in to the ... | [
"def",
"configure",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"whitelist_keys_from_mappings",
"=",
"kwargs",
".",
"get",
"(",
"'whitelist_keys_from_mappings'",
",",
"False",
")",
"whitelist",
"=",
"kwargs",
".",
"get",
"(",
"'whitelis... | Configure the Application through a varied number of sources of
different types.
This function chains multiple possible configuration methods together
in order to just "make it work". You can pass multiple configuration
sources in to the method and each one will be tried in a sane fashi... | [
"Configure",
"the",
"Application",
"through",
"a",
"varied",
"number",
"of",
"sources",
"of",
"different",
"types",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/config.py#L56-L156 |
croscon/fleaker | fleaker/config.py | MultiStageConfigurableApp._configure_from_module | def _configure_from_module(self, item):
"""Configure from a module by import path.
Effectively, you give this an absolute or relative import path, it will
import it, and then pass the resulting object to
``_configure_from_object``.
Args:
item (str):
... | python | def _configure_from_module(self, item):
"""Configure from a module by import path.
Effectively, you give this an absolute or relative import path, it will
import it, and then pass the resulting object to
``_configure_from_object``.
Args:
item (str):
... | [
"def",
"_configure_from_module",
"(",
"self",
",",
"item",
")",
":",
"package",
"=",
"None",
"if",
"item",
"[",
"0",
"]",
"==",
"'.'",
":",
"package",
"=",
"self",
".",
"import_name",
"obj",
"=",
"importlib",
".",
"import_module",
"(",
"item",
",",
"pa... | Configure from a module by import path.
Effectively, you give this an absolute or relative import path, it will
import it, and then pass the resulting object to
``_configure_from_object``.
Args:
item (str):
A string pointing to a valid import path.
... | [
"Configure",
"from",
"a",
"module",
"by",
"import",
"path",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/config.py#L195-L218 |
croscon/fleaker | fleaker/config.py | MultiStageConfigurableApp._configure_from_mapping | def _configure_from_mapping(self, item, whitelist_keys=False,
whitelist=None):
"""Configure from a mapping, or dict, like object.
Args:
item (dict):
A dict-like object that we can pluck values from.
Keyword Args:
whitelist... | python | def _configure_from_mapping(self, item, whitelist_keys=False,
whitelist=None):
"""Configure from a mapping, or dict, like object.
Args:
item (dict):
A dict-like object that we can pluck values from.
Keyword Args:
whitelist... | [
"def",
"_configure_from_mapping",
"(",
"self",
",",
"item",
",",
"whitelist_keys",
"=",
"False",
",",
"whitelist",
"=",
"None",
")",
":",
"if",
"whitelist",
"is",
"None",
":",
"whitelist",
"=",
"self",
".",
"config",
".",
"keys",
"(",
")",
"if",
"whiteli... | Configure from a mapping, or dict, like object.
Args:
item (dict):
A dict-like object that we can pluck values from.
Keyword Args:
whitelist_keys (bool):
Should we whitelist the keys before adding them to the
configuration? If no ... | [
"Configure",
"from",
"a",
"mapping",
"or",
"dict",
"like",
"object",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/config.py#L220-L250 |
croscon/fleaker | fleaker/config.py | MultiStageConfigurableApp.configure_from_environment | def configure_from_environment(self, whitelist_keys=False, whitelist=None):
"""Configure from the entire set of available environment variables.
This is really a shorthand for grabbing ``os.environ`` and passing to
:meth:`_configure_from_mapping`.
As always, only uppercase keys are loa... | python | def configure_from_environment(self, whitelist_keys=False, whitelist=None):
"""Configure from the entire set of available environment variables.
This is really a shorthand for grabbing ``os.environ`` and passing to
:meth:`_configure_from_mapping`.
As always, only uppercase keys are loa... | [
"def",
"configure_from_environment",
"(",
"self",
",",
"whitelist_keys",
"=",
"False",
",",
"whitelist",
"=",
"None",
")",
":",
"self",
".",
"_configure_from_mapping",
"(",
"os",
".",
"environ",
",",
"whitelist_keys",
"=",
"whitelist_keys",
",",
"whitelist",
"="... | Configure from the entire set of available environment variables.
This is really a shorthand for grabbing ``os.environ`` and passing to
:meth:`_configure_from_mapping`.
As always, only uppercase keys are loaded.
Keyword Args:
whitelist_keys (bool):
Should w... | [
"Configure",
"from",
"the",
"entire",
"set",
"of",
"available",
"environment",
"variables",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/config.py#L267-L293 |
croscon/fleaker | fleaker/config.py | MultiStageConfigurableApp.add_post_configure_callback | def add_post_configure_callback(self, callback, run_once=False):
"""Add a new callback to be run after every call to :meth:`configure`.
Functions run at the end of :meth:`configure` are given the
application's resulting configuration and the arguments passed to
:meth:`configure`, in tha... | python | def add_post_configure_callback(self, callback, run_once=False):
"""Add a new callback to be run after every call to :meth:`configure`.
Functions run at the end of :meth:`configure` are given the
application's resulting configuration and the arguments passed to
:meth:`configure`, in tha... | [
"def",
"add_post_configure_callback",
"(",
"self",
",",
"callback",
",",
"run_once",
"=",
"False",
")",
":",
"if",
"run_once",
":",
"self",
".",
"_post_configure_callbacks",
"[",
"'single'",
"]",
".",
"append",
"(",
"callback",
")",
"else",
":",
"self",
".",... | Add a new callback to be run after every call to :meth:`configure`.
Functions run at the end of :meth:`configure` are given the
application's resulting configuration and the arguments passed to
:meth:`configure`, in that order. As a note, this first argument will
be an immutable diction... | [
"Add",
"a",
"new",
"callback",
"to",
"be",
"run",
"after",
"every",
"call",
"to",
":",
"meth",
":",
"configure",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/config.py#L295-L344 |
croscon/fleaker | fleaker/config.py | MultiStageConfigurableApp._run_post_configure_callbacks | def _run_post_configure_callbacks(self, configure_args):
"""Run all post configure callbacks we have stored.
Functions are passed the configuration that resulted from the call to
:meth:`configure` as the first argument, in an immutable form; and are
given the arguments passed to :meth:`... | python | def _run_post_configure_callbacks(self, configure_args):
"""Run all post configure callbacks we have stored.
Functions are passed the configuration that resulted from the call to
:meth:`configure` as the first argument, in an immutable form; and are
given the arguments passed to :meth:`... | [
"def",
"_run_post_configure_callbacks",
"(",
"self",
",",
"configure_args",
")",
":",
"resulting_configuration",
"=",
"ImmutableDict",
"(",
"self",
".",
"config",
")",
"# copy callbacks in case people edit them while running",
"multiple_callbacks",
"=",
"copy",
".",
"copy",... | Run all post configure callbacks we have stored.
Functions are passed the configuration that resulted from the call to
:meth:`configure` as the first argument, in an immutable form; and are
given the arguments passed to :meth:`configure` for the second
argument.
Returns from ca... | [
"Run",
"all",
"post",
"configure",
"callbacks",
"we",
"have",
"stored",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/config.py#L346-L379 |
croscon/fleaker | fleaker/marshmallow/schema.py | Schema.make_instance | def make_instance(cls, data):
"""Validate the data and create a model instance from the data.
Args:
data (dict): The unserialized data to insert into the new model
instance through it's constructor.
Returns:
peewee.Model|sqlalchemy.Model: The model insta... | python | def make_instance(cls, data):
"""Validate the data and create a model instance from the data.
Args:
data (dict): The unserialized data to insert into the new model
instance through it's constructor.
Returns:
peewee.Model|sqlalchemy.Model: The model insta... | [
"def",
"make_instance",
"(",
"cls",
",",
"data",
")",
":",
"schema",
"=",
"cls",
"(",
")",
"if",
"not",
"hasattr",
"(",
"schema",
".",
"Meta",
",",
"'model'",
")",
":",
"raise",
"AttributeError",
"(",
"\"In order to make an instance, a model for \"",
"\"the sc... | Validate the data and create a model instance from the data.
Args:
data (dict): The unserialized data to insert into the new model
instance through it's constructor.
Returns:
peewee.Model|sqlalchemy.Model: The model instance with it's data
insert... | [
"Validate",
"the",
"data",
"and",
"create",
"a",
"model",
"instance",
"from",
"the",
"data",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/marshmallow/schema.py#L41-L65 |
croscon/fleaker | fleaker/marshmallow/schema.py | Schema.invalid_fields | def invalid_fields(self, data, original_data):
"""Validator that checks if any keys provided aren't in the schema.
Say your schema has support for keys ``a`` and ``b`` and the data
provided has keys ``a``, ``b``, and ``c``. When the data is loaded into
the schema, a :class:`marshmallow.... | python | def invalid_fields(self, data, original_data):
"""Validator that checks if any keys provided aren't in the schema.
Say your schema has support for keys ``a`` and ``b`` and the data
provided has keys ``a``, ``b``, and ``c``. When the data is loaded into
the schema, a :class:`marshmallow.... | [
"def",
"invalid_fields",
"(",
"self",
",",
"data",
",",
"original_data",
")",
":",
"errors",
"=",
"[",
"]",
"for",
"field",
"in",
"original_data",
":",
"# Skip nested fields because they will loop infinitely",
"if",
"isinstance",
"(",
"field",
",",
"(",
"set",
"... | Validator that checks if any keys provided aren't in the schema.
Say your schema has support for keys ``a`` and ``b`` and the data
provided has keys ``a``, ``b``, and ``c``. When the data is loaded into
the schema, a :class:`marshmallow.ValidationError` will be raised
informing the deve... | [
"Validator",
"that",
"checks",
"if",
"any",
"keys",
"provided",
"aren",
"t",
"in",
"the",
"schema",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/marshmallow/schema.py#L68-L91 |
croscon/fleaker | fleaker/peewee/fields/arrow.py | ArrowDateTimeField.python_value | def python_value(self, value):
"""Return the value in the data base as an arrow object.
Returns:
arrow.Arrow: An instance of arrow with the field filled in.
"""
value = super(ArrowDateTimeField, self).python_value(value)
if (isinstance(value, (datetime.datetime, dat... | python | def python_value(self, value):
"""Return the value in the data base as an arrow object.
Returns:
arrow.Arrow: An instance of arrow with the field filled in.
"""
value = super(ArrowDateTimeField, self).python_value(value)
if (isinstance(value, (datetime.datetime, dat... | [
"def",
"python_value",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"super",
"(",
"ArrowDateTimeField",
",",
"self",
")",
".",
"python_value",
"(",
"value",
")",
"if",
"(",
"isinstance",
"(",
"value",
",",
"(",
"datetime",
".",
"datetime",
",",
"... | Return the value in the data base as an arrow object.
Returns:
arrow.Arrow: An instance of arrow with the field filled in. | [
"Return",
"the",
"value",
"in",
"the",
"data",
"base",
"as",
"an",
"arrow",
"object",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/peewee/fields/arrow.py#L68-L80 |
croscon/fleaker | fleaker/peewee/fields/arrow.py | ArrowDateTimeField.db_value | def db_value(self, value):
"""Convert the Arrow instance to a datetime for saving in the db."""
if isinstance(value, string_types):
value = arrow.get(value)
if isinstance(value, arrow.Arrow):
value = value.datetime
return super(ArrowDateTimeField, self).db_value... | python | def db_value(self, value):
"""Convert the Arrow instance to a datetime for saving in the db."""
if isinstance(value, string_types):
value = arrow.get(value)
if isinstance(value, arrow.Arrow):
value = value.datetime
return super(ArrowDateTimeField, self).db_value... | [
"def",
"db_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"string_types",
")",
":",
"value",
"=",
"arrow",
".",
"get",
"(",
"value",
")",
"if",
"isinstance",
"(",
"value",
",",
"arrow",
".",
"Arrow",
")",
":",
"... | Convert the Arrow instance to a datetime for saving in the db. | [
"Convert",
"the",
"Arrow",
"instance",
"to",
"a",
"datetime",
"for",
"saving",
"in",
"the",
"db",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/peewee/fields/arrow.py#L82-L90 |
croscon/fleaker | fleaker/component.py | Component.init_app | def init_app(self, app, context=DEFAULT_DICT):
"""Lazy constructor for the :class:`Component` class.
This method will allow the component to be used like a Flask
extension/singleton.
Args:
app (flask.Flask): The Application to base this Component upon.
Usefu... | python | def init_app(self, app, context=DEFAULT_DICT):
"""Lazy constructor for the :class:`Component` class.
This method will allow the component to be used like a Flask
extension/singleton.
Args:
app (flask.Flask): The Application to base this Component upon.
Usefu... | [
"def",
"init_app",
"(",
"self",
",",
"app",
",",
"context",
"=",
"DEFAULT_DICT",
")",
":",
"if",
"context",
"is",
"not",
"_CONTEXT_MISSING",
":",
"self",
".",
"update_context",
"(",
"context",
",",
"app",
"=",
"app",
")",
"# do not readd callbacks if already p... | Lazy constructor for the :class:`Component` class.
This method will allow the component to be used like a Flask
extension/singleton.
Args:
app (flask.Flask): The Application to base this Component upon.
Useful for app wide singletons.
Keyword Args:
... | [
"Lazy",
"constructor",
"for",
"the",
":",
"class",
":",
"Component",
"class",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/component.py#L102-L124 |
croscon/fleaker | fleaker/component.py | Component._context_callbacks | def _context_callbacks(app, key, original_context=_CONTEXT_MISSING):
"""Register the callbacks we need to properly pop and push the
app-local context for a component.
Args:
app (flask.Flask): The app who this context belongs to. This is the
only sender our Blinker si... | python | def _context_callbacks(app, key, original_context=_CONTEXT_MISSING):
"""Register the callbacks we need to properly pop and push the
app-local context for a component.
Args:
app (flask.Flask): The app who this context belongs to. This is the
only sender our Blinker si... | [
"def",
"_context_callbacks",
"(",
"app",
",",
"key",
",",
"original_context",
"=",
"_CONTEXT_MISSING",
")",
":",
"def",
"_get_context",
"(",
"dummy_app",
")",
":",
"\"\"\"Set the context proxy so that it points to a specific context.\n \"\"\"",
"_CONTEXT_LOCALS",
"... | Register the callbacks we need to properly pop and push the
app-local context for a component.
Args:
app (flask.Flask): The app who this context belongs to. This is the
only sender our Blinker signal will listen to.
key (str): The key on ``_CONTEXT_LOCALS`` that ... | [
"Register",
"the",
"callbacks",
"we",
"need",
"to",
"properly",
"pop",
"and",
"push",
"the",
"app",
"-",
"local",
"context",
"for",
"a",
"component",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/component.py#L127-L175 |
croscon/fleaker | fleaker/component.py | Component.update_context | def update_context(self, context, app=None):
"""Replace the component's context with a new one.
Args:
context (dict): The new context to set this component's context to.
Keyword Args:
app (flask.Flask, optional): The app to update this context for. If
no... | python | def update_context(self, context, app=None):
"""Replace the component's context with a new one.
Args:
context (dict): The new context to set this component's context to.
Keyword Args:
app (flask.Flask, optional): The app to update this context for. If
no... | [
"def",
"update_context",
"(",
"self",
",",
"context",
",",
"app",
"=",
"None",
")",
":",
"if",
"(",
"app",
"is",
"None",
"and",
"self",
".",
"_context",
"is",
"_CONTEXT_MISSING",
"and",
"not",
"in_app_context",
"(",
")",
")",
":",
"raise",
"RuntimeError"... | Replace the component's context with a new one.
Args:
context (dict): The new context to set this component's context to.
Keyword Args:
app (flask.Flask, optional): The app to update this context for. If
not provided, the result of ``Component.app`` will be used... | [
"Replace",
"the",
"component",
"s",
"context",
"with",
"a",
"new",
"one",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/component.py#L199-L220 |
croscon/fleaker | fleaker/component.py | Component.clear_context | def clear_context(self, app=None):
"""Clear the component's context.
Keyword Args:
app (flask.Flask, optional): The app to clear this component's
context for. If omitted, the value from ``Component.app`` is
used.
"""
if (app is None and self._... | python | def clear_context(self, app=None):
"""Clear the component's context.
Keyword Args:
app (flask.Flask, optional): The app to clear this component's
context for. If omitted, the value from ``Component.app`` is
used.
"""
if (app is None and self._... | [
"def",
"clear_context",
"(",
"self",
",",
"app",
"=",
"None",
")",
":",
"if",
"(",
"app",
"is",
"None",
"and",
"self",
".",
"_context",
"is",
"_CONTEXT_MISSING",
"and",
"not",
"in_app_context",
"(",
")",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Attempt... | Clear the component's context.
Keyword Args:
app (flask.Flask, optional): The app to clear this component's
context for. If omitted, the value from ``Component.app`` is
used. | [
"Clear",
"the",
"component",
"s",
"context",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/component.py#L222-L241 |
croscon/fleaker | fleaker/component.py | Component.app | def app(self):
"""Internal method that will supply the app to use internally.
Returns:
flask.Flask: The app to use within the component.
Raises:
RuntimeError: This is raised if no app was provided to the
component and the method is being called outside o... | python | def app(self):
"""Internal method that will supply the app to use internally.
Returns:
flask.Flask: The app to use within the component.
Raises:
RuntimeError: This is raised if no app was provided to the
component and the method is being called outside o... | [
"def",
"app",
"(",
"self",
")",
":",
"app",
"=",
"self",
".",
"_app",
"or",
"current_app",
"if",
"not",
"in_app_context",
"(",
"app",
")",
":",
"raise",
"RuntimeError",
"(",
"\"This component hasn't been initialized yet \"",
"\"and an app context doesn't exist.\"",
... | Internal method that will supply the app to use internally.
Returns:
flask.Flask: The app to use within the component.
Raises:
RuntimeError: This is raised if no app was provided to the
component and the method is being called outside of an
appli... | [
"Internal",
"method",
"that",
"will",
"supply",
"the",
"app",
"to",
"use",
"internally",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/component.py#L244-L266 |
croscon/fleaker | fleaker/component.py | Component._get_context_name | def _get_context_name(self, app=None):
"""Generate the name of the context variable for this component & app.
Because we store the ``context`` in a Local so the component
can be used across multiple apps, we cannot store the context on the
instance itself. This function will generate a ... | python | def _get_context_name(self, app=None):
"""Generate the name of the context variable for this component & app.
Because we store the ``context`` in a Local so the component
can be used across multiple apps, we cannot store the context on the
instance itself. This function will generate a ... | [
"def",
"_get_context_name",
"(",
"self",
",",
"app",
"=",
"None",
")",
":",
"elements",
"=",
"[",
"self",
".",
"__class__",
".",
"__name__",
",",
"'context'",
",",
"text_type",
"(",
"id",
"(",
"self",
")",
")",
",",
"]",
"if",
"app",
":",
"elements",... | Generate the name of the context variable for this component & app.
Because we store the ``context`` in a Local so the component
can be used across multiple apps, we cannot store the context on the
instance itself. This function will generate a unique and predictable
key in which to sto... | [
"Generate",
"the",
"name",
"of",
"the",
"context",
"variable",
"for",
"this",
"component",
"&",
"app",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/component.py#L277-L303 |
croscon/fleaker | fleaker/base.py | BaseApplication.create_app | def create_app(cls, import_name, **settings):
"""Create a standard Fleaker web application.
This is the main entrypoint for creating your Fleaker application.
Instead of defining your own app factory function, it's preferred that
you use :meth:`create_app`, which is responsible for auto... | python | def create_app(cls, import_name, **settings):
"""Create a standard Fleaker web application.
This is the main entrypoint for creating your Fleaker application.
Instead of defining your own app factory function, it's preferred that
you use :meth:`create_app`, which is responsible for auto... | [
"def",
"create_app",
"(",
"cls",
",",
"import_name",
",",
"*",
"*",
"settings",
")",
":",
"settings",
"=",
"cls",
".",
"pre_create_app",
"(",
"*",
"*",
"settings",
")",
"# now whitelist the settings",
"flask_kwargs",
"=",
"cls",
".",
"_whitelist_standard_flask_k... | Create a standard Fleaker web application.
This is the main entrypoint for creating your Fleaker application.
Instead of defining your own app factory function, it's preferred that
you use :meth:`create_app`, which is responsible for automatically
configuring extensions (such as your OR... | [
"Create",
"a",
"standard",
"Fleaker",
"web",
"application",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/base.py#L72-L104 |
croscon/fleaker | fleaker/base.py | BaseApplication._whitelist_standard_flask_kwargs | def _whitelist_standard_flask_kwargs(cls, kwargs):
"""Whitelist a dictionary of kwargs to remove any that are not valid
for Flask's ``__init__`` constructor.
Since many Fleaker app mixins define their own kwargs for use in
construction and Flask itself does not accept ``**kwargs``, we n... | python | def _whitelist_standard_flask_kwargs(cls, kwargs):
"""Whitelist a dictionary of kwargs to remove any that are not valid
for Flask's ``__init__`` constructor.
Since many Fleaker app mixins define their own kwargs for use in
construction and Flask itself does not accept ``**kwargs``, we n... | [
"def",
"_whitelist_standard_flask_kwargs",
"(",
"cls",
",",
"kwargs",
")",
":",
"# prevent any copy shenanigans from happening",
"kwargs",
"=",
"deepcopy",
"(",
"kwargs",
")",
"if",
"not",
"cls",
".",
"_flask_init_argspec_cache",
":",
"cls",
".",
"_flask_init_argspec_ca... | Whitelist a dictionary of kwargs to remove any that are not valid
for Flask's ``__init__`` constructor.
Since many Fleaker app mixins define their own kwargs for use in
construction and Flask itself does not accept ``**kwargs``, we need to
whitelist anything unknown.
Uses the p... | [
"Whitelist",
"a",
"dictionary",
"of",
"kwargs",
"to",
"remove",
"any",
"that",
"are",
"not",
"valid",
"for",
"Flask",
"s",
"__init__",
"constructor",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/base.py#L107-L131 |
croscon/fleaker | fleaker/logging.py | FleakerLogFormatter.format | def format(self, record):
"""Format the log record."""
levelname = getattr(record, 'levelname', None)
record.levelcolor = ''
record.endlevelcolor = ''
if levelname:
level_color = getattr(self.TermColors, levelname, '')
record.levelcolor = level_color
... | python | def format(self, record):
"""Format the log record."""
levelname = getattr(record, 'levelname', None)
record.levelcolor = ''
record.endlevelcolor = ''
if levelname:
level_color = getattr(self.TermColors, levelname, '')
record.levelcolor = level_color
... | [
"def",
"format",
"(",
"self",
",",
"record",
")",
":",
"levelname",
"=",
"getattr",
"(",
"record",
",",
"'levelname'",
",",
"None",
")",
"record",
".",
"levelcolor",
"=",
"''",
"record",
".",
"endlevelcolor",
"=",
"''",
"if",
"levelname",
":",
"level_col... | Format the log record. | [
"Format",
"the",
"log",
"record",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/logging.py#L59-L70 |
croscon/fleaker | fleaker/exceptions.py | FleakerBaseException.errorhandler_callback | def errorhandler_callback(cls, exc):
"""This function should be called in the global error handlers. This
will allow for consolidating of cleanup tasks if the exception
bubbles all the way to the top of the stack.
For example, this method will automatically rollback the database
... | python | def errorhandler_callback(cls, exc):
"""This function should be called in the global error handlers. This
will allow for consolidating of cleanup tasks if the exception
bubbles all the way to the top of the stack.
For example, this method will automatically rollback the database
... | [
"def",
"errorhandler_callback",
"(",
"cls",
",",
"exc",
")",
":",
"# @TODO (orm, exc): Implement this when the ORM/DB stuff is done",
"# if not exc.prevent_rollback:",
"# db.session.rollback()",
"if",
"exc",
".",
"flash_message",
":",
"flash",
"(",
"exc",
".",
"flash_mess... | This function should be called in the global error handlers. This
will allow for consolidating of cleanup tasks if the exception
bubbles all the way to the top of the stack.
For example, this method will automatically rollback the database
session if the exception bubbles to the top.
... | [
"This",
"function",
"should",
"be",
"called",
"in",
"the",
"global",
"error",
"handlers",
".",
"This",
"will",
"allow",
"for",
"consolidating",
"of",
"cleanup",
"tasks",
"if",
"the",
"exception",
"bubbles",
"all",
"the",
"way",
"to",
"the",
"top",
"of",
"t... | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/exceptions.py#L116-L144 |
croscon/fleaker | fleaker/exceptions.py | ErrorAwareApp.post_create_app | def post_create_app(cls, app, **settings):
"""Register the errorhandler for the AppException to the passed in
App.
Args:
app (fleaker.base.BaseApplication): A Flask application that
extends the Fleaker Base Application, such that the hooks are
impleme... | python | def post_create_app(cls, app, **settings):
"""Register the errorhandler for the AppException to the passed in
App.
Args:
app (fleaker.base.BaseApplication): A Flask application that
extends the Fleaker Base Application, such that the hooks are
impleme... | [
"def",
"post_create_app",
"(",
"cls",
",",
"app",
",",
"*",
"*",
"settings",
")",
":",
"register_errorhandler",
"=",
"settings",
".",
"pop",
"(",
"'register_errorhandler'",
",",
"True",
")",
"if",
"register_errorhandler",
":",
"AppException",
".",
"register_erro... | Register the errorhandler for the AppException to the passed in
App.
Args:
app (fleaker.base.BaseApplication): A Flask application that
extends the Fleaker Base Application, such that the hooks are
implemented.
Kwargs:
register_errorhandl... | [
"Register",
"the",
"errorhandler",
"for",
"the",
"AppException",
"to",
"the",
"passed",
"in",
"App",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/exceptions.py#L349-L373 |
croscon/fleaker | examples/fleaker_config/fleaker_config/fleaker_config.py | create_app | def create_app():
"""Create the standard app for ``fleaker_config`` and register the two
routes required.
"""
app = App.create_app(__name__)
app.configure('.configs.settings')
# yes, I should use blueprints; but I don't really care for such a small
# toy app
@app.route('/config')
de... | python | def create_app():
"""Create the standard app for ``fleaker_config`` and register the two
routes required.
"""
app = App.create_app(__name__)
app.configure('.configs.settings')
# yes, I should use blueprints; but I don't really care for such a small
# toy app
@app.route('/config')
de... | [
"def",
"create_app",
"(",
")",
":",
"app",
"=",
"App",
".",
"create_app",
"(",
"__name__",
")",
"app",
".",
"configure",
"(",
"'.configs.settings'",
")",
"# yes, I should use blueprints; but I don't really care for such a small",
"# toy app",
"@",
"app",
".",
"route",... | Create the standard app for ``fleaker_config`` and register the two
routes required. | [
"Create",
"the",
"standard",
"app",
"for",
"fleaker_config",
"and",
"register",
"the",
"two",
"routes",
"required",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/examples/fleaker_config/fleaker_config/fleaker_config.py#L15-L43 |
croscon/fleaker | fleaker/peewee/mixins/field_signature.py | FieldSignatureMixin.update_signature | def update_signature(self):
"""Update the signature field by hashing the ``signature_fields``.
Raises:
AttributeError: This is raised if ``Meta.signature_fields`` has no
values in it or if a field in there is not a field on the
model.
"""
if n... | python | def update_signature(self):
"""Update the signature field by hashing the ``signature_fields``.
Raises:
AttributeError: This is raised if ``Meta.signature_fields`` has no
values in it or if a field in there is not a field on the
model.
"""
if n... | [
"def",
"update_signature",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_meta",
".",
"signature_fields",
":",
"raise",
"AttributeError",
"(",
"\"No fields defined in {}.Meta.signature_fields. Please define \"",
"\"at least one.\"",
".",
"format",
"(",
"type",
"(",
... | Update the signature field by hashing the ``signature_fields``.
Raises:
AttributeError: This is raised if ``Meta.signature_fields`` has no
values in it or if a field in there is not a field on the
model. | [
"Update",
"the",
"signature",
"field",
"by",
"hashing",
"the",
"signature_fields",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/peewee/mixins/field_signature.py#L102-L130 |
mozilla-releng/mozapkpublisher | mozapkpublisher/common/googleplay.py | connect | def connect(service_account, credentials_file_path, api_version='v2'):
""" Connect to the google play interface
"""
# Create an httplib2.Http object to handle our HTTP requests an
# authorize it with the Credentials. Note that the first parameter,
# service_account_name, is the Email address create... | python | def connect(service_account, credentials_file_path, api_version='v2'):
""" Connect to the google play interface
"""
# Create an httplib2.Http object to handle our HTTP requests an
# authorize it with the Credentials. Note that the first parameter,
# service_account_name, is the Email address create... | [
"def",
"connect",
"(",
"service_account",
",",
"credentials_file_path",
",",
"api_version",
"=",
"'v2'",
")",
":",
"# Create an httplib2.Http object to handle our HTTP requests an",
"# authorize it with the Credentials. Note that the first parameter,",
"# service_account_name, is the Ema... | Connect to the google play interface | [
"Connect",
"to",
"the",
"google",
"play",
"interface"
] | train | https://github.com/mozilla-releng/mozapkpublisher/blob/df61034220153cbb98da74c8ef6de637f9185e12/mozapkpublisher/common/googleplay.py#L159-L175 |
croscon/fleaker | fleaker/marshmallow/fields/pendulum.py | PendulumField._deserialize | def _deserialize(self, value, attr, obj):
"""Deserializes a string into a Pendulum object."""
if not self.context.get('convert_dates', True) or not value:
return value
value = super(PendulumField, self)._deserialize(value, attr, value)
timezone = self.get_field_value('timezo... | python | def _deserialize(self, value, attr, obj):
"""Deserializes a string into a Pendulum object."""
if not self.context.get('convert_dates', True) or not value:
return value
value = super(PendulumField, self)._deserialize(value, attr, value)
timezone = self.get_field_value('timezo... | [
"def",
"_deserialize",
"(",
"self",
",",
"value",
",",
"attr",
",",
"obj",
")",
":",
"if",
"not",
"self",
".",
"context",
".",
"get",
"(",
"'convert_dates'",
",",
"True",
")",
"or",
"not",
"value",
":",
"return",
"value",
"value",
"=",
"super",
"(",
... | Deserializes a string into a Pendulum object. | [
"Deserializes",
"a",
"string",
"into",
"a",
"Pendulum",
"object",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/marshmallow/fields/pendulum.py#L42-L58 |
croscon/fleaker | fleaker/marshmallow/fields/phone_number.py | PhoneNumberField._format_phone_number | def _format_phone_number(self, value, attr):
"""Format and validate a phone number."""
strict_validation = self.get_field_value(
'strict_phone_validation',
default=False
)
strict_region = self.get_field_value(
'strict_phone_region',
default... | python | def _format_phone_number(self, value, attr):
"""Format and validate a phone number."""
strict_validation = self.get_field_value(
'strict_phone_validation',
default=False
)
strict_region = self.get_field_value(
'strict_phone_region',
default... | [
"def",
"_format_phone_number",
"(",
"self",
",",
"value",
",",
"attr",
")",
":",
"strict_validation",
"=",
"self",
".",
"get_field_value",
"(",
"'strict_phone_validation'",
",",
"default",
"=",
"False",
")",
"strict_region",
"=",
"self",
".",
"get_field_value",
... | Format and validate a phone number. | [
"Format",
"and",
"validate",
"a",
"phone",
"number",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/marshmallow/fields/phone_number.py#L50-L87 |
croscon/fleaker | fleaker/marshmallow/fields/phone_number.py | PhoneNumberField._deserialize | def _deserialize(self, value, attr, data):
"""Format and validate the phone number using libphonenumber."""
if value:
value = self._format_phone_number(value, attr)
return super(PhoneNumberField, self)._deserialize(value, attr, data) | python | def _deserialize(self, value, attr, data):
"""Format and validate the phone number using libphonenumber."""
if value:
value = self._format_phone_number(value, attr)
return super(PhoneNumberField, self)._deserialize(value, attr, data) | [
"def",
"_deserialize",
"(",
"self",
",",
"value",
",",
"attr",
",",
"data",
")",
":",
"if",
"value",
":",
"value",
"=",
"self",
".",
"_format_phone_number",
"(",
"value",
",",
"attr",
")",
"return",
"super",
"(",
"PhoneNumberField",
",",
"self",
")",
"... | Format and validate the phone number using libphonenumber. | [
"Format",
"and",
"validate",
"the",
"phone",
"number",
"using",
"libphonenumber",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/marshmallow/fields/phone_number.py#L89-L94 |
croscon/fleaker | fleaker/marshmallow/fields/phone_number.py | PhoneNumberField._serialize | def _serialize(self, value, attr, obj):
"""Format and validate the phone number user libphonenumber."""
value = super(PhoneNumberField, self)._serialize(value, attr, obj)
if value:
value = self._format_phone_number(value, attr)
return value | python | def _serialize(self, value, attr, obj):
"""Format and validate the phone number user libphonenumber."""
value = super(PhoneNumberField, self)._serialize(value, attr, obj)
if value:
value = self._format_phone_number(value, attr)
return value | [
"def",
"_serialize",
"(",
"self",
",",
"value",
",",
"attr",
",",
"obj",
")",
":",
"value",
"=",
"super",
"(",
"PhoneNumberField",
",",
"self",
")",
".",
"_serialize",
"(",
"value",
",",
"attr",
",",
"obj",
")",
"if",
"value",
":",
"value",
"=",
"s... | Format and validate the phone number user libphonenumber. | [
"Format",
"and",
"validate",
"the",
"phone",
"number",
"user",
"libphonenumber",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/marshmallow/fields/phone_number.py#L96-L103 |
croscon/fleaker | fleaker/json.py | FleakerJSONEncoder.default | def default(self, obj):
"""Encode individual objects into their JSON representation.
This method is used by :class:`flask.json.JSONEncoder` to encode
individual items in the JSON object.
Args:
obj (object): Any Python object we wish to convert to JSON.
Returns:
... | python | def default(self, obj):
"""Encode individual objects into their JSON representation.
This method is used by :class:`flask.json.JSONEncoder` to encode
individual items in the JSON object.
Args:
obj (object): Any Python object we wish to convert to JSON.
Returns:
... | [
"def",
"default",
"(",
"self",
",",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"decimal",
".",
"Decimal",
")",
":",
"obj",
"=",
"format",
"(",
"obj",
",",
"'f'",
")",
"str_digit",
"=",
"text_type",
"(",
"obj",
")",
"return",
"(",
"str_di... | Encode individual objects into their JSON representation.
This method is used by :class:`flask.json.JSONEncoder` to encode
individual items in the JSON object.
Args:
obj (object): Any Python object we wish to convert to JSON.
Returns:
str: The stringified, vali... | [
"Encode",
"individual",
"objects",
"into",
"their",
"JSON",
"representation",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/json.py#L63-L104 |
croscon/fleaker | fleaker/marshmallow/fields/arrow.py | ArrowField._serialize | def _serialize(self, value, attr, obj):
"""Convert the Arrow object into a string."""
if isinstance(value, arrow.arrow.Arrow):
value = value.datetime
return super(ArrowField, self)._serialize(value, attr, obj) | python | def _serialize(self, value, attr, obj):
"""Convert the Arrow object into a string."""
if isinstance(value, arrow.arrow.Arrow):
value = value.datetime
return super(ArrowField, self)._serialize(value, attr, obj) | [
"def",
"_serialize",
"(",
"self",
",",
"value",
",",
"attr",
",",
"obj",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"arrow",
".",
"arrow",
".",
"Arrow",
")",
":",
"value",
"=",
"value",
".",
"datetime",
"return",
"super",
"(",
"ArrowField",
","... | Convert the Arrow object into a string. | [
"Convert",
"the",
"Arrow",
"object",
"into",
"a",
"string",
"."
] | train | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/marshmallow/fields/arrow.py#L42-L47 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.