repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
aeguana/PyFileMaker | PyFileMaker/xml2obj.py | Xml2Obj.CharacterData | def CharacterData(self,data):
'SAX character data event handler'
## HACK: to preserve the newlines
#if string.strip(data):
data = data.encode("utf-8")
element = self.nodeStack[-1]
element.cdata += data
return | python | def CharacterData(self,data):
'SAX character data event handler'
## HACK: to preserve the newlines
#if string.strip(data):
data = data.encode("utf-8")
element = self.nodeStack[-1]
element.cdata += data
return | [
"def",
"CharacterData",
"(",
"self",
",",
"data",
")",
":",
"## HACK: to preserve the newlines",
"#if string.strip(data):",
"data",
"=",
"data",
".",
"encode",
"(",
"\"utf-8\"",
")",
"element",
"=",
"self",
".",
"nodeStack",
"[",
"-",
"1",
"]",
"element",
".",... | SAX character data event handler | [
"SAX",
"character",
"data",
"event",
"handler"
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/xml2obj.py#L71-L78 | train | 59,500 |
aeguana/PyFileMaker | PyFileMaker/FMResultset.py | FMResultset.doShow | def doShow(self, xml=0):
"""Shows the contents of our resultset."""
if xml == 0:
print 'Errorcode:', self.errorcode
print
print 'Product information:'
for key in self.product.keys():
print ' ', key.encode('UTF-8'),
print '->', self.product[key].encode('UTF-8')
print
print 'Datab... | python | def doShow(self, xml=0):
"""Shows the contents of our resultset."""
if xml == 0:
print 'Errorcode:', self.errorcode
print
print 'Product information:'
for key in self.product.keys():
print ' ', key.encode('UTF-8'),
print '->', self.product[key].encode('UTF-8')
print
print 'Datab... | [
"def",
"doShow",
"(",
"self",
",",
"xml",
"=",
"0",
")",
":",
"if",
"xml",
"==",
"0",
":",
"print",
"'Errorcode:'",
",",
"self",
".",
"errorcode",
"print",
"print",
"'Product information:'",
"for",
"key",
"in",
"self",
".",
"product",
".",
"keys",
"(",... | Shows the contents of our resultset. | [
"Shows",
"the",
"contents",
"of",
"our",
"resultset",
"."
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMResultset.py#L128-L186 | train | 59,501 |
aeguana/PyFileMaker | PyFileMaker/FMServer.py | FMServer._setSkipRecords | def _setSkipRecords(self, skipRec):
"""Specifies how many records to skip in the found set"""
if type(skipRec) == int or (type(skipRec) == str and skipRec.isdigit()):
self._skipRecords = skipRec
else:
raise FMError, 'Unsupported -skip value (not a number).' | python | def _setSkipRecords(self, skipRec):
"""Specifies how many records to skip in the found set"""
if type(skipRec) == int or (type(skipRec) == str and skipRec.isdigit()):
self._skipRecords = skipRec
else:
raise FMError, 'Unsupported -skip value (not a number).' | [
"def",
"_setSkipRecords",
"(",
"self",
",",
"skipRec",
")",
":",
"if",
"type",
"(",
"skipRec",
")",
"==",
"int",
"or",
"(",
"type",
"(",
"skipRec",
")",
"==",
"str",
"and",
"skipRec",
".",
"isdigit",
"(",
")",
")",
":",
"self",
".",
"_skipRecords",
... | Specifies how many records to skip in the found set | [
"Specifies",
"how",
"many",
"records",
"to",
"skip",
"in",
"the",
"found",
"set"
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMServer.py#L111-L117 | train | 59,502 |
aeguana/PyFileMaker | PyFileMaker/FMServer.py | FMServer._setLogicalOperator | def _setLogicalOperator(self, lop):
"""Sets the way the find fields should be combined together."""
if not lop.lower() in ['and', 'or']:
raise FMError, 'Unsupported logical operator (not one of "and" or "or").'
self._lop = lop.lower() | python | def _setLogicalOperator(self, lop):
"""Sets the way the find fields should be combined together."""
if not lop.lower() in ['and', 'or']:
raise FMError, 'Unsupported logical operator (not one of "and" or "or").'
self._lop = lop.lower() | [
"def",
"_setLogicalOperator",
"(",
"self",
",",
"lop",
")",
":",
"if",
"not",
"lop",
".",
"lower",
"(",
")",
"in",
"[",
"'and'",
",",
"'or'",
"]",
":",
"raise",
"FMError",
",",
"'Unsupported logical operator (not one of \"and\" or \"or\").'",
"self",
".",
"_lo... | Sets the way the find fields should be combined together. | [
"Sets",
"the",
"way",
"the",
"find",
"fields",
"should",
"be",
"combined",
"together",
"."
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMServer.py#L119-L125 | train | 59,503 |
aeguana/PyFileMaker | PyFileMaker/FMServer.py | FMServer._setComparasionOperator | def _setComparasionOperator(self, field, oper):
"""Sets correct operator for given string representation"""
if oper != '':
validOperators = {
'eq':'eq',
'equals':'eq',
'=':'eq',
'==':'eq',
'cn':'cn',
'contains':'cn',
'%%':'cn',
'%':'cn',
'*':'cn',
'bw':'bw',
'begins w... | python | def _setComparasionOperator(self, field, oper):
"""Sets correct operator for given string representation"""
if oper != '':
validOperators = {
'eq':'eq',
'equals':'eq',
'=':'eq',
'==':'eq',
'cn':'cn',
'contains':'cn',
'%%':'cn',
'%':'cn',
'*':'cn',
'bw':'bw',
'begins w... | [
"def",
"_setComparasionOperator",
"(",
"self",
",",
"field",
",",
"oper",
")",
":",
"if",
"oper",
"!=",
"''",
":",
"validOperators",
"=",
"{",
"'eq'",
":",
"'eq'",
",",
"'equals'",
":",
"'eq'",
",",
"'='",
":",
"'eq'",
",",
"'=='",
":",
"'eq'",
",",
... | Sets correct operator for given string representation | [
"Sets",
"correct",
"operator",
"for",
"given",
"string",
"representation"
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMServer.py#L127-L171 | train | 59,504 |
aeguana/PyFileMaker | PyFileMaker/FMServer.py | FMServer._addDBParam | def _addDBParam(self, name, value):
"""Adds a database parameter"""
if name[-4:] == '__OP':
return self._setComparasionOperator(name[:-4], value)
if name[-3:] == '.op':
return self._setComparasionOperator(name[:-3], value)
if name.find('__') != -1:
import re
name = name.replace('__','::')
elif na... | python | def _addDBParam(self, name, value):
"""Adds a database parameter"""
if name[-4:] == '__OP':
return self._setComparasionOperator(name[:-4], value)
if name[-3:] == '.op':
return self._setComparasionOperator(name[:-3], value)
if name.find('__') != -1:
import re
name = name.replace('__','::')
elif na... | [
"def",
"_addDBParam",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"if",
"name",
"[",
"-",
"4",
":",
"]",
"==",
"'__OP'",
":",
"return",
"self",
".",
"_setComparasionOperator",
"(",
"name",
"[",
":",
"-",
"4",
"]",
",",
"value",
")",
"if",
"... | Adds a database parameter | [
"Adds",
"a",
"database",
"parameter"
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMServer.py#L173-L188 | train | 59,505 |
aeguana/PyFileMaker | PyFileMaker/FMServer.py | FMServer.getFile | def getFile(self, file_xml_uri):
""" This will execute cmd to fetch file data from FMServer """
find = re.match('/fmi/xml/cnt/([\w\d.-]+)\.([\w]+)?-*', file_xml_uri)
file_name = find.group(1)
file_extension = find.group(2)
file_binary = self._doRequest(is_file=True, file_xml_uri=file_xml_uri)
return (file_... | python | def getFile(self, file_xml_uri):
""" This will execute cmd to fetch file data from FMServer """
find = re.match('/fmi/xml/cnt/([\w\d.-]+)\.([\w]+)?-*', file_xml_uri)
file_name = find.group(1)
file_extension = find.group(2)
file_binary = self._doRequest(is_file=True, file_xml_uri=file_xml_uri)
return (file_... | [
"def",
"getFile",
"(",
"self",
",",
"file_xml_uri",
")",
":",
"find",
"=",
"re",
".",
"match",
"(",
"'/fmi/xml/cnt/([\\w\\d.-]+)\\.([\\w]+)?-*'",
",",
"file_xml_uri",
")",
"file_name",
"=",
"find",
".",
"group",
"(",
"1",
")",
"file_extension",
"=",
"find",
... | This will execute cmd to fetch file data from FMServer | [
"This",
"will",
"execute",
"cmd",
"to",
"fetch",
"file",
"data",
"from",
"FMServer"
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMServer.py#L222-L229 | train | 59,506 |
aeguana/PyFileMaker | PyFileMaker/FMServer.py | FMServer.doScript | def doScript(self, script_name, params=None, return_all=False):
"""This function executes the script for given layout for the current db."""
request = [
uu({'-db': self._db }),
uu({'-lay': self._layout }),
uu({'-script': script_name})
]
if params:
request.append(uu({'-script.param': params }))
r... | python | def doScript(self, script_name, params=None, return_all=False):
"""This function executes the script for given layout for the current db."""
request = [
uu({'-db': self._db }),
uu({'-lay': self._layout }),
uu({'-script': script_name})
]
if params:
request.append(uu({'-script.param': params }))
r... | [
"def",
"doScript",
"(",
"self",
",",
"script_name",
",",
"params",
"=",
"None",
",",
"return_all",
"=",
"False",
")",
":",
"request",
"=",
"[",
"uu",
"(",
"{",
"'-db'",
":",
"self",
".",
"_db",
"}",
")",
",",
"uu",
"(",
"{",
"'-lay'",
":",
"self"... | This function executes the script for given layout for the current db. | [
"This",
"function",
"executes",
"the",
"script",
"for",
"given",
"layout",
"for",
"the",
"current",
"db",
"."
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMServer.py#L231-L253 | train | 59,507 |
aeguana/PyFileMaker | PyFileMaker/FMServer.py | FMServer.doScriptAfter | def doScriptAfter(self, func, func_kwargs={}, script_name='', params=None):
""" This function will execute extra script after passed function """
request = [
uu({'-script': script_name})
]
if params:
request.append(uu({'-script.param': params }))
self._extra_script = request
return func(**func_kwar... | python | def doScriptAfter(self, func, func_kwargs={}, script_name='', params=None):
""" This function will execute extra script after passed function """
request = [
uu({'-script': script_name})
]
if params:
request.append(uu({'-script.param': params }))
self._extra_script = request
return func(**func_kwar... | [
"def",
"doScriptAfter",
"(",
"self",
",",
"func",
",",
"func_kwargs",
"=",
"{",
"}",
",",
"script_name",
"=",
"''",
",",
"params",
"=",
"None",
")",
":",
"request",
"=",
"[",
"uu",
"(",
"{",
"'-script'",
":",
"script_name",
"}",
")",
"]",
"if",
"pa... | This function will execute extra script after passed function | [
"This",
"function",
"will",
"execute",
"extra",
"script",
"after",
"passed",
"function"
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMServer.py#L255-L266 | train | 59,508 |
aeguana/PyFileMaker | PyFileMaker/FMServer.py | FMServer.getDbNames | def getDbNames(self):
"""This function returns the list of open databases"""
request = []
request.append(uu({'-dbnames': '' }))
result = self._doRequest(request)
result = FMResultset.FMResultset(result)
dbNames = []
for dbName in result.resultset:
dbNames.append(string.lower(dbName['DATABASE_NAME'])... | python | def getDbNames(self):
"""This function returns the list of open databases"""
request = []
request.append(uu({'-dbnames': '' }))
result = self._doRequest(request)
result = FMResultset.FMResultset(result)
dbNames = []
for dbName in result.resultset:
dbNames.append(string.lower(dbName['DATABASE_NAME'])... | [
"def",
"getDbNames",
"(",
"self",
")",
":",
"request",
"=",
"[",
"]",
"request",
".",
"append",
"(",
"uu",
"(",
"{",
"'-dbnames'",
":",
"''",
"}",
")",
")",
"result",
"=",
"self",
".",
"_doRequest",
"(",
"request",
")",
"result",
"=",
"FMResultset",
... | This function returns the list of open databases | [
"This",
"function",
"returns",
"the",
"list",
"of",
"open",
"databases"
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMServer.py#L346-L359 | train | 59,509 |
aeguana/PyFileMaker | PyFileMaker/FMServer.py | FMServer.doFind | def doFind(self, WHAT={}, SORT=[], SKIP=None, MAX=None, LOP='AND', **params):
"""This function will perform the command -find."""
self._preFind(WHAT, SORT, SKIP, MAX, LOP)
for key in params:
self._addDBParam(key, params[key])
try:
return self._doAction('-find')
except FMServerError as e:
if e.args... | python | def doFind(self, WHAT={}, SORT=[], SKIP=None, MAX=None, LOP='AND', **params):
"""This function will perform the command -find."""
self._preFind(WHAT, SORT, SKIP, MAX, LOP)
for key in params:
self._addDBParam(key, params[key])
try:
return self._doAction('-find')
except FMServerError as e:
if e.args... | [
"def",
"doFind",
"(",
"self",
",",
"WHAT",
"=",
"{",
"}",
",",
"SORT",
"=",
"[",
"]",
",",
"SKIP",
"=",
"None",
",",
"MAX",
"=",
"None",
",",
"LOP",
"=",
"'AND'",
",",
"*",
"*",
"params",
")",
":",
"self",
".",
"_preFind",
"(",
"WHAT",
",",
... | This function will perform the command -find. | [
"This",
"function",
"will",
"perform",
"the",
"command",
"-",
"find",
"."
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMServer.py#L420-L432 | train | 59,510 |
aeguana/PyFileMaker | PyFileMaker/FMServer.py | FMServer.doFindAll | def doFindAll(self, WHAT={}, SORT=[], SKIP=None, MAX=None):
"""This function will perform the command -findall."""
self._preFind(WHAT, SORT, SKIP, MAX)
return self._doAction('-findall') | python | def doFindAll(self, WHAT={}, SORT=[], SKIP=None, MAX=None):
"""This function will perform the command -findall."""
self._preFind(WHAT, SORT, SKIP, MAX)
return self._doAction('-findall') | [
"def",
"doFindAll",
"(",
"self",
",",
"WHAT",
"=",
"{",
"}",
",",
"SORT",
"=",
"[",
"]",
",",
"SKIP",
"=",
"None",
",",
"MAX",
"=",
"None",
")",
":",
"self",
".",
"_preFind",
"(",
"WHAT",
",",
"SORT",
",",
"SKIP",
",",
"MAX",
")",
"return",
"... | This function will perform the command -findall. | [
"This",
"function",
"will",
"perform",
"the",
"command",
"-",
"findall",
"."
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMServer.py#L434-L439 | train | 59,511 |
aeguana/PyFileMaker | PyFileMaker/FMServer.py | FMServer.doFindAny | def doFindAny(self, WHAT={}, SORT=[], SKIP=None, MAX=None, LOP='AND', **params):
"""This function will perform the command -findany."""
self._preFind(WHAT, SORT, SKIP, MAX, LOP)
for key in params:
self._addDBParam(key, params[key])
return self._doAction('-findany') | python | def doFindAny(self, WHAT={}, SORT=[], SKIP=None, MAX=None, LOP='AND', **params):
"""This function will perform the command -findany."""
self._preFind(WHAT, SORT, SKIP, MAX, LOP)
for key in params:
self._addDBParam(key, params[key])
return self._doAction('-findany') | [
"def",
"doFindAny",
"(",
"self",
",",
"WHAT",
"=",
"{",
"}",
",",
"SORT",
"=",
"[",
"]",
",",
"SKIP",
"=",
"None",
",",
"MAX",
"=",
"None",
",",
"LOP",
"=",
"'AND'",
",",
"*",
"*",
"params",
")",
":",
"self",
".",
"_preFind",
"(",
"WHAT",
","... | This function will perform the command -findany. | [
"This",
"function",
"will",
"perform",
"the",
"command",
"-",
"findany",
"."
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMServer.py#L441-L449 | train | 59,512 |
aeguana/PyFileMaker | PyFileMaker/FMServer.py | FMServer.doDelete | def doDelete(self, WHAT={}):
"""This function will perform the command -delete."""
if hasattr(WHAT, '_modified'):
self._addDBParam('RECORDID', WHAT.RECORDID)
self._addDBParam('MODID', WHAT.MODID)
elif type(WHAT) == dict and WHAT.has_key('RECORDID'):
self._addDBParam('RECORDID', WHAT['RECORDID'])
else:... | python | def doDelete(self, WHAT={}):
"""This function will perform the command -delete."""
if hasattr(WHAT, '_modified'):
self._addDBParam('RECORDID', WHAT.RECORDID)
self._addDBParam('MODID', WHAT.MODID)
elif type(WHAT) == dict and WHAT.has_key('RECORDID'):
self._addDBParam('RECORDID', WHAT['RECORDID'])
else:... | [
"def",
"doDelete",
"(",
"self",
",",
"WHAT",
"=",
"{",
"}",
")",
":",
"if",
"hasattr",
"(",
"WHAT",
",",
"'_modified'",
")",
":",
"self",
".",
"_addDBParam",
"(",
"'RECORDID'",
",",
"WHAT",
".",
"RECORDID",
")",
"self",
".",
"_addDBParam",
"(",
"'MOD... | This function will perform the command -delete. | [
"This",
"function",
"will",
"perform",
"the",
"command",
"-",
"delete",
"."
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMServer.py#L451-L468 | train | 59,513 |
aeguana/PyFileMaker | PyFileMaker/FMServer.py | FMServer.doNew | def doNew(self, WHAT={}, **params):
"""This function will perform the command -new."""
if hasattr(WHAT, '_modified'):
for key in WHAT:
if key not in ['RECORDID','MODID']:
if WHAT.__new2old__.has_key(key):
self._addDBParam(WHAT.__new2old__[key].encode('utf-8'), WHAT[key])
else:
self._ad... | python | def doNew(self, WHAT={}, **params):
"""This function will perform the command -new."""
if hasattr(WHAT, '_modified'):
for key in WHAT:
if key not in ['RECORDID','MODID']:
if WHAT.__new2old__.has_key(key):
self._addDBParam(WHAT.__new2old__[key].encode('utf-8'), WHAT[key])
else:
self._ad... | [
"def",
"doNew",
"(",
"self",
",",
"WHAT",
"=",
"{",
"}",
",",
"*",
"*",
"params",
")",
":",
"if",
"hasattr",
"(",
"WHAT",
",",
"'_modified'",
")",
":",
"for",
"key",
"in",
"WHAT",
":",
"if",
"key",
"not",
"in",
"[",
"'RECORDID'",
",",
"'MODID'",
... | This function will perform the command -new. | [
"This",
"function",
"will",
"perform",
"the",
"command",
"-",
"new",
"."
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMServer.py#L501-L526 | train | 59,514 |
aeguana/PyFileMaker | PyFileMaker/FMServer.py | FMServer.doDup | def doDup(self, WHAT={}, **params):
"""This function will perform the command -dup."""
if hasattr(WHAT, '_modified'):
for key, value in WHAT._modified():
if WHAT.__new2old__.has_key(key):
self._addDBParam(WHAT.__new2old__[key].encode('utf-8'), value)
else:
self._addDBParam(key, value)
self.... | python | def doDup(self, WHAT={}, **params):
"""This function will perform the command -dup."""
if hasattr(WHAT, '_modified'):
for key, value in WHAT._modified():
if WHAT.__new2old__.has_key(key):
self._addDBParam(WHAT.__new2old__[key].encode('utf-8'), value)
else:
self._addDBParam(key, value)
self.... | [
"def",
"doDup",
"(",
"self",
",",
"WHAT",
"=",
"{",
"}",
",",
"*",
"*",
"params",
")",
":",
"if",
"hasattr",
"(",
"WHAT",
",",
"'_modified'",
")",
":",
"for",
"key",
",",
"value",
"in",
"WHAT",
".",
"_modified",
"(",
")",
":",
"if",
"WHAT",
"."... | This function will perform the command -dup. | [
"This",
"function",
"will",
"perform",
"the",
"command",
"-",
"dup",
"."
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMServer.py#L536-L562 | train | 59,515 |
aeguana/PyFileMaker | PyFileMaker/FMServer.py | FMServer._buildUrl | def _buildUrl(self):
"""Builds url for normal FM requests."""
return '%(protocol)s://%(host)s:%(port)s%(address)s'%{
'protocol': self._protocol,
'host': self._host,
'port': self._port,
'address': self._address,
} | python | def _buildUrl(self):
"""Builds url for normal FM requests."""
return '%(protocol)s://%(host)s:%(port)s%(address)s'%{
'protocol': self._protocol,
'host': self._host,
'port': self._port,
'address': self._address,
} | [
"def",
"_buildUrl",
"(",
"self",
")",
":",
"return",
"'%(protocol)s://%(host)s:%(port)s%(address)s'",
"%",
"{",
"'protocol'",
":",
"self",
".",
"_protocol",
",",
"'host'",
":",
"self",
".",
"_host",
",",
"'port'",
":",
"self",
".",
"_port",
",",
"'address'",
... | Builds url for normal FM requests. | [
"Builds",
"url",
"for",
"normal",
"FM",
"requests",
"."
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMServer.py#L646-L653 | train | 59,516 |
aeguana/PyFileMaker | PyFileMaker/FMServer.py | FMServer._buildFileUrl | def _buildFileUrl(self, xml_req):
"""Builds url for fetching the files from FM."""
return '%(protocol)s://%(host)s:%(port)s%(xml_req)s'%{
'protocol': self._protocol,
'host': self._host,
'port': self._port,
'xml_req': xml_req,
} | python | def _buildFileUrl(self, xml_req):
"""Builds url for fetching the files from FM."""
return '%(protocol)s://%(host)s:%(port)s%(xml_req)s'%{
'protocol': self._protocol,
'host': self._host,
'port': self._port,
'xml_req': xml_req,
} | [
"def",
"_buildFileUrl",
"(",
"self",
",",
"xml_req",
")",
":",
"return",
"'%(protocol)s://%(host)s:%(port)s%(xml_req)s'",
"%",
"{",
"'protocol'",
":",
"self",
".",
"_protocol",
",",
"'host'",
":",
"self",
".",
"_host",
",",
"'port'",
":",
"self",
".",
"_port",... | Builds url for fetching the files from FM. | [
"Builds",
"url",
"for",
"fetching",
"the",
"files",
"from",
"FM",
"."
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMServer.py#L655-L662 | train | 59,517 |
aeguana/PyFileMaker | PyFileMaker/FMServer.py | FMServer._doRequest | def _doRequest(self, request=None, is_file=False, file_xml_uri=''):
"""This function will perform the specified request on the FileMaker
server, and it will return the raw result from FileMaker."""
if request is None:
request = []
if is_file and file_xml_uri:
url = self._buildFileUrl(file_xml_uri)
else... | python | def _doRequest(self, request=None, is_file=False, file_xml_uri=''):
"""This function will perform the specified request on the FileMaker
server, and it will return the raw result from FileMaker."""
if request is None:
request = []
if is_file and file_xml_uri:
url = self._buildFileUrl(file_xml_uri)
else... | [
"def",
"_doRequest",
"(",
"self",
",",
"request",
"=",
"None",
",",
"is_file",
"=",
"False",
",",
"file_xml_uri",
"=",
"''",
")",
":",
"if",
"request",
"is",
"None",
":",
"request",
"=",
"[",
"]",
"if",
"is_file",
"and",
"file_xml_uri",
":",
"url",
"... | This function will perform the specified request on the FileMaker
server, and it will return the raw result from FileMaker. | [
"This",
"function",
"will",
"perform",
"the",
"specified",
"request",
"on",
"the",
"FileMaker",
"server",
"and",
"it",
"will",
"return",
"the",
"raw",
"result",
"from",
"FileMaker",
"."
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMServer.py#L664-L685 | train | 59,518 |
aeguana/PyFileMaker | PyFileMaker/FMError.py | FMErrorByNum | def FMErrorByNum( num ):
"""This function raises an error based on the specified error code."""
if not num in FMErrorNum.keys():
raise FMServerError, (num, FMErrorNum[-1])
elif num == 102:
raise FMFieldError, (num, FMErrorNum[num])
else:
raise FMServerError, (num, FMErrorNum[num... | python | def FMErrorByNum( num ):
"""This function raises an error based on the specified error code."""
if not num in FMErrorNum.keys():
raise FMServerError, (num, FMErrorNum[-1])
elif num == 102:
raise FMFieldError, (num, FMErrorNum[num])
else:
raise FMServerError, (num, FMErrorNum[num... | [
"def",
"FMErrorByNum",
"(",
"num",
")",
":",
"if",
"not",
"num",
"in",
"FMErrorNum",
".",
"keys",
"(",
")",
":",
"raise",
"FMServerError",
",",
"(",
"num",
",",
"FMErrorNum",
"[",
"-",
"1",
"]",
")",
"elif",
"num",
"==",
"102",
":",
"raise",
"FMFie... | This function raises an error based on the specified error code. | [
"This",
"function",
"raises",
"an",
"error",
"based",
"on",
"the",
"specified",
"error",
"code",
"."
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMError.py#L295-L303 | train | 59,519 |
aeguana/PyFileMaker | PyFileMaker/FMXML.py | FMXML.doParseXMLData | def doParseXMLData( self ):
"""This function parses the XML output of FileMaker."""
parser = xml2obj.Xml2Obj()
# Not valid document comming from FMServer
if self.data[-6:] == '</COL>':
self.data += '</ROW></RESULTSET></FMPXMLRESULT>'
xobj = parser.ParseString( self.data )
try:
el = xobj.getElemen... | python | def doParseXMLData( self ):
"""This function parses the XML output of FileMaker."""
parser = xml2obj.Xml2Obj()
# Not valid document comming from FMServer
if self.data[-6:] == '</COL>':
self.data += '</ROW></RESULTSET></FMPXMLRESULT>'
xobj = parser.ParseString( self.data )
try:
el = xobj.getElemen... | [
"def",
"doParseXMLData",
"(",
"self",
")",
":",
"parser",
"=",
"xml2obj",
".",
"Xml2Obj",
"(",
")",
"# Not valid document comming from FMServer",
"if",
"self",
".",
"data",
"[",
"-",
"6",
":",
"]",
"==",
"'</COL>'",
":",
"self",
".",
"data",
"+=",
"'</ROW>... | This function parses the XML output of FileMaker. | [
"This",
"function",
"parses",
"the",
"XML",
"output",
"of",
"FileMaker",
"."
] | ef269b52a97e329d91da3c4851ddac800d7fd7e6 | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMXML.py#L22-L44 | train | 59,520 |
googleapis/gax-python | google/gax/utils/metrics.py | fill | def fill(metrics_headers=()):
"""Add the metrics headers known to GAX.
Return an OrderedDict with all of the metrics headers provided to
this function, as well as the metrics known to GAX (such as its own
version, the GRPC version, etc.).
"""
# Create an ordered dictionary with the Python versi... | python | def fill(metrics_headers=()):
"""Add the metrics headers known to GAX.
Return an OrderedDict with all of the metrics headers provided to
this function, as well as the metrics known to GAX (such as its own
version, the GRPC version, etc.).
"""
# Create an ordered dictionary with the Python versi... | [
"def",
"fill",
"(",
"metrics_headers",
"=",
"(",
")",
")",
":",
"# Create an ordered dictionary with the Python version, which",
"# should go first.",
"answer",
"=",
"collections",
".",
"OrderedDict",
"(",
"(",
"(",
"'gl-python'",
",",
"platform",
".",
"python_version",... | Add the metrics headers known to GAX.
Return an OrderedDict with all of the metrics headers provided to
this function, as well as the metrics known to GAX (such as its own
version, the GRPC version, etc.). | [
"Add",
"the",
"metrics",
"headers",
"known",
"to",
"GAX",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/utils/metrics.py#L42-L68 | train | 59,521 |
googleapis/gax-python | google/gax/utils/metrics.py | stringify | def stringify(metrics_headers=()):
"""Convert the provided metrics headers to a string.
Iterate over the metrics headers (a dictionary, usually ordered) and
return a properly-formatted space-separated string
(e.g. foo/1.2.3 bar/3.14.159).
"""
metrics_headers = collections.OrderedDict(metrics_he... | python | def stringify(metrics_headers=()):
"""Convert the provided metrics headers to a string.
Iterate over the metrics headers (a dictionary, usually ordered) and
return a properly-formatted space-separated string
(e.g. foo/1.2.3 bar/3.14.159).
"""
metrics_headers = collections.OrderedDict(metrics_he... | [
"def",
"stringify",
"(",
"metrics_headers",
"=",
"(",
")",
")",
":",
"metrics_headers",
"=",
"collections",
".",
"OrderedDict",
"(",
"metrics_headers",
")",
"return",
"' '",
".",
"join",
"(",
"[",
"'%s/%s'",
"%",
"(",
"k",
",",
"v",
")",
"for",
"k",
",... | Convert the provided metrics headers to a string.
Iterate over the metrics headers (a dictionary, usually ordered) and
return a properly-formatted space-separated string
(e.g. foo/1.2.3 bar/3.14.159). | [
"Convert",
"the",
"provided",
"metrics",
"headers",
"to",
"a",
"string",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/utils/metrics.py#L71-L79 | train | 59,522 |
googleapis/gax-python | google/gax/bundling.py | _str_dotted_getattr | def _str_dotted_getattr(obj, name):
"""Expands extends getattr to allow dots in x to indicate nested objects.
Args:
obj (object): an object.
name (str): a name for a field in the object.
Returns:
Any: the value of named attribute.
Raises:
AttributeError: if the named attri... | python | def _str_dotted_getattr(obj, name):
"""Expands extends getattr to allow dots in x to indicate nested objects.
Args:
obj (object): an object.
name (str): a name for a field in the object.
Returns:
Any: the value of named attribute.
Raises:
AttributeError: if the named attri... | [
"def",
"_str_dotted_getattr",
"(",
"obj",
",",
"name",
")",
":",
"for",
"part",
"in",
"name",
".",
"split",
"(",
"'.'",
")",
":",
"obj",
"=",
"getattr",
"(",
"obj",
",",
"part",
")",
"return",
"str",
"(",
"obj",
")",
"if",
"obj",
"else",
"None"
] | Expands extends getattr to allow dots in x to indicate nested objects.
Args:
obj (object): an object.
name (str): a name for a field in the object.
Returns:
Any: the value of named attribute.
Raises:
AttributeError: if the named attribute does not exist. | [
"Expands",
"extends",
"getattr",
"to",
"allow",
"dots",
"in",
"x",
"to",
"indicate",
"nested",
"objects",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/bundling.py#L57-L72 | train | 59,523 |
googleapis/gax-python | google/gax/bundling.py | Task.request_bytesize | def request_bytesize(self):
"""The size of in bytes of the bundled field elements."""
return sum(len(str(e)) for elts in self._in_deque for e in elts) | python | def request_bytesize(self):
"""The size of in bytes of the bundled field elements."""
return sum(len(str(e)) for elts in self._in_deque for e in elts) | [
"def",
"request_bytesize",
"(",
"self",
")",
":",
"return",
"sum",
"(",
"len",
"(",
"str",
"(",
"e",
")",
")",
"for",
"elts",
"in",
"self",
".",
"_in_deque",
"for",
"e",
"in",
"elts",
")"
] | The size of in bytes of the bundled field elements. | [
"The",
"size",
"of",
"in",
"bytes",
"of",
"the",
"bundled",
"field",
"elements",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/bundling.py#L141-L143 | train | 59,524 |
googleapis/gax-python | google/gax/bundling.py | Task.run | def run(self):
"""Call the task's func.
The task's func will be called with the bundling requests func
"""
if not self._in_deque:
return
req = self._bundling_request
del getattr(req, self.bundled_field)[:]
getattr(req, self.bundled_field).extend(
... | python | def run(self):
"""Call the task's func.
The task's func will be called with the bundling requests func
"""
if not self._in_deque:
return
req = self._bundling_request
del getattr(req, self.bundled_field)[:]
getattr(req, self.bundled_field).extend(
... | [
"def",
"run",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_in_deque",
":",
"return",
"req",
"=",
"self",
".",
"_bundling_request",
"del",
"getattr",
"(",
"req",
",",
"self",
".",
"bundled_field",
")",
"[",
":",
"]",
"getattr",
"(",
"req",
",",
... | Call the task's func.
The task's func will be called with the bundling requests func | [
"Call",
"the",
"task",
"s",
"func",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/bundling.py#L145-L161 | train | 59,525 |
googleapis/gax-python | google/gax/bundling.py | Task.extend | def extend(self, elts):
"""Adds elts to the tasks.
Args:
elts (Sequence): a iterable of elements that can be appended to the
task's bundle_field.
Returns:
Event: an event that can be used to wait on the response.
"""
# Use a copy, not a refere... | python | def extend(self, elts):
"""Adds elts to the tasks.
Args:
elts (Sequence): a iterable of elements that can be appended to the
task's bundle_field.
Returns:
Event: an event that can be used to wait on the response.
"""
# Use a copy, not a refere... | [
"def",
"extend",
"(",
"self",
",",
"elts",
")",
":",
"# Use a copy, not a reference, as it is later necessary to mutate",
"# the proto field from which elts are drawn in order to construct",
"# the bundled request.",
"elts",
"=",
"elts",
"[",
":",
"]",
"self",
".",
"_in_deque",... | Adds elts to the tasks.
Args:
elts (Sequence): a iterable of elements that can be appended to the
task's bundle_field.
Returns:
Event: an event that can be used to wait on the response. | [
"Adds",
"elts",
"to",
"the",
"tasks",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/bundling.py#L206-L223 | train | 59,526 |
googleapis/gax-python | google/gax/bundling.py | Task._event_for | def _event_for(self, elts):
"""Creates an Event that is set when the bundle with elts is sent."""
event = Event()
event.canceller = self._canceller_for(elts, event)
return event | python | def _event_for(self, elts):
"""Creates an Event that is set when the bundle with elts is sent."""
event = Event()
event.canceller = self._canceller_for(elts, event)
return event | [
"def",
"_event_for",
"(",
"self",
",",
"elts",
")",
":",
"event",
"=",
"Event",
"(",
")",
"event",
".",
"canceller",
"=",
"self",
".",
"_canceller_for",
"(",
"elts",
",",
"event",
")",
"return",
"event"
] | Creates an Event that is set when the bundle with elts is sent. | [
"Creates",
"an",
"Event",
"that",
"is",
"set",
"when",
"the",
"bundle",
"with",
"elts",
"is",
"sent",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/bundling.py#L225-L229 | train | 59,527 |
googleapis/gax-python | google/gax/bundling.py | Task._canceller_for | def _canceller_for(self, elts, event):
"""Obtains a cancellation function that removes elts.
The returned cancellation function returns ``True`` if all elements
was removed successfully from the _in_deque, and false if it was not.
"""
def canceller():
"""Cancels subm... | python | def _canceller_for(self, elts, event):
"""Obtains a cancellation function that removes elts.
The returned cancellation function returns ``True`` if all elements
was removed successfully from the _in_deque, and false if it was not.
"""
def canceller():
"""Cancels subm... | [
"def",
"_canceller_for",
"(",
"self",
",",
"elts",
",",
"event",
")",
":",
"def",
"canceller",
"(",
")",
":",
"\"\"\"Cancels submission of ``elts`` as part of this bundle.\n\n Returns:\n bool: ``False`` if any of elements had already been sent,\n ... | Obtains a cancellation function that removes elts.
The returned cancellation function returns ``True`` if all elements
was removed successfully from the _in_deque, and false if it was not. | [
"Obtains",
"a",
"cancellation",
"function",
"that",
"removes",
"elts",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/bundling.py#L231-L251 | train | 59,528 |
googleapis/gax-python | google/gax/bundling.py | Executor.schedule | def schedule(self, api_call, bundle_id, bundle_desc, bundling_request,
kwargs=None):
"""Schedules bundle_desc of bundling_request as part of bundle_id.
The returned value an :class:`Event` that
* has a ``result`` attribute that will eventually be set to the result
th... | python | def schedule(self, api_call, bundle_id, bundle_desc, bundling_request,
kwargs=None):
"""Schedules bundle_desc of bundling_request as part of bundle_id.
The returned value an :class:`Event` that
* has a ``result`` attribute that will eventually be set to the result
th... | [
"def",
"schedule",
"(",
"self",
",",
"api_call",
",",
"bundle_id",
",",
"bundle_desc",
",",
"bundling_request",
",",
"kwargs",
"=",
"None",
")",
":",
"kwargs",
"=",
"kwargs",
"or",
"dict",
"(",
")",
"bundle",
"=",
"self",
".",
"_bundle_for",
"(",
"api_ca... | Schedules bundle_desc of bundling_request as part of bundle_id.
The returned value an :class:`Event` that
* has a ``result`` attribute that will eventually be set to the result
the api call
* will be used to wait for the response
* holds the canceller function for canceling t... | [
"Schedules",
"bundle_desc",
"of",
"bundling_request",
"as",
"part",
"of",
"bundle_id",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/bundling.py#L277-L317 | train | 59,529 |
googleapis/gax-python | google/gax/grpc.py | create_stub | def create_stub(generated_create_stub, channel=None, service_path=None,
service_port=None, credentials=None, scopes=None,
ssl_credentials=None):
"""Creates a gRPC client stub.
Args:
generated_create_stub (Callable): The generated gRPC method to create a
stub.... | python | def create_stub(generated_create_stub, channel=None, service_path=None,
service_port=None, credentials=None, scopes=None,
ssl_credentials=None):
"""Creates a gRPC client stub.
Args:
generated_create_stub (Callable): The generated gRPC method to create a
stub.... | [
"def",
"create_stub",
"(",
"generated_create_stub",
",",
"channel",
"=",
"None",
",",
"service_path",
"=",
"None",
",",
"service_port",
"=",
"None",
",",
"credentials",
"=",
"None",
",",
"scopes",
"=",
"None",
",",
"ssl_credentials",
"=",
"None",
")",
":",
... | Creates a gRPC client stub.
Args:
generated_create_stub (Callable): The generated gRPC method to create a
stub.
channel (grpc.Channel): A Channel object through which to make calls.
If None, a secure channel is constructed. If specified, all
remaining arguments a... | [
"Creates",
"a",
"gRPC",
"client",
"stub",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/grpc.py#L77-L111 | train | 59,530 |
googleapis/gax-python | google/gax/_grpc_google_auth.py | get_default_credentials | def get_default_credentials(scopes):
"""Gets the Application Default Credentials."""
credentials, _ = google.auth.default(scopes=scopes)
return credentials | python | def get_default_credentials(scopes):
"""Gets the Application Default Credentials."""
credentials, _ = google.auth.default(scopes=scopes)
return credentials | [
"def",
"get_default_credentials",
"(",
"scopes",
")",
":",
"credentials",
",",
"_",
"=",
"google",
".",
"auth",
".",
"default",
"(",
"scopes",
"=",
"scopes",
")",
"return",
"credentials"
] | Gets the Application Default Credentials. | [
"Gets",
"the",
"Application",
"Default",
"Credentials",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/_grpc_google_auth.py#L60-L63 | train | 59,531 |
googleapis/gax-python | google/gax/retry.py | add_timeout_arg | def add_timeout_arg(a_func, timeout, **kwargs):
"""Updates a_func so that it gets called with the timeout as its final arg.
This converts a callable, a_func, into another callable with an additional
positional arg.
Args:
a_func (callable): a callable to be updated
timeout (int): to be adde... | python | def add_timeout_arg(a_func, timeout, **kwargs):
"""Updates a_func so that it gets called with the timeout as its final arg.
This converts a callable, a_func, into another callable with an additional
positional arg.
Args:
a_func (callable): a callable to be updated
timeout (int): to be adde... | [
"def",
"add_timeout_arg",
"(",
"a_func",
",",
"timeout",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"inner",
"(",
"*",
"args",
")",
":",
"\"\"\"Updates args with the timeout.\"\"\"",
"updated_args",
"=",
"args",
"+",
"(",
"timeout",
",",
")",
"return",
"a_fun... | Updates a_func so that it gets called with the timeout as its final arg.
This converts a callable, a_func, into another callable with an additional
positional arg.
Args:
a_func (callable): a callable to be updated
timeout (int): to be added to the original callable as it final positional
... | [
"Updates",
"a_func",
"so",
"that",
"it",
"gets",
"called",
"with",
"the",
"timeout",
"as",
"its",
"final",
"arg",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/retry.py#L49-L70 | train | 59,532 |
googleapis/gax-python | google/gax/retry.py | retryable | def retryable(a_func, retry_options, **kwargs):
"""Creates a function equivalent to a_func, but that retries on certain
exceptions.
Args:
a_func (callable): A callable.
retry_options (RetryOptions): Configures the exceptions upon which the
callable should retry, and the parameters to th... | python | def retryable(a_func, retry_options, **kwargs):
"""Creates a function equivalent to a_func, but that retries on certain
exceptions.
Args:
a_func (callable): A callable.
retry_options (RetryOptions): Configures the exceptions upon which the
callable should retry, and the parameters to th... | [
"def",
"retryable",
"(",
"a_func",
",",
"retry_options",
",",
"*",
"*",
"kwargs",
")",
":",
"delay_mult",
"=",
"retry_options",
".",
"backoff_settings",
".",
"retry_delay_multiplier",
"max_delay_millis",
"=",
"retry_options",
".",
"backoff_settings",
".",
"max_retry... | Creates a function equivalent to a_func, but that retries on certain
exceptions.
Args:
a_func (callable): A callable.
retry_options (RetryOptions): Configures the exceptions upon which the
callable should retry, and the parameters to the exponential backoff
retry algorithm.
kw... | [
"Creates",
"a",
"function",
"equivalent",
"to",
"a_func",
"but",
"that",
"retries",
"on",
"certain",
"exceptions",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/retry.py#L73-L145 | train | 59,533 |
googleapis/gax-python | google/gax/errors.py | create_error | def create_error(msg, cause=None):
"""Creates a ``GaxError`` or subclass.
Attributes:
msg (string): describes the error that occurred.
cause (Exception, optional): the exception raised by a lower
layer of the RPC stack (for example, gRPC) that caused this
exception, or N... | python | def create_error(msg, cause=None):
"""Creates a ``GaxError`` or subclass.
Attributes:
msg (string): describes the error that occurred.
cause (Exception, optional): the exception raised by a lower
layer of the RPC stack (for example, gRPC) that caused this
exception, or N... | [
"def",
"create_error",
"(",
"msg",
",",
"cause",
"=",
"None",
")",
":",
"status_code",
"=",
"config",
".",
"exc_to_code",
"(",
"cause",
")",
"status_name",
"=",
"config",
".",
"NAME_STATUS_CODES",
".",
"get",
"(",
"status_code",
")",
"if",
"status_name",
"... | Creates a ``GaxError`` or subclass.
Attributes:
msg (string): describes the error that occurred.
cause (Exception, optional): the exception raised by a lower
layer of the RPC stack (for example, gRPC) that caused this
exception, or None if this exception originated in GAX.
... | [
"Creates",
"a",
"GaxError",
"or",
"subclass",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/errors.py#L73-L90 | train | 59,534 |
googleapis/gax-python | google/gapic/longrunning/operations_client.py | OperationsClient.get_operation | def get_operation(self, name, options=None):
"""
Gets the latest state of a long-running operation. Clients can use this
method to poll the operation result at intervals as recommended by the API
service.
Example:
>>> from google.gapic.longrunning import operations_cl... | python | def get_operation(self, name, options=None):
"""
Gets the latest state of a long-running operation. Clients can use this
method to poll the operation result at intervals as recommended by the API
service.
Example:
>>> from google.gapic.longrunning import operations_cl... | [
"def",
"get_operation",
"(",
"self",
",",
"name",
",",
"options",
"=",
"None",
")",
":",
"# Create the request object.",
"request",
"=",
"operations_pb2",
".",
"GetOperationRequest",
"(",
"name",
"=",
"name",
")",
"return",
"self",
".",
"_get_operation",
"(",
... | Gets the latest state of a long-running operation. Clients can use this
method to poll the operation result at intervals as recommended by the API
service.
Example:
>>> from google.gapic.longrunning import operations_client
>>> api = operations_client.OperationsClient()
... | [
"Gets",
"the",
"latest",
"state",
"of",
"a",
"long",
"-",
"running",
"operation",
".",
"Clients",
"can",
"use",
"this",
"method",
"to",
"poll",
"the",
"operation",
"result",
"at",
"intervals",
"as",
"recommended",
"by",
"the",
"API",
"service",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gapic/longrunning/operations_client.py#L187-L213 | train | 59,535 |
googleapis/gax-python | google/gapic/longrunning/operations_client.py | OperationsClient.cancel_operation | def cancel_operation(self, name, options=None):
"""
Starts asynchronous cancellation on a long-running operation. The server
makes a best effort to cancel the operation, but success is not
guaranteed. If the server doesn't support this method, it returns
``google.rpc.Code.UNIMP... | python | def cancel_operation(self, name, options=None):
"""
Starts asynchronous cancellation on a long-running operation. The server
makes a best effort to cancel the operation, but success is not
guaranteed. If the server doesn't support this method, it returns
``google.rpc.Code.UNIMP... | [
"def",
"cancel_operation",
"(",
"self",
",",
"name",
",",
"options",
"=",
"None",
")",
":",
"# Create the request object.",
"request",
"=",
"operations_pb2",
".",
"CancelOperationRequest",
"(",
"name",
"=",
"name",
")",
"self",
".",
"_cancel_operation",
"(",
"re... | Starts asynchronous cancellation on a long-running operation. The server
makes a best effort to cancel the operation, but success is not
guaranteed. If the server doesn't support this method, it returns
``google.rpc.Code.UNIMPLEMENTED``. Clients can use
``Operations.GetOperation`` or
... | [
"Starts",
"asynchronous",
"cancellation",
"on",
"a",
"long",
"-",
"running",
"operation",
".",
"The",
"server",
"makes",
"a",
"best",
"effort",
"to",
"cancel",
"the",
"operation",
"but",
"success",
"is",
"not",
"guaranteed",
".",
"If",
"the",
"server",
"does... | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gapic/longrunning/operations_client.py#L266-L296 | train | 59,536 |
googleapis/gax-python | google/gapic/longrunning/operations_client.py | OperationsClient.delete_operation | def delete_operation(self, name, options=None):
"""
Deletes a long-running operation. This method indicates that the client is
no longer interested in the operation result. It does not cancel the
operation. If the server doesn't support this method, it returns
``google.rpc.Code.U... | python | def delete_operation(self, name, options=None):
"""
Deletes a long-running operation. This method indicates that the client is
no longer interested in the operation result. It does not cancel the
operation. If the server doesn't support this method, it returns
``google.rpc.Code.U... | [
"def",
"delete_operation",
"(",
"self",
",",
"name",
",",
"options",
"=",
"None",
")",
":",
"# Create the request object.",
"request",
"=",
"operations_pb2",
".",
"DeleteOperationRequest",
"(",
"name",
"=",
"name",
")",
"self",
".",
"_delete_operation",
"(",
"re... | Deletes a long-running operation. This method indicates that the client is
no longer interested in the operation result. It does not cancel the
operation. If the server doesn't support this method, it returns
``google.rpc.Code.UNIMPLEMENTED``.
Example:
>>> from google.gapic.lo... | [
"Deletes",
"a",
"long",
"-",
"running",
"operation",
".",
"This",
"method",
"indicates",
"that",
"the",
"client",
"is",
"no",
"longer",
"interested",
"in",
"the",
"operation",
"result",
".",
"It",
"does",
"not",
"cancel",
"the",
"operation",
".",
"If",
"th... | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gapic/longrunning/operations_client.py#L298-L322 | train | 59,537 |
googleapis/gax-python | google/gax/utils/oneof.py | check_oneof | def check_oneof(**kwargs):
"""Raise ValueError if more than one keyword argument is not none.
Args:
kwargs (dict): The keyword arguments sent to the function.
Returns: None
Raises:
ValueError: If more than one entry in kwargs is not none.
"""
# Sanity check: If no keyword argu... | python | def check_oneof(**kwargs):
"""Raise ValueError if more than one keyword argument is not none.
Args:
kwargs (dict): The keyword arguments sent to the function.
Returns: None
Raises:
ValueError: If more than one entry in kwargs is not none.
"""
# Sanity check: If no keyword argu... | [
"def",
"check_oneof",
"(",
"*",
"*",
"kwargs",
")",
":",
"# Sanity check: If no keyword arguments were sent, this is fine.",
"if",
"not",
"kwargs",
":",
"return",
"None",
"not_nones",
"=",
"[",
"val",
"for",
"val",
"in",
"kwargs",
".",
"values",
"(",
")",
"if",
... | Raise ValueError if more than one keyword argument is not none.
Args:
kwargs (dict): The keyword arguments sent to the function.
Returns: None
Raises:
ValueError: If more than one entry in kwargs is not none. | [
"Raise",
"ValueError",
"if",
"more",
"than",
"one",
"keyword",
"argument",
"is",
"not",
"none",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/utils/oneof.py#L35-L54 | train | 59,538 |
googleapis/gax-python | google/gax/api_callable.py | _bundleable | def _bundleable(desc):
"""Creates a function that transforms an API call into a bundling call.
It transform a_func from an API call that receives the requests and returns
the response into a callable that receives the same request, and
returns a :class:`bundling.Event`.
The returned Event object c... | python | def _bundleable(desc):
"""Creates a function that transforms an API call into a bundling call.
It transform a_func from an API call that receives the requests and returns
the response into a callable that receives the same request, and
returns a :class:`bundling.Event`.
The returned Event object c... | [
"def",
"_bundleable",
"(",
"desc",
")",
":",
"def",
"inner",
"(",
"a_func",
",",
"settings",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Schedules execution of a bundling task.\"\"\"",
"if",
"not",
"settings",
".",
"bundler",
":",
"return",
"a_fu... | Creates a function that transforms an API call into a bundling call.
It transform a_func from an API call that receives the requests and returns
the response into a callable that receives the same request, and
returns a :class:`bundling.Event`.
The returned Event object can be used to obtain the event... | [
"Creates",
"a",
"function",
"that",
"transforms",
"an",
"API",
"call",
"into",
"a",
"bundling",
"call",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/api_callable.py#L43-L71 | train | 59,539 |
googleapis/gax-python | google/gax/api_callable.py | _page_streamable | def _page_streamable(page_descriptor):
"""Creates a function that yields an iterable to performs page-streaming.
Args:
page_descriptor (:class:`PageDescriptor`): indicates the structure
of page streaming to be performed.
Returns:
Callable: A function that returns an iterator.
... | python | def _page_streamable(page_descriptor):
"""Creates a function that yields an iterable to performs page-streaming.
Args:
page_descriptor (:class:`PageDescriptor`): indicates the structure
of page streaming to be performed.
Returns:
Callable: A function that returns an iterator.
... | [
"def",
"_page_streamable",
"(",
"page_descriptor",
")",
":",
"def",
"inner",
"(",
"a_func",
",",
"settings",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Actual page-streaming based on the settings.\"\"\"",
"page_iterator",
"=",
"gax",
".",
"PageIterato... | Creates a function that yields an iterable to performs page-streaming.
Args:
page_descriptor (:class:`PageDescriptor`): indicates the structure
of page streaming to be performed.
Returns:
Callable: A function that returns an iterator. | [
"Creates",
"a",
"function",
"that",
"yields",
"an",
"iterable",
"to",
"performs",
"page",
"-",
"streaming",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/api_callable.py#L74-L94 | train | 59,540 |
googleapis/gax-python | google/gax/api_callable.py | construct_settings | def construct_settings(
service_name, client_config, config_override,
retry_names, bundle_descriptors=None, page_descriptors=None,
metrics_headers=(), kwargs=None):
"""Constructs a dictionary mapping method names to _CallSettings.
The ``client_config`` parameter is parsed from a client ... | python | def construct_settings(
service_name, client_config, config_override,
retry_names, bundle_descriptors=None, page_descriptors=None,
metrics_headers=(), kwargs=None):
"""Constructs a dictionary mapping method names to _CallSettings.
The ``client_config`` parameter is parsed from a client ... | [
"def",
"construct_settings",
"(",
"service_name",
",",
"client_config",
",",
"config_override",
",",
"retry_names",
",",
"bundle_descriptors",
"=",
"None",
",",
"page_descriptors",
"=",
"None",
",",
"metrics_headers",
"=",
"(",
")",
",",
"kwargs",
"=",
"None",
"... | Constructs a dictionary mapping method names to _CallSettings.
The ``client_config`` parameter is parsed from a client configuration JSON
file of the form:
.. code-block:: json
{
"interfaces": {
"google.fake.v1.ServiceName": {
"retry_codes": {
"idemp... | [
"Constructs",
"a",
"dictionary",
"mapping",
"method",
"names",
"to",
"_CallSettings",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/api_callable.py#L216-L360 | train | 59,541 |
googleapis/gax-python | google/gax/api_callable.py | _catch_errors | def _catch_errors(a_func, to_catch):
"""Updates a_func to wrap exceptions with GaxError
Args:
a_func (callable): A callable.
to_catch (list[Exception]): Configures the exceptions to wrap.
Returns:
Callable: A function that will wrap certain exceptions with GaxError
"""
def ... | python | def _catch_errors(a_func, to_catch):
"""Updates a_func to wrap exceptions with GaxError
Args:
a_func (callable): A callable.
to_catch (list[Exception]): Configures the exceptions to wrap.
Returns:
Callable: A function that will wrap certain exceptions with GaxError
"""
def ... | [
"def",
"_catch_errors",
"(",
"a_func",
",",
"to_catch",
")",
":",
"def",
"inner",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Wraps specified exceptions\"\"\"",
"try",
":",
"return",
"a_func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")... | Updates a_func to wrap exceptions with GaxError
Args:
a_func (callable): A callable.
to_catch (list[Exception]): Configures the exceptions to wrap.
Returns:
Callable: A function that will wrap certain exceptions with GaxError | [
"Updates",
"a_func",
"to",
"wrap",
"exceptions",
"with",
"GaxError"
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/api_callable.py#L363-L382 | train | 59,542 |
googleapis/gax-python | google/gax/api_callable.py | create_api_call | def create_api_call(func, settings):
"""Converts an rpc call into an API call governed by the settings.
In typical usage, ``func`` will be a callable used to make an rpc request.
This will mostly likely be a bound method from a request stub used to make
an rpc call.
The result is created by applyi... | python | def create_api_call(func, settings):
"""Converts an rpc call into an API call governed by the settings.
In typical usage, ``func`` will be a callable used to make an rpc request.
This will mostly likely be a bound method from a request stub used to make
an rpc call.
The result is created by applyi... | [
"def",
"create_api_call",
"(",
"func",
",",
"settings",
")",
":",
"def",
"base_caller",
"(",
"api_call",
",",
"_",
",",
"*",
"args",
")",
":",
"\"\"\"Simply call api_call and ignore settings.\"\"\"",
"return",
"api_call",
"(",
"*",
"args",
")",
"def",
"inner",
... | Converts an rpc call into an API call governed by the settings.
In typical usage, ``func`` will be a callable used to make an rpc request.
This will mostly likely be a bound method from a request stub used to make
an rpc call.
The result is created by applying a series of function decorators defined
... | [
"Converts",
"an",
"rpc",
"call",
"into",
"an",
"API",
"call",
"governed",
"by",
"the",
"settings",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/api_callable.py#L407-L464 | train | 59,543 |
googleapis/gax-python | google/gax/utils/protobuf.py | get | def get(pb_or_dict, key, default=_SENTINEL):
"""Retrieve the given key off of the object.
If a default is specified, return it if the key is not found, otherwise
raise KeyError.
Args:
pb_or_dict (Union[~google.protobuf.message.Message, Mapping]): the
object.
key (str): The ... | python | def get(pb_or_dict, key, default=_SENTINEL):
"""Retrieve the given key off of the object.
If a default is specified, return it if the key is not found, otherwise
raise KeyError.
Args:
pb_or_dict (Union[~google.protobuf.message.Message, Mapping]): the
object.
key (str): The ... | [
"def",
"get",
"(",
"pb_or_dict",
",",
"key",
",",
"default",
"=",
"_SENTINEL",
")",
":",
"# We may need to get a nested key. Resolve this.",
"key",
",",
"subkey",
"=",
"_resolve_subkeys",
"(",
"key",
")",
"# Attempt to get the value from the two types of objects we know bao... | Retrieve the given key off of the object.
If a default is specified, return it if the key is not found, otherwise
raise KeyError.
Args:
pb_or_dict (Union[~google.protobuf.message.Message, Mapping]): the
object.
key (str): The key to retrieve from the object in question.
... | [
"Retrieve",
"the",
"given",
"key",
"off",
"of",
"the",
"object",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/utils/protobuf.py#L42-L91 | train | 59,544 |
googleapis/gax-python | google/gax/utils/protobuf.py | set | def set(pb_or_dict, key, value):
"""Set the given key on the object.
Args:
pb_or_dict (Union[~google.protobuf.message.Message, Mapping]): the
object.
key (str): The key on the object in question.
value (Any): The value to set.
Raises:
TypeError: If pb_or_dict is... | python | def set(pb_or_dict, key, value):
"""Set the given key on the object.
Args:
pb_or_dict (Union[~google.protobuf.message.Message, Mapping]): the
object.
key (str): The key on the object in question.
value (Any): The value to set.
Raises:
TypeError: If pb_or_dict is... | [
"def",
"set",
"(",
"pb_or_dict",
",",
"key",
",",
"value",
")",
":",
"# pylint: disable=redefined-builtin,too-many-branches",
"# redefined-builtin: We want 'set' to be part of the public interface.",
"# too-many-branches: This method is inherently complex.",
"# Sanity check: Is our target ... | Set the given key on the object.
Args:
pb_or_dict (Union[~google.protobuf.message.Message, Mapping]): the
object.
key (str): The key on the object in question.
value (Any): The value to set.
Raises:
TypeError: If pb_or_dict is not a Message or Mapping. | [
"Set",
"the",
"given",
"key",
"on",
"the",
"object",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/utils/protobuf.py#L94-L151 | train | 59,545 |
googleapis/gax-python | google/gax/utils/protobuf.py | setdefault | def setdefault(pb_or_dict, key, value):
"""Set the key on the object to the value if the current value is falsy.
Because protobuf Messages do not distinguish between unset values and
falsy ones particularly well, this method treats any falsy value
(e.g. 0, empty list) as a target to be overwritten, on ... | python | def setdefault(pb_or_dict, key, value):
"""Set the key on the object to the value if the current value is falsy.
Because protobuf Messages do not distinguish between unset values and
falsy ones particularly well, this method treats any falsy value
(e.g. 0, empty list) as a target to be overwritten, on ... | [
"def",
"setdefault",
"(",
"pb_or_dict",
",",
"key",
",",
"value",
")",
":",
"if",
"not",
"get",
"(",
"pb_or_dict",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"set",
"(",
"pb_or_dict",
",",
"key",
",",
"value",
")"
] | Set the key on the object to the value if the current value is falsy.
Because protobuf Messages do not distinguish between unset values and
falsy ones particularly well, this method treats any falsy value
(e.g. 0, empty list) as a target to be overwritten, on both Messages
and dictionaries.
Args:
... | [
"Set",
"the",
"key",
"on",
"the",
"object",
"to",
"the",
"value",
"if",
"the",
"current",
"value",
"is",
"falsy",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/utils/protobuf.py#L154-L172 | train | 59,546 |
googleapis/gax-python | google/gax/utils/protobuf.py | _resolve_subkeys | def _resolve_subkeys(key, separator='.'):
"""Given a key which may actually be a nested key, return the top level
key and any nested subkeys as separate values.
Args:
key (str): A string that may or may not contain the separator.
separator (str): The namespace separator. Defaults to `.`.
... | python | def _resolve_subkeys(key, separator='.'):
"""Given a key which may actually be a nested key, return the top level
key and any nested subkeys as separate values.
Args:
key (str): A string that may or may not contain the separator.
separator (str): The namespace separator. Defaults to `.`.
... | [
"def",
"_resolve_subkeys",
"(",
"key",
",",
"separator",
"=",
"'.'",
")",
":",
"subkey",
"=",
"None",
"if",
"separator",
"in",
"key",
":",
"index",
"=",
"key",
".",
"index",
"(",
"separator",
")",
"subkey",
"=",
"key",
"[",
"index",
"+",
"1",
":",
... | Given a key which may actually be a nested key, return the top level
key and any nested subkeys as separate values.
Args:
key (str): A string that may or may not contain the separator.
separator (str): The namespace separator. Defaults to `.`.
Returns:
Tuple[str, str]: The key and ... | [
"Given",
"a",
"key",
"which",
"may",
"actually",
"be",
"a",
"nested",
"key",
"return",
"the",
"top",
"level",
"key",
"and",
"any",
"nested",
"subkeys",
"as",
"separate",
"values",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/utils/protobuf.py#L175-L191 | train | 59,547 |
googleapis/gax-python | google/gax/__init__.py | _CallSettings.merge | def merge(self, options):
"""Returns new _CallSettings merged from this and a CallOptions object.
Note that passing if the CallOptions instance specifies a page_token,
the merged _CallSettings will have ``flatten_pages`` disabled. This
permits toggling per-resource/per-page page streami... | python | def merge(self, options):
"""Returns new _CallSettings merged from this and a CallOptions object.
Note that passing if the CallOptions instance specifies a page_token,
the merged _CallSettings will have ``flatten_pages`` disabled. This
permits toggling per-resource/per-page page streami... | [
"def",
"merge",
"(",
"self",
",",
"options",
")",
":",
"if",
"not",
"options",
":",
"return",
"_CallSettings",
"(",
"timeout",
"=",
"self",
".",
"timeout",
",",
"retry",
"=",
"self",
".",
"retry",
",",
"page_descriptor",
"=",
"self",
".",
"page_descripto... | Returns new _CallSettings merged from this and a CallOptions object.
Note that passing if the CallOptions instance specifies a page_token,
the merged _CallSettings will have ``flatten_pages`` disabled. This
permits toggling per-resource/per-page page streaming.
Args:
option... | [
"Returns",
"new",
"_CallSettings",
"merged",
"from",
"this",
"and",
"a",
"CallOptions",
"object",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/__init__.py#L112-L165 | train | 59,548 |
googleapis/gax-python | google/gax/__init__.py | _OperationFuture.cancel | def cancel(self):
"""If last Operation's value of `done` is true, returns false;
otherwise, issues OperationsClient.cancel_operation and returns true.
"""
if self.done():
return False
self._client.cancel_operation(self._operation.name)
return True | python | def cancel(self):
"""If last Operation's value of `done` is true, returns false;
otherwise, issues OperationsClient.cancel_operation and returns true.
"""
if self.done():
return False
self._client.cancel_operation(self._operation.name)
return True | [
"def",
"cancel",
"(",
"self",
")",
":",
"if",
"self",
".",
"done",
"(",
")",
":",
"return",
"False",
"self",
".",
"_client",
".",
"cancel_operation",
"(",
"self",
".",
"_operation",
".",
"name",
")",
"return",
"True"
] | If last Operation's value of `done` is true, returns false;
otherwise, issues OperationsClient.cancel_operation and returns true. | [
"If",
"last",
"Operation",
"s",
"value",
"of",
"done",
"is",
"true",
"returns",
"false",
";",
"otherwise",
"issues",
"OperationsClient",
".",
"cancel_operation",
"and",
"returns",
"true",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/__init__.py#L574-L582 | train | 59,549 |
googleapis/gax-python | google/gax/__init__.py | _OperationFuture.result | def result(self, timeout=None):
"""Enters polling loop on OperationsClient.get_operation, and once
Operation.done is true, then returns Operation.response if successful or
throws GaxError if not successful.
This method will wait up to timeout seconds. If the call hasn't
complete... | python | def result(self, timeout=None):
"""Enters polling loop on OperationsClient.get_operation, and once
Operation.done is true, then returns Operation.response if successful or
throws GaxError if not successful.
This method will wait up to timeout seconds. If the call hasn't
complete... | [
"def",
"result",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"# Check exceptional case: raise if no response",
"if",
"not",
"self",
".",
"_poll",
"(",
"timeout",
")",
".",
"HasField",
"(",
"'response'",
")",
":",
"raise",
"GaxError",
"(",
"self",
"."... | Enters polling loop on OperationsClient.get_operation, and once
Operation.done is true, then returns Operation.response if successful or
throws GaxError if not successful.
This method will wait up to timeout seconds. If the call hasn't
completed in timeout seconds, then a RetryError wil... | [
"Enters",
"polling",
"loop",
"on",
"OperationsClient",
".",
"get_operation",
"and",
"once",
"Operation",
".",
"done",
"is",
"true",
"then",
"returns",
"Operation",
".",
"response",
"if",
"successful",
"or",
"throws",
"GaxError",
"if",
"not",
"successful",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/__init__.py#L584-L599 | train | 59,550 |
googleapis/gax-python | google/gax/__init__.py | _OperationFuture.add_done_callback | def add_done_callback(self, fn): # pylint: disable=invalid-name
"""Enters a polling loop on OperationsClient.get_operation, and once the
operation is done or cancelled, calls the function with this
_OperationFuture. Added callables are called in the order that they were
added.
"... | python | def add_done_callback(self, fn): # pylint: disable=invalid-name
"""Enters a polling loop on OperationsClient.get_operation, and once the
operation is done or cancelled, calls the function with this
_OperationFuture. Added callables are called in the order that they were
added.
"... | [
"def",
"add_done_callback",
"(",
"self",
",",
"fn",
")",
":",
"# pylint: disable=invalid-name",
"if",
"self",
".",
"_operation",
".",
"done",
":",
"_try_callback",
"(",
"self",
",",
"fn",
")",
"else",
":",
"self",
".",
"_queue",
".",
"put",
"(",
"dill",
... | Enters a polling loop on OperationsClient.get_operation, and once the
operation is done or cancelled, calls the function with this
_OperationFuture. Added callables are called in the order that they were
added. | [
"Enters",
"a",
"polling",
"loop",
"on",
"OperationsClient",
".",
"get_operation",
"and",
"once",
"the",
"operation",
"is",
"done",
"or",
"cancelled",
"calls",
"the",
"function",
"with",
"this",
"_OperationFuture",
".",
"Added",
"callables",
"are",
"called",
"in"... | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/__init__.py#L622-L634 | train | 59,551 |
ambitioninc/django-query-builder | querybuilder/query.py | Join.get_sql | def get_sql(self):
"""
Generates the JOIN sql for the join tables and join condition
:rtype: str
:return: the JOIN sql for the join tables and join condition
"""
return '{0} {1} ON {2}'.format(self.join_type, self.right_table.get_sql(), self.get_condition()) | python | def get_sql(self):
"""
Generates the JOIN sql for the join tables and join condition
:rtype: str
:return: the JOIN sql for the join tables and join condition
"""
return '{0} {1} ON {2}'.format(self.join_type, self.right_table.get_sql(), self.get_condition()) | [
"def",
"get_sql",
"(",
"self",
")",
":",
"return",
"'{0} {1} ON {2}'",
".",
"format",
"(",
"self",
".",
"join_type",
",",
"self",
".",
"right_table",
".",
"get_sql",
"(",
")",
",",
"self",
".",
"get_condition",
"(",
")",
")"
] | Generates the JOIN sql for the join tables and join condition
:rtype: str
:return: the JOIN sql for the join tables and join condition | [
"Generates",
"the",
"JOIN",
"sql",
"for",
"the",
"join",
"tables",
"and",
"join",
"condition"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L94-L101 | train | 59,552 |
ambitioninc/django-query-builder | querybuilder/query.py | Join.set_left_table | def set_left_table(self, left_table=None):
"""
Sets the left table for this join clause. If no table is specified, the first table
in the query will be used
:type left_table: str or dict or :class:`Table <querybuilder.tables.Table>` or None
:param left_table: The left table bein... | python | def set_left_table(self, left_table=None):
"""
Sets the left table for this join clause. If no table is specified, the first table
in the query will be used
:type left_table: str or dict or :class:`Table <querybuilder.tables.Table>` or None
:param left_table: The left table bein... | [
"def",
"set_left_table",
"(",
"self",
",",
"left_table",
"=",
"None",
")",
":",
"if",
"left_table",
":",
"self",
".",
"left_table",
"=",
"TableFactory",
"(",
"table",
"=",
"left_table",
",",
"owner",
"=",
"self",
".",
"owner",
",",
")",
"else",
":",
"s... | Sets the left table for this join clause. If no table is specified, the first table
in the query will be used
:type left_table: str or dict or :class:`Table <querybuilder.tables.Table>` or None
:param left_table: The left table being joined with. This can be a string of the table
na... | [
"Sets",
"the",
"left",
"table",
"for",
"this",
"join",
"clause",
".",
"If",
"no",
"table",
"is",
"specified",
"the",
"first",
"table",
"in",
"the",
"query",
"will",
"be",
"used"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L103-L119 | train | 59,553 |
ambitioninc/django-query-builder | querybuilder/query.py | Join.get_left_table | def get_left_table(self):
"""
Returns the left table if one was specified, otherwise the first
table in the query is returned
:rtype: :class:`Table <querybuilder.tables.Table>`
:return: the left table if one was specified, otherwise the first table in the query
"""
... | python | def get_left_table(self):
"""
Returns the left table if one was specified, otherwise the first
table in the query is returned
:rtype: :class:`Table <querybuilder.tables.Table>`
:return: the left table if one was specified, otherwise the first table in the query
"""
... | [
"def",
"get_left_table",
"(",
"self",
")",
":",
"if",
"self",
".",
"left_table",
":",
"return",
"self",
".",
"left_table",
"if",
"len",
"(",
"self",
".",
"owner",
".",
"tables",
")",
":",
"return",
"self",
".",
"owner",
".",
"tables",
"[",
"0",
"]"
] | Returns the left table if one was specified, otherwise the first
table in the query is returned
:rtype: :class:`Table <querybuilder.tables.Table>`
:return: the left table if one was specified, otherwise the first table in the query | [
"Returns",
"the",
"left",
"table",
"if",
"one",
"was",
"specified",
"otherwise",
"the",
"first",
"table",
"in",
"the",
"query",
"is",
"returned"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L121-L132 | train | 59,554 |
ambitioninc/django-query-builder | querybuilder/query.py | Join.get_all_related_objects | def get_all_related_objects(self, table):
"""
Fix for django 1.10 to replace deprecated code. Keep support for django 1.7
"""
# Django 1.7 method
if hasattr(table.model._meta, 'get_all_related_objects'):
return table.model._meta.get_all_related_objects()
else:... | python | def get_all_related_objects(self, table):
"""
Fix for django 1.10 to replace deprecated code. Keep support for django 1.7
"""
# Django 1.7 method
if hasattr(table.model._meta, 'get_all_related_objects'):
return table.model._meta.get_all_related_objects()
else:... | [
"def",
"get_all_related_objects",
"(",
"self",
",",
"table",
")",
":",
"# Django 1.7 method",
"if",
"hasattr",
"(",
"table",
".",
"model",
".",
"_meta",
",",
"'get_all_related_objects'",
")",
":",
"return",
"table",
".",
"model",
".",
"_meta",
".",
"get_all_re... | Fix for django 1.10 to replace deprecated code. Keep support for django 1.7 | [
"Fix",
"for",
"django",
"1",
".",
"10",
"to",
"replace",
"deprecated",
"code",
".",
"Keep",
"support",
"for",
"django",
"1",
".",
"7"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L134-L146 | train | 59,555 |
ambitioninc/django-query-builder | querybuilder/query.py | Join.set_right_table | def set_right_table(self, table):
"""
Sets the right table for this join clause and try to automatically set the condition
if one isn't specified
"""
self.right_table = table
if self.left_table is None:
return
# find table prefix
if type(self.... | python | def set_right_table(self, table):
"""
Sets the right table for this join clause and try to automatically set the condition
if one isn't specified
"""
self.right_table = table
if self.left_table is None:
return
# find table prefix
if type(self.... | [
"def",
"set_right_table",
"(",
"self",
",",
"table",
")",
":",
"self",
".",
"right_table",
"=",
"table",
"if",
"self",
".",
"left_table",
"is",
"None",
":",
"return",
"# find table prefix",
"if",
"type",
"(",
"self",
".",
"left_table",
")",
"is",
"ModelTab... | Sets the right table for this join clause and try to automatically set the condition
if one isn't specified | [
"Sets",
"the",
"right",
"table",
"for",
"this",
"join",
"clause",
"and",
"try",
"to",
"automatically",
"set",
"the",
"condition",
"if",
"one",
"isn",
"t",
"specified"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L148-L182 | train | 59,556 |
ambitioninc/django-query-builder | querybuilder/query.py | Join.get_condition | def get_condition(self):
"""
Determines the condition to be used in the condition part of the join sql.
:return: The condition for the join clause
:rtype: str or None
"""
if self.condition:
return self.condition
if type(self.right_table) is ModelTabl... | python | def get_condition(self):
"""
Determines the condition to be used in the condition part of the join sql.
:return: The condition for the join clause
:rtype: str or None
"""
if self.condition:
return self.condition
if type(self.right_table) is ModelTabl... | [
"def",
"get_condition",
"(",
"self",
")",
":",
"if",
"self",
".",
"condition",
":",
"return",
"self",
".",
"condition",
"if",
"type",
"(",
"self",
".",
"right_table",
")",
"is",
"ModelTable",
"and",
"type",
"(",
"self",
".",
"right_table",
")",
"is",
"... | Determines the condition to be used in the condition part of the join sql.
:return: The condition for the join clause
:rtype: str or None | [
"Determines",
"the",
"condition",
"to",
"be",
"used",
"in",
"the",
"condition",
"part",
"of",
"the",
"join",
"sql",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L184-L229 | train | 59,557 |
ambitioninc/django-query-builder | querybuilder/query.py | Where.get_sql | def get_sql(self):
"""
Builds and returns the WHERE portion of the sql
:return: the WHERE portion of the sql
:rtype: str
"""
# reset arg index and args
self.arg_index = 0
self.args = {}
# build the WHERE sql portion if needed
if len(self.... | python | def get_sql(self):
"""
Builds and returns the WHERE portion of the sql
:return: the WHERE portion of the sql
:rtype: str
"""
# reset arg index and args
self.arg_index = 0
self.args = {}
# build the WHERE sql portion if needed
if len(self.... | [
"def",
"get_sql",
"(",
"self",
")",
":",
"# reset arg index and args",
"self",
".",
"arg_index",
"=",
"0",
"self",
".",
"args",
"=",
"{",
"}",
"# build the WHERE sql portion if needed",
"if",
"len",
"(",
"self",
".",
"wheres",
")",
":",
"where",
"=",
"self",... | Builds and returns the WHERE portion of the sql
:return: the WHERE portion of the sql
:rtype: str | [
"Builds",
"and",
"returns",
"the",
"WHERE",
"portion",
"of",
"the",
"sql"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L284-L299 | train | 59,558 |
ambitioninc/django-query-builder | querybuilder/query.py | Where.get_condition_value | def get_condition_value(self, operator, value):
"""
Gets the condition value based on the operator and value
:param operator: the condition operator name
:type operator: str
:param value: the value to be formatted based on the condition operator
:type value: object
... | python | def get_condition_value(self, operator, value):
"""
Gets the condition value based on the operator and value
:param operator: the condition operator name
:type operator: str
:param value: the value to be formatted based on the condition operator
:type value: object
... | [
"def",
"get_condition_value",
"(",
"self",
",",
"operator",
",",
"value",
")",
":",
"if",
"operator",
"in",
"(",
"'contains'",
",",
"'icontains'",
")",
":",
"value",
"=",
"'%{0}%'",
".",
"format",
"(",
"value",
")",
"elif",
"operator",
"==",
"'startswith'"... | Gets the condition value based on the operator and value
:param operator: the condition operator name
:type operator: str
:param value: the value to be formatted based on the condition operator
:type value: object
:return: the comparison operator from the Where class's comparis... | [
"Gets",
"the",
"condition",
"value",
"based",
"on",
"the",
"operator",
"and",
"value"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L310-L326 | train | 59,559 |
ambitioninc/django-query-builder | querybuilder/query.py | Where.set_arg | def set_arg(self, value):
"""
Set the query param in self.args based on the prefix and arg index
and auto increment the arg_index
:return: the string placeholder for the arg
:rtype: str
"""
named_arg = '{0}A{1}'.format(self.arg_prefix, self.arg_index)
sel... | python | def set_arg(self, value):
"""
Set the query param in self.args based on the prefix and arg index
and auto increment the arg_index
:return: the string placeholder for the arg
:rtype: str
"""
named_arg = '{0}A{1}'.format(self.arg_prefix, self.arg_index)
sel... | [
"def",
"set_arg",
"(",
"self",
",",
"value",
")",
":",
"named_arg",
"=",
"'{0}A{1}'",
".",
"format",
"(",
"self",
".",
"arg_prefix",
",",
"self",
".",
"arg_index",
")",
"self",
".",
"args",
"[",
"named_arg",
"]",
"=",
"value",
"self",
".",
"arg_index",... | Set the query param in self.args based on the prefix and arg index
and auto increment the arg_index
:return: the string placeholder for the arg
:rtype: str | [
"Set",
"the",
"query",
"param",
"in",
"self",
".",
"args",
"based",
"on",
"the",
"prefix",
"and",
"arg",
"index",
"and",
"auto",
"increment",
"the",
"arg_index"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L424-L435 | train | 59,560 |
ambitioninc/django-query-builder | querybuilder/query.py | Sorter.get_name | def get_name(self, use_alias=True):
"""
Gets the name to reference the sorted field
:return: the name to reference the sorted field
:rtype: str
"""
if self.desc:
direction = 'DESC'
else:
direction = 'ASC'
if use_alias:
... | python | def get_name(self, use_alias=True):
"""
Gets the name to reference the sorted field
:return: the name to reference the sorted field
:rtype: str
"""
if self.desc:
direction = 'DESC'
else:
direction = 'ASC'
if use_alias:
... | [
"def",
"get_name",
"(",
"self",
",",
"use_alias",
"=",
"True",
")",
":",
"if",
"self",
".",
"desc",
":",
"direction",
"=",
"'DESC'",
"else",
":",
"direction",
"=",
"'ASC'",
"if",
"use_alias",
":",
"return",
"'{0} {1}'",
".",
"format",
"(",
"self",
".",... | Gets the name to reference the sorted field
:return: the name to reference the sorted field
:rtype: str | [
"Gets",
"the",
"name",
"to",
"reference",
"the",
"sorted",
"field"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L508-L522 | train | 59,561 |
ambitioninc/django-query-builder | querybuilder/query.py | Limit.get_sql | def get_sql(self):
"""
Generates the sql used for the limit clause of a Query
:return: the sql for the limit clause of a Query
:rtype: str
"""
sql = ''
if self.limit and self.limit > 0:
sql += 'LIMIT {0} '.format(self.limit)
if self.offset and... | python | def get_sql(self):
"""
Generates the sql used for the limit clause of a Query
:return: the sql for the limit clause of a Query
:rtype: str
"""
sql = ''
if self.limit and self.limit > 0:
sql += 'LIMIT {0} '.format(self.limit)
if self.offset and... | [
"def",
"get_sql",
"(",
"self",
")",
":",
"sql",
"=",
"''",
"if",
"self",
".",
"limit",
"and",
"self",
".",
"limit",
">",
"0",
":",
"sql",
"+=",
"'LIMIT {0} '",
".",
"format",
"(",
"self",
".",
"limit",
")",
"if",
"self",
".",
"offset",
"and",
"se... | Generates the sql used for the limit clause of a Query
:return: the sql for the limit clause of a Query
:rtype: str | [
"Generates",
"the",
"sql",
"used",
"for",
"the",
"limit",
"clause",
"of",
"a",
"Query"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L543-L555 | train | 59,562 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.init_defaults | def init_defaults(self):
"""
Sets the default values for this instance
"""
self.sql = ''
self.tables = []
self.joins = []
self._where = Where()
self.groups = []
self.sorters = []
self._limit = None
self.table_prefix = ''
sel... | python | def init_defaults(self):
"""
Sets the default values for this instance
"""
self.sql = ''
self.tables = []
self.joins = []
self._where = Where()
self.groups = []
self.sorters = []
self._limit = None
self.table_prefix = ''
sel... | [
"def",
"init_defaults",
"(",
"self",
")",
":",
"self",
".",
"sql",
"=",
"''",
"self",
".",
"tables",
"=",
"[",
"]",
"self",
".",
"joins",
"=",
"[",
"]",
"self",
".",
"_where",
"=",
"Where",
"(",
")",
"self",
".",
"groups",
"=",
"[",
"]",
"self"... | Sets the default values for this instance | [
"Sets",
"the",
"default",
"values",
"for",
"this",
"instance"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L596-L614 | train | 59,563 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.from_table | def from_table(self, table=None, fields='*', schema=None, **kwargs):
"""
Adds a ``Table`` and any optional fields to the list of tables
this query is selecting from.
:type table: str or dict or :class:`Table <querybuilder.tables.Table>`
or :class:`Query <querybuilder.query.Q... | python | def from_table(self, table=None, fields='*', schema=None, **kwargs):
"""
Adds a ``Table`` and any optional fields to the list of tables
this query is selecting from.
:type table: str or dict or :class:`Table <querybuilder.tables.Table>`
or :class:`Query <querybuilder.query.Q... | [
"def",
"from_table",
"(",
"self",
",",
"table",
"=",
"None",
",",
"fields",
"=",
"'*'",
",",
"schema",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# self.mark_dirty()",
"self",
".",
"tables",
".",
"append",
"(",
"TableFactory",
"(",
"table",
"=",
... | Adds a ``Table`` and any optional fields to the list of tables
this query is selecting from.
:type table: str or dict or :class:`Table <querybuilder.tables.Table>`
or :class:`Query <querybuilder.query.Query>` or
:class:`ModelBase <django:django.db.models.base.ModelBase>`
... | [
"Adds",
"a",
"Table",
"and",
"any",
"optional",
"fields",
"to",
"the",
"list",
"of",
"tables",
"this",
"query",
"is",
"selecting",
"from",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L648-L683 | train | 59,564 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.insert_into | def insert_into(self, table=None, field_names=None, values=None, **kwargs):
"""
Bulk inserts a list of values into a table
:type table: str or dict or :class:`Table <querybuilder.tables.Table>`
or :class:`Query <querybuilder.query.Query>` or :class:`ModelBase <django:django.db.model... | python | def insert_into(self, table=None, field_names=None, values=None, **kwargs):
"""
Bulk inserts a list of values into a table
:type table: str or dict or :class:`Table <querybuilder.tables.Table>`
or :class:`Query <querybuilder.query.Query>` or :class:`ModelBase <django:django.db.model... | [
"def",
"insert_into",
"(",
"self",
",",
"table",
"=",
"None",
",",
"field_names",
"=",
"None",
",",
"values",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"table",
"=",
"TableFactory",
"(",
"table",
"=",
"table",
",",
"*",
"*",
"kwargs",
")",
"s... | Bulk inserts a list of values into a table
:type table: str or dict or :class:`Table <querybuilder.tables.Table>`
or :class:`Query <querybuilder.query.Query>` or :class:`ModelBase <django:django.db.models.base.ModelBase>`
:param table: The table to select fields from. This can be a string o... | [
"Bulk",
"inserts",
"a",
"list",
"of",
"values",
"into",
"a",
"table"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L685-L715 | train | 59,565 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.update_table | def update_table(self, table=None, field_names=None, values=None, pk=None, **kwargs):
"""
Bulk updates rows in a table
:type table: str or dict or :class:`Table <querybuilder.tables.Table>`
or :class:`Query <querybuilder.query.Query>` or :class:`ModelBase <django:django.db.models.ba... | python | def update_table(self, table=None, field_names=None, values=None, pk=None, **kwargs):
"""
Bulk updates rows in a table
:type table: str or dict or :class:`Table <querybuilder.tables.Table>`
or :class:`Query <querybuilder.query.Query>` or :class:`ModelBase <django:django.db.models.ba... | [
"def",
"update_table",
"(",
"self",
",",
"table",
"=",
"None",
",",
"field_names",
"=",
"None",
",",
"values",
"=",
"None",
",",
"pk",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"table",
"=",
"TableFactory",
"(",
"table",
"=",
"table",
",",
"*... | Bulk updates rows in a table
:type table: str or dict or :class:`Table <querybuilder.tables.Table>`
or :class:`Query <querybuilder.query.Query>` or :class:`ModelBase <django:django.db.models.base.ModelBase>`
:param table: The table to select fields from. This can be a string of the table
... | [
"Bulk",
"updates",
"rows",
"in",
"a",
"table"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L717-L749 | train | 59,566 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.join | def join(self, right_table=None, fields=None, condition=None, join_type='JOIN',
schema=None, left_table=None, extract_fields=True, prefix_fields=False, field_prefix=None,
allow_duplicates=False):
"""
Joins a table to another table based on a condition and adds fields from the j... | python | def join(self, right_table=None, fields=None, condition=None, join_type='JOIN',
schema=None, left_table=None, extract_fields=True, prefix_fields=False, field_prefix=None,
allow_duplicates=False):
"""
Joins a table to another table based on a condition and adds fields from the j... | [
"def",
"join",
"(",
"self",
",",
"right_table",
"=",
"None",
",",
"fields",
"=",
"None",
",",
"condition",
"=",
"None",
",",
"join_type",
"=",
"'JOIN'",
",",
"schema",
"=",
"None",
",",
"left_table",
"=",
"None",
",",
"extract_fields",
"=",
"True",
","... | Joins a table to another table based on a condition and adds fields from the joined table
to the returned fields.
:type right_table: str or dict or :class:`Table <querybuilder.tables.Table>`
:param right_table: The table being joined with. This can be a string of the table
name, a d... | [
"Joins",
"a",
"table",
"to",
"another",
"table",
"based",
"on",
"a",
"condition",
"and",
"adds",
"fields",
"from",
"the",
"joined",
"table",
"to",
"the",
"returned",
"fields",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L762-L848 | train | 59,567 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.join_left | def join_left(self, right_table=None, fields=None, condition=None, join_type='LEFT JOIN',
schema=None, left_table=None, extract_fields=True, prefix_fields=False,
field_prefix=None, allow_duplicates=False):
"""
Wrapper for ``self.join`` with a default join of 'LEFT JOI... | python | def join_left(self, right_table=None, fields=None, condition=None, join_type='LEFT JOIN',
schema=None, left_table=None, extract_fields=True, prefix_fields=False,
field_prefix=None, allow_duplicates=False):
"""
Wrapper for ``self.join`` with a default join of 'LEFT JOI... | [
"def",
"join_left",
"(",
"self",
",",
"right_table",
"=",
"None",
",",
"fields",
"=",
"None",
",",
"condition",
"=",
"None",
",",
"join_type",
"=",
"'LEFT JOIN'",
",",
"schema",
"=",
"None",
",",
"left_table",
"=",
"None",
",",
"extract_fields",
"=",
"Tr... | Wrapper for ``self.join`` with a default join of 'LEFT JOIN'
:type right_table: str or dict or :class:`Table <querybuilder.tables.Table>`
:param right_table: The table being joined with. This can be a string of the table
name, a dict of {'alias': table}, or a ``Table`` instance
:ty... | [
"Wrapper",
"for",
"self",
".",
"join",
"with",
"a",
"default",
"join",
"of",
"LEFT",
"JOIN"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L850-L910 | train | 59,568 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.where | def where(self, q=None, where_type='AND', **kwargs):
"""
Adds a where condition as a Q object to the query's ``Where`` instance.
:type q: :class:`Q <django:django.db.models.Q>`
:param q: A django ``Q`` instance. This will be added to the query's ``Where`` object. If no
Q obj... | python | def where(self, q=None, where_type='AND', **kwargs):
"""
Adds a where condition as a Q object to the query's ``Where`` instance.
:type q: :class:`Q <django:django.db.models.Q>`
:param q: A django ``Q`` instance. This will be added to the query's ``Where`` object. If no
Q obj... | [
"def",
"where",
"(",
"self",
",",
"q",
"=",
"None",
",",
"where_type",
"=",
"'AND'",
",",
"*",
"*",
"kwargs",
")",
":",
"# self.mark_dirty()",
"if",
"q",
"is",
"not",
"None",
":",
"self",
".",
"_where",
".",
"wheres",
".",
"add",
"(",
"q",
",",
"... | Adds a where condition as a Q object to the query's ``Where`` instance.
:type q: :class:`Q <django:django.db.models.Q>`
:param q: A django ``Q`` instance. This will be added to the query's ``Where`` object. If no
Q object is passed, the kwargs will be examined for params to be added to Q ob... | [
"Adds",
"a",
"where",
"condition",
"as",
"a",
"Q",
"object",
"to",
"the",
"query",
"s",
"Where",
"instance",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L912-L935 | train | 59,569 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.group_by | def group_by(self, field=None, table=None, allow_duplicates=False):
"""
Adds a group by clause to the query by adding a ``Group`` instance to the query's
groups list
:type field: str or dict or :class:`Field <querybuilder.fields.Field>`
:param field: This can be a string of a fi... | python | def group_by(self, field=None, table=None, allow_duplicates=False):
"""
Adds a group by clause to the query by adding a ``Group`` instance to the query's
groups list
:type field: str or dict or :class:`Field <querybuilder.fields.Field>`
:param field: This can be a string of a fi... | [
"def",
"group_by",
"(",
"self",
",",
"field",
"=",
"None",
",",
"table",
"=",
"None",
",",
"allow_duplicates",
"=",
"False",
")",
":",
"new_group_item",
"=",
"Group",
"(",
"field",
"=",
"field",
",",
"table",
"=",
"table",
",",
")",
"if",
"allow_duplic... | Adds a group by clause to the query by adding a ``Group`` instance to the query's
groups list
:type field: str or dict or :class:`Field <querybuilder.fields.Field>`
:param field: This can be a string of a field name, a dict of {'alias': field}, or
a ``Field`` instance
:type... | [
"Adds",
"a",
"group",
"by",
"clause",
"to",
"the",
"query",
"by",
"adding",
"a",
"Group",
"instance",
"to",
"the",
"query",
"s",
"groups",
"list"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L937-L966 | train | 59,570 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.order_by | def order_by(self, field=None, table=None, desc=False):
"""
Adds an order by clause to the query by adding a ``Sorter`` instance to the query's
sorters list
:type field: str or dict or :class:`Field <querybuilder.fields.Field>`
:param field: This can be a string of a field name,... | python | def order_by(self, field=None, table=None, desc=False):
"""
Adds an order by clause to the query by adding a ``Sorter`` instance to the query's
sorters list
:type field: str or dict or :class:`Field <querybuilder.fields.Field>`
:param field: This can be a string of a field name,... | [
"def",
"order_by",
"(",
"self",
",",
"field",
"=",
"None",
",",
"table",
"=",
"None",
",",
"desc",
"=",
"False",
")",
":",
"self",
".",
"sorters",
".",
"append",
"(",
"Sorter",
"(",
"field",
"=",
"field",
",",
"table",
"=",
"table",
",",
"desc",
... | Adds an order by clause to the query by adding a ``Sorter`` instance to the query's
sorters list
:type field: str or dict or :class:`Field <querybuilder.fields.Field>`
:param field: This can be a string of a field name, a dict of {'alias': field}, or
a ``Field`` instance
:t... | [
"Adds",
"an",
"order",
"by",
"clause",
"to",
"the",
"query",
"by",
"adding",
"a",
"Sorter",
"instance",
"to",
"the",
"query",
"s",
"sorters",
"list"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L968-L994 | train | 59,571 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.check_name_collisions | def check_name_collisions(self):
"""
Checks if there are any tables referenced by the same identifier and updated the
auto_alias accordingly. This is called when generating the sql for a query
and should only be called internally.
"""
table_index = 0
table_names =... | python | def check_name_collisions(self):
"""
Checks if there are any tables referenced by the same identifier and updated the
auto_alias accordingly. This is called when generating the sql for a query
and should only be called internally.
"""
table_index = 0
table_names =... | [
"def",
"check_name_collisions",
"(",
"self",
")",
":",
"table_index",
"=",
"0",
"table_names",
"=",
"{",
"}",
"for",
"table",
"in",
"self",
".",
"tables",
"+",
"self",
".",
"with_tables",
":",
"table_prefix",
"=",
"'T{0}'",
".",
"format",
"(",
"table_index... | Checks if there are any tables referenced by the same identifier and updated the
auto_alias accordingly. This is called when generating the sql for a query
and should only be called internally. | [
"Checks",
"if",
"there",
"are",
"any",
"tables",
"referenced",
"by",
"the",
"same",
"identifier",
"and",
"updated",
"the",
"auto_alias",
"accordingly",
".",
"This",
"is",
"called",
"when",
"generating",
"the",
"sql",
"for",
"a",
"query",
"and",
"should",
"on... | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1033-L1055 | train | 59,572 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.get_sql | def get_sql(self, debug=False, use_cache=True):
"""
Generates the sql for this query and returns the sql as a string.
:type debug: bool
:param debug: If True, the sql will be returned in a format that is easier to read and debug.
Defaults to False
:type use_cache: b... | python | def get_sql(self, debug=False, use_cache=True):
"""
Generates the sql for this query and returns the sql as a string.
:type debug: bool
:param debug: If True, the sql will be returned in a format that is easier to read and debug.
Defaults to False
:type use_cache: b... | [
"def",
"get_sql",
"(",
"self",
",",
"debug",
"=",
"False",
",",
"use_cache",
"=",
"True",
")",
":",
"# TODO: enable caching",
"# if self.sql and use_cache and not debug:",
"# return self.sql",
"# auto alias any naming collisions",
"self",
".",
"check_name_collisions",
"... | Generates the sql for this query and returns the sql as a string.
:type debug: bool
:param debug: If True, the sql will be returned in a format that is easier to read and debug.
Defaults to False
:type use_cache: bool
:param use_cache: If True, the query will returned the c... | [
"Generates",
"the",
"sql",
"for",
"this",
"query",
"and",
"returns",
"the",
"sql",
"as",
"a",
"string",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1064-L1104 | train | 59,573 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.get_update_sql | def get_update_sql(self, rows):
"""
Returns SQL UPDATE for rows ``rows``
.. code-block:: sql
UPDATE table_name
SET
field1 = new_values.field1
field2 = new_values.field2
FROM (
VALUES
(1, 'va... | python | def get_update_sql(self, rows):
"""
Returns SQL UPDATE for rows ``rows``
.. code-block:: sql
UPDATE table_name
SET
field1 = new_values.field1
field2 = new_values.field2
FROM (
VALUES
(1, 'va... | [
"def",
"get_update_sql",
"(",
"self",
",",
"rows",
")",
":",
"field_names",
"=",
"self",
".",
"get_field_names",
"(",
")",
"pk",
"=",
"field_names",
"[",
"0",
"]",
"update_field_names",
"=",
"field_names",
"[",
"1",
":",
"]",
"num_columns",
"=",
"len",
"... | Returns SQL UPDATE for rows ``rows``
.. code-block:: sql
UPDATE table_name
SET
field1 = new_values.field1
field2 = new_values.field2
FROM (
VALUES
(1, 'value1', 'value2'),
(2, 'value1', ... | [
"Returns",
"SQL",
"UPDATE",
"for",
"rows",
"rows"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1126-L1186 | train | 59,574 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.format_sql | def format_sql(self):
"""
Builds the sql in a format that is easy for humans to read and debug
:return: The formatted sql for this query
:rtype: str
"""
# TODO: finish adding the other parts of the sql generation
sql = ''
# build SELECT
select_se... | python | def format_sql(self):
"""
Builds the sql in a format that is easy for humans to read and debug
:return: The formatted sql for this query
:rtype: str
"""
# TODO: finish adding the other parts of the sql generation
sql = ''
# build SELECT
select_se... | [
"def",
"format_sql",
"(",
"self",
")",
":",
"# TODO: finish adding the other parts of the sql generation",
"sql",
"=",
"''",
"# build SELECT",
"select_segment",
"=",
"self",
".",
"build_select_fields",
"(",
")",
"select_segment",
"=",
"select_segment",
".",
"replace",
"... | Builds the sql in a format that is easy for humans to read and debug
:return: The formatted sql for this query
:rtype: str | [
"Builds",
"the",
"sql",
"in",
"a",
"format",
"that",
"is",
"easy",
"for",
"humans",
"to",
"read",
"and",
"debug"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1267-L1307 | train | 59,575 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.build_select_fields | def build_select_fields(self):
"""
Generates the sql for the SELECT portion of the query
:return: the SELECT portion of the query
:rtype: str
"""
field_sql = []
# get the field sql for each table
for table in self.tables:
field_sql += table.g... | python | def build_select_fields(self):
"""
Generates the sql for the SELECT portion of the query
:return: the SELECT portion of the query
:rtype: str
"""
field_sql = []
# get the field sql for each table
for table in self.tables:
field_sql += table.g... | [
"def",
"build_select_fields",
"(",
"self",
")",
":",
"field_sql",
"=",
"[",
"]",
"# get the field sql for each table",
"for",
"table",
"in",
"self",
".",
"tables",
":",
"field_sql",
"+=",
"table",
".",
"get_field_sql",
"(",
")",
"# get the field sql for each join ta... | Generates the sql for the SELECT portion of the query
:return: the SELECT portion of the query
:rtype: str | [
"Generates",
"the",
"sql",
"for",
"the",
"SELECT",
"portion",
"of",
"the",
"query"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1365-L1384 | train | 59,576 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.build_from_table | def build_from_table(self):
"""
Generates the sql for the FROM portion of the query
:return: the FROM portion of the query
:rtype: str
"""
table_parts = []
# get the table sql for each table
for table in self.tables:
sql = table.get_sql()
... | python | def build_from_table(self):
"""
Generates the sql for the FROM portion of the query
:return: the FROM portion of the query
:rtype: str
"""
table_parts = []
# get the table sql for each table
for table in self.tables:
sql = table.get_sql()
... | [
"def",
"build_from_table",
"(",
"self",
")",
":",
"table_parts",
"=",
"[",
"]",
"# get the table sql for each table",
"for",
"table",
"in",
"self",
".",
"tables",
":",
"sql",
"=",
"table",
".",
"get_sql",
"(",
")",
"if",
"len",
"(",
"sql",
")",
":",
"tab... | Generates the sql for the FROM portion of the query
:return: the FROM portion of the query
:rtype: str | [
"Generates",
"the",
"sql",
"for",
"the",
"FROM",
"portion",
"of",
"the",
"query"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1395-L1413 | train | 59,577 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.build_joins | def build_joins(self):
"""
Generates the sql for the JOIN portion of the query
:return: the JOIN portion of the query
:rtype: str
"""
join_parts = []
# get the sql for each join object
for join_item in self.joins:
join_parts.append(join_item.... | python | def build_joins(self):
"""
Generates the sql for the JOIN portion of the query
:return: the JOIN portion of the query
:rtype: str
"""
join_parts = []
# get the sql for each join object
for join_item in self.joins:
join_parts.append(join_item.... | [
"def",
"build_joins",
"(",
"self",
")",
":",
"join_parts",
"=",
"[",
"]",
"# get the sql for each join object",
"for",
"join_item",
"in",
"self",
".",
"joins",
":",
"join_parts",
".",
"append",
"(",
"join_item",
".",
"get_sql",
"(",
")",
")",
"# if there are a... | Generates the sql for the JOIN portion of the query
:return: the JOIN portion of the query
:rtype: str | [
"Generates",
"the",
"sql",
"for",
"the",
"JOIN",
"portion",
"of",
"the",
"query"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1415-L1432 | train | 59,578 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.build_groups | def build_groups(self):
"""
Generates the sql for the GROUP BY portion of the query
:return: the GROUP BY portion of the query
:rtype: str
"""
# check if there are any groupings
if len(self.groups):
groups = []
# get the group sql for eac... | python | def build_groups(self):
"""
Generates the sql for the GROUP BY portion of the query
:return: the GROUP BY portion of the query
:rtype: str
"""
# check if there are any groupings
if len(self.groups):
groups = []
# get the group sql for eac... | [
"def",
"build_groups",
"(",
"self",
")",
":",
"# check if there are any groupings",
"if",
"len",
"(",
"self",
".",
"groups",
")",
":",
"groups",
"=",
"[",
"]",
"# get the group sql for each grouping",
"for",
"group",
"in",
"self",
".",
"groups",
":",
"groups",
... | Generates the sql for the GROUP BY portion of the query
:return: the GROUP BY portion of the query
:rtype: str | [
"Generates",
"the",
"sql",
"for",
"the",
"GROUP",
"BY",
"portion",
"of",
"the",
"query"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1443-L1458 | train | 59,579 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.build_order_by | def build_order_by(self, use_alias=True):
"""
Generates the sql for the ORDER BY portion of the query
:type use_alias: bool
:param use_alias: If True, the alias for the field will be used in the order by.
This is an option before query windows do not use the alias. Defaults ... | python | def build_order_by(self, use_alias=True):
"""
Generates the sql for the ORDER BY portion of the query
:type use_alias: bool
:param use_alias: If True, the alias for the field will be used in the order by.
This is an option before query windows do not use the alias. Defaults ... | [
"def",
"build_order_by",
"(",
"self",
",",
"use_alias",
"=",
"True",
")",
":",
"# check if there are any sorters",
"if",
"len",
"(",
"self",
".",
"sorters",
")",
":",
"sorters",
"=",
"[",
"]",
"# get the sql for each sorter",
"for",
"sorter",
"in",
"self",
"."... | Generates the sql for the ORDER BY portion of the query
:type use_alias: bool
:param use_alias: If True, the alias for the field will be used in the order by.
This is an option before query windows do not use the alias. Defaults to True.
:return: the ORDER BY portion of the query
... | [
"Generates",
"the",
"sql",
"for",
"the",
"ORDER",
"BY",
"portion",
"of",
"the",
"query"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1460-L1479 | train | 59,580 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.find_table | def find_table(self, table):
"""
Finds a table by name or alias. The FROM tables and JOIN tables
are included in the search.
:type table: str or :class:`ModelBase <django:django.db.models.base.ModelBase>`
:param table: string of the table name or alias or a ModelBase instance
... | python | def find_table(self, table):
"""
Finds a table by name or alias. The FROM tables and JOIN tables
are included in the search.
:type table: str or :class:`ModelBase <django:django.db.models.base.ModelBase>`
:param table: string of the table name or alias or a ModelBase instance
... | [
"def",
"find_table",
"(",
"self",
",",
"table",
")",
":",
"table",
"=",
"TableFactory",
"(",
"table",
")",
"identifier",
"=",
"table",
".",
"get_identifier",
"(",
")",
"join_tables",
"=",
"[",
"join_item",
".",
"right_table",
"for",
"join_item",
"in",
"sel... | Finds a table by name or alias. The FROM tables and JOIN tables
are included in the search.
:type table: str or :class:`ModelBase <django:django.db.models.base.ModelBase>`
:param table: string of the table name or alias or a ModelBase instance
:return: The table if it is found, otherwi... | [
"Finds",
"a",
"table",
"by",
"name",
"or",
"alias",
".",
"The",
"FROM",
"tables",
"and",
"JOIN",
"tables",
"are",
"included",
"in",
"the",
"search",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1492-L1509 | train | 59,581 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.wrap | def wrap(self, alias=None):
"""
Wraps the query by selecting all fields from itself
:rtype: :class:`Query <querybuilder.query.Query>`
:return: The wrapped query
"""
field_names = self.get_field_names()
query = Query(self.connection).from_table(deepcopy(self), ali... | python | def wrap(self, alias=None):
"""
Wraps the query by selecting all fields from itself
:rtype: :class:`Query <querybuilder.query.Query>`
:return: The wrapped query
"""
field_names = self.get_field_names()
query = Query(self.connection).from_table(deepcopy(self), ali... | [
"def",
"wrap",
"(",
"self",
",",
"alias",
"=",
"None",
")",
":",
"field_names",
"=",
"self",
".",
"get_field_names",
"(",
")",
"query",
"=",
"Query",
"(",
"self",
".",
"connection",
")",
".",
"from_table",
"(",
"deepcopy",
"(",
"self",
")",
",",
"ali... | Wraps the query by selecting all fields from itself
:rtype: :class:`Query <querybuilder.query.Query>`
:return: The wrapped query | [
"Wraps",
"the",
"query",
"by",
"selecting",
"all",
"fields",
"from",
"itself"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1514-L1529 | train | 59,582 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.copy | def copy(self):
"""
Deeply copies everything in the query object except the connection object is shared
"""
connection = self.connection
del self.connection
copied_query = deepcopy(self)
copied_query.connection = connection
self.connection = connection
... | python | def copy(self):
"""
Deeply copies everything in the query object except the connection object is shared
"""
connection = self.connection
del self.connection
copied_query = deepcopy(self)
copied_query.connection = connection
self.connection = connection
... | [
"def",
"copy",
"(",
"self",
")",
":",
"connection",
"=",
"self",
".",
"connection",
"del",
"self",
".",
"connection",
"copied_query",
"=",
"deepcopy",
"(",
"self",
")",
"copied_query",
".",
"connection",
"=",
"connection",
"self",
".",
"connection",
"=",
"... | Deeply copies everything in the query object except the connection object is shared | [
"Deeply",
"copies",
"everything",
"in",
"the",
"query",
"object",
"except",
"the",
"connection",
"object",
"is",
"shared"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1531-L1540 | train | 59,583 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.get_args | def get_args(self):
"""
Gets the args for the query which will be escaped when being executed by the
db. All inner queries are inspected and their args are combined with this
query's args.
:return: all args for this query as a dict
:rtype: dict
"""
for ta... | python | def get_args(self):
"""
Gets the args for the query which will be escaped when being executed by the
db. All inner queries are inspected and their args are combined with this
query's args.
:return: all args for this query as a dict
:rtype: dict
"""
for ta... | [
"def",
"get_args",
"(",
"self",
")",
":",
"for",
"table",
"in",
"self",
".",
"tables",
"+",
"self",
".",
"with_tables",
":",
"if",
"type",
"(",
"table",
")",
"is",
"QueryTable",
":",
"self",
".",
"_where",
".",
"args",
".",
"update",
"(",
"table",
... | Gets the args for the query which will be escaped when being executed by the
db. All inner queries are inspected and their args are combined with this
query's args.
:return: all args for this query as a dict
:rtype: dict | [
"Gets",
"the",
"args",
"for",
"the",
"query",
"which",
"will",
"be",
"escaped",
"when",
"being",
"executed",
"by",
"the",
"db",
".",
"All",
"inner",
"queries",
"are",
"inspected",
"and",
"their",
"args",
"are",
"combined",
"with",
"this",
"query",
"s",
"... | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1542-L1555 | train | 59,584 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.explain | def explain(self, sql=None, sql_args=None):
"""
Runs EXPLAIN on this query
:type sql: str or None
:param sql: The sql to run EXPLAIN on. If None is specified, the query will
use ``self.get_sql()``
:type sql_args: dict or None
:param sql_args: A dictionary of... | python | def explain(self, sql=None, sql_args=None):
"""
Runs EXPLAIN on this query
:type sql: str or None
:param sql: The sql to run EXPLAIN on. If None is specified, the query will
use ``self.get_sql()``
:type sql_args: dict or None
:param sql_args: A dictionary of... | [
"def",
"explain",
"(",
"self",
",",
"sql",
"=",
"None",
",",
"sql_args",
"=",
"None",
")",
":",
"cursor",
"=",
"self",
".",
"get_cursor",
"(",
")",
"if",
"sql",
"is",
"None",
":",
"sql",
"=",
"self",
".",
"get_sql",
"(",
")",
"sql_args",
"=",
"se... | Runs EXPLAIN on this query
:type sql: str or None
:param sql: The sql to run EXPLAIN on. If None is specified, the query will
use ``self.get_sql()``
:type sql_args: dict or None
:param sql_args: A dictionary of the arguments to be escaped in the query. If None and
... | [
"Runs",
"EXPLAIN",
"on",
"this",
"query"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1557-L1581 | train | 59,585 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.select | def select(self, return_models=False, nest=False, bypass_safe_limit=False, sql=None, sql_args=None):
"""
Executes the SELECT statement and returns the rows as a list of dictionaries or a list of
model instances
:type return_models: bool
:param return_models: Set to True to retur... | python | def select(self, return_models=False, nest=False, bypass_safe_limit=False, sql=None, sql_args=None):
"""
Executes the SELECT statement and returns the rows as a list of dictionaries or a list of
model instances
:type return_models: bool
:param return_models: Set to True to retur... | [
"def",
"select",
"(",
"self",
",",
"return_models",
"=",
"False",
",",
"nest",
"=",
"False",
",",
"bypass_safe_limit",
"=",
"False",
",",
"sql",
"=",
"None",
",",
"sql_args",
"=",
"None",
")",
":",
"# Check if we need to set a safe limit",
"if",
"bypass_safe_l... | Executes the SELECT statement and returns the rows as a list of dictionaries or a list of
model instances
:type return_models: bool
:param return_models: Set to True to return a list of models instead of a list of dictionaries.
Defaults to False
:type nest: bool
:pa... | [
"Executes",
"the",
"SELECT",
"statement",
"and",
"returns",
"the",
"rows",
"as",
"a",
"list",
"of",
"dictionaries",
"or",
"a",
"list",
"of",
"model",
"instances"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1583-L1680 | train | 59,586 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.update | def update(self, rows):
"""
Updates records in the db
"""
if len(rows) == 0:
return
sql, sql_args = self.get_update_sql(rows)
# get the cursor to execute the query
cursor = self.get_cursor()
# execute the query
cursor.execute(sql, sq... | python | def update(self, rows):
"""
Updates records in the db
"""
if len(rows) == 0:
return
sql, sql_args = self.get_update_sql(rows)
# get the cursor to execute the query
cursor = self.get_cursor()
# execute the query
cursor.execute(sql, sq... | [
"def",
"update",
"(",
"self",
",",
"rows",
")",
":",
"if",
"len",
"(",
"rows",
")",
"==",
"0",
":",
"return",
"sql",
",",
"sql_args",
"=",
"self",
".",
"get_update_sql",
"(",
"rows",
")",
"# get the cursor to execute the query",
"cursor",
"=",
"self",
".... | Updates records in the db | [
"Updates",
"records",
"in",
"the",
"db"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1698-L1711 | train | 59,587 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.get_auto_field_name | def get_auto_field_name(self, model_class):
"""
If one of the unique_fields is the model's AutoField, return the field name, otherwise return None
"""
# Get auto field name (a model can only have one AutoField)
for field in model_class._meta.fields:
if isinstance(fiel... | python | def get_auto_field_name(self, model_class):
"""
If one of the unique_fields is the model's AutoField, return the field name, otherwise return None
"""
# Get auto field name (a model can only have one AutoField)
for field in model_class._meta.fields:
if isinstance(fiel... | [
"def",
"get_auto_field_name",
"(",
"self",
",",
"model_class",
")",
":",
"# Get auto field name (a model can only have one AutoField)",
"for",
"field",
"in",
"model_class",
".",
"_meta",
".",
"fields",
":",
"if",
"isinstance",
"(",
"field",
",",
"AutoField",
")",
":... | If one of the unique_fields is the model's AutoField, return the field name, otherwise return None | [
"If",
"one",
"of",
"the",
"unique_fields",
"is",
"the",
"model",
"s",
"AutoField",
"return",
"the",
"field",
"name",
"otherwise",
"return",
"None"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1713-L1722 | train | 59,588 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.upsert | def upsert(self, rows, unique_fields, update_fields, return_rows=False, return_models=False):
"""
Performs an upsert with the set of models defined in rows. If the unique field which is meant
to cause a conflict is an auto increment field, then the field should be excluded when its value is null... | python | def upsert(self, rows, unique_fields, update_fields, return_rows=False, return_models=False):
"""
Performs an upsert with the set of models defined in rows. If the unique field which is meant
to cause a conflict is an auto increment field, then the field should be excluded when its value is null... | [
"def",
"upsert",
"(",
"self",
",",
"rows",
",",
"unique_fields",
",",
"update_fields",
",",
"return_rows",
"=",
"False",
",",
"return_models",
"=",
"False",
")",
":",
"if",
"len",
"(",
"rows",
")",
"==",
"0",
":",
"return",
"ModelClass",
"=",
"self",
"... | Performs an upsert with the set of models defined in rows. If the unique field which is meant
to cause a conflict is an auto increment field, then the field should be excluded when its value is null.
In this case, an upsert will be performed followed by a bulk_create | [
"Performs",
"an",
"upsert",
"with",
"the",
"set",
"of",
"models",
"defined",
"in",
"rows",
".",
"If",
"the",
"unique",
"field",
"which",
"is",
"meant",
"to",
"cause",
"a",
"conflict",
"is",
"an",
"auto",
"increment",
"field",
"then",
"the",
"field",
"sho... | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1724-L1799 | train | 59,589 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.get_count_query | def get_count_query(self):
"""
Copies the query object and alters the field list and order by to do a more efficient count
"""
query_copy = self.copy()
if not query_copy.tables:
raise Exception('No tables specified to do a count')
for table in query_copy.tabl... | python | def get_count_query(self):
"""
Copies the query object and alters the field list and order by to do a more efficient count
"""
query_copy = self.copy()
if not query_copy.tables:
raise Exception('No tables specified to do a count')
for table in query_copy.tabl... | [
"def",
"get_count_query",
"(",
"self",
")",
":",
"query_copy",
"=",
"self",
".",
"copy",
"(",
")",
"if",
"not",
"query_copy",
".",
"tables",
":",
"raise",
"Exception",
"(",
"'No tables specified to do a count'",
")",
"for",
"table",
"in",
"query_copy",
".",
... | Copies the query object and alters the field list and order by to do a more efficient count | [
"Copies",
"the",
"query",
"object",
"and",
"alters",
"the",
"field",
"list",
"and",
"order",
"by",
"to",
"do",
"a",
"more",
"efficient",
"count"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1808-L1821 | train | 59,590 |
ambitioninc/django-query-builder | querybuilder/query.py | Query.count | def count(self, field='*'):
"""
Returns a COUNT of the query by wrapping the query and performing a COUNT
aggregate of the specified field
:param field: the field to pass to the COUNT aggregate. Defaults to '*'
:type field: str
:return: The number of rows that the query... | python | def count(self, field='*'):
"""
Returns a COUNT of the query by wrapping the query and performing a COUNT
aggregate of the specified field
:param field: the field to pass to the COUNT aggregate. Defaults to '*'
:type field: str
:return: The number of rows that the query... | [
"def",
"count",
"(",
"self",
",",
"field",
"=",
"'*'",
")",
":",
"rows",
"=",
"self",
".",
"get_count_query",
"(",
")",
".",
"select",
"(",
"bypass_safe_limit",
"=",
"True",
")",
"return",
"list",
"(",
"rows",
"[",
"0",
"]",
".",
"values",
"(",
")"... | Returns a COUNT of the query by wrapping the query and performing a COUNT
aggregate of the specified field
:param field: the field to pass to the COUNT aggregate. Defaults to '*'
:type field: str
:return: The number of rows that the query will return
:rtype: int | [
"Returns",
"a",
"COUNT",
"of",
"the",
"query",
"by",
"wrapping",
"the",
"query",
"and",
"performing",
"a",
"COUNT",
"aggregate",
"of",
"the",
"specified",
"field"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1823-L1835 | train | 59,591 |
ambitioninc/django-query-builder | querybuilder/query.py | Query._fetch_all_as_dict | def _fetch_all_as_dict(self, cursor):
"""
Iterates over the result set and converts each row to a dictionary
:return: A list of dictionaries where each row is a dictionary
:rtype: list of dict
"""
desc = cursor.description
return [
dict(zip([col[0] fo... | python | def _fetch_all_as_dict(self, cursor):
"""
Iterates over the result set and converts each row to a dictionary
:return: A list of dictionaries where each row is a dictionary
:rtype: list of dict
"""
desc = cursor.description
return [
dict(zip([col[0] fo... | [
"def",
"_fetch_all_as_dict",
"(",
"self",
",",
"cursor",
")",
":",
"desc",
"=",
"cursor",
".",
"description",
"return",
"[",
"dict",
"(",
"zip",
"(",
"[",
"col",
"[",
"0",
"]",
"for",
"col",
"in",
"desc",
"]",
",",
"row",
")",
")",
"for",
"row",
... | Iterates over the result set and converts each row to a dictionary
:return: A list of dictionaries where each row is a dictionary
:rtype: list of dict | [
"Iterates",
"over",
"the",
"result",
"set",
"and",
"converts",
"each",
"row",
"to",
"a",
"dictionary"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1901-L1912 | train | 59,592 |
ambitioninc/django-query-builder | querybuilder/query.py | QueryWindow.get_sql | def get_sql(self, debug=False, use_cache=True):
"""
Generates the sql for this query window and returns the sql as a string.
:type debug: bool
:param debug: If True, the sql will be returned in a format that is easier to read and debug.
Defaults to False
:type use_c... | python | def get_sql(self, debug=False, use_cache=True):
"""
Generates the sql for this query window and returns the sql as a string.
:type debug: bool
:param debug: If True, the sql will be returned in a format that is easier to read and debug.
Defaults to False
:type use_c... | [
"def",
"get_sql",
"(",
"self",
",",
"debug",
"=",
"False",
",",
"use_cache",
"=",
"True",
")",
":",
"# TODO: implement caching and debug",
"sql",
"=",
"''",
"sql",
"+=",
"self",
".",
"build_partition_by_fields",
"(",
")",
"sql",
"+=",
"self",
".",
"build_ord... | Generates the sql for this query window and returns the sql as a string.
:type debug: bool
:param debug: If True, the sql will be returned in a format that is easier to read and debug.
Defaults to False
:type use_cache: bool
:param use_cache: If True, the query will returne... | [
"Generates",
"the",
"sql",
"for",
"this",
"query",
"window",
"and",
"returns",
"the",
"sql",
"as",
"a",
"string",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1941-L1965 | train | 59,593 |
ambitioninc/django-query-builder | querybuilder/helpers.py | value_for_keypath | def value_for_keypath(dict, keypath):
"""
Returns the value of a keypath in a dictionary
if the keypath exists or None if the keypath
does not exist.
"""
if len(keypath) == 0:
return dict
keys = keypath.split('.')
value = dict
for key in keys:
if key in value:
... | python | def value_for_keypath(dict, keypath):
"""
Returns the value of a keypath in a dictionary
if the keypath exists or None if the keypath
does not exist.
"""
if len(keypath) == 0:
return dict
keys = keypath.split('.')
value = dict
for key in keys:
if key in value:
... | [
"def",
"value_for_keypath",
"(",
"dict",
",",
"keypath",
")",
":",
"if",
"len",
"(",
"keypath",
")",
"==",
"0",
":",
"return",
"dict",
"keys",
"=",
"keypath",
".",
"split",
"(",
"'.'",
")",
"value",
"=",
"dict",
"for",
"key",
"in",
"keys",
":",
"if... | Returns the value of a keypath in a dictionary
if the keypath exists or None if the keypath
does not exist. | [
"Returns",
"the",
"value",
"of",
"a",
"keypath",
"in",
"a",
"dictionary",
"if",
"the",
"keypath",
"exists",
"or",
"None",
"if",
"the",
"keypath",
"does",
"not",
"exist",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/helpers.py#L1-L19 | train | 59,594 |
ambitioninc/django-query-builder | querybuilder/helpers.py | set_value_for_keypath | def set_value_for_keypath(item, keypath, value, create_if_needed=False, delimeter='.'):
"""
Sets the value for a keypath in a dictionary
if the keypath exists. This modifies the
original dictionary.
"""
if len(keypath) == 0:
return None
keys = keypath.split(delimeter)
if len(ke... | python | def set_value_for_keypath(item, keypath, value, create_if_needed=False, delimeter='.'):
"""
Sets the value for a keypath in a dictionary
if the keypath exists. This modifies the
original dictionary.
"""
if len(keypath) == 0:
return None
keys = keypath.split(delimeter)
if len(ke... | [
"def",
"set_value_for_keypath",
"(",
"item",
",",
"keypath",
",",
"value",
",",
"create_if_needed",
"=",
"False",
",",
"delimeter",
"=",
"'.'",
")",
":",
"if",
"len",
"(",
"keypath",
")",
"==",
"0",
":",
"return",
"None",
"keys",
"=",
"keypath",
".",
"... | Sets the value for a keypath in a dictionary
if the keypath exists. This modifies the
original dictionary. | [
"Sets",
"the",
"value",
"for",
"a",
"keypath",
"in",
"a",
"dictionary",
"if",
"the",
"keypath",
"exists",
".",
"This",
"modifies",
"the",
"original",
"dictionary",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/helpers.py#L22-L53 | train | 59,595 |
ambitioninc/django-query-builder | querybuilder/fields.py | Field.get_alias | def get_alias(self):
"""
Gets the alias for the field or the auto_alias if one is set.
If there isn't any kind of alias, None is returned.
:return: The field alias, auto_alias, or None
:rtype: str or None
"""
alias = None
if self.alias:
alias ... | python | def get_alias(self):
"""
Gets the alias for the field or the auto_alias if one is set.
If there isn't any kind of alias, None is returned.
:return: The field alias, auto_alias, or None
:rtype: str or None
"""
alias = None
if self.alias:
alias ... | [
"def",
"get_alias",
"(",
"self",
")",
":",
"alias",
"=",
"None",
"if",
"self",
".",
"alias",
":",
"alias",
"=",
"self",
".",
"alias",
"elif",
"self",
".",
"auto_alias",
":",
"alias",
"=",
"self",
".",
"auto_alias",
"if",
"self",
".",
"table",
"and",
... | Gets the alias for the field or the auto_alias if one is set.
If there isn't any kind of alias, None is returned.
:return: The field alias, auto_alias, or None
:rtype: str or None | [
"Gets",
"the",
"alias",
"for",
"the",
"field",
"or",
"the",
"auto_alias",
"if",
"one",
"is",
"set",
".",
"If",
"there",
"isn",
"t",
"any",
"kind",
"of",
"alias",
"None",
"is",
"returned",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/fields.py#L123-L144 | train | 59,596 |
ambitioninc/django-query-builder | querybuilder/fields.py | Field.get_select_sql | def get_select_sql(self):
"""
Gets the SELECT field portion for the field without the alias. If the field
has a table, it will be included here like table.field
:return: Gets the SELECT field portion for the field without the alias
:rtype: str
"""
if self.table:
... | python | def get_select_sql(self):
"""
Gets the SELECT field portion for the field without the alias. If the field
has a table, it will be included here like table.field
:return: Gets the SELECT field portion for the field without the alias
:rtype: str
"""
if self.table:
... | [
"def",
"get_select_sql",
"(",
"self",
")",
":",
"if",
"self",
".",
"table",
":",
"return",
"'{0}.{1}'",
".",
"format",
"(",
"self",
".",
"table",
".",
"get_identifier",
"(",
")",
",",
"self",
".",
"name",
")",
"return",
"'{0}'",
".",
"format",
"(",
"... | Gets the SELECT field portion for the field without the alias. If the field
has a table, it will be included here like table.field
:return: Gets the SELECT field portion for the field without the alias
:rtype: str | [
"Gets",
"the",
"SELECT",
"field",
"portion",
"for",
"the",
"field",
"without",
"the",
"alias",
".",
"If",
"the",
"field",
"has",
"a",
"table",
"it",
"will",
"be",
"included",
"here",
"like",
"table",
".",
"field"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/fields.py#L159-L169 | train | 59,597 |
ambitioninc/django-query-builder | querybuilder/fields.py | MultiField.set_table | def set_table(self, table):
"""
Setter for the table of this field. Also sets the inner field's table.
"""
super(MultiField, self).set_table(table)
if self.field and self.field.table is None:
self.field.set_table(self.table) | python | def set_table(self, table):
"""
Setter for the table of this field. Also sets the inner field's table.
"""
super(MultiField, self).set_table(table)
if self.field and self.field.table is None:
self.field.set_table(self.table) | [
"def",
"set_table",
"(",
"self",
",",
"table",
")",
":",
"super",
"(",
"MultiField",
",",
"self",
")",
".",
"set_table",
"(",
"table",
")",
"if",
"self",
".",
"field",
"and",
"self",
".",
"field",
".",
"table",
"is",
"None",
":",
"self",
".",
"fiel... | Setter for the table of this field. Also sets the inner field's table. | [
"Setter",
"for",
"the",
"table",
"of",
"this",
"field",
".",
"Also",
"sets",
"the",
"inner",
"field",
"s",
"table",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/fields.py#L247-L253 | train | 59,598 |
ambitioninc/django-query-builder | querybuilder/fields.py | DatePartField.add_to_table | def add_to_table(self, field, alias, add_group=False):
"""
Adds this field to the field's table and optionally group by it
:param field: The field to add to the table
:type field: str or :class:`Field <querybuilder.fields.Field>`
:param alias: The alias for the field
:t... | python | def add_to_table(self, field, alias, add_group=False):
"""
Adds this field to the field's table and optionally group by it
:param field: The field to add to the table
:type field: str or :class:`Field <querybuilder.fields.Field>`
:param alias: The alias for the field
:t... | [
"def",
"add_to_table",
"(",
"self",
",",
"field",
",",
"alias",
",",
"add_group",
"=",
"False",
")",
":",
"self",
".",
"table",
".",
"add_field",
"(",
"{",
"alias",
":",
"field",
"}",
")",
"if",
"add_group",
":",
"self",
".",
"table",
".",
"owner",
... | Adds this field to the field's table and optionally group by it
:param field: The field to add to the table
:type field: str or :class:`Field <querybuilder.fields.Field>`
:param alias: The alias for the field
:type alias: str
:param add_group: Whether or not the table should g... | [
"Adds",
"this",
"field",
"to",
"the",
"field",
"s",
"table",
"and",
"optionally",
"group",
"by",
"it"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/fields.py#L793-L810 | train | 59,599 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.