repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
santoshphilip/eppy
eppy/idf_helpers.py
getobject_use_prevfield
def getobject_use_prevfield(idf, idfobject, fieldname): """field=object_name, prev_field=object_type. Return the object""" if not fieldname.endswith("Name"): return None # test if prevfieldname ends with "Object_Type" fdnames = idfobject.fieldnames ifieldname = fdnames.index(fieldname) p...
python
def getobject_use_prevfield(idf, idfobject, fieldname): """field=object_name, prev_field=object_type. Return the object""" if not fieldname.endswith("Name"): return None # test if prevfieldname ends with "Object_Type" fdnames = idfobject.fieldnames ifieldname = fdnames.index(fieldname) p...
[ "def", "getobject_use_prevfield", "(", "idf", ",", "idfobject", ",", "fieldname", ")", ":", "if", "not", "fieldname", ".", "endswith", "(", "\"Name\"", ")", ":", "return", "None", "# test if prevfieldname ends with \"Object_Type\"", "fdnames", "=", "idfobject", ".",...
field=object_name, prev_field=object_type. Return the object
[ "field", "=", "object_name", "prev_field", "=", "object_type", ".", "Return", "the", "object" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/idf_helpers.py#L44-L60
santoshphilip/eppy
eppy/idf_helpers.py
getidfkeyswithnodes
def getidfkeyswithnodes(): """return a list of keys of idfobjects that hve 'None Name' fields""" idf = IDF(StringIO("")) keys = idfobjectkeys(idf) keysfieldnames = ((key, idf.newidfobject(key.upper()).fieldnames) for key in keys) keysnodefdnames = ((key, (name for name in fdnames ...
python
def getidfkeyswithnodes(): """return a list of keys of idfobjects that hve 'None Name' fields""" idf = IDF(StringIO("")) keys = idfobjectkeys(idf) keysfieldnames = ((key, idf.newidfobject(key.upper()).fieldnames) for key in keys) keysnodefdnames = ((key, (name for name in fdnames ...
[ "def", "getidfkeyswithnodes", "(", ")", ":", "idf", "=", "IDF", "(", "StringIO", "(", "\"\"", ")", ")", "keys", "=", "idfobjectkeys", "(", "idf", ")", "keysfieldnames", "=", "(", "(", "key", ",", "idf", ".", "newidfobject", "(", "key", ".", "upper", ...
return a list of keys of idfobjects that hve 'None Name' fields
[ "return", "a", "list", "of", "keys", "of", "idfobjects", "that", "hve", "None", "Name", "fields" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/idf_helpers.py#L62-L72
santoshphilip/eppy
eppy/idf_helpers.py
getobjectswithnode
def getobjectswithnode(idf, nodekeys, nodename): """return all objects that mention this node name""" keys = nodekeys # TODO getidfkeyswithnodes needs to be done only once. take out of here listofidfobjects = (idf.idfobjects[key.upper()] for key in keys if idf.idfobjects[key.upper()]) ...
python
def getobjectswithnode(idf, nodekeys, nodename): """return all objects that mention this node name""" keys = nodekeys # TODO getidfkeyswithnodes needs to be done only once. take out of here listofidfobjects = (idf.idfobjects[key.upper()] for key in keys if idf.idfobjects[key.upper()]) ...
[ "def", "getobjectswithnode", "(", "idf", ",", "nodekeys", ",", "nodename", ")", ":", "keys", "=", "nodekeys", "# TODO getidfkeyswithnodes needs to be done only once. take out of here", "listofidfobjects", "=", "(", "idf", ".", "idfobjects", "[", "key", ".", "upper", "...
return all objects that mention this node name
[ "return", "all", "objects", "that", "mention", "this", "node", "name" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/idf_helpers.py#L74-L92
santoshphilip/eppy
eppy/idf_helpers.py
name2idfobject
def name2idfobject(idf, groupnamess=None, objkeys=None, **kwargs): """return the object, if the Name or some other field is known. send filed in **kwargs as Name='a name', Roughness='smooth' Returns the first find (field search is unordered) objkeys -> if objkeys=['ZONE', 'Material'], search only those ...
python
def name2idfobject(idf, groupnamess=None, objkeys=None, **kwargs): """return the object, if the Name or some other field is known. send filed in **kwargs as Name='a name', Roughness='smooth' Returns the first find (field search is unordered) objkeys -> if objkeys=['ZONE', 'Material'], search only those ...
[ "def", "name2idfobject", "(", "idf", ",", "groupnamess", "=", "None", ",", "objkeys", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# TODO : this is a very slow search. revist to speed it up.", "if", "not", "objkeys", ":", "objkeys", "=", "idfobjectkeys", "(", ...
return the object, if the Name or some other field is known. send filed in **kwargs as Name='a name', Roughness='smooth' Returns the first find (field search is unordered) objkeys -> if objkeys=['ZONE', 'Material'], search only those groupnames -> not yet coded
[ "return", "the", "object", "if", "the", "Name", "or", "some", "other", "field", "is", "known", ".", "send", "filed", "in", "**", "kwargs", "as", "Name", "=", "a", "name", "Roughness", "=", "smooth", "Returns", "the", "first", "find", "(", "field", "sea...
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/idf_helpers.py#L94-L111
santoshphilip/eppy
eppy/idf_helpers.py
getidfobjectlist
def getidfobjectlist(idf): """return a list of all idfobjects in idf""" idfobjects = idf.idfobjects # idfobjlst = [idfobjects[key] for key in idfobjects if idfobjects[key]] idfobjlst = [idfobjects[key] for key in idf.model.dtls if idfobjects[key]] # `for key in idf.model.dtls` maintains the or...
python
def getidfobjectlist(idf): """return a list of all idfobjects in idf""" idfobjects = idf.idfobjects # idfobjlst = [idfobjects[key] for key in idfobjects if idfobjects[key]] idfobjlst = [idfobjects[key] for key in idf.model.dtls if idfobjects[key]] # `for key in idf.model.dtls` maintains the or...
[ "def", "getidfobjectlist", "(", "idf", ")", ":", "idfobjects", "=", "idf", ".", "idfobjects", "# idfobjlst = [idfobjects[key] for key in idfobjects if idfobjects[key]]", "idfobjlst", "=", "[", "idfobjects", "[", "key", "]", "for", "key", "in", "idf", ".", "model", "...
return a list of all idfobjects in idf
[ "return", "a", "list", "of", "all", "idfobjects", "in", "idf" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/idf_helpers.py#L113-L122
santoshphilip/eppy
eppy/idf_helpers.py
copyidfintoidf
def copyidfintoidf(toidf, fromidf): """copy fromidf completely into toidf""" idfobjlst = getidfobjectlist(fromidf) for idfobj in idfobjlst: toidf.copyidfobject(idfobj)
python
def copyidfintoidf(toidf, fromidf): """copy fromidf completely into toidf""" idfobjlst = getidfobjectlist(fromidf) for idfobj in idfobjlst: toidf.copyidfobject(idfobj)
[ "def", "copyidfintoidf", "(", "toidf", ",", "fromidf", ")", ":", "idfobjlst", "=", "getidfobjectlist", "(", "fromidf", ")", "for", "idfobj", "in", "idfobjlst", ":", "toidf", ".", "copyidfobject", "(", "idfobj", ")" ]
copy fromidf completely into toidf
[ "copy", "fromidf", "completely", "into", "toidf" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/idf_helpers.py#L124-L128
santoshphilip/eppy
eppy/useful_scripts/idfdiff_missing.py
idfdiffs
def idfdiffs(idf1, idf2): """return the diffs between the two idfs""" thediffs = {} keys = idf1.model.dtls # undocumented variable for akey in keys: idfobjs1 = idf1.idfobjects[akey] idfobjs2 = idf2.idfobjects[akey] names = set([getobjname(i) for i in idfobjs1] + ...
python
def idfdiffs(idf1, idf2): """return the diffs between the two idfs""" thediffs = {} keys = idf1.model.dtls # undocumented variable for akey in keys: idfobjs1 = idf1.idfobjects[akey] idfobjs2 = idf2.idfobjects[akey] names = set([getobjname(i) for i in idfobjs1] + ...
[ "def", "idfdiffs", "(", "idf1", ",", "idf2", ")", ":", "thediffs", "=", "{", "}", "keys", "=", "idf1", ".", "model", ".", "dtls", "# undocumented variable", "for", "akey", "in", "keys", ":", "idfobjs1", "=", "idf1", ".", "idfobjects", "[", "akey", "]",...
return the diffs between the two idfs
[ "return", "the", "diffs", "between", "the", "two", "idfs" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/useful_scripts/idfdiff_missing.py#L92-L127
santoshphilip/eppy
eppy/useful_scripts/autosize.py
autosize_fieldname
def autosize_fieldname(idfobject): """return autsizeable field names in idfobject""" # undocumented stuff in this code return [fname for (fname, dct) in zip(idfobject.objls, idfobject['objidd']) if 'autosizable' in dct]
python
def autosize_fieldname(idfobject): """return autsizeable field names in idfobject""" # undocumented stuff in this code return [fname for (fname, dct) in zip(idfobject.objls, idfobject['objidd']) if 'autosizable' in dct]
[ "def", "autosize_fieldname", "(", "idfobject", ")", ":", "# undocumented stuff in this code", "return", "[", "fname", "for", "(", "fname", ",", "dct", ")", "in", "zip", "(", "idfobject", ".", "objls", ",", "idfobject", "[", "'objidd'", "]", ")", "if", "'auto...
return autsizeable field names in idfobject
[ "return", "autsizeable", "field", "names", "in", "idfobject" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/useful_scripts/autosize.py#L36-L41
santoshphilip/eppy
eppy/EPlusInterfaceFunctions/iddgroups.py
idd2group
def idd2group(fhandle): """wrapper for iddtxt2groups""" try: txt = fhandle.read() return iddtxt2groups(txt) except AttributeError as e: txt = open(fhandle, 'r').read() return iddtxt2groups(txt)
python
def idd2group(fhandle): """wrapper for iddtxt2groups""" try: txt = fhandle.read() return iddtxt2groups(txt) except AttributeError as e: txt = open(fhandle, 'r').read() return iddtxt2groups(txt)
[ "def", "idd2group", "(", "fhandle", ")", ":", "try", ":", "txt", "=", "fhandle", ".", "read", "(", ")", "return", "iddtxt2groups", "(", "txt", ")", "except", "AttributeError", "as", "e", ":", "txt", "=", "open", "(", "fhandle", ",", "'r'", ")", ".", ...
wrapper for iddtxt2groups
[ "wrapper", "for", "iddtxt2groups" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/EPlusInterfaceFunctions/iddgroups.py#L27-L34
santoshphilip/eppy
eppy/EPlusInterfaceFunctions/iddgroups.py
idd2grouplist
def idd2grouplist(fhandle): """wrapper for iddtxt2grouplist""" try: txt = fhandle.read() return iddtxt2grouplist(txt) except AttributeError as e: txt = open(fhandle, 'r').read() return iddtxt2grouplist(txt)
python
def idd2grouplist(fhandle): """wrapper for iddtxt2grouplist""" try: txt = fhandle.read() return iddtxt2grouplist(txt) except AttributeError as e: txt = open(fhandle, 'r').read() return iddtxt2grouplist(txt)
[ "def", "idd2grouplist", "(", "fhandle", ")", ":", "try", ":", "txt", "=", "fhandle", ".", "read", "(", ")", "return", "iddtxt2grouplist", "(", "txt", ")", "except", "AttributeError", "as", "e", ":", "txt", "=", "open", "(", "fhandle", ",", "'r'", ")", ...
wrapper for iddtxt2grouplist
[ "wrapper", "for", "iddtxt2grouplist" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/EPlusInterfaceFunctions/iddgroups.py#L36-L43
santoshphilip/eppy
eppy/EPlusInterfaceFunctions/iddgroups.py
iddtxt2groups
def iddtxt2groups(txt): """extract the groups from the idd file""" try: txt = txt.decode('ISO-8859-2') except AttributeError as e: pass # for python 3 txt = nocomment(txt, '!') txt = txt.replace("\\group", "!-group") # retains group in next line txt = nocomment(txt, '\\') # remov...
python
def iddtxt2groups(txt): """extract the groups from the idd file""" try: txt = txt.decode('ISO-8859-2') except AttributeError as e: pass # for python 3 txt = nocomment(txt, '!') txt = txt.replace("\\group", "!-group") # retains group in next line txt = nocomment(txt, '\\') # remov...
[ "def", "iddtxt2groups", "(", "txt", ")", ":", "try", ":", "txt", "=", "txt", ".", "decode", "(", "'ISO-8859-2'", ")", "except", "AttributeError", "as", "e", ":", "pass", "# for python 3", "txt", "=", "nocomment", "(", "txt", ",", "'!'", ")", "txt", "="...
extract the groups from the idd file
[ "extract", "the", "groups", "from", "the", "idd", "file" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/EPlusInterfaceFunctions/iddgroups.py#L46-L82
santoshphilip/eppy
eppy/EPlusInterfaceFunctions/iddgroups.py
iddtxt2grouplist
def iddtxt2grouplist(txt): """return a list of group names the list in the same order as the idf objects in idd file """ def makenone(astr): if astr == 'None': return None else: return astr txt = nocomment(txt, '!') txt = txt.replace("\\group", "!-group")...
python
def iddtxt2grouplist(txt): """return a list of group names the list in the same order as the idf objects in idd file """ def makenone(astr): if astr == 'None': return None else: return astr txt = nocomment(txt, '!') txt = txt.replace("\\group", "!-group")...
[ "def", "iddtxt2grouplist", "(", "txt", ")", ":", "def", "makenone", "(", "astr", ")", ":", "if", "astr", "==", "'None'", ":", "return", "None", "else", ":", "return", "astr", "txt", "=", "nocomment", "(", "txt", ",", "'!'", ")", "txt", "=", "txt", ...
return a list of group names the list in the same order as the idf objects in idd file
[ "return", "a", "list", "of", "group", "names", "the", "list", "in", "the", "same", "order", "as", "the", "idf", "objects", "in", "idd", "file" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/EPlusInterfaceFunctions/iddgroups.py#L84-L129
santoshphilip/eppy
eppy/EPlusInterfaceFunctions/iddgroups.py
group2commlst
def group2commlst(commlst, glist): """add group info to commlst""" for (gname, objname), commitem in zip(glist, commlst): newitem1 = "group %s" % (gname, ) newitem2 = "idfobj %s" % (objname, ) commitem[0].insert(0, newitem1) commitem[0].insert(1, newitem2) return commlst
python
def group2commlst(commlst, glist): """add group info to commlst""" for (gname, objname), commitem in zip(glist, commlst): newitem1 = "group %s" % (gname, ) newitem2 = "idfobj %s" % (objname, ) commitem[0].insert(0, newitem1) commitem[0].insert(1, newitem2) return commlst
[ "def", "group2commlst", "(", "commlst", ",", "glist", ")", ":", "for", "(", "gname", ",", "objname", ")", ",", "commitem", "in", "zip", "(", "glist", ",", "commlst", ")", ":", "newitem1", "=", "\"group %s\"", "%", "(", "gname", ",", ")", "newitem2", ...
add group info to commlst
[ "add", "group", "info", "to", "commlst" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/EPlusInterfaceFunctions/iddgroups.py#L131-L138
santoshphilip/eppy
eppy/EPlusInterfaceFunctions/iddgroups.py
group2commdct
def group2commdct(commdct, glist): """add group info tocomdct""" for (gname, objname), commitem in zip(glist, commdct): commitem[0]['group'] = gname commitem[0]['idfobj'] = objname return commdct
python
def group2commdct(commdct, glist): """add group info tocomdct""" for (gname, objname), commitem in zip(glist, commdct): commitem[0]['group'] = gname commitem[0]['idfobj'] = objname return commdct
[ "def", "group2commdct", "(", "commdct", ",", "glist", ")", ":", "for", "(", "gname", ",", "objname", ")", ",", "commitem", "in", "zip", "(", "glist", ",", "commdct", ")", ":", "commitem", "[", "0", "]", "[", "'group'", "]", "=", "gname", "commitem", ...
add group info tocomdct
[ "add", "group", "info", "tocomdct" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/EPlusInterfaceFunctions/iddgroups.py#L140-L145
santoshphilip/eppy
eppy/EPlusInterfaceFunctions/iddgroups.py
commdct2grouplist
def commdct2grouplist(gcommdct): """extract embedded group data from commdct. return gdict -> {g1:[obj1, obj2, obj3], g2:[obj4, ..]}""" gdict = {} for objidd in gcommdct: group = objidd[0]['group'] objname = objidd[0]['idfobj'] if group in gdict: gdict[group].append(o...
python
def commdct2grouplist(gcommdct): """extract embedded group data from commdct. return gdict -> {g1:[obj1, obj2, obj3], g2:[obj4, ..]}""" gdict = {} for objidd in gcommdct: group = objidd[0]['group'] objname = objidd[0]['idfobj'] if group in gdict: gdict[group].append(o...
[ "def", "commdct2grouplist", "(", "gcommdct", ")", ":", "gdict", "=", "{", "}", "for", "objidd", "in", "gcommdct", ":", "group", "=", "objidd", "[", "0", "]", "[", "'group'", "]", "objname", "=", "objidd", "[", "0", "]", "[", "'idfobj'", "]", "if", ...
extract embedded group data from commdct. return gdict -> {g1:[obj1, obj2, obj3], g2:[obj4, ..]}
[ "extract", "embedded", "group", "data", "from", "commdct", ".", "return", "gdict", "-", ">", "{", "g1", ":", "[", "obj1", "obj2", "obj3", "]", "g2", ":", "[", "obj4", "..", "]", "}" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/EPlusInterfaceFunctions/iddgroups.py#L147-L158
santoshphilip/eppy
eppy/hvacbuilder.py
flattencopy
def flattencopy(lst): """flatten and return a copy of the list indefficient on large lists""" # modified from # http://stackoverflow.com/questions/2158395/flatten-an-irregular-list-of-lists-in-python thelist = copy.deepcopy(lst) list_is_nested = True while list_is_nested: # outer loop ...
python
def flattencopy(lst): """flatten and return a copy of the list indefficient on large lists""" # modified from # http://stackoverflow.com/questions/2158395/flatten-an-irregular-list-of-lists-in-python thelist = copy.deepcopy(lst) list_is_nested = True while list_is_nested: # outer loop ...
[ "def", "flattencopy", "(", "lst", ")", ":", "# modified from", "# http://stackoverflow.com/questions/2158395/flatten-an-irregular-list-of-lists-in-python", "thelist", "=", "copy", ".", "deepcopy", "(", "lst", ")", "list_is_nested", "=", "True", "while", "list_is_nested", ":...
flatten and return a copy of the list indefficient on large lists
[ "flatten", "and", "return", "a", "copy", "of", "the", "list", "indefficient", "on", "large", "lists" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L52-L70
santoshphilip/eppy
eppy/hvacbuilder.py
makepipecomponent
def makepipecomponent(idf, pname): """make a pipe component generate inlet outlet names""" apipe = idf.newidfobject("Pipe:Adiabatic".upper(), Name=pname) apipe.Inlet_Node_Name = "%s_inlet" % (pname,) apipe.Outlet_Node_Name = "%s_outlet" % (pname,) return apipe
python
def makepipecomponent(idf, pname): """make a pipe component generate inlet outlet names""" apipe = idf.newidfobject("Pipe:Adiabatic".upper(), Name=pname) apipe.Inlet_Node_Name = "%s_inlet" % (pname,) apipe.Outlet_Node_Name = "%s_outlet" % (pname,) return apipe
[ "def", "makepipecomponent", "(", "idf", ",", "pname", ")", ":", "apipe", "=", "idf", ".", "newidfobject", "(", "\"Pipe:Adiabatic\"", ".", "upper", "(", ")", ",", "Name", "=", "pname", ")", "apipe", ".", "Inlet_Node_Name", "=", "\"%s_inlet\"", "%", "(", "...
make a pipe component generate inlet outlet names
[ "make", "a", "pipe", "component", "generate", "inlet", "outlet", "names" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L72-L78
santoshphilip/eppy
eppy/hvacbuilder.py
makeductcomponent
def makeductcomponent(idf, dname): """make a duct component generate inlet outlet names""" aduct = idf.newidfobject("duct".upper(), Name=dname) aduct.Inlet_Node_Name = "%s_inlet" % (dname,) aduct.Outlet_Node_Name = "%s_outlet" % (dname,) return aduct
python
def makeductcomponent(idf, dname): """make a duct component generate inlet outlet names""" aduct = idf.newidfobject("duct".upper(), Name=dname) aduct.Inlet_Node_Name = "%s_inlet" % (dname,) aduct.Outlet_Node_Name = "%s_outlet" % (dname,) return aduct
[ "def", "makeductcomponent", "(", "idf", ",", "dname", ")", ":", "aduct", "=", "idf", ".", "newidfobject", "(", "\"duct\"", ".", "upper", "(", ")", ",", "Name", "=", "dname", ")", "aduct", ".", "Inlet_Node_Name", "=", "\"%s_inlet\"", "%", "(", "dname", ...
make a duct component generate inlet outlet names
[ "make", "a", "duct", "component", "generate", "inlet", "outlet", "names" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L80-L86
santoshphilip/eppy
eppy/hvacbuilder.py
makepipebranch
def makepipebranch(idf, bname): """make a branch with a pipe use standard inlet outlet names""" # make the pipe component first pname = "%s_pipe" % (bname,) apipe = makepipecomponent(idf, pname) # now make the branch with the pipe in it abranch = idf.newidfobject("BRANCH", Name=bname) ab...
python
def makepipebranch(idf, bname): """make a branch with a pipe use standard inlet outlet names""" # make the pipe component first pname = "%s_pipe" % (bname,) apipe = makepipecomponent(idf, pname) # now make the branch with the pipe in it abranch = idf.newidfobject("BRANCH", Name=bname) ab...
[ "def", "makepipebranch", "(", "idf", ",", "bname", ")", ":", "# make the pipe component first", "pname", "=", "\"%s_pipe\"", "%", "(", "bname", ",", ")", "apipe", "=", "makepipecomponent", "(", "idf", ",", "pname", ")", "# now make the branch with the pipe in it", ...
make a branch with a pipe use standard inlet outlet names
[ "make", "a", "branch", "with", "a", "pipe", "use", "standard", "inlet", "outlet", "names" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L88-L101
santoshphilip/eppy
eppy/hvacbuilder.py
makeductbranch
def makeductbranch(idf, bname): """make a branch with a duct use standard inlet outlet names""" # make the duct component first pname = "%s_duct" % (bname,) aduct = makeductcomponent(idf, pname) # now make the branch with the duct in it abranch = idf.newidfobject("BRANCH", Name=bname) ab...
python
def makeductbranch(idf, bname): """make a branch with a duct use standard inlet outlet names""" # make the duct component first pname = "%s_duct" % (bname,) aduct = makeductcomponent(idf, pname) # now make the branch with the duct in it abranch = idf.newidfobject("BRANCH", Name=bname) ab...
[ "def", "makeductbranch", "(", "idf", ",", "bname", ")", ":", "# make the duct component first", "pname", "=", "\"%s_duct\"", "%", "(", "bname", ",", ")", "aduct", "=", "makeductcomponent", "(", "idf", ",", "pname", ")", "# now make the branch with the duct in it", ...
make a branch with a duct use standard inlet outlet names
[ "make", "a", "branch", "with", "a", "duct", "use", "standard", "inlet", "outlet", "names" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L103-L116
santoshphilip/eppy
eppy/hvacbuilder.py
getbranchcomponents
def getbranchcomponents(idf, branch, utest=False): """get the components of the branch""" fobjtype = 'Component_%s_Object_Type' fobjname = 'Component_%s_Name' complist = [] for i in range(1, 100000): try: objtype = branch[fobjtype % (i,)] if objtype.strip() == '': ...
python
def getbranchcomponents(idf, branch, utest=False): """get the components of the branch""" fobjtype = 'Component_%s_Object_Type' fobjname = 'Component_%s_Name' complist = [] for i in range(1, 100000): try: objtype = branch[fobjtype % (i,)] if objtype.strip() == '': ...
[ "def", "getbranchcomponents", "(", "idf", ",", "branch", ",", "utest", "=", "False", ")", ":", "fobjtype", "=", "'Component_%s_Object_Type'", "fobjname", "=", "'Component_%s_Name'", "complist", "=", "[", "]", "for", "i", "in", "range", "(", "1", ",", "100000...
get the components of the branch
[ "get", "the", "components", "of", "the", "branch" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L118-L135
santoshphilip/eppy
eppy/hvacbuilder.py
renamenodes
def renamenodes(idf, fieldtype): """rename all the changed nodes""" renameds = [] for key in idf.model.dtls: for idfobject in idf.idfobjects[key]: for fieldvalue in idfobject.obj: if type(fieldvalue) is list: if fieldvalue not in renameds: ...
python
def renamenodes(idf, fieldtype): """rename all the changed nodes""" renameds = [] for key in idf.model.dtls: for idfobject in idf.idfobjects[key]: for fieldvalue in idfobject.obj: if type(fieldvalue) is list: if fieldvalue not in renameds: ...
[ "def", "renamenodes", "(", "idf", ",", "fieldtype", ")", ":", "renameds", "=", "[", "]", "for", "key", "in", "idf", ".", "model", ".", "dtls", ":", "for", "idfobject", "in", "idf", ".", "idfobjects", "[", "key", "]", ":", "for", "fieldvalue", "in", ...
rename all the changed nodes
[ "rename", "all", "the", "changed", "nodes" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L137-L162
santoshphilip/eppy
eppy/hvacbuilder.py
getfieldnamesendswith
def getfieldnamesendswith(idfobject, endswith): """get the filednames for the idfobject based on endswith""" objls = idfobject.objls tmp = [name for name in objls if name.endswith(endswith)] if tmp == []: pass return [name for name in objls if name.endswith(endswith)]
python
def getfieldnamesendswith(idfobject, endswith): """get the filednames for the idfobject based on endswith""" objls = idfobject.objls tmp = [name for name in objls if name.endswith(endswith)] if tmp == []: pass return [name for name in objls if name.endswith(endswith)]
[ "def", "getfieldnamesendswith", "(", "idfobject", ",", "endswith", ")", ":", "objls", "=", "idfobject", ".", "objls", "tmp", "=", "[", "name", "for", "name", "in", "objls", "if", "name", ".", "endswith", "(", "endswith", ")", "]", "if", "tmp", "==", "[...
get the filednames for the idfobject based on endswith
[ "get", "the", "filednames", "for", "the", "idfobject", "based", "on", "endswith" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L164-L170
santoshphilip/eppy
eppy/hvacbuilder.py
getnodefieldname
def getnodefieldname(idfobject, endswith, fluid=None, startswith=None): """return the field name of the node fluid is only needed if there are air and water nodes fluid is Air or Water or ''. if the fluid is Steam, use Water""" if startswith is None: startswith = '' if fluid is None: ...
python
def getnodefieldname(idfobject, endswith, fluid=None, startswith=None): """return the field name of the node fluid is only needed if there are air and water nodes fluid is Air or Water or ''. if the fluid is Steam, use Water""" if startswith is None: startswith = '' if fluid is None: ...
[ "def", "getnodefieldname", "(", "idfobject", ",", "endswith", ",", "fluid", "=", "None", ",", "startswith", "=", "None", ")", ":", "if", "startswith", "is", "None", ":", "startswith", "=", "''", "if", "fluid", "is", "None", ":", "fluid", "=", "''", "no...
return the field name of the node fluid is only needed if there are air and water nodes fluid is Air or Water or ''. if the fluid is Steam, use Water
[ "return", "the", "field", "name", "of", "the", "node", "fluid", "is", "only", "needed", "if", "there", "are", "air", "and", "water", "nodes", "fluid", "is", "Air", "or", "Water", "or", ".", "if", "the", "fluid", "is", "Steam", "use", "Water" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L172-L189
santoshphilip/eppy
eppy/hvacbuilder.py
connectcomponents
def connectcomponents(idf, components, fluid=None): """rename nodes so that the components get connected fluid is only needed if there are air and water nodes fluid is Air or Water or ''. if the fluid is Steam, use Water""" if fluid is None: fluid = '' if len(components) == 1: th...
python
def connectcomponents(idf, components, fluid=None): """rename nodes so that the components get connected fluid is only needed if there are air and water nodes fluid is Air or Water or ''. if the fluid is Steam, use Water""" if fluid is None: fluid = '' if len(components) == 1: th...
[ "def", "connectcomponents", "(", "idf", ",", "components", ",", "fluid", "=", "None", ")", ":", "if", "fluid", "is", "None", ":", "fluid", "=", "''", "if", "len", "(", "components", ")", "==", "1", ":", "thiscomp", ",", "thiscompnode", "=", "components...
rename nodes so that the components get connected fluid is only needed if there are air and water nodes fluid is Air or Water or ''. if the fluid is Steam, use Water
[ "rename", "nodes", "so", "that", "the", "components", "get", "connected", "fluid", "is", "only", "needed", "if", "there", "are", "air", "and", "water", "nodes", "fluid", "is", "Air", "or", "Water", "or", ".", "if", "the", "fluid", "is", "Steam", "use", ...
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L192-L220
santoshphilip/eppy
eppy/hvacbuilder.py
initinletoutlet
def initinletoutlet(idf, idfobject, thisnode, force=False): """initialze values for all the inlet outlet nodes for the object. if force == False, it willl init only if field = '' """ def blankfield(fieldvalue): """test for blank field""" try: if fieldvalue.strip() == '': ...
python
def initinletoutlet(idf, idfobject, thisnode, force=False): """initialze values for all the inlet outlet nodes for the object. if force == False, it willl init only if field = '' """ def blankfield(fieldvalue): """test for blank field""" try: if fieldvalue.strip() == '': ...
[ "def", "initinletoutlet", "(", "idf", ",", "idfobject", ",", "thisnode", ",", "force", "=", "False", ")", ":", "def", "blankfield", "(", "fieldvalue", ")", ":", "\"\"\"test for blank field\"\"\"", "try", ":", "if", "fieldvalue", ".", "strip", "(", ")", "==",...
initialze values for all the inlet outlet nodes for the object. if force == False, it willl init only if field = ''
[ "initialze", "values", "for", "all", "the", "inlet", "outlet", "nodes", "for", "the", "object", ".", "if", "force", "==", "False", "it", "willl", "init", "only", "if", "field", "=" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L223-L260
santoshphilip/eppy
eppy/hvacbuilder.py
componentsintobranch
def componentsintobranch(idf, branch, listofcomponents, fluid=None): """insert a list of components into a branch fluid is only needed if there are air and water nodes in same object fluid is Air or Water or ''. if the fluid is Steam, use Water""" if fluid is None: fluid = '' componentli...
python
def componentsintobranch(idf, branch, listofcomponents, fluid=None): """insert a list of components into a branch fluid is only needed if there are air and water nodes in same object fluid is Air or Water or ''. if the fluid is Steam, use Water""" if fluid is None: fluid = '' componentli...
[ "def", "componentsintobranch", "(", "idf", ",", "branch", ",", "listofcomponents", ",", "fluid", "=", "None", ")", ":", "if", "fluid", "is", "None", ":", "fluid", "=", "''", "componentlist", "=", "[", "item", "[", "0", "]", "for", "item", "in", "listof...
insert a list of components into a branch fluid is only needed if there are air and water nodes in same object fluid is Air or Water or ''. if the fluid is Steam, use Water
[ "insert", "a", "list", "of", "components", "into", "a", "branch", "fluid", "is", "only", "needed", "if", "there", "are", "air", "and", "water", "nodes", "in", "same", "object", "fluid", "is", "Air", "or", "Water", "or", ".", "if", "the", "fluid", "is",...
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L262-L290
santoshphilip/eppy
eppy/hvacbuilder.py
makeairloop
def makeairloop(idf, loopname, sloop, dloop, testing=None): """make an airloop""" # -------- testing --------- testn = 0 # -------- testing --------- newairloop = idf.newidfobject("AirLoopHVAC".upper(), Name=loopname) # -------- testing --------- testn = doingtesting(testing, testn, newairlo...
python
def makeairloop(idf, loopname, sloop, dloop, testing=None): """make an airloop""" # -------- testing --------- testn = 0 # -------- testing --------- newairloop = idf.newidfobject("AirLoopHVAC".upper(), Name=loopname) # -------- testing --------- testn = doingtesting(testing, testn, newairlo...
[ "def", "makeairloop", "(", "idf", ",", "loopname", ",", "sloop", ",", "dloop", ",", "testing", "=", "None", ")", ":", "# -------- testing ---------", "testn", "=", "0", "# -------- testing ---------", "newairloop", "=", "idf", ".", "newidfobject", "(", "\"AirLoo...
make an airloop
[ "make", "an", "airloop" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L305-L573
santoshphilip/eppy
eppy/hvacbuilder.py
makeplantloop
def makeplantloop(idf, loopname, sloop, dloop, testing=None): """make plant loop with pip components""" # -------- <testing --------- testn = 0 # -------- testing> --------- newplantloop = idf.newidfobject("PLANTLOOP", Name=loopname) # -------- <testing --------- testn = doingtesting(testing...
python
def makeplantloop(idf, loopname, sloop, dloop, testing=None): """make plant loop with pip components""" # -------- <testing --------- testn = 0 # -------- testing> --------- newplantloop = idf.newidfobject("PLANTLOOP", Name=loopname) # -------- <testing --------- testn = doingtesting(testing...
[ "def", "makeplantloop", "(", "idf", ",", "loopname", ",", "sloop", ",", "dloop", ",", "testing", "=", "None", ")", ":", "# -------- <testing ---------", "testn", "=", "0", "# -------- testing> ---------", "newplantloop", "=", "idf", ".", "newidfobject", "(", "\"...
make plant loop with pip components
[ "make", "plant", "loop", "with", "pip", "components" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L575-L765
santoshphilip/eppy
eppy/hvacbuilder.py
makecondenserloop
def makecondenserloop(idf, loopname, sloop, dloop, testing=None): """make condenser loop with pipe components""" # -------- <testing --------- testn = 0 # -------- testing> --------- newcondenserloop = idf.newidfobject("CondenserLoop".upper(), Name=loopname) # -------- <testing --------- tes...
python
def makecondenserloop(idf, loopname, sloop, dloop, testing=None): """make condenser loop with pipe components""" # -------- <testing --------- testn = 0 # -------- testing> --------- newcondenserloop = idf.newidfobject("CondenserLoop".upper(), Name=loopname) # -------- <testing --------- tes...
[ "def", "makecondenserloop", "(", "idf", ",", "loopname", ",", "sloop", ",", "dloop", ",", "testing", "=", "None", ")", ":", "# -------- <testing ---------", "testn", "=", "0", "# -------- testing> ---------", "newcondenserloop", "=", "idf", ".", "newidfobject", "(...
make condenser loop with pipe components
[ "make", "condenser", "loop", "with", "pipe", "components" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L767-L960
santoshphilip/eppy
eppy/hvacbuilder.py
_clean_listofcomponents
def _clean_listofcomponents(listofcomponents): """force it to be a list of tuples""" def totuple(item): """return a tuple""" if isinstance(item, (tuple, list)): return item else: return (item, None) return [totuple(item) for item in listofcomponents]
python
def _clean_listofcomponents(listofcomponents): """force it to be a list of tuples""" def totuple(item): """return a tuple""" if isinstance(item, (tuple, list)): return item else: return (item, None) return [totuple(item) for item in listofcomponents]
[ "def", "_clean_listofcomponents", "(", "listofcomponents", ")", ":", "def", "totuple", "(", "item", ")", ":", "\"\"\"return a tuple\"\"\"", "if", "isinstance", "(", "item", ",", "(", "tuple", ",", "list", ")", ")", ":", "return", "item", "else", ":", "return...
force it to be a list of tuples
[ "force", "it", "to", "be", "a", "list", "of", "tuples" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L962-L970
santoshphilip/eppy
eppy/hvacbuilder.py
_clean_listofcomponents_tuples
def _clean_listofcomponents_tuples(listofcomponents_tuples): """force 3 items in the tuple""" def to3tuple(item): """return a 3 item tuple""" if len(item) == 3: return item else: return (item[0], item[1], None) return [to3tuple(item) for item in listofcomponen...
python
def _clean_listofcomponents_tuples(listofcomponents_tuples): """force 3 items in the tuple""" def to3tuple(item): """return a 3 item tuple""" if len(item) == 3: return item else: return (item[0], item[1], None) return [to3tuple(item) for item in listofcomponen...
[ "def", "_clean_listofcomponents_tuples", "(", "listofcomponents_tuples", ")", ":", "def", "to3tuple", "(", "item", ")", ":", "\"\"\"return a 3 item tuple\"\"\"", "if", "len", "(", "item", ")", "==", "3", ":", "return", "item", "else", ":", "return", "(", "item",...
force 3 items in the tuple
[ "force", "3", "items", "in", "the", "tuple" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L972-L980
santoshphilip/eppy
eppy/hvacbuilder.py
getmakeidfobject
def getmakeidfobject(idf, key, name): """get idfobject or make it if it does not exist""" idfobject = idf.getobject(key, name) if not idfobject: return idf.newidfobject(key, Name=name) else: return idfobject
python
def getmakeidfobject(idf, key, name): """get idfobject or make it if it does not exist""" idfobject = idf.getobject(key, name) if not idfobject: return idf.newidfobject(key, Name=name) else: return idfobject
[ "def", "getmakeidfobject", "(", "idf", ",", "key", ",", "name", ")", ":", "idfobject", "=", "idf", ".", "getobject", "(", "key", ",", "name", ")", "if", "not", "idfobject", ":", "return", "idf", ".", "newidfobject", "(", "key", ",", "Name", "=", "nam...
get idfobject or make it if it does not exist
[ "get", "idfobject", "or", "make", "it", "if", "it", "does", "not", "exist" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L982-L988
santoshphilip/eppy
eppy/hvacbuilder.py
replacebranch1
def replacebranch1(idf, loop, branchname, listofcomponents_tuples, fluid=None, debugsave=False): """do I even use this ? .... yup! I do""" if fluid is None: fluid = '' listofcomponents_tuples = _clean_listofcomponents_tuples(listofcomponents_tuples) branch = idf.getobject('BRA...
python
def replacebranch1(idf, loop, branchname, listofcomponents_tuples, fluid=None, debugsave=False): """do I even use this ? .... yup! I do""" if fluid is None: fluid = '' listofcomponents_tuples = _clean_listofcomponents_tuples(listofcomponents_tuples) branch = idf.getobject('BRA...
[ "def", "replacebranch1", "(", "idf", ",", "loop", ",", "branchname", ",", "listofcomponents_tuples", ",", "fluid", "=", "None", ",", "debugsave", "=", "False", ")", ":", "if", "fluid", "is", "None", ":", "fluid", "=", "''", "listofcomponents_tuples", "=", ...
do I even use this ? .... yup! I do
[ "do", "I", "even", "use", "this", "?", "....", "yup!", "I", "do" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L990-L1003
santoshphilip/eppy
eppy/hvacbuilder.py
replacebranch
def replacebranch(idf, loop, branch, listofcomponents, fluid=None, debugsave=False, testing=None): """It will replace the components in the branch with components in listofcomponents""" if fluid is None: fluid = '' # -------- testing --------...
python
def replacebranch(idf, loop, branch, listofcomponents, fluid=None, debugsave=False, testing=None): """It will replace the components in the branch with components in listofcomponents""" if fluid is None: fluid = '' # -------- testing --------...
[ "def", "replacebranch", "(", "idf", ",", "loop", ",", "branch", ",", "listofcomponents", ",", "fluid", "=", "None", ",", "debugsave", "=", "False", ",", "testing", "=", "None", ")", ":", "if", "fluid", "is", "None", ":", "fluid", "=", "''", "# --------...
It will replace the components in the branch with components in listofcomponents
[ "It", "will", "replace", "the", "components", "in", "the", "branch", "with", "components", "in", "listofcomponents" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L1005-L1178
santoshphilip/eppy
eppy/hvacbuilder.py
main
def main(): """the main routine""" from six import StringIO import eppy.iddv7 as iddv7 IDF.setiddname(StringIO(iddv7.iddtxt)) idf1 = IDF(StringIO('')) loopname = "p_loop" sloop = ['sb0', ['sb1', 'sb2', 'sb3'], 'sb4'] dloop = ['db0', ['db1', 'db2', 'db3'], 'db4'] # makeplantloop(idf1,...
python
def main(): """the main routine""" from six import StringIO import eppy.iddv7 as iddv7 IDF.setiddname(StringIO(iddv7.iddtxt)) idf1 = IDF(StringIO('')) loopname = "p_loop" sloop = ['sb0', ['sb1', 'sb2', 'sb3'], 'sb4'] dloop = ['db0', ['db1', 'db2', 'db3'], 'db4'] # makeplantloop(idf1,...
[ "def", "main", "(", ")", ":", "from", "six", "import", "StringIO", "import", "eppy", ".", "iddv7", "as", "iddv7", "IDF", ".", "setiddname", "(", "StringIO", "(", "iddv7", ".", "iddtxt", ")", ")", "idf1", "=", "IDF", "(", "StringIO", "(", "''", ")", ...
the main routine
[ "the", "main", "routine" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/hvacbuilder.py#L1180-L1198
santoshphilip/eppy
eppy/geometry/surface.py
area
def area(poly): """Area of a polygon poly""" if len(poly) < 3: # not a plane - no area return 0 total = [0, 0, 0] num = len(poly) for i in range(num): vi1 = poly[i] vi2 = poly[(i+1) % num] prod = np.cross(vi1, vi2) total[0] += prod[0] total[1] += prod[...
python
def area(poly): """Area of a polygon poly""" if len(poly) < 3: # not a plane - no area return 0 total = [0, 0, 0] num = len(poly) for i in range(num): vi1 = poly[i] vi2 = poly[(i+1) % num] prod = np.cross(vi1, vi2) total[0] += prod[0] total[1] += prod[...
[ "def", "area", "(", "poly", ")", ":", "if", "len", "(", "poly", ")", "<", "3", ":", "# not a plane - no area", "return", "0", "total", "=", "[", "0", ",", "0", ",", "0", "]", "num", "=", "len", "(", "poly", ")", "for", "i", "in", "range", "(", ...
Area of a polygon poly
[ "Area", "of", "a", "polygon", "poly" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/geometry/surface.py#L32-L48
santoshphilip/eppy
eppy/geometry/surface.py
unit_normal
def unit_normal(pt_a, pt_b, pt_c): """unit normal vector of plane defined by points pt_a, pt_b, and pt_c""" x_val = np.linalg.det([[1, pt_a[1], pt_a[2]], [1, pt_b[1], pt_b[2]], [1, pt_c[1], pt_c[2]]]) y_val = np.linalg.det([[pt_a[0], 1, pt_a[2]], [pt_b[0], 1, pt_b[2]], [pt_c[0], 1, pt_c[2]]]) z_val = np...
python
def unit_normal(pt_a, pt_b, pt_c): """unit normal vector of plane defined by points pt_a, pt_b, and pt_c""" x_val = np.linalg.det([[1, pt_a[1], pt_a[2]], [1, pt_b[1], pt_b[2]], [1, pt_c[1], pt_c[2]]]) y_val = np.linalg.det([[pt_a[0], 1, pt_a[2]], [pt_b[0], 1, pt_b[2]], [pt_c[0], 1, pt_c[2]]]) z_val = np...
[ "def", "unit_normal", "(", "pt_a", ",", "pt_b", ",", "pt_c", ")", ":", "x_val", "=", "np", ".", "linalg", ".", "det", "(", "[", "[", "1", ",", "pt_a", "[", "1", "]", ",", "pt_a", "[", "2", "]", "]", ",", "[", "1", ",", "pt_b", "[", "1", "...
unit normal vector of plane defined by points pt_a, pt_b, and pt_c
[ "unit", "normal", "vector", "of", "plane", "defined", "by", "points", "pt_a", "pt_b", "and", "pt_c" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/geometry/surface.py#L50-L59
santoshphilip/eppy
eppy/geometry/surface.py
width
def width(poly): """Width of a polygon poly""" num = len(poly) - 1 if abs(poly[num][2] - poly[0][2]) < abs(poly[1][2] - poly[0][2]): return dist(poly[num], poly[0]) elif abs(poly[num][2] - poly[0][2]) > abs(poly[1][2] - poly[0][2]): return dist(poly[1], poly[0]) else: return max(dist...
python
def width(poly): """Width of a polygon poly""" num = len(poly) - 1 if abs(poly[num][2] - poly[0][2]) < abs(poly[1][2] - poly[0][2]): return dist(poly[num], poly[0]) elif abs(poly[num][2] - poly[0][2]) > abs(poly[1][2] - poly[0][2]): return dist(poly[1], poly[0]) else: return max(dist...
[ "def", "width", "(", "poly", ")", ":", "num", "=", "len", "(", "poly", ")", "-", "1", "if", "abs", "(", "poly", "[", "num", "]", "[", "2", "]", "-", "poly", "[", "0", "]", "[", "2", "]", ")", "<", "abs", "(", "poly", "[", "1", "]", "[",...
Width of a polygon poly
[ "Width", "of", "a", "polygon", "poly" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/geometry/surface.py#L68-L75
santoshphilip/eppy
eppy/geometry/surface.py
height
def height(poly): """Height of a polygon poly""" num = len(poly) - 1 if abs(poly[num][2] - poly[0][2]) > abs(poly[1][2] - poly[0][2]): return dist(poly[num], poly[0]) elif abs(poly[num][2] - poly[0][2]) < abs(poly[1][2] - poly[0][2]): return dist(poly[1], poly[0]) else: retur...
python
def height(poly): """Height of a polygon poly""" num = len(poly) - 1 if abs(poly[num][2] - poly[0][2]) > abs(poly[1][2] - poly[0][2]): return dist(poly[num], poly[0]) elif abs(poly[num][2] - poly[0][2]) < abs(poly[1][2] - poly[0][2]): return dist(poly[1], poly[0]) else: retur...
[ "def", "height", "(", "poly", ")", ":", "num", "=", "len", "(", "poly", ")", "-", "1", "if", "abs", "(", "poly", "[", "num", "]", "[", "2", "]", "-", "poly", "[", "0", "]", "[", "2", "]", ")", ">", "abs", "(", "poly", "[", "1", "]", "["...
Height of a polygon poly
[ "Height", "of", "a", "polygon", "poly" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/geometry/surface.py#L78-L86
santoshphilip/eppy
eppy/geometry/surface.py
angle2vecs
def angle2vecs(vec1, vec2): """angle between two vectors""" # vector a * vector b = |a|*|b|* cos(angle between vector a and vector b) dot = np.dot(vec1, vec2) vec1_modulus = np.sqrt(np.multiply(vec1, vec1).sum()) vec2_modulus = np.sqrt(np.multiply(vec2, vec2).sum()) if (vec1_modulus * vec2_modul...
python
def angle2vecs(vec1, vec2): """angle between two vectors""" # vector a * vector b = |a|*|b|* cos(angle between vector a and vector b) dot = np.dot(vec1, vec2) vec1_modulus = np.sqrt(np.multiply(vec1, vec1).sum()) vec2_modulus = np.sqrt(np.multiply(vec2, vec2).sum()) if (vec1_modulus * vec2_modul...
[ "def", "angle2vecs", "(", "vec1", ",", "vec2", ")", ":", "# vector a * vector b = |a|*|b|* cos(angle between vector a and vector b)", "dot", "=", "np", ".", "dot", "(", "vec1", ",", "vec2", ")", "vec1_modulus", "=", "np", ".", "sqrt", "(", "np", ".", "multiply",...
angle between two vectors
[ "angle", "between", "two", "vectors" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/geometry/surface.py#L89-L98
santoshphilip/eppy
eppy/geometry/surface.py
azimuth
def azimuth(poly): """Azimuth of a polygon poly""" num = len(poly) - 1 vec = unit_normal(poly[0], poly[1], poly[num]) vec_azi = np.array([vec[0], vec[1], 0]) vec_n = np.array([0, 1, 0]) # update by Santosh # angle2vecs gives the smallest angle between the vectors # so for a west wall ang...
python
def azimuth(poly): """Azimuth of a polygon poly""" num = len(poly) - 1 vec = unit_normal(poly[0], poly[1], poly[num]) vec_azi = np.array([vec[0], vec[1], 0]) vec_n = np.array([0, 1, 0]) # update by Santosh # angle2vecs gives the smallest angle between the vectors # so for a west wall ang...
[ "def", "azimuth", "(", "poly", ")", ":", "num", "=", "len", "(", "poly", ")", "-", "1", "vec", "=", "unit_normal", "(", "poly", "[", "0", "]", ",", "poly", "[", "1", "]", ",", "poly", "[", "num", "]", ")", "vec_azi", "=", "np", ".", "array", ...
Azimuth of a polygon poly
[ "Azimuth", "of", "a", "polygon", "poly" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/geometry/surface.py#L101-L115
santoshphilip/eppy
eppy/geometry/surface.py
tilt
def tilt(poly): """Tilt of a polygon poly""" num = len(poly) - 1 vec = unit_normal(poly[0], poly[1], poly[num]) vec_alt = np.array([vec[0], vec[1], vec[2]]) vec_z = np.array([0, 0, 1]) # return (90 - angle2vecs(vec_alt, vec_z)) # update by Santosh return angle2vecs(vec_alt, vec_z)
python
def tilt(poly): """Tilt of a polygon poly""" num = len(poly) - 1 vec = unit_normal(poly[0], poly[1], poly[num]) vec_alt = np.array([vec[0], vec[1], vec[2]]) vec_z = np.array([0, 0, 1]) # return (90 - angle2vecs(vec_alt, vec_z)) # update by Santosh return angle2vecs(vec_alt, vec_z)
[ "def", "tilt", "(", "poly", ")", ":", "num", "=", "len", "(", "poly", ")", "-", "1", "vec", "=", "unit_normal", "(", "poly", "[", "0", "]", ",", "poly", "[", "1", "]", ",", "poly", "[", "num", "]", ")", "vec_alt", "=", "np", ".", "array", "...
Tilt of a polygon poly
[ "Tilt", "of", "a", "polygon", "poly" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/geometry/surface.py#L117-L124
santoshphilip/eppy
eppy/iddgaps.py
getfields
def getfields(comm): """get all the fields that have the key 'field' """ fields = [] for field in comm: if 'field' in field: fields.append(field) return fields
python
def getfields(comm): """get all the fields that have the key 'field' """ fields = [] for field in comm: if 'field' in field: fields.append(field) return fields
[ "def", "getfields", "(", "comm", ")", ":", "fields", "=", "[", "]", "for", "field", "in", "comm", ":", "if", "'field'", "in", "field", ":", "fields", ".", "append", "(", "field", ")", "return", "fields" ]
get all the fields that have the key 'field'
[ "get", "all", "the", "fields", "that", "have", "the", "key", "field" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/iddgaps.py#L63-L69
santoshphilip/eppy
eppy/iddgaps.py
repeatingfieldsnames
def repeatingfieldsnames(fields): """get the names of the repeating fields""" fnames = [field['field'][0] for field in fields] fnames = [bunchhelpers.onlylegalchar(fname) for fname in fnames] fnames = [fname for fname in fnames if bunchhelpers.intinlist(fname.split())] fnames = [(bunchhelpers.replac...
python
def repeatingfieldsnames(fields): """get the names of the repeating fields""" fnames = [field['field'][0] for field in fields] fnames = [bunchhelpers.onlylegalchar(fname) for fname in fnames] fnames = [fname for fname in fnames if bunchhelpers.intinlist(fname.split())] fnames = [(bunchhelpers.replac...
[ "def", "repeatingfieldsnames", "(", "fields", ")", ":", "fnames", "=", "[", "field", "[", "'field'", "]", "[", "0", "]", "for", "field", "in", "fields", "]", "fnames", "=", "[", "bunchhelpers", ".", "onlylegalchar", "(", "fname", ")", "for", "fname", "...
get the names of the repeating fields
[ "get", "the", "names", "of", "the", "repeating", "fields" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/iddgaps.py#L71-L79
santoshphilip/eppy
eppy/iddgaps.py
missingkeys_standard
def missingkeys_standard(commdct, dtls, skiplist=None): """put missing keys in commdct for standard objects return a list of keys where it is unable to do so commdct is not returned, but is updated""" if skiplist == None: skiplist = [] # find objects where all the fields are not named gk...
python
def missingkeys_standard(commdct, dtls, skiplist=None): """put missing keys in commdct for standard objects return a list of keys where it is unable to do so commdct is not returned, but is updated""" if skiplist == None: skiplist = [] # find objects where all the fields are not named gk...
[ "def", "missingkeys_standard", "(", "commdct", ",", "dtls", ",", "skiplist", "=", "None", ")", ":", "if", "skiplist", "==", "None", ":", "skiplist", "=", "[", "]", "# find objects where all the fields are not named", "gkeys", "=", "[", "dtls", "[", "i", "]", ...
put missing keys in commdct for standard objects return a list of keys where it is unable to do so commdct is not returned, but is updated
[ "put", "missing", "keys", "in", "commdct", "for", "standard", "objects", "return", "a", "list", "of", "keys", "where", "it", "is", "unable", "to", "do", "so", "commdct", "is", "not", "returned", "but", "is", "updated" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/iddgaps.py#L82-L150
santoshphilip/eppy
eppy/iddgaps.py
missingkeys_nonstandard
def missingkeys_nonstandard(block, commdct, dtls, objectlist, afield='afiled %s'): """This is an object list where thre is no first field name to give a hint of what the first field name should be""" afield = 'afield %s' for key_txt in objectlist: key_i = dtls.index(key_txt.upper()) comm...
python
def missingkeys_nonstandard(block, commdct, dtls, objectlist, afield='afiled %s'): """This is an object list where thre is no first field name to give a hint of what the first field name should be""" afield = 'afield %s' for key_txt in objectlist: key_i = dtls.index(key_txt.upper()) comm...
[ "def", "missingkeys_nonstandard", "(", "block", ",", "commdct", ",", "dtls", ",", "objectlist", ",", "afield", "=", "'afiled %s'", ")", ":", "afield", "=", "'afield %s'", "for", "key_txt", "in", "objectlist", ":", "key_i", "=", "dtls", ".", "index", "(", "...
This is an object list where thre is no first field name to give a hint of what the first field name should be
[ "This", "is", "an", "object", "list", "where", "thre", "is", "no", "first", "field", "name", "to", "give", "a", "hint", "of", "what", "the", "first", "field", "name", "should", "be" ]
train
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/iddgaps.py#L152-L170
GoogleCloudPlatform/datastore-ndb-python
ndb/eventloop.py
get_event_loop
def get_event_loop(): """Return a EventLoop instance. A new instance is created for each new HTTP request. We determine that we're in a new request by inspecting os.environ, which is reset at the start of each request. Also, each thread gets its own loop. """ ev = _state.event_loop if not os.getenv(_EV...
python
def get_event_loop(): """Return a EventLoop instance. A new instance is created for each new HTTP request. We determine that we're in a new request by inspecting os.environ, which is reset at the start of each request. Also, each thread gets its own loop. """ ev = _state.event_loop if not os.getenv(_EV...
[ "def", "get_event_loop", "(", ")", ":", "ev", "=", "_state", ".", "event_loop", "if", "not", "os", ".", "getenv", "(", "_EVENT_LOOP_KEY", ")", "and", "ev", "is", "not", "None", ":", "ev", ".", "clear", "(", ")", "_state", ".", "event_loop", "=", "Non...
Return a EventLoop instance. A new instance is created for each new HTTP request. We determine that we're in a new request by inspecting os.environ, which is reset at the start of each request. Also, each thread gets its own loop.
[ "Return", "a", "EventLoop", "instance", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/eventloop.py#L293-L309
GoogleCloudPlatform/datastore-ndb-python
ndb/eventloop.py
EventLoop.clear
def clear(self): """Remove all pending events without running any.""" while self.current or self.idlers or self.queue or self.rpcs: current = self.current idlers = self.idlers queue = self.queue rpcs = self.rpcs _logging_debug('Clearing stale EventLoop instance...') if curren...
python
def clear(self): """Remove all pending events without running any.""" while self.current or self.idlers or self.queue or self.rpcs: current = self.current idlers = self.idlers queue = self.queue rpcs = self.rpcs _logging_debug('Clearing stale EventLoop instance...') if curren...
[ "def", "clear", "(", "self", ")", ":", "while", "self", ".", "current", "or", "self", ".", "idlers", "or", "self", ".", "queue", "or", "self", ".", "rpcs", ":", "current", "=", "self", ".", "current", "idlers", "=", "self", ".", "idlers", "queue", ...
Remove all pending events without running any.
[ "Remove", "all", "pending", "events", "without", "running", "any", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/eventloop.py#L90-L111
GoogleCloudPlatform/datastore-ndb-python
ndb/eventloop.py
EventLoop.insort_event_right
def insort_event_right(self, event, lo=0, hi=None): """Insert event in queue, and keep it sorted assuming queue is sorted. If event is already in queue, insert it to the right of the rightmost event (to keep FIFO order). Optional args lo (default 0) and hi (default len(a)) bound the slice of a to ...
python
def insort_event_right(self, event, lo=0, hi=None): """Insert event in queue, and keep it sorted assuming queue is sorted. If event is already in queue, insert it to the right of the rightmost event (to keep FIFO order). Optional args lo (default 0) and hi (default len(a)) bound the slice of a to ...
[ "def", "insort_event_right", "(", "self", ",", "event", ",", "lo", "=", "0", ",", "hi", "=", "None", ")", ":", "if", "lo", "<", "0", ":", "raise", "ValueError", "(", "'lo must be non-negative'", ")", "if", "hi", "is", "None", ":", "hi", "=", "len", ...
Insert event in queue, and keep it sorted assuming queue is sorted. If event is already in queue, insert it to the right of the rightmost event (to keep FIFO order). Optional args lo (default 0) and hi (default len(a)) bound the slice of a to be searched. Args: event: a (time in sec since u...
[ "Insert", "event", "in", "queue", "and", "keep", "it", "sorted", "assuming", "queue", "is", "sorted", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/eventloop.py#L113-L136
GoogleCloudPlatform/datastore-ndb-python
ndb/eventloop.py
EventLoop.queue_call
def queue_call(self, delay, callback, *args, **kwds): """Schedule a function call at a specific time in the future.""" if delay is None: self.current.append((callback, args, kwds)) return if delay < 1e9: when = delay + self.clock.now() else: # Times over a billion seconds are ass...
python
def queue_call(self, delay, callback, *args, **kwds): """Schedule a function call at a specific time in the future.""" if delay is None: self.current.append((callback, args, kwds)) return if delay < 1e9: when = delay + self.clock.now() else: # Times over a billion seconds are ass...
[ "def", "queue_call", "(", "self", ",", "delay", ",", "callback", ",", "*", "args", ",", "*", "*", "kwds", ")", ":", "if", "delay", "is", "None", ":", "self", ".", "current", ".", "append", "(", "(", "callback", ",", "args", ",", "kwds", ")", ")",...
Schedule a function call at a specific time in the future.
[ "Schedule", "a", "function", "call", "at", "a", "specific", "time", "in", "the", "future", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/eventloop.py#L138-L148
GoogleCloudPlatform/datastore-ndb-python
ndb/eventloop.py
EventLoop.queue_rpc
def queue_rpc(self, rpc, callback=None, *args, **kwds): """Schedule an RPC with an optional callback. The caller must have previously sent the call to the service. The optional callback is called with the remaining arguments. NOTE: If the rpc is a MultiRpc, the callback will be called once for eac...
python
def queue_rpc(self, rpc, callback=None, *args, **kwds): """Schedule an RPC with an optional callback. The caller must have previously sent the call to the service. The optional callback is called with the remaining arguments. NOTE: If the rpc is a MultiRpc, the callback will be called once for eac...
[ "def", "queue_rpc", "(", "self", ",", "rpc", ",", "callback", "=", "None", ",", "*", "args", ",", "*", "*", "kwds", ")", ":", "if", "rpc", "is", "None", ":", "return", "if", "rpc", ".", "state", "not", "in", "(", "_RUNNING", ",", "_FINISHING", ")...
Schedule an RPC with an optional callback. The caller must have previously sent the call to the service. The optional callback is called with the remaining arguments. NOTE: If the rpc is a MultiRpc, the callback will be called once for each sub-RPC. TODO: Is this a good idea?
[ "Schedule", "an", "RPC", "with", "an", "optional", "callback", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/eventloop.py#L150-L180
GoogleCloudPlatform/datastore-ndb-python
ndb/eventloop.py
EventLoop.add_idle
def add_idle(self, callback, *args, **kwds): """Add an idle callback. An idle callback can return True, False or None. These mean: - None: remove the callback (don't reschedule) - False: the callback did no work; reschedule later - True: the callback did some work; reschedule soon If the cal...
python
def add_idle(self, callback, *args, **kwds): """Add an idle callback. An idle callback can return True, False or None. These mean: - None: remove the callback (don't reschedule) - False: the callback did no work; reschedule later - True: the callback did some work; reschedule soon If the cal...
[ "def", "add_idle", "(", "self", ",", "callback", ",", "*", "args", ",", "*", "*", "kwds", ")", ":", "self", ".", "idlers", ".", "append", "(", "(", "callback", ",", "args", ",", "kwds", ")", ")" ]
Add an idle callback. An idle callback can return True, False or None. These mean: - None: remove the callback (don't reschedule) - False: the callback did no work; reschedule later - True: the callback did some work; reschedule soon If the callback raises an exception, the traceback is logged a...
[ "Add", "an", "idle", "callback", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/eventloop.py#L182-L194
GoogleCloudPlatform/datastore-ndb-python
ndb/eventloop.py
EventLoop.run_idle
def run_idle(self): """Run one of the idle callbacks. Returns: True if one was called, False if no idle callback was called. """ if not self.idlers or self.inactive >= len(self.idlers): return False idler = self.idlers.popleft() callback, args, kwds = idler _logging_debug('idler...
python
def run_idle(self): """Run one of the idle callbacks. Returns: True if one was called, False if no idle callback was called. """ if not self.idlers or self.inactive >= len(self.idlers): return False idler = self.idlers.popleft() callback, args, kwds = idler _logging_debug('idler...
[ "def", "run_idle", "(", "self", ")", ":", "if", "not", "self", ".", "idlers", "or", "self", ".", "inactive", ">=", "len", "(", "self", ".", "idlers", ")", ":", "return", "False", "idler", "=", "self", ".", "idlers", ".", "popleft", "(", ")", "callb...
Run one of the idle callbacks. Returns: True if one was called, False if no idle callback was called.
[ "Run", "one", "of", "the", "idle", "callbacks", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/eventloop.py#L196-L217
GoogleCloudPlatform/datastore-ndb-python
ndb/eventloop.py
EventLoop.run0
def run0(self): """Run one item (a callback or an RPC wait_any). Returns: A time to sleep if something happened (may be 0); None if all queues are empty. """ if self.current: self.inactive = 0 callback, args, kwds = self.current.popleft() _logging_debug('nowevent: %s', cal...
python
def run0(self): """Run one item (a callback or an RPC wait_any). Returns: A time to sleep if something happened (may be 0); None if all queues are empty. """ if self.current: self.inactive = 0 callback, args, kwds = self.current.popleft() _logging_debug('nowevent: %s', cal...
[ "def", "run0", "(", "self", ")", ":", "if", "self", ".", "current", ":", "self", ".", "inactive", "=", "0", "callback", ",", "args", ",", "kwds", "=", "self", ".", "current", ".", "popleft", "(", ")", "_logging_debug", "(", "'nowevent: %s'", ",", "ca...
Run one item (a callback or an RPC wait_any). Returns: A time to sleep if something happened (may be 0); None if all queues are empty.
[ "Run", "one", "item", "(", "a", "callback", "or", "an", "RPC", "wait_any", ")", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/eventloop.py#L219-L260
GoogleCloudPlatform/datastore-ndb-python
ndb/eventloop.py
EventLoop.run1
def run1(self): """Run one item (a callback or an RPC wait_any) or sleep. Returns: True if something happened; False if all queues are empty. """ delay = self.run0() if delay is None: return False if delay > 0: self.clock.sleep(delay) return True
python
def run1(self): """Run one item (a callback or an RPC wait_any) or sleep. Returns: True if something happened; False if all queues are empty. """ delay = self.run0() if delay is None: return False if delay > 0: self.clock.sleep(delay) return True
[ "def", "run1", "(", "self", ")", ":", "delay", "=", "self", ".", "run0", "(", ")", "if", "delay", "is", "None", ":", "return", "False", "if", "delay", ">", "0", ":", "self", ".", "clock", ".", "sleep", "(", "delay", ")", "return", "True" ]
Run one item (a callback or an RPC wait_any) or sleep. Returns: True if something happened; False if all queues are empty.
[ "Run", "one", "item", "(", "a", "callback", "or", "an", "RPC", "wait_any", ")", "or", "sleep", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/eventloop.py#L262-L273
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
_args_to_val
def _args_to_val(func, args): """Helper for GQL parsing to extract values from GQL expressions. This can extract the value from a GQL literal, return a Parameter for a GQL bound parameter (:1 or :foo), and interprets casts like KEY(...) and plain lists of values like (1, 2, 3). Args: func: A string indi...
python
def _args_to_val(func, args): """Helper for GQL parsing to extract values from GQL expressions. This can extract the value from a GQL literal, return a Parameter for a GQL bound parameter (:1 or :foo), and interprets casts like KEY(...) and plain lists of values like (1, 2, 3). Args: func: A string indi...
[ "def", "_args_to_val", "(", "func", ",", "args", ")", ":", "from", ".", "google_imports", "import", "gql", "# Late import, to avoid name conflict.", "vals", "=", "[", "]", "for", "arg", "in", "args", ":", "if", "isinstance", "(", "arg", ",", "(", "int", ",...
Helper for GQL parsing to extract values from GQL expressions. This can extract the value from a GQL literal, return a Parameter for a GQL bound parameter (:1 or :foo), and interprets casts like KEY(...) and plain lists of values like (1, 2, 3). Args: func: A string indicating what kind of thing this is. ...
[ "Helper", "for", "GQL", "parsing", "to", "extract", "values", "from", "GQL", "expressions", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L700-L729
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
_get_prop_from_modelclass
def _get_prop_from_modelclass(modelclass, name): """Helper for FQL parsing to turn a property name into a property object. Args: modelclass: The model class specified in the query. name: The property name. This may contain dots which indicate sub-properties of structured properties. Returns: ...
python
def _get_prop_from_modelclass(modelclass, name): """Helper for FQL parsing to turn a property name into a property object. Args: modelclass: The model class specified in the query. name: The property name. This may contain dots which indicate sub-properties of structured properties. Returns: ...
[ "def", "_get_prop_from_modelclass", "(", "modelclass", ",", "name", ")", ":", "if", "name", "==", "'__key__'", ":", "return", "modelclass", ".", "_key", "parts", "=", "name", ".", "split", "(", "'.'", ")", "part", ",", "more", "=", "parts", "[", "0", "...
Helper for FQL parsing to turn a property name into a property object. Args: modelclass: The model class specified in the query. name: The property name. This may contain dots which indicate sub-properties of structured properties. Returns: A Property object. Raises: KeyError if the prop...
[ "Helper", "for", "FQL", "parsing", "to", "turn", "a", "property", "name", "into", "a", "property", "object", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L732-L782
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
gql
def gql(query_string, *args, **kwds): """Parse a GQL query string. Args: query_string: Full GQL query, e.g. 'SELECT * FROM Kind WHERE prop = 1'. *args, **kwds: If present, used to call bind(). Returns: An instance of query_class. """ qry = _gql(query_string) if args or kwds: qry = qry._bin...
python
def gql(query_string, *args, **kwds): """Parse a GQL query string. Args: query_string: Full GQL query, e.g. 'SELECT * FROM Kind WHERE prop = 1'. *args, **kwds: If present, used to call bind(). Returns: An instance of query_class. """ qry = _gql(query_string) if args or kwds: qry = qry._bin...
[ "def", "gql", "(", "query_string", ",", "*", "args", ",", "*", "*", "kwds", ")", ":", "qry", "=", "_gql", "(", "query_string", ")", "if", "args", "or", "kwds", ":", "qry", "=", "qry", ".", "_bind", "(", "args", ",", "kwds", ")", "return", "qry" ]
Parse a GQL query string. Args: query_string: Full GQL query, e.g. 'SELECT * FROM Kind WHERE prop = 1'. *args, **kwds: If present, used to call bind(). Returns: An instance of query_class.
[ "Parse", "a", "GQL", "query", "string", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1501-L1514
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
_gql
def _gql(query_string, query_class=Query): """Parse a GQL query string (internal version). Args: query_string: Full GQL query, e.g. 'SELECT * FROM Kind WHERE prop = 1'. query_class: Optional class to use, default Query. Returns: An instance of query_class. """ from .google_imports import gql # ...
python
def _gql(query_string, query_class=Query): """Parse a GQL query string (internal version). Args: query_string: Full GQL query, e.g. 'SELECT * FROM Kind WHERE prop = 1'. query_class: Optional class to use, default Query. Returns: An instance of query_class. """ from .google_imports import gql # ...
[ "def", "_gql", "(", "query_string", ",", "query_class", "=", "Query", ")", ":", "from", ".", "google_imports", "import", "gql", "# Late import, to avoid name conflict.", "gql_qry", "=", "gql", ".", "GQL", "(", "query_string", ")", "kind", "=", "gql_qry", ".", ...
Parse a GQL query string (internal version). Args: query_string: Full GQL query, e.g. 'SELECT * FROM Kind WHERE prop = 1'. query_class: Optional class to use, default Query. Returns: An instance of query_class.
[ "Parse", "a", "GQL", "query", "string", "(", "internal", "version", ")", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1518-L1596
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
RepeatedStructuredPropertyPredicate._apply
def _apply(self, key_value_map): """Apply the filter to values extracted from an entity. Think of self.match_keys and self.match_values as representing a table with one row. For example: match_keys = ('name', 'age', 'rank') match_values = ('Joe', 24, 5) (Except that in reality, the value...
python
def _apply(self, key_value_map): """Apply the filter to values extracted from an entity. Think of self.match_keys and self.match_values as representing a table with one row. For example: match_keys = ('name', 'age', 'rank') match_values = ('Joe', 24, 5) (Except that in reality, the value...
[ "def", "_apply", "(", "self", ",", "key_value_map", ")", ":", "columns", "=", "[", "]", "for", "key", "in", "self", ".", "match_keys", ":", "column", "=", "key_value_map", ".", "get", "(", "key", ")", "if", "not", "column", ":", "# None, or an empty list...
Apply the filter to values extracted from an entity. Think of self.match_keys and self.match_values as representing a table with one row. For example: match_keys = ('name', 'age', 'rank') match_values = ('Joe', 24, 5) (Except that in reality, the values are represented by tuples produced...
[ "Apply", "the", "filter", "to", "values", "extracted", "from", "an", "entity", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L208-L257
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
Query._fix_namespace
def _fix_namespace(self): """Internal helper to fix the namespace. This is called to ensure that for queries without an explicit namespace, the namespace used by async calls is the one in effect at the time the async call is made, not the one in effect when the the request is actually generated. ...
python
def _fix_namespace(self): """Internal helper to fix the namespace. This is called to ensure that for queries without an explicit namespace, the namespace used by async calls is the one in effect at the time the async call is made, not the one in effect when the the request is actually generated. ...
[ "def", "_fix_namespace", "(", "self", ")", ":", "if", "self", ".", "namespace", "is", "not", "None", ":", "return", "self", "namespace", "=", "namespace_manager", ".", "get_namespace", "(", ")", "return", "self", ".", "__class__", "(", "kind", "=", "self",...
Internal helper to fix the namespace. This is called to ensure that for queries without an explicit namespace, the namespace used by async calls is the one in effect at the time the async call is made, not the one in effect when the the request is actually generated.
[ "Internal", "helper", "to", "fix", "the", "namespace", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L912-L927
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
Query.run_to_queue
def run_to_queue(self, queue, conn, options=None, dsquery=None): """Run this query, putting entities into the given queue.""" try: multiquery = self._maybe_multi_query() if multiquery is not None: yield multiquery.run_to_queue(queue, conn, options=options) return if dsquery is...
python
def run_to_queue(self, queue, conn, options=None, dsquery=None): """Run this query, putting entities into the given queue.""" try: multiquery = self._maybe_multi_query() if multiquery is not None: yield multiquery.run_to_queue(queue, conn, options=options) return if dsquery is...
[ "def", "run_to_queue", "(", "self", ",", "queue", ",", "conn", ",", "options", "=", "None", ",", "dsquery", "=", "None", ")", ":", "try", ":", "multiquery", "=", "self", ".", "_maybe_multi_query", "(", ")", "if", "multiquery", "is", "not", "None", ":",...
Run this query, putting entities into the given queue.
[ "Run", "this", "query", "putting", "entities", "into", "the", "given", "queue", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L957-L985
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
Query.is_distinct
def is_distinct(self): """True if results are guaranteed to contain a unique set of property values. This happens when every property in the group_by is also in the projection. """ return bool(self.__group_by and set(self._to_property_names(self.__group_by)) <= set(s...
python
def is_distinct(self): """True if results are guaranteed to contain a unique set of property values. This happens when every property in the group_by is also in the projection. """ return bool(self.__group_by and set(self._to_property_names(self.__group_by)) <= set(s...
[ "def", "is_distinct", "(", "self", ")", ":", "return", "bool", "(", "self", ".", "__group_by", "and", "set", "(", "self", ".", "_to_property_names", "(", "self", ".", "__group_by", ")", ")", "<=", "set", "(", "self", ".", "_to_property_names", "(", "self...
True if results are guaranteed to contain a unique set of property values. This happens when every property in the group_by is also in the projection.
[ "True", "if", "results", "are", "guaranteed", "to", "contain", "a", "unique", "set", "of", "property", "values", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1074-L1082
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
Query.filter
def filter(self, *args): """Return a new Query with additional filter(s) applied.""" if not args: return self preds = [] f = self.filters if f: preds.append(f) for arg in args: if not isinstance(arg, Node): raise TypeError('Cannot filter a non-Node argument; received %r...
python
def filter(self, *args): """Return a new Query with additional filter(s) applied.""" if not args: return self preds = [] f = self.filters if f: preds.append(f) for arg in args: if not isinstance(arg, Node): raise TypeError('Cannot filter a non-Node argument; received %r...
[ "def", "filter", "(", "self", ",", "*", "args", ")", ":", "if", "not", "args", ":", "return", "self", "preds", "=", "[", "]", "f", "=", "self", ".", "filters", "if", "f", ":", "preds", ".", "append", "(", "f", ")", "for", "arg", "in", "args", ...
Return a new Query with additional filter(s) applied.
[ "Return", "a", "new", "Query", "with", "additional", "filter", "(", "s", ")", "applied", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1084-L1106
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
Query.order
def order(self, *args): """Return a new Query with additional sort order(s) applied.""" # q.order(Employee.name, -Employee.age) if not args: return self orders = [] o = self.orders if o: orders.append(o) for arg in args: if isinstance(arg, model.Property): orders.ap...
python
def order(self, *args): """Return a new Query with additional sort order(s) applied.""" # q.order(Employee.name, -Employee.age) if not args: return self orders = [] o = self.orders if o: orders.append(o) for arg in args: if isinstance(arg, model.Property): orders.ap...
[ "def", "order", "(", "self", ",", "*", "args", ")", ":", "# q.order(Employee.name, -Employee.age)", "if", "not", "args", ":", "return", "self", "orders", "=", "[", "]", "o", "=", "self", ".", "orders", "if", "o", ":", "orders", ".", "append", "(", "o",...
Return a new Query with additional sort order(s) applied.
[ "Return", "a", "new", "Query", "with", "additional", "sort", "order", "(", "s", ")", "applied", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1108-L1135
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
Query.map
def map(self, callback, pass_batch_into_callback=None, merge_future=None, **q_options): """Map a callback function or tasklet over the query results. Args: callback: A function or tasklet to be applied to each result; see below. merge_future: Optional Future subclass; see below. **q...
python
def map(self, callback, pass_batch_into_callback=None, merge_future=None, **q_options): """Map a callback function or tasklet over the query results. Args: callback: A function or tasklet to be applied to each result; see below. merge_future: Optional Future subclass; see below. **q...
[ "def", "map", "(", "self", ",", "callback", ",", "pass_batch_into_callback", "=", "None", ",", "merge_future", "=", "None", ",", "*", "*", "q_options", ")", ":", "return", "self", ".", "map_async", "(", "callback", ",", "pass_batch_into_callback", "=", "pass...
Map a callback function or tasklet over the query results. Args: callback: A function or tasklet to be applied to each result; see below. merge_future: Optional Future subclass; see below. **q_options: All query options keyword arguments are supported. Callback signature: The callback is nor...
[ "Map", "a", "callback", "function", "or", "tasklet", "over", "the", "query", "results", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1154-L1190
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
Query.map_async
def map_async(self, callback, pass_batch_into_callback=None, merge_future=None, **q_options): """Map a callback function or tasklet over the query results. This is the asynchronous version of Query.map(). """ qry = self._fix_namespace() return tasklets.get_context().map_query( ...
python
def map_async(self, callback, pass_batch_into_callback=None, merge_future=None, **q_options): """Map a callback function or tasklet over the query results. This is the asynchronous version of Query.map(). """ qry = self._fix_namespace() return tasklets.get_context().map_query( ...
[ "def", "map_async", "(", "self", ",", "callback", ",", "pass_batch_into_callback", "=", "None", ",", "merge_future", "=", "None", ",", "*", "*", "q_options", ")", ":", "qry", "=", "self", ".", "_fix_namespace", "(", ")", "return", "tasklets", ".", "get_con...
Map a callback function or tasklet over the query results. This is the asynchronous version of Query.map().
[ "Map", "a", "callback", "function", "or", "tasklet", "over", "the", "query", "results", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1193-L1205
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
Query.fetch_async
def fetch_async(self, limit=None, **q_options): """Fetch a list of query results, up to a limit. This is the asynchronous version of Query.fetch(). """ if limit is None: default_options = self._make_options(q_options) if default_options is not None and default_options.limit is not None: ...
python
def fetch_async(self, limit=None, **q_options): """Fetch a list of query results, up to a limit. This is the asynchronous version of Query.fetch(). """ if limit is None: default_options = self._make_options(q_options) if default_options is not None and default_options.limit is not None: ...
[ "def", "fetch_async", "(", "self", ",", "limit", "=", "None", ",", "*", "*", "q_options", ")", ":", "if", "limit", "is", "None", ":", "default_options", "=", "self", ".", "_make_options", "(", "q_options", ")", "if", "default_options", "is", "not", "None...
Fetch a list of query results, up to a limit. This is the asynchronous version of Query.fetch().
[ "Fetch", "a", "list", "of", "query", "results", "up", "to", "a", "limit", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1221-L1239
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
Query._get_async
def _get_async(self, **q_options): """Internal version of get_async().""" res = yield self.fetch_async(1, **q_options) if not res: raise tasklets.Return(None) raise tasklets.Return(res[0])
python
def _get_async(self, **q_options): """Internal version of get_async().""" res = yield self.fetch_async(1, **q_options) if not res: raise tasklets.Return(None) raise tasklets.Return(res[0])
[ "def", "_get_async", "(", "self", ",", "*", "*", "q_options", ")", ":", "res", "=", "yield", "self", ".", "fetch_async", "(", "1", ",", "*", "*", "q_options", ")", "if", "not", "res", ":", "raise", "tasklets", ".", "Return", "(", "None", ")", "rais...
Internal version of get_async().
[ "Internal", "version", "of", "get_async", "()", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1264-L1269
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
Query.count_async
def count_async(self, limit=None, **q_options): """Count the number of query results, up to a limit. This is the asynchronous version of Query.count(). """ qry = self._fix_namespace() return qry._count_async(limit=limit, **q_options)
python
def count_async(self, limit=None, **q_options): """Count the number of query results, up to a limit. This is the asynchronous version of Query.count(). """ qry = self._fix_namespace() return qry._count_async(limit=limit, **q_options)
[ "def", "count_async", "(", "self", ",", "limit", "=", "None", ",", "*", "*", "q_options", ")", ":", "qry", "=", "self", ".", "_fix_namespace", "(", ")", "return", "qry", ".", "_count_async", "(", "limit", "=", "limit", ",", "*", "*", "q_options", ")"...
Count the number of query results, up to a limit. This is the asynchronous version of Query.count().
[ "Count", "the", "number", "of", "query", "results", "up", "to", "a", "limit", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1290-L1296
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
Query._count_async
def _count_async(self, limit=None, **q_options): """Internal version of count_async().""" # TODO: Support offset by incorporating it to the limit. if 'offset' in q_options: raise NotImplementedError('.count() and .count_async() do not support ' 'offsets at present.') ...
python
def _count_async(self, limit=None, **q_options): """Internal version of count_async().""" # TODO: Support offset by incorporating it to the limit. if 'offset' in q_options: raise NotImplementedError('.count() and .count_async() do not support ' 'offsets at present.') ...
[ "def", "_count_async", "(", "self", ",", "limit", "=", "None", ",", "*", "*", "q_options", ")", ":", "# TODO: Support offset by incorporating it to the limit.", "if", "'offset'", "in", "q_options", ":", "raise", "NotImplementedError", "(", "'.count() and .count_async() ...
Internal version of count_async().
[ "Internal", "version", "of", "count_async", "()", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1299-L1335
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
Query.fetch_page_async
def fetch_page_async(self, page_size, **q_options): """Fetch a page of results. This is the asynchronous version of Query.fetch_page(). """ qry = self._fix_namespace() return qry._fetch_page_async(page_size, **q_options)
python
def fetch_page_async(self, page_size, **q_options): """Fetch a page of results. This is the asynchronous version of Query.fetch_page(). """ qry = self._fix_namespace() return qry._fetch_page_async(page_size, **q_options)
[ "def", "fetch_page_async", "(", "self", ",", "page_size", ",", "*", "*", "q_options", ")", ":", "qry", "=", "self", ".", "_fix_namespace", "(", ")", "return", "qry", ".", "_fetch_page_async", "(", "page_size", ",", "*", "*", "q_options", ")" ]
Fetch a page of results. This is the asynchronous version of Query.fetch_page().
[ "Fetch", "a", "page", "of", "results", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1365-L1371
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
Query._fetch_page_async
def _fetch_page_async(self, page_size, **q_options): """Internal version of fetch_page_async().""" q_options.setdefault('batch_size', page_size) q_options.setdefault('produce_cursors', True) it = self.iter(limit=page_size + 1, **q_options) results = [] while (yield it.has_next_async()): re...
python
def _fetch_page_async(self, page_size, **q_options): """Internal version of fetch_page_async().""" q_options.setdefault('batch_size', page_size) q_options.setdefault('produce_cursors', True) it = self.iter(limit=page_size + 1, **q_options) results = [] while (yield it.has_next_async()): re...
[ "def", "_fetch_page_async", "(", "self", ",", "page_size", ",", "*", "*", "q_options", ")", ":", "q_options", ".", "setdefault", "(", "'batch_size'", ",", "page_size", ")", "q_options", ".", "setdefault", "(", "'produce_cursors'", ",", "True", ")", "it", "="...
Internal version of fetch_page_async().
[ "Internal", "version", "of", "fetch_page_async", "()", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1374-L1388
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
Query._make_options
def _make_options(self, q_options): """Helper to construct a QueryOptions object from keyword arguments. Args: q_options: a dict of keyword arguments. Note that either 'options' or 'config' can be used to pass another QueryOptions object, but not both. If another QueryOptions object is give...
python
def _make_options(self, q_options): """Helper to construct a QueryOptions object from keyword arguments. Args: q_options: a dict of keyword arguments. Note that either 'options' or 'config' can be used to pass another QueryOptions object, but not both. If another QueryOptions object is give...
[ "def", "_make_options", "(", "self", ",", "q_options", ")", ":", "if", "not", "(", "q_options", "or", "self", ".", "__projection", ")", ":", "return", "self", ".", "default_options", "if", "'options'", "in", "q_options", ":", "# Move 'options' to 'config' since ...
Helper to construct a QueryOptions object from keyword arguments. Args: q_options: a dict of keyword arguments. Note that either 'options' or 'config' can be used to pass another QueryOptions object, but not both. If another QueryOptions object is given it provides default values. If self....
[ "Helper", "to", "construct", "a", "QueryOptions", "object", "from", "keyword", "arguments", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1390-L1432
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
Query.analyze
def analyze(self): """Return a list giving the parameters required by a query.""" class MockBindings(dict): def __contains__(self, key): self[key] = None return True bindings = MockBindings() used = {} ancestor = self.ancestor if isinstance(ancestor, ParameterizedThing): ...
python
def analyze(self): """Return a list giving the parameters required by a query.""" class MockBindings(dict): def __contains__(self, key): self[key] = None return True bindings = MockBindings() used = {} ancestor = self.ancestor if isinstance(ancestor, ParameterizedThing): ...
[ "def", "analyze", "(", "self", ")", ":", "class", "MockBindings", "(", "dict", ")", ":", "def", "__contains__", "(", "self", ",", "key", ")", ":", "self", "[", "key", "]", "=", "None", "return", "True", "bindings", "=", "MockBindings", "(", ")", "use...
Return a list giving the parameters required by a query.
[ "Return", "a", "list", "giving", "the", "parameters", "required", "by", "a", "query", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1453-L1468
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
Query._bind
def _bind(self, args, kwds): """Bind parameter values. Returns a new Query object.""" bindings = dict(kwds) for i, arg in enumerate(args): bindings[i + 1] = arg used = {} ancestor = self.ancestor if isinstance(ancestor, ParameterizedThing): ancestor = ancestor.resolve(bindings, used...
python
def _bind(self, args, kwds): """Bind parameter values. Returns a new Query object.""" bindings = dict(kwds) for i, arg in enumerate(args): bindings[i + 1] = arg used = {} ancestor = self.ancestor if isinstance(ancestor, ParameterizedThing): ancestor = ancestor.resolve(bindings, used...
[ "def", "_bind", "(", "self", ",", "args", ",", "kwds", ")", ":", "bindings", "=", "dict", "(", "kwds", ")", "for", "i", ",", "arg", "in", "enumerate", "(", "args", ")", ":", "bindings", "[", "i", "+", "1", "]", "=", "arg", "used", "=", "{", "...
Bind parameter values. Returns a new Query object.
[ "Bind", "parameter", "values", ".", "Returns", "a", "new", "Query", "object", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1474-L1498
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
QueryIterator.cursor_before
def cursor_before(self): """Return the cursor before the current item. You must pass a QueryOptions object with produce_cursors=True for this to work. If there is no cursor or no current item, raise BadArgumentError. Before next() has returned there is no cursor. Once the loop is exhausted, t...
python
def cursor_before(self): """Return the cursor before the current item. You must pass a QueryOptions object with produce_cursors=True for this to work. If there is no cursor or no current item, raise BadArgumentError. Before next() has returned there is no cursor. Once the loop is exhausted, t...
[ "def", "cursor_before", "(", "self", ")", ":", "if", "self", ".", "_exhausted", ":", "return", "self", ".", "cursor_after", "(", ")", "if", "isinstance", "(", "self", ".", "_cursor_before", ",", "BaseException", ")", ":", "raise", "self", ".", "_cursor_bef...
Return the cursor before the current item. You must pass a QueryOptions object with produce_cursors=True for this to work. If there is no cursor or no current item, raise BadArgumentError. Before next() has returned there is no cursor. Once the loop is exhausted, this returns the cursor after the...
[ "Return", "the", "cursor", "before", "the", "current", "item", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1693-L1707
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
QueryIterator.cursor_after
def cursor_after(self): """Return the cursor after the current item. You must pass a QueryOptions object with produce_cursors=True for this to work. If there is no cursor or no current item, raise BadArgumentError. Before next() has returned there is no cursor. Once the loop is exhausted, t...
python
def cursor_after(self): """Return the cursor after the current item. You must pass a QueryOptions object with produce_cursors=True for this to work. If there is no cursor or no current item, raise BadArgumentError. Before next() has returned there is no cursor. Once the loop is exhausted, t...
[ "def", "cursor_after", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "_cursor_after", ",", "BaseException", ")", ":", "raise", "self", ".", "_cursor_after", "return", "self", ".", "_cursor_after" ]
Return the cursor after the current item. You must pass a QueryOptions object with produce_cursors=True for this to work. If there is no cursor or no current item, raise BadArgumentError. Before next() has returned there is no cursor. Once the loop is exhausted, this returns the cursor after th...
[ "Return", "the", "cursor", "after", "the", "current", "item", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1709-L1721
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
QueryIterator.has_next_async
def has_next_async(self): """Return a Future whose result will say whether a next item is available. See the module docstring for the usage pattern. """ if self._fut is None: self._fut = self._iter.getq() flag = True try: yield self._fut except EOFError: flag = False r...
python
def has_next_async(self): """Return a Future whose result will say whether a next item is available. See the module docstring for the usage pattern. """ if self._fut is None: self._fut = self._iter.getq() flag = True try: yield self._fut except EOFError: flag = False r...
[ "def", "has_next_async", "(", "self", ")", ":", "if", "self", ".", "_fut", "is", "None", ":", "self", ".", "_fut", "=", "self", ".", "_iter", ".", "getq", "(", ")", "flag", "=", "True", "try", ":", "yield", "self", ".", "_fut", "except", "EOFError"...
Return a Future whose result will say whether a next item is available. See the module docstring for the usage pattern.
[ "Return", "a", "Future", "whose", "result", "will", "say", "whether", "a", "next", "item", "is", "available", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1784-L1796
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
QueryIterator.next
def next(self): """Iterator protocol: get next item or raise StopIteration.""" if self._fut is None: self._fut = self._iter.getq() try: try: # The future result is set by this class's _extended_callback # method. # pylint: disable=unpacking-non-sequence (ent, ...
python
def next(self): """Iterator protocol: get next item or raise StopIteration.""" if self._fut is None: self._fut = self._iter.getq() try: try: # The future result is set by this class's _extended_callback # method. # pylint: disable=unpacking-non-sequence (ent, ...
[ "def", "next", "(", "self", ")", ":", "if", "self", ".", "_fut", "is", "None", ":", "self", ".", "_fut", "=", "self", ".", "_iter", ".", "getq", "(", ")", "try", ":", "try", ":", "# The future result is set by this class's _extended_callback", "# method.", ...
Iterator protocol: get next item or raise StopIteration.
[ "Iterator", "protocol", ":", "get", "next", "item", "or", "raise", "StopIteration", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1798-L1816
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
_MultiQuery.run_to_queue
def run_to_queue(self, queue, conn, options=None): """Run this query, putting entities into the given queue.""" if options is None: # Default options. offset = None limit = None keys_only = None else: # Capture options we need to simulate. offset = options.offset li...
python
def run_to_queue(self, queue, conn, options=None): """Run this query, putting entities into the given queue.""" if options is None: # Default options. offset = None limit = None keys_only = None else: # Capture options we need to simulate. offset = options.offset li...
[ "def", "run_to_queue", "(", "self", ",", "queue", ",", "conn", ",", "options", "=", "None", ")", ":", "if", "options", "is", "None", ":", "# Default options.", "offset", "=", "None", "limit", "=", "None", "keys_only", "=", "None", "else", ":", "# Capture...
Run this query, putting entities into the given queue.
[ "Run", "this", "query", "putting", "entities", "into", "the", "given", "queue", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1910-L2047
GoogleCloudPlatform/datastore-ndb-python
ndb/memcache_client.py
MemcacheClient.memcache_get
def memcache_get(self, key, for_cas=False, namespace=None, use_cache=False, deadline=None): """An auto-batching wrapper for memcache.get() or .get_multi(). Args: key: Key to set. This must be a string; no prefix is applied. for_cas: If True, request and store CAS ids on the Cont...
python
def memcache_get(self, key, for_cas=False, namespace=None, use_cache=False, deadline=None): """An auto-batching wrapper for memcache.get() or .get_multi(). Args: key: Key to set. This must be a string; no prefix is applied. for_cas: If True, request and store CAS ids on the Cont...
[ "def", "memcache_get", "(", "self", ",", "key", ",", "for_cas", "=", "False", ",", "namespace", "=", "None", ",", "use_cache", "=", "False", ",", "deadline", "=", "None", ")", ":", "if", "not", "isinstance", "(", "key", ",", "basestring", ")", ":", "...
An auto-batching wrapper for memcache.get() or .get_multi(). Args: key: Key to set. This must be a string; no prefix is applied. for_cas: If True, request and store CAS ids on the Context. namespace: Optional namespace. deadline: Optional deadline for the RPC. Returns: A Future ...
[ "An", "auto", "-", "batching", "wrapper", "for", "memcache", ".", "get", "()", "or", ".", "get_multi", "()", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/memcache_client.py#L103-L128
GoogleCloudPlatform/datastore-ndb-python
ndb/utils.py
positional
def positional(max_pos_args): """A decorator to declare that only the first N arguments may be positional. Note that for methods, n includes 'self'. """ __ndb_debug__ = 'SKIP' def positional_decorator(wrapped): if not DEBUG: return wrapped __ndb_debug__ = 'SKIP' @wrapping(wrapped) def...
python
def positional(max_pos_args): """A decorator to declare that only the first N arguments may be positional. Note that for methods, n includes 'self'. """ __ndb_debug__ = 'SKIP' def positional_decorator(wrapped): if not DEBUG: return wrapped __ndb_debug__ = 'SKIP' @wrapping(wrapped) def...
[ "def", "positional", "(", "max_pos_args", ")", ":", "__ndb_debug__", "=", "'SKIP'", "def", "positional_decorator", "(", "wrapped", ")", ":", "if", "not", "DEBUG", ":", "return", "wrapped", "__ndb_debug__", "=", "'SKIP'", "@", "wrapping", "(", "wrapped", ")", ...
A decorator to declare that only the first N arguments may be positional. Note that for methods, n includes 'self'.
[ "A", "decorator", "to", "declare", "that", "only", "the", "first", "N", "arguments", "may", "be", "positional", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/utils.py#L138-L162
GoogleCloudPlatform/datastore-ndb-python
ndb/utils.py
decorator
def decorator(wrapped_decorator): """Converts a function into a decorator that optionally accepts keyword arguments in its declaration. Example usage: @utils.decorator def decorator(func, args, kwds, op1=None): ... apply op1 ... return func(*args, **kwds) # Form (1), vanilla @decorat...
python
def decorator(wrapped_decorator): """Converts a function into a decorator that optionally accepts keyword arguments in its declaration. Example usage: @utils.decorator def decorator(func, args, kwds, op1=None): ... apply op1 ... return func(*args, **kwds) # Form (1), vanilla @decorat...
[ "def", "decorator", "(", "wrapped_decorator", ")", ":", "def", "helper", "(", "_func", "=", "None", ",", "*", "*", "options", ")", ":", "def", "outer_wrapper", "(", "func", ")", ":", "@", "wrapping", "(", "func", ")", "def", "inner_wrapper", "(", "*", ...
Converts a function into a decorator that optionally accepts keyword arguments in its declaration. Example usage: @utils.decorator def decorator(func, args, kwds, op1=None): ... apply op1 ... return func(*args, **kwds) # Form (1), vanilla @decorator foo(...) ... # Form (...
[ "Converts", "a", "function", "into", "a", "decorator", "that", "optionally", "accepts", "keyword", "arguments", "in", "its", "declaration", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/utils.py#L165-L210
GoogleCloudPlatform/datastore-ndb-python
demo/app/fibo.py
fibonacci
def fibonacci(n): """A recursive Fibonacci to exercise task switching.""" if n <= 1: raise ndb.Return(n) a, b = yield fibonacci(n - 1), fibonacci(n - 2) raise ndb.Return(a + b)
python
def fibonacci(n): """A recursive Fibonacci to exercise task switching.""" if n <= 1: raise ndb.Return(n) a, b = yield fibonacci(n - 1), fibonacci(n - 2) raise ndb.Return(a + b)
[ "def", "fibonacci", "(", "n", ")", ":", "if", "n", "<=", "1", ":", "raise", "ndb", ".", "Return", "(", "n", ")", "a", ",", "b", "=", "yield", "fibonacci", "(", "n", "-", "1", ")", ",", "fibonacci", "(", "n", "-", "2", ")", "raise", "ndb", "...
A recursive Fibonacci to exercise task switching.
[ "A", "recursive", "Fibonacci", "to", "exercise", "task", "switching", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/demo/app/fibo.py#L32-L37
GoogleCloudPlatform/datastore-ndb-python
demo/app/fibo.py
memoizing_fibonacci
def memoizing_fibonacci(n): """A memoizing recursive Fibonacci to exercise RPCs.""" if n <= 1: raise ndb.Return(n) key = ndb.Key(FibonacciMemo, str(n)) memo = yield key.get_async(ndb_should_cache=False) if memo is not None: assert memo.arg == n logging.info('memo hit: %d -> %d', n, memo.value) ...
python
def memoizing_fibonacci(n): """A memoizing recursive Fibonacci to exercise RPCs.""" if n <= 1: raise ndb.Return(n) key = ndb.Key(FibonacciMemo, str(n)) memo = yield key.get_async(ndb_should_cache=False) if memo is not None: assert memo.arg == n logging.info('memo hit: %d -> %d', n, memo.value) ...
[ "def", "memoizing_fibonacci", "(", "n", ")", ":", "if", "n", "<=", "1", ":", "raise", "ndb", ".", "Return", "(", "n", ")", "key", "=", "ndb", ".", "Key", "(", "FibonacciMemo", ",", "str", "(", "n", ")", ")", "memo", "=", "yield", "key", ".", "g...
A memoizing recursive Fibonacci to exercise RPCs.
[ "A", "memoizing", "recursive", "Fibonacci", "to", "exercise", "RPCs", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/demo/app/fibo.py#L46-L63
GoogleCloudPlatform/datastore-ndb-python
ndb/autobatcher.py
AutoBatcher.run_queue
def run_queue(self, options, todo): """Actually run the _todo_tasklet.""" utils.logging_debug('AutoBatcher(%s): %d items', self._todo_tasklet.__name__, len(todo)) batch_fut = self._todo_tasklet(todo, options) self._running.append(batch_fut) # Add a callback when we're done. ...
python
def run_queue(self, options, todo): """Actually run the _todo_tasklet.""" utils.logging_debug('AutoBatcher(%s): %d items', self._todo_tasklet.__name__, len(todo)) batch_fut = self._todo_tasklet(todo, options) self._running.append(batch_fut) # Add a callback when we're done. ...
[ "def", "run_queue", "(", "self", ",", "options", ",", "todo", ")", ":", "utils", ".", "logging_debug", "(", "'AutoBatcher(%s): %d items'", ",", "self", ".", "_todo_tasklet", ".", "__name__", ",", "len", "(", "todo", ")", ")", "batch_fut", "=", "self", ".",...
Actually run the _todo_tasklet.
[ "Actually", "run", "the", "_todo_tasklet", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/autobatcher.py#L71-L78
GoogleCloudPlatform/datastore-ndb-python
ndb/autobatcher.py
AutoBatcher.add
def add(self, arg, options=None): """Adds an arg and gets back a future. Args: arg: one argument for _todo_tasklet. options: rpc options. Return: An instance of future, representing the result of running _todo_tasklet without batching. """ fut = tasklets.Future('%s.add(%s...
python
def add(self, arg, options=None): """Adds an arg and gets back a future. Args: arg: one argument for _todo_tasklet. options: rpc options. Return: An instance of future, representing the result of running _todo_tasklet without batching. """ fut = tasklets.Future('%s.add(%s...
[ "def", "add", "(", "self", ",", "arg", ",", "options", "=", "None", ")", ":", "fut", "=", "tasklets", ".", "Future", "(", "'%s.add(%s, %s)'", "%", "(", "self", ",", "arg", ",", "options", ")", ")", "todo", "=", "self", ".", "_queues", ".", "get", ...
Adds an arg and gets back a future. Args: arg: one argument for _todo_tasklet. options: rpc options. Return: An instance of future, representing the result of running _todo_tasklet without batching.
[ "Adds", "an", "arg", "and", "gets", "back", "a", "future", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/autobatcher.py#L90-L113
GoogleCloudPlatform/datastore-ndb-python
ndb/autobatcher.py
AutoBatcher._finished_callback
def _finished_callback(self, batch_fut, todo): """Passes exception along. Args: batch_fut: the batch future returned by running todo_tasklet. todo: (fut, option) pair. fut is the future return by each add() call. If the batch fut was successful, it has already called fut.set_result() on ot...
python
def _finished_callback(self, batch_fut, todo): """Passes exception along. Args: batch_fut: the batch future returned by running todo_tasklet. todo: (fut, option) pair. fut is the future return by each add() call. If the batch fut was successful, it has already called fut.set_result() on ot...
[ "def", "_finished_callback", "(", "self", ",", "batch_fut", ",", "todo", ")", ":", "self", ".", "_running", ".", "remove", "(", "batch_fut", ")", "err", "=", "batch_fut", ".", "get_exception", "(", ")", "if", "err", "is", "not", "None", ":", "tb", "=",...
Passes exception along. Args: batch_fut: the batch future returned by running todo_tasklet. todo: (fut, option) pair. fut is the future return by each add() call. If the batch fut was successful, it has already called fut.set_result() on other individual futs. This method only handles when the...
[ "Passes", "exception", "along", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/autobatcher.py#L132-L149
GoogleCloudPlatform/datastore-ndb-python
ndb/metadata.py
get_namespaces
def get_namespaces(start=None, end=None): """Return all namespaces in the specified range. Args: start: only return namespaces >= start if start is not None. end: only return namespaces < end if end is not None. Returns: A list of namespace names between the (optional) start and end values. """ ...
python
def get_namespaces(start=None, end=None): """Return all namespaces in the specified range. Args: start: only return namespaces >= start if start is not None. end: only return namespaces < end if end is not None. Returns: A list of namespace names between the (optional) start and end values. """ ...
[ "def", "get_namespaces", "(", "start", "=", "None", ",", "end", "=", "None", ")", ":", "q", "=", "Namespace", ".", "query", "(", ")", "if", "start", "is", "not", "None", ":", "q", "=", "q", ".", "filter", "(", "Namespace", ".", "key", ">=", "Name...
Return all namespaces in the specified range. Args: start: only return namespaces >= start if start is not None. end: only return namespaces < end if end is not None. Returns: A list of namespace names between the (optional) start and end values.
[ "Return", "all", "namespaces", "in", "the", "specified", "range", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/metadata.py#L239-L254
GoogleCloudPlatform/datastore-ndb-python
ndb/metadata.py
get_kinds
def get_kinds(start=None, end=None): """Return all kinds in the specified range, for the current namespace. Args: start: only return kinds >= start if start is not None. end: only return kinds < end if end is not None. Returns: A list of kind names between the (optional) start and end values. """ ...
python
def get_kinds(start=None, end=None): """Return all kinds in the specified range, for the current namespace. Args: start: only return kinds >= start if start is not None. end: only return kinds < end if end is not None. Returns: A list of kind names between the (optional) start and end values. """ ...
[ "def", "get_kinds", "(", "start", "=", "None", ",", "end", "=", "None", ")", ":", "q", "=", "Kind", ".", "query", "(", ")", "if", "start", "is", "not", "None", "and", "start", "!=", "''", ":", "q", "=", "q", ".", "filter", "(", "Kind", ".", "...
Return all kinds in the specified range, for the current namespace. Args: start: only return kinds >= start if start is not None. end: only return kinds < end if end is not None. Returns: A list of kind names between the (optional) start and end values.
[ "Return", "all", "kinds", "in", "the", "specified", "range", "for", "the", "current", "namespace", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/metadata.py#L257-L275
GoogleCloudPlatform/datastore-ndb-python
ndb/metadata.py
get_properties_of_kind
def get_properties_of_kind(kind, start=None, end=None): """Return all properties of kind in the specified range. NOTE: This function does not return unindexed properties. Args: kind: name of kind whose properties you want. start: only return properties >= start if start is not None. end: only return...
python
def get_properties_of_kind(kind, start=None, end=None): """Return all properties of kind in the specified range. NOTE: This function does not return unindexed properties. Args: kind: name of kind whose properties you want. start: only return properties >= start if start is not None. end: only return...
[ "def", "get_properties_of_kind", "(", "kind", ",", "start", "=", "None", ",", "end", "=", "None", ")", ":", "q", "=", "Property", ".", "query", "(", "ancestor", "=", "Property", ".", "key_for_kind", "(", "kind", ")", ")", "if", "start", "is", "not", ...
Return all properties of kind in the specified range. NOTE: This function does not return unindexed properties. Args: kind: name of kind whose properties you want. start: only return properties >= start if start is not None. end: only return properties < end if end is not None. Returns: A list ...
[ "Return", "all", "properties", "of", "kind", "in", "the", "specified", "range", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/metadata.py#L278-L300
GoogleCloudPlatform/datastore-ndb-python
ndb/metadata.py
get_representations_of_kind
def get_representations_of_kind(kind, start=None, end=None): """Return all representations of properties of kind in the specified range. NOTE: This function does not return unindexed properties. Args: kind: name of kind whose properties you want. start: only return properties >= start if start is not No...
python
def get_representations_of_kind(kind, start=None, end=None): """Return all representations of properties of kind in the specified range. NOTE: This function does not return unindexed properties. Args: kind: name of kind whose properties you want. start: only return properties >= start if start is not No...
[ "def", "get_representations_of_kind", "(", "kind", ",", "start", "=", "None", ",", "end", "=", "None", ")", ":", "q", "=", "Property", ".", "query", "(", "ancestor", "=", "Property", ".", "key_for_kind", "(", "kind", ")", ")", "if", "start", "is", "not...
Return all representations of properties of kind in the specified range. NOTE: This function does not return unindexed properties. Args: kind: name of kind whose properties you want. start: only return properties >= start if start is not None. end: only return properties < end if end is not None. R...
[ "Return", "all", "representations", "of", "properties", "of", "kind", "in", "the", "specified", "range", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/metadata.py#L303-L328
GoogleCloudPlatform/datastore-ndb-python
ndb/metadata.py
get_entity_group_version
def get_entity_group_version(key): """Return the version of the entity group containing key. Args: key: a key for an entity group whose __entity_group__ key you want. Returns: The version of the entity group containing key. This version is guaranteed to increase on every change to the entity group. ...
python
def get_entity_group_version(key): """Return the version of the entity group containing key. Args: key: a key for an entity group whose __entity_group__ key you want. Returns: The version of the entity group containing key. This version is guaranteed to increase on every change to the entity group. ...
[ "def", "get_entity_group_version", "(", "key", ")", ":", "eg", "=", "EntityGroup", ".", "key_for_entity_group", "(", "key", ")", ".", "get", "(", ")", "if", "eg", ":", "return", "eg", ".", "version", "else", ":", "return", "None" ]
Return the version of the entity group containing key. Args: key: a key for an entity group whose __entity_group__ key you want. Returns: The version of the entity group containing key. This version is guaranteed to increase on every change to the entity group. The version may increase even in the...
[ "Return", "the", "version", "of", "the", "entity", "group", "containing", "key", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/metadata.py#L331-L350
GoogleCloudPlatform/datastore-ndb-python
ndb/metadata.py
Namespace.key_for_namespace
def key_for_namespace(cls, namespace): """Return the Key for a namespace. Args: namespace: A string giving the namespace whose key is requested. Returns: The Key for the namespace. """ if namespace: return model.Key(cls.KIND_NAME, namespace) else: return model.Key(cls.K...
python
def key_for_namespace(cls, namespace): """Return the Key for a namespace. Args: namespace: A string giving the namespace whose key is requested. Returns: The Key for the namespace. """ if namespace: return model.Key(cls.KIND_NAME, namespace) else: return model.Key(cls.K...
[ "def", "key_for_namespace", "(", "cls", ",", "namespace", ")", ":", "if", "namespace", ":", "return", "model", ".", "Key", "(", "cls", ".", "KIND_NAME", ",", "namespace", ")", "else", ":", "return", "model", ".", "Key", "(", "cls", ".", "KIND_NAME", ",...
Return the Key for a namespace. Args: namespace: A string giving the namespace whose key is requested. Returns: The Key for the namespace.
[ "Return", "the", "Key", "for", "a", "namespace", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/metadata.py#L76-L88
GoogleCloudPlatform/datastore-ndb-python
ndb/metadata.py
Property.key_for_property
def key_for_property(cls, kind, property): """Return the __property__ key for property of kind. Args: kind: kind whose key is requested. property: property whose key is requested. Returns: The key for property of kind. """ return model.Key(Kind.KIND_NAME, kind, Property.KIND_NAME...
python
def key_for_property(cls, kind, property): """Return the __property__ key for property of kind. Args: kind: kind whose key is requested. property: property whose key is requested. Returns: The key for property of kind. """ return model.Key(Kind.KIND_NAME, kind, Property.KIND_NAME...
[ "def", "key_for_property", "(", "cls", ",", "kind", ",", "property", ")", ":", "return", "model", ".", "Key", "(", "Kind", ".", "KIND_NAME", ",", "kind", ",", "Property", ".", "KIND_NAME", ",", "property", ")" ]
Return the __property__ key for property of kind. Args: kind: kind whose key is requested. property: property whose key is requested. Returns: The key for property of kind.
[ "Return", "the", "__property__", "key", "for", "property", "of", "kind", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/metadata.py#L168-L178
GoogleCloudPlatform/datastore-ndb-python
ndb/metadata.py
Property.key_to_kind
def key_to_kind(cls, key): """Return the kind specified by a given __property__ key. Args: key: key whose kind name is requested. Returns: The kind specified by key. """ if key.kind() == Kind.KIND_NAME: return key.id() else: return key.parent().id()
python
def key_to_kind(cls, key): """Return the kind specified by a given __property__ key. Args: key: key whose kind name is requested. Returns: The kind specified by key. """ if key.kind() == Kind.KIND_NAME: return key.id() else: return key.parent().id()
[ "def", "key_to_kind", "(", "cls", ",", "key", ")", ":", "if", "key", ".", "kind", "(", ")", "==", "Kind", ".", "KIND_NAME", ":", "return", "key", ".", "id", "(", ")", "else", ":", "return", "key", ".", "parent", "(", ")", ".", "id", "(", ")" ]
Return the kind specified by a given __property__ key. Args: key: key whose kind name is requested. Returns: The kind specified by key.
[ "Return", "the", "kind", "specified", "by", "a", "given", "__property__", "key", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/metadata.py#L181-L193
GoogleCloudPlatform/datastore-ndb-python
ndb/metadata.py
EntityGroup.key_for_entity_group
def key_for_entity_group(cls, key): """Return the key for the entity group containing key. Args: key: a key for an entity group whose __entity_group__ key you want. Returns: The __entity_group__ key for the entity group containing key. """ return model.Key(cls.KIND_NAME, cls.ID, parent...
python
def key_for_entity_group(cls, key): """Return the key for the entity group containing key. Args: key: a key for an entity group whose __entity_group__ key you want. Returns: The __entity_group__ key for the entity group containing key. """ return model.Key(cls.KIND_NAME, cls.ID, parent...
[ "def", "key_for_entity_group", "(", "cls", ",", "key", ")", ":", "return", "model", ".", "Key", "(", "cls", ".", "KIND_NAME", ",", "cls", ".", "ID", ",", "parent", "=", "key", ".", "root", "(", ")", ")" ]
Return the key for the entity group containing key. Args: key: a key for an entity group whose __entity_group__ key you want. Returns: The __entity_group__ key for the entity group containing key.
[ "Return", "the", "key", "for", "the", "entity", "group", "containing", "key", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/metadata.py#L227-L236
GoogleCloudPlatform/datastore-ndb-python
ndb/django_middleware.py
NdbDjangoMiddleware.process_request
def process_request(self, unused_request): """Called by Django before deciding which view to execute.""" # Compare to the first half of toplevel() in context.py. tasklets._state.clear_all_pending() # Create and install a new context. ctx = tasklets.make_default_context() tasklets.set_context(ctx...
python
def process_request(self, unused_request): """Called by Django before deciding which view to execute.""" # Compare to the first half of toplevel() in context.py. tasklets._state.clear_all_pending() # Create and install a new context. ctx = tasklets.make_default_context() tasklets.set_context(ctx...
[ "def", "process_request", "(", "self", ",", "unused_request", ")", ":", "# Compare to the first half of toplevel() in context.py.", "tasklets", ".", "_state", ".", "clear_all_pending", "(", ")", "# Create and install a new context.", "ctx", "=", "tasklets", ".", "make_defau...
Called by Django before deciding which view to execute.
[ "Called", "by", "Django", "before", "deciding", "which", "view", "to", "execute", "." ]
train
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/django_middleware.py#L42-L48