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 |
|---|---|---|---|---|---|---|---|---|---|---|
spacetelescope/drizzlepac | drizzlepac/ablot.py | run | def run(configObj,wcsmap=None):
"""
Run the blot task based on parameters provided interactively by the user.
"""
# Insure all output filenames specified have .fits extensions
if configObj['outdata'][-5:] != '.fits': configObj['outdata'] += '.fits'
scale_pars = configObj['Data Scaling Paramet... | python | def run(configObj,wcsmap=None):
"""
Run the blot task based on parameters provided interactively by the user.
"""
# Insure all output filenames specified have .fits extensions
if configObj['outdata'][-5:] != '.fits': configObj['outdata'] += '.fits'
scale_pars = configObj['Data Scaling Paramet... | [
"def",
"run",
"(",
"configObj",
",",
"wcsmap",
"=",
"None",
")",
":",
"# Insure all output filenames specified have .fits extensions",
"if",
"configObj",
"[",
"'outdata'",
"]",
"[",
"-",
"5",
":",
"]",
"!=",
"'.fits'",
":",
"configObj",
"[",
"'outdata'",
"]",
... | Run the blot task based on parameters provided interactively by the user. | [
"Run",
"the",
"blot",
"task",
"based",
"on",
"parameters",
"provided",
"interactively",
"by",
"the",
"user",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/ablot.py#L65-L160 |
spacetelescope/drizzlepac | drizzlepac/ablot.py | runBlot | def runBlot(imageObjectList, output_wcs, configObj={},
wcsmap=wcs_functions.WCSMap, procSteps=None):
"""
runBlot(imageObjectList, output_wcs, configObj={},
wcsmap=wcs_functions.WCSMap, procSteps=None)
"""
if procSteps is not None:
procSteps.addStep('Blot')
blot_name ... | python | def runBlot(imageObjectList, output_wcs, configObj={},
wcsmap=wcs_functions.WCSMap, procSteps=None):
"""
runBlot(imageObjectList, output_wcs, configObj={},
wcsmap=wcs_functions.WCSMap, procSteps=None)
"""
if procSteps is not None:
procSteps.addStep('Blot')
blot_name ... | [
"def",
"runBlot",
"(",
"imageObjectList",
",",
"output_wcs",
",",
"configObj",
"=",
"{",
"}",
",",
"wcsmap",
"=",
"wcs_functions",
".",
"WCSMap",
",",
"procSteps",
"=",
"None",
")",
":",
"if",
"procSteps",
"is",
"not",
"None",
":",
"procSteps",
".",
"add... | runBlot(imageObjectList, output_wcs, configObj={},
wcsmap=wcs_functions.WCSMap, procSteps=None) | [
"runBlot",
"(",
"imageObjectList",
"output_wcs",
"configObj",
"=",
"{}",
"wcsmap",
"=",
"wcs_functions",
".",
"WCSMap",
"procSteps",
"=",
"None",
")"
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/ablot.py#L166-L191 |
spacetelescope/drizzlepac | drizzlepac/ablot.py | run_blot | def run_blot(imageObjectList,output_wcs,paramDict,wcsmap=wcs_functions.WCSMap):
"""
run_blot(imageObjectList, output_wcs, paramDict, wcsmap=wcs_functions.WCSMap)
Perform the blot operation on the list of images.
"""
# Insure that input imageObject is a list
if not isinstance(imageObjectList, li... | python | def run_blot(imageObjectList,output_wcs,paramDict,wcsmap=wcs_functions.WCSMap):
"""
run_blot(imageObjectList, output_wcs, paramDict, wcsmap=wcs_functions.WCSMap)
Perform the blot operation on the list of images.
"""
# Insure that input imageObject is a list
if not isinstance(imageObjectList, li... | [
"def",
"run_blot",
"(",
"imageObjectList",
",",
"output_wcs",
",",
"paramDict",
",",
"wcsmap",
"=",
"wcs_functions",
".",
"WCSMap",
")",
":",
"# Insure that input imageObject is a list",
"if",
"not",
"isinstance",
"(",
"imageObjectList",
",",
"list",
")",
":",
"im... | run_blot(imageObjectList, output_wcs, paramDict, wcsmap=wcs_functions.WCSMap)
Perform the blot operation on the list of images. | [
"run_blot",
"(",
"imageObjectList",
"output_wcs",
"paramDict",
"wcsmap",
"=",
"wcs_functions",
".",
"WCSMap",
")"
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/ablot.py#L237-L326 |
spacetelescope/drizzlepac | drizzlepac/ablot.py | do_blot | def do_blot(source, source_wcs, blot_wcs, exptime, coeffs = True,
interp='poly5', sinscl=1.0, stepsize=10, wcsmap=None):
""" Core functionality of performing the 'blot' operation to create a single
blotted image from a single source image.
All distortion information is assumed to be incl... | python | def do_blot(source, source_wcs, blot_wcs, exptime, coeffs = True,
interp='poly5', sinscl=1.0, stepsize=10, wcsmap=None):
""" Core functionality of performing the 'blot' operation to create a single
blotted image from a single source image.
All distortion information is assumed to be incl... | [
"def",
"do_blot",
"(",
"source",
",",
"source_wcs",
",",
"blot_wcs",
",",
"exptime",
",",
"coeffs",
"=",
"True",
",",
"interp",
"=",
"'poly5'",
",",
"sinscl",
"=",
"1.0",
",",
"stepsize",
"=",
"10",
",",
"wcsmap",
"=",
"None",
")",
":",
"_outsci",
"=... | Core functionality of performing the 'blot' operation to create a single
blotted image from a single source image.
All distortion information is assumed to be included in the WCS specification
of the 'output' blotted image given in 'blot_wcs'.
This is the simplest interface that can be ... | [
"Core",
"functionality",
"of",
"performing",
"the",
"blot",
"operation",
"to",
"create",
"a",
"single",
"blotted",
"image",
"from",
"a",
"single",
"source",
"image",
".",
"All",
"distortion",
"information",
"is",
"assumed",
"to",
"be",
"included",
"in",
"the",... | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/ablot.py#L329-L419 |
spacetelescope/drizzlepac | drizzlepac/runastrodriz.py | process | def process(inFile,force=False,newpath=None, inmemory=False, num_cores=None,
headerlets=True, align_to_gaia=True):
""" Run astrodrizzle on input file/ASN table
using default values for astrodrizzle parameters.
"""
# We only need to import this package if a user run the task
import dr... | python | def process(inFile,force=False,newpath=None, inmemory=False, num_cores=None,
headerlets=True, align_to_gaia=True):
""" Run astrodrizzle on input file/ASN table
using default values for astrodrizzle parameters.
"""
# We only need to import this package if a user run the task
import dr... | [
"def",
"process",
"(",
"inFile",
",",
"force",
"=",
"False",
",",
"newpath",
"=",
"None",
",",
"inmemory",
"=",
"False",
",",
"num_cores",
"=",
"None",
",",
"headerlets",
"=",
"True",
",",
"align_to_gaia",
"=",
"True",
")",
":",
"# We only need to import t... | Run astrodrizzle on input file/ASN table
using default values for astrodrizzle parameters. | [
"Run",
"astrodrizzle",
"on",
"input",
"file",
"/",
"ASN",
"table",
"using",
"default",
"values",
"for",
"astrodrizzle",
"parameters",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/runastrodriz.py#L131-L518 |
spacetelescope/drizzlepac | drizzlepac/runastrodriz.py | _lowerAsn | def _lowerAsn(asnfile):
""" Create a copy of the original asn file and change
the case of all members to lower-case.
"""
# Start by creating a new name for the ASN table
_indx = asnfile.find('_asn.fits')
_new_asn = asnfile[:_indx]+'_pipeline'+asnfile[_indx:]
if os.path.exists(_new_asn):
... | python | def _lowerAsn(asnfile):
""" Create a copy of the original asn file and change
the case of all members to lower-case.
"""
# Start by creating a new name for the ASN table
_indx = asnfile.find('_asn.fits')
_new_asn = asnfile[:_indx]+'_pipeline'+asnfile[_indx:]
if os.path.exists(_new_asn):
... | [
"def",
"_lowerAsn",
"(",
"asnfile",
")",
":",
"# Start by creating a new name for the ASN table",
"_indx",
"=",
"asnfile",
".",
"find",
"(",
"'_asn.fits'",
")",
"_new_asn",
"=",
"asnfile",
"[",
":",
"_indx",
"]",
"+",
"'_pipeline'",
"+",
"asnfile",
"[",
"_indx",... | Create a copy of the original asn file and change
the case of all members to lower-case. | [
"Create",
"a",
"copy",
"of",
"the",
"original",
"asn",
"file",
"and",
"change",
"the",
"case",
"of",
"all",
"members",
"to",
"lower",
"-",
"case",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/runastrodriz.py#L520-L538 |
spacetelescope/drizzlepac | drizzlepac/runastrodriz.py | _appendTrlFile | def _appendTrlFile(trlfile,drizfile):
""" Append drizfile to already existing trlfile from CALXXX.
"""
if not os.path.exists(drizfile):
return
# Open already existing CALWF3 trailer file for appending
ftrl = open(trlfile,'a')
# Open astrodrizzle trailer file
fdriz = open(drizfile)
... | python | def _appendTrlFile(trlfile,drizfile):
""" Append drizfile to already existing trlfile from CALXXX.
"""
if not os.path.exists(drizfile):
return
# Open already existing CALWF3 trailer file for appending
ftrl = open(trlfile,'a')
# Open astrodrizzle trailer file
fdriz = open(drizfile)
... | [
"def",
"_appendTrlFile",
"(",
"trlfile",
",",
"drizfile",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"drizfile",
")",
":",
"return",
"# Open already existing CALWF3 trailer file for appending",
"ftrl",
"=",
"open",
"(",
"trlfile",
",",
"'a'",
... | Append drizfile to already existing trlfile from CALXXX. | [
"Append",
"drizfile",
"to",
"already",
"existing",
"trlfile",
"from",
"CALXXX",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/runastrodriz.py#L540-L561 |
spacetelescope/drizzlepac | drizzlepac/runastrodriz.py | _timestamp | def _timestamp(_process_name):
"""Create formatted time string recognizable by OPUS."""
_prefix= time.strftime("%Y%j%H%M%S-I-----",time.localtime())
_lenstr = 60 - len(_process_name)
return _prefix+_process_name+(_lenstr*'-')+'\n' | python | def _timestamp(_process_name):
"""Create formatted time string recognizable by OPUS."""
_prefix= time.strftime("%Y%j%H%M%S-I-----",time.localtime())
_lenstr = 60 - len(_process_name)
return _prefix+_process_name+(_lenstr*'-')+'\n' | [
"def",
"_timestamp",
"(",
"_process_name",
")",
":",
"_prefix",
"=",
"time",
".",
"strftime",
"(",
"\"%Y%j%H%M%S-I-----\"",
",",
"time",
".",
"localtime",
"(",
")",
")",
"_lenstr",
"=",
"60",
"-",
"len",
"(",
"_process_name",
")",
"return",
"_prefix",
"+",... | Create formatted time string recognizable by OPUS. | [
"Create",
"formatted",
"time",
"string",
"recognizable",
"by",
"OPUS",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/runastrodriz.py#L564-L568 |
spacetelescope/drizzlepac | drizzlepac/runastrodriz.py | _createWorkingDir | def _createWorkingDir(rootdir,input):
"""
Create a working directory based on input name under the parent directory specified as rootdir
"""
# extract rootname from input
rootname = input[:input.find('_')]
newdir = os.path.join(rootdir,rootname)
if not os.path.exists(newdir):
os.mkdi... | python | def _createWorkingDir(rootdir,input):
"""
Create a working directory based on input name under the parent directory specified as rootdir
"""
# extract rootname from input
rootname = input[:input.find('_')]
newdir = os.path.join(rootdir,rootname)
if not os.path.exists(newdir):
os.mkdi... | [
"def",
"_createWorkingDir",
"(",
"rootdir",
",",
"input",
")",
":",
"# extract rootname from input",
"rootname",
"=",
"input",
"[",
":",
"input",
".",
"find",
"(",
"'_'",
")",
"]",
"newdir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"rootdir",
",",
"root... | Create a working directory based on input name under the parent directory specified as rootdir | [
"Create",
"a",
"working",
"directory",
"based",
"on",
"input",
"name",
"under",
"the",
"parent",
"directory",
"specified",
"as",
"rootdir"
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/runastrodriz.py#L578-L587 |
spacetelescope/drizzlepac | drizzlepac/runastrodriz.py | _copyToNewWorkingDir | def _copyToNewWorkingDir(newdir,input):
""" Copy input file and all related files necessary for processing to the new working directory.
This function works in a greedy manner, in that all files associated
with all inputs(have the same rootname) will be copied to the new
working directory.
... | python | def _copyToNewWorkingDir(newdir,input):
""" Copy input file and all related files necessary for processing to the new working directory.
This function works in a greedy manner, in that all files associated
with all inputs(have the same rootname) will be copied to the new
working directory.
... | [
"def",
"_copyToNewWorkingDir",
"(",
"newdir",
",",
"input",
")",
":",
"flist",
"=",
"[",
"]",
"if",
"'_asn.fits'",
"in",
"input",
":",
"asndict",
"=",
"asnutil",
".",
"readASNTable",
"(",
"input",
",",
"None",
")",
"flist",
".",
"append",
"(",
"input",
... | Copy input file and all related files necessary for processing to the new working directory.
This function works in a greedy manner, in that all files associated
with all inputs(have the same rootname) will be copied to the new
working directory. | [
"Copy",
"input",
"file",
"and",
"all",
"related",
"files",
"necessary",
"for",
"processing",
"to",
"the",
"new",
"working",
"directory",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/runastrodriz.py#L589-L607 |
spacetelescope/drizzlepac | drizzlepac/runastrodriz.py | _restoreResults | def _restoreResults(newdir,origdir):
""" Move (not copy) all files from newdir back to the original directory
"""
for fname in glob.glob(os.path.join(newdir,'*')):
shutil.move(fname,os.path.join(origdir,os.path.basename(fname))) | python | def _restoreResults(newdir,origdir):
""" Move (not copy) all files from newdir back to the original directory
"""
for fname in glob.glob(os.path.join(newdir,'*')):
shutil.move(fname,os.path.join(origdir,os.path.basename(fname))) | [
"def",
"_restoreResults",
"(",
"newdir",
",",
"origdir",
")",
":",
"for",
"fname",
"in",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"newdir",
",",
"'*'",
")",
")",
":",
"shutil",
".",
"move",
"(",
"fname",
",",
"os",
".",
"pat... | Move (not copy) all files from newdir back to the original directory | [
"Move",
"(",
"not",
"copy",
")",
"all",
"files",
"from",
"newdir",
"back",
"to",
"the",
"original",
"directory"
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/runastrodriz.py#L609-L613 |
spacetelescope/drizzlepac | drizzlepac/createMedian.py | median | def median(input=None, configObj=None, editpars=False, **inputDict):
"""
Create a median image from the seperately drizzled images.
"""
if input is not None:
inputDict["input"] = input
else:
raise ValueError("Please supply an input image")
configObj = util.getDefaultConfigObj(__... | python | def median(input=None, configObj=None, editpars=False, **inputDict):
"""
Create a median image from the seperately drizzled images.
"""
if input is not None:
inputDict["input"] = input
else:
raise ValueError("Please supply an input image")
configObj = util.getDefaultConfigObj(__... | [
"def",
"median",
"(",
"input",
"=",
"None",
",",
"configObj",
"=",
"None",
",",
"editpars",
"=",
"False",
",",
"*",
"*",
"inputDict",
")",
":",
"if",
"input",
"is",
"not",
"None",
":",
"inputDict",
"[",
"\"input\"",
"]",
"=",
"input",
"else",
":",
... | Create a median image from the seperately drizzled images. | [
"Create",
"a",
"median",
"image",
"from",
"the",
"seperately",
"drizzled",
"images",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/createMedian.py#L37-L52 |
spacetelescope/drizzlepac | drizzlepac/createMedian.py | createMedian | def createMedian(imgObjList, configObj, procSteps=None):
""" Top-level interface to createMedian step called from top-level
AstroDrizzle.
This function parses the input parameters then calls the `_median()`
function to median-combine the input images into a single image.
"""
if imgObjList is N... | python | def createMedian(imgObjList, configObj, procSteps=None):
""" Top-level interface to createMedian step called from top-level
AstroDrizzle.
This function parses the input parameters then calls the `_median()`
function to median-combine the input images into a single image.
"""
if imgObjList is N... | [
"def",
"createMedian",
"(",
"imgObjList",
",",
"configObj",
",",
"procSteps",
"=",
"None",
")",
":",
"if",
"imgObjList",
"is",
"None",
":",
"msg",
"=",
"\"Please provide a list of imageObjects to the median step\"",
"print",
"(",
"msg",
",",
"file",
"=",
"sys",
... | Top-level interface to createMedian step called from top-level
AstroDrizzle.
This function parses the input parameters then calls the `_median()`
function to median-combine the input images into a single image. | [
"Top",
"-",
"level",
"interface",
"to",
"createMedian",
"step",
"called",
"from",
"top",
"-",
"level",
"AstroDrizzle",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/createMedian.py#L67-L102 |
spacetelescope/drizzlepac | drizzlepac/createMedian.py | _median | def _median(imageObjectList, paramDict):
"""Create a median image from the list of image Objects
that has been given.
"""
newmasks = paramDict['median_newmasks']
comb_type = paramDict['combine_type'].lower()
nlow = paramDict['combine_nlow']
nhigh = paramDict['combine_nhigh']
grow = pa... | python | def _median(imageObjectList, paramDict):
"""Create a median image from the list of image Objects
that has been given.
"""
newmasks = paramDict['median_newmasks']
comb_type = paramDict['combine_type'].lower()
nlow = paramDict['combine_nlow']
nhigh = paramDict['combine_nhigh']
grow = pa... | [
"def",
"_median",
"(",
"imageObjectList",
",",
"paramDict",
")",
":",
"newmasks",
"=",
"paramDict",
"[",
"'median_newmasks'",
"]",
"comb_type",
"=",
"paramDict",
"[",
"'combine_type'",
"]",
".",
"lower",
"(",
")",
"nlow",
"=",
"paramDict",
"[",
"'combine_nlow'... | Create a median image from the list of image Objects
that has been given. | [
"Create",
"a",
"median",
"image",
"from",
"the",
"list",
"of",
"image",
"Objects",
"that",
"has",
"been",
"given",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/createMedian.py#L106-L451 |
spacetelescope/drizzlepac | drizzlepac/createMedian.py | _writeImage | def _writeImage(dataArray=None, inputHeader=None):
""" Writes out the result of the combination step.
The header of the first 'outsingle' file in the
association parlist is used as the header of the
new image.
Parameters
----------
dataArray : arr
Array o... | python | def _writeImage(dataArray=None, inputHeader=None):
""" Writes out the result of the combination step.
The header of the first 'outsingle' file in the
association parlist is used as the header of the
new image.
Parameters
----------
dataArray : arr
Array o... | [
"def",
"_writeImage",
"(",
"dataArray",
"=",
"None",
",",
"inputHeader",
"=",
"None",
")",
":",
"prihdu",
"=",
"fits",
".",
"PrimaryHDU",
"(",
"data",
"=",
"dataArray",
",",
"header",
"=",
"inputHeader",
")",
"pf",
"=",
"fits",
".",
"HDUList",
"(",
")"... | Writes out the result of the combination step.
The header of the first 'outsingle' file in the
association parlist is used as the header of the
new image.
Parameters
----------
dataArray : arr
Array of data to be written to a fits.PrimaryHDU object
i... | [
"Writes",
"out",
"the",
"result",
"of",
"the",
"combination",
"step",
".",
"The",
"header",
"of",
"the",
"first",
"outsingle",
"file",
"in",
"the",
"association",
"parlist",
"is",
"used",
"as",
"the",
"header",
"of",
"the",
"new",
"image",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/createMedian.py#L454-L472 |
spacetelescope/drizzlepac | drizzlepac/pixtopix.py | tran | def tran(inimage,outimage,direction='forward',x=None,y=None,
coords=None, coordfile=None,colnames=None,separator=None,
precision=6, output=None,verbose=True):
""" Primary interface to perform coordinate transformations in pixel
coordinates between 2 images using STWCS and full distortion mod... | python | def tran(inimage,outimage,direction='forward',x=None,y=None,
coords=None, coordfile=None,colnames=None,separator=None,
precision=6, output=None,verbose=True):
""" Primary interface to perform coordinate transformations in pixel
coordinates between 2 images using STWCS and full distortion mod... | [
"def",
"tran",
"(",
"inimage",
",",
"outimage",
",",
"direction",
"=",
"'forward'",
",",
"x",
"=",
"None",
",",
"y",
"=",
"None",
",",
"coords",
"=",
"None",
",",
"coordfile",
"=",
"None",
",",
"colnames",
"=",
"None",
",",
"separator",
"=",
"None",
... | Primary interface to perform coordinate transformations in pixel
coordinates between 2 images using STWCS and full distortion models
read from each image's header. | [
"Primary",
"interface",
"to",
"perform",
"coordinate",
"transformations",
"in",
"pixel",
"coordinates",
"between",
"2",
"images",
"using",
"STWCS",
"and",
"full",
"distortion",
"models",
"read",
"from",
"each",
"image",
"s",
"header",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/pixtopix.py#L113-L214 |
ethpm/py-ethpm | ethpm/backends/registry.py | RegistryURIBackend.fetch_uri_contents | def fetch_uri_contents(self, uri: str) -> URI:
"""
Return content-addressed URI stored at registry URI.
"""
address, pkg_name, pkg_version = parse_registry_uri(uri)
self.w3.enable_unstable_package_management_api()
self.w3.pm.set_registry(address)
_, _, manifest_ur... | python | def fetch_uri_contents(self, uri: str) -> URI:
"""
Return content-addressed URI stored at registry URI.
"""
address, pkg_name, pkg_version = parse_registry_uri(uri)
self.w3.enable_unstable_package_management_api()
self.w3.pm.set_registry(address)
_, _, manifest_ur... | [
"def",
"fetch_uri_contents",
"(",
"self",
",",
"uri",
":",
"str",
")",
"->",
"URI",
":",
"address",
",",
"pkg_name",
",",
"pkg_version",
"=",
"parse_registry_uri",
"(",
"uri",
")",
"self",
".",
"w3",
".",
"enable_unstable_package_management_api",
"(",
")",
"... | Return content-addressed URI stored at registry URI. | [
"Return",
"content",
"-",
"addressed",
"URI",
"stored",
"at",
"registry",
"URI",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/backends/registry.py#L35-L43 |
ethpm/py-ethpm | ethpm/backends/ipfs.py | DummyIPFSBackend.pin_assets | def pin_assets(self, file_or_dir_path: Path) -> List[Dict[str, str]]:
"""
Return a dict containing the IPFS hash, file name, and size of a file.
"""
if file_or_dir_path.is_dir():
asset_data = [dummy_ipfs_pin(path) for path in file_or_dir_path.glob("*")]
elif file_or_d... | python | def pin_assets(self, file_or_dir_path: Path) -> List[Dict[str, str]]:
"""
Return a dict containing the IPFS hash, file name, and size of a file.
"""
if file_or_dir_path.is_dir():
asset_data = [dummy_ipfs_pin(path) for path in file_or_dir_path.glob("*")]
elif file_or_d... | [
"def",
"pin_assets",
"(",
"self",
",",
"file_or_dir_path",
":",
"Path",
")",
"->",
"List",
"[",
"Dict",
"[",
"str",
",",
"str",
"]",
"]",
":",
"if",
"file_or_dir_path",
".",
"is_dir",
"(",
")",
":",
"asset_data",
"=",
"[",
"dummy_ipfs_pin",
"(",
"path"... | Return a dict containing the IPFS hash, file name, and size of a file. | [
"Return",
"a",
"dict",
"containing",
"the",
"IPFS",
"hash",
"file",
"name",
"and",
"size",
"of",
"a",
"file",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/backends/ipfs.py#L158-L170 |
BrewBlox/brewblox-service | brewblox_service/scheduler.py | create_task | async def create_task(app: web.Application,
coro: Coroutine,
*args, **kwargs
) -> asyncio.Task:
"""
Convenience function for calling `TaskScheduler.create(coro)`
This will use the default `TaskScheduler` to create a new background task.
... | python | async def create_task(app: web.Application,
coro: Coroutine,
*args, **kwargs
) -> asyncio.Task:
"""
Convenience function for calling `TaskScheduler.create(coro)`
This will use the default `TaskScheduler` to create a new background task.
... | [
"async",
"def",
"create_task",
"(",
"app",
":",
"web",
".",
"Application",
",",
"coro",
":",
"Coroutine",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"asyncio",
".",
"Task",
":",
"return",
"await",
"get_scheduler",
"(",
"app",
")",
".",
"cr... | Convenience function for calling `TaskScheduler.create(coro)`
This will use the default `TaskScheduler` to create a new background task.
Example:
import asyncio
from datetime import datetime
from brewblox_service import scheduler, service
async def current_time(interval):
... | [
"Convenience",
"function",
"for",
"calling",
"TaskScheduler",
".",
"create",
"(",
"coro",
")"
] | train | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/scheduler.py#L24-L58 |
BrewBlox/brewblox-service | brewblox_service/scheduler.py | cancel_task | async def cancel_task(app: web.Application,
task: asyncio.Task,
*args, **kwargs
) -> Any:
"""
Convenience function for calling `TaskScheduler.cancel(task)`
This will use the default `TaskScheduler` to cancel the given task.
Example:
... | python | async def cancel_task(app: web.Application,
task: asyncio.Task,
*args, **kwargs
) -> Any:
"""
Convenience function for calling `TaskScheduler.cancel(task)`
This will use the default `TaskScheduler` to cancel the given task.
Example:
... | [
"async",
"def",
"cancel_task",
"(",
"app",
":",
"web",
".",
"Application",
",",
"task",
":",
"asyncio",
".",
"Task",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"Any",
":",
"return",
"await",
"get_scheduler",
"(",
"app",
")",
".",
"cancel",... | Convenience function for calling `TaskScheduler.cancel(task)`
This will use the default `TaskScheduler` to cancel the given task.
Example:
import asyncio
from datetime import datetime
from brewblox_service import scheduler, service
async def current_time(interval):
... | [
"Convenience",
"function",
"for",
"calling",
"TaskScheduler",
".",
"cancel",
"(",
"task",
")"
] | train | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/scheduler.py#L61-L104 |
BrewBlox/brewblox-service | brewblox_service/scheduler.py | TaskScheduler._cleanup | async def _cleanup(self):
"""
Periodically removes completed tasks from the collection,
allowing fire-and-forget tasks to be garbage collected.
This does not delete the task object, it merely removes the reference in the scheduler.
"""
while True:
await async... | python | async def _cleanup(self):
"""
Periodically removes completed tasks from the collection,
allowing fire-and-forget tasks to be garbage collected.
This does not delete the task object, it merely removes the reference in the scheduler.
"""
while True:
await async... | [
"async",
"def",
"_cleanup",
"(",
"self",
")",
":",
"while",
"True",
":",
"await",
"asyncio",
".",
"sleep",
"(",
"CLEANUP_INTERVAL_S",
")",
"self",
".",
"_tasks",
"=",
"{",
"t",
"for",
"t",
"in",
"self",
".",
"_tasks",
"if",
"not",
"t",
".",
"done",
... | Periodically removes completed tasks from the collection,
allowing fire-and-forget tasks to be garbage collected.
This does not delete the task object, it merely removes the reference in the scheduler. | [
"Periodically",
"removes",
"completed",
"tasks",
"from",
"the",
"collection",
"allowing",
"fire",
"-",
"and",
"-",
"forget",
"tasks",
"to",
"be",
"garbage",
"collected",
"."
] | train | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/scheduler.py#L121-L130 |
BrewBlox/brewblox-service | brewblox_service/scheduler.py | TaskScheduler.create | async def create(self, coro: Coroutine) -> asyncio.Task:
"""
Starts execution of a coroutine.
The created asyncio.Task is returned, and added to managed tasks.
The scheduler guarantees that it is cancelled during application shutdown,
regardless of whether it was already cancell... | python | async def create(self, coro: Coroutine) -> asyncio.Task:
"""
Starts execution of a coroutine.
The created asyncio.Task is returned, and added to managed tasks.
The scheduler guarantees that it is cancelled during application shutdown,
regardless of whether it was already cancell... | [
"async",
"def",
"create",
"(",
"self",
",",
"coro",
":",
"Coroutine",
")",
"->",
"asyncio",
".",
"Task",
":",
"task",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
".",
"create_task",
"(",
"coro",
")",
"self",
".",
"_tasks",
".",
"add",
"(",
"task... | Starts execution of a coroutine.
The created asyncio.Task is returned, and added to managed tasks.
The scheduler guarantees that it is cancelled during application shutdown,
regardless of whether it was already cancelled manually.
Args:
coro (Coroutine):
The... | [
"Starts",
"execution",
"of",
"a",
"coroutine",
"."
] | train | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/scheduler.py#L132-L151 |
BrewBlox/brewblox-service | brewblox_service/scheduler.py | TaskScheduler.cancel | async def cancel(self, task: asyncio.Task, wait_for: bool = True) -> Any:
"""
Cancels and waits for an `asyncio.Task` to finish.
Removes it from the collection of managed tasks.
Args:
task (asyncio.Task):
The to be cancelled task.
It is not re... | python | async def cancel(self, task: asyncio.Task, wait_for: bool = True) -> Any:
"""
Cancels and waits for an `asyncio.Task` to finish.
Removes it from the collection of managed tasks.
Args:
task (asyncio.Task):
The to be cancelled task.
It is not re... | [
"async",
"def",
"cancel",
"(",
"self",
",",
"task",
":",
"asyncio",
".",
"Task",
",",
"wait_for",
":",
"bool",
"=",
"True",
")",
"->",
"Any",
":",
"if",
"task",
"is",
"None",
":",
"return",
"task",
".",
"cancel",
"(",
")",
"with",
"suppress",
"(",
... | Cancels and waits for an `asyncio.Task` to finish.
Removes it from the collection of managed tasks.
Args:
task (asyncio.Task):
The to be cancelled task.
It is not required that the task was was created with `TaskScheduler.create_task()`.
wait_for... | [
"Cancels",
"and",
"waits",
"for",
"an",
"asyncio",
".",
"Task",
"to",
"finish",
".",
"Removes",
"it",
"from",
"the",
"collection",
"of",
"managed",
"tasks",
"."
] | train | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/scheduler.py#L153-L180 |
ethpm/py-ethpm | ethpm/utils/uri.py | create_content_addressed_github_uri | def create_content_addressed_github_uri(uri: URI) -> URI:
"""
Returns a content-addressed Github "git_url" that conforms to this scheme.
https://api.github.com/repos/:owner/:repo/git/blobs/:file_sha
Accepts Github-defined "url" that conforms to this scheme
https://api.github.com/repos/:owner/:repo/... | python | def create_content_addressed_github_uri(uri: URI) -> URI:
"""
Returns a content-addressed Github "git_url" that conforms to this scheme.
https://api.github.com/repos/:owner/:repo/git/blobs/:file_sha
Accepts Github-defined "url" that conforms to this scheme
https://api.github.com/repos/:owner/:repo/... | [
"def",
"create_content_addressed_github_uri",
"(",
"uri",
":",
"URI",
")",
"->",
"URI",
":",
"if",
"not",
"is_valid_api_github_uri",
"(",
"uri",
")",
":",
"raise",
"CannotHandleURI",
"(",
"f\"{uri} does not conform to Github's API 'url' scheme.\"",
")",
"response",
"=",... | Returns a content-addressed Github "git_url" that conforms to this scheme.
https://api.github.com/repos/:owner/:repo/git/blobs/:file_sha
Accepts Github-defined "url" that conforms to this scheme
https://api.github.com/repos/:owner/:repo/contents/:path/:to/manifest.json | [
"Returns",
"a",
"content",
"-",
"addressed",
"Github",
"git_url",
"that",
"conforms",
"to",
"this",
"scheme",
".",
"https",
":",
"//",
"api",
".",
"github",
".",
"com",
"/",
"repos",
"/",
":",
"owner",
"/",
":",
"repo",
"/",
"git",
"/",
"blobs",
"/",... | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/uri.py#L19-L36 |
ethpm/py-ethpm | ethpm/utils/uri.py | is_valid_github_uri | def is_valid_github_uri(uri: URI, expected_path_terms: Tuple[str, ...]) -> bool:
"""
Return a bool indicating whether or not the URI fulfills the following specs
Valid Github URIs *must*:
- Have 'https' scheme
- Have 'api.github.com' authority
- Have a path that contains all "expected_path_terms... | python | def is_valid_github_uri(uri: URI, expected_path_terms: Tuple[str, ...]) -> bool:
"""
Return a bool indicating whether or not the URI fulfills the following specs
Valid Github URIs *must*:
- Have 'https' scheme
- Have 'api.github.com' authority
- Have a path that contains all "expected_path_terms... | [
"def",
"is_valid_github_uri",
"(",
"uri",
":",
"URI",
",",
"expected_path_terms",
":",
"Tuple",
"[",
"str",
",",
"...",
"]",
")",
"->",
"bool",
":",
"if",
"not",
"is_text",
"(",
"uri",
")",
":",
"return",
"False",
"parsed",
"=",
"parse",
".",
"urlparse... | Return a bool indicating whether or not the URI fulfills the following specs
Valid Github URIs *must*:
- Have 'https' scheme
- Have 'api.github.com' authority
- Have a path that contains all "expected_path_terms" | [
"Return",
"a",
"bool",
"indicating",
"whether",
"or",
"not",
"the",
"URI",
"fulfills",
"the",
"following",
"specs",
"Valid",
"Github",
"URIs",
"*",
"must",
"*",
":",
"-",
"Have",
"https",
"scheme",
"-",
"Have",
"api",
".",
"github",
".",
"com",
"authorit... | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/uri.py#L55-L79 |
ethpm/py-ethpm | ethpm/utils/uri.py | validate_blob_uri_contents | def validate_blob_uri_contents(contents: bytes, blob_uri: str) -> None:
"""
Raises an exception if the sha1 hash of the contents does not match the hash found in te
blob_uri. Formula for how git calculates the hash found here:
http://alblue.bandlem.com/2011/08/git-tip-of-week-objects.html
"""
bl... | python | def validate_blob_uri_contents(contents: bytes, blob_uri: str) -> None:
"""
Raises an exception if the sha1 hash of the contents does not match the hash found in te
blob_uri. Formula for how git calculates the hash found here:
http://alblue.bandlem.com/2011/08/git-tip-of-week-objects.html
"""
bl... | [
"def",
"validate_blob_uri_contents",
"(",
"contents",
":",
"bytes",
",",
"blob_uri",
":",
"str",
")",
"->",
"None",
":",
"blob_path",
"=",
"parse",
".",
"urlparse",
"(",
"blob_uri",
")",
".",
"path",
"blob_hash",
"=",
"blob_path",
".",
"split",
"(",
"\"/\"... | Raises an exception if the sha1 hash of the contents does not match the hash found in te
blob_uri. Formula for how git calculates the hash found here:
http://alblue.bandlem.com/2011/08/git-tip-of-week-objects.html | [
"Raises",
"an",
"exception",
"if",
"the",
"sha1",
"hash",
"of",
"the",
"contents",
"does",
"not",
"match",
"the",
"hash",
"found",
"in",
"te",
"blob_uri",
".",
"Formula",
"for",
"how",
"git",
"calculates",
"the",
"hash",
"found",
"here",
":",
"http",
":"... | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/uri.py#L82-L97 |
ethpm/py-ethpm | ethpm/utils/uri.py | parse_registry_uri | def parse_registry_uri(uri: str) -> RegistryURI:
"""
Validate and return (authority, pkg name, version) from a valid registry URI
"""
validate_registry_uri(uri)
parsed_uri = parse.urlparse(uri)
authority = parsed_uri.netloc
pkg_name = parsed_uri.path.strip("/")
pkg_version = parsed_uri.q... | python | def parse_registry_uri(uri: str) -> RegistryURI:
"""
Validate and return (authority, pkg name, version) from a valid registry URI
"""
validate_registry_uri(uri)
parsed_uri = parse.urlparse(uri)
authority = parsed_uri.netloc
pkg_name = parsed_uri.path.strip("/")
pkg_version = parsed_uri.q... | [
"def",
"parse_registry_uri",
"(",
"uri",
":",
"str",
")",
"->",
"RegistryURI",
":",
"validate_registry_uri",
"(",
"uri",
")",
"parsed_uri",
"=",
"parse",
".",
"urlparse",
"(",
"uri",
")",
"authority",
"=",
"parsed_uri",
".",
"netloc",
"pkg_name",
"=",
"parse... | Validate and return (authority, pkg name, version) from a valid registry URI | [
"Validate",
"and",
"return",
"(",
"authority",
"pkg",
"name",
"version",
")",
"from",
"a",
"valid",
"registry",
"URI"
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/uri.py#L100-L109 |
ethpm/py-ethpm | ethpm/utils/uri.py | is_supported_content_addressed_uri | def is_supported_content_addressed_uri(uri: URI) -> bool:
"""
Returns a bool indicating whether provided uri is currently supported.
Currently Py-EthPM only supports IPFS and Github blob content-addressed uris.
"""
if not is_ipfs_uri(uri) and not is_valid_content_addressed_github_uri(uri):
r... | python | def is_supported_content_addressed_uri(uri: URI) -> bool:
"""
Returns a bool indicating whether provided uri is currently supported.
Currently Py-EthPM only supports IPFS and Github blob content-addressed uris.
"""
if not is_ipfs_uri(uri) and not is_valid_content_addressed_github_uri(uri):
r... | [
"def",
"is_supported_content_addressed_uri",
"(",
"uri",
":",
"URI",
")",
"->",
"bool",
":",
"if",
"not",
"is_ipfs_uri",
"(",
"uri",
")",
"and",
"not",
"is_valid_content_addressed_github_uri",
"(",
"uri",
")",
":",
"return",
"False",
"return",
"True"
] | Returns a bool indicating whether provided uri is currently supported.
Currently Py-EthPM only supports IPFS and Github blob content-addressed uris. | [
"Returns",
"a",
"bool",
"indicating",
"whether",
"provided",
"uri",
"is",
"currently",
"supported",
".",
"Currently",
"Py",
"-",
"EthPM",
"only",
"supports",
"IPFS",
"and",
"Github",
"blob",
"content",
"-",
"addressed",
"uris",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/uri.py#L112-L119 |
ethpm/py-ethpm | ethpm/utils/chains.py | create_BIP122_uri | def create_BIP122_uri(
chain_id: str, resource_type: str, resource_identifier: str
) -> URI:
"""
See: https://github.com/bitcoin/bips/blob/master/bip-0122.mediawiki
"""
if resource_type != BLOCK:
raise ValueError("Invalid resource_type. Must be one of 'block'")
elif not is_block_or_tran... | python | def create_BIP122_uri(
chain_id: str, resource_type: str, resource_identifier: str
) -> URI:
"""
See: https://github.com/bitcoin/bips/blob/master/bip-0122.mediawiki
"""
if resource_type != BLOCK:
raise ValueError("Invalid resource_type. Must be one of 'block'")
elif not is_block_or_tran... | [
"def",
"create_BIP122_uri",
"(",
"chain_id",
":",
"str",
",",
"resource_type",
":",
"str",
",",
"resource_identifier",
":",
"str",
")",
"->",
"URI",
":",
"if",
"resource_type",
"!=",
"BLOCK",
":",
"raise",
"ValueError",
"(",
"\"Invalid resource_type. Must be one ... | See: https://github.com/bitcoin/bips/blob/master/bip-0122.mediawiki | [
"See",
":",
"https",
":",
"//",
"github",
".",
"com",
"/",
"bitcoin",
"/",
"bips",
"/",
"blob",
"/",
"master",
"/",
"bip",
"-",
"0122",
".",
"mediawiki"
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/chains.py#L75-L100 |
ethpm/py-ethpm | ethpm/package.py | Package.update_w3 | def update_w3(self, w3: Web3) -> "Package":
"""
Returns a new instance of `Package` containing the same manifest,
but connected to a different web3 instance.
.. doctest::
>>> new_w3 = Web3(Web3.EthereumTesterProvider())
>>> NewPackage = OwnedPackage.update_w3(new_... | python | def update_w3(self, w3: Web3) -> "Package":
"""
Returns a new instance of `Package` containing the same manifest,
but connected to a different web3 instance.
.. doctest::
>>> new_w3 = Web3(Web3.EthereumTesterProvider())
>>> NewPackage = OwnedPackage.update_w3(new_... | [
"def",
"update_w3",
"(",
"self",
",",
"w3",
":",
"Web3",
")",
"->",
"\"Package\"",
":",
"validate_w3_instance",
"(",
"w3",
")",
"return",
"Package",
"(",
"self",
".",
"manifest",
",",
"w3",
",",
"self",
".",
"uri",
")"
] | Returns a new instance of `Package` containing the same manifest,
but connected to a different web3 instance.
.. doctest::
>>> new_w3 = Web3(Web3.EthereumTesterProvider())
>>> NewPackage = OwnedPackage.update_w3(new_w3)
>>> assert NewPackage.w3 == new_w3
>>>... | [
"Returns",
"a",
"new",
"instance",
"of",
"Package",
"containing",
"the",
"same",
"manifest",
"but",
"connected",
"to",
"a",
"different",
"web3",
"instance",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/package.py#L70-L83 |
ethpm/py-ethpm | ethpm/package.py | Package.from_file | def from_file(cls, file_path: Path, w3: Web3) -> "Package":
"""
Returns a ``Package`` instantiated by a manifest located at the provided Path.
``file_path`` arg must be a ``pathlib.Path`` instance.
A valid ``Web3`` instance is required to instantiate a ``Package``.
"""
if... | python | def from_file(cls, file_path: Path, w3: Web3) -> "Package":
"""
Returns a ``Package`` instantiated by a manifest located at the provided Path.
``file_path`` arg must be a ``pathlib.Path`` instance.
A valid ``Web3`` instance is required to instantiate a ``Package``.
"""
if... | [
"def",
"from_file",
"(",
"cls",
",",
"file_path",
":",
"Path",
",",
"w3",
":",
"Web3",
")",
"->",
"\"Package\"",
":",
"if",
"isinstance",
"(",
"file_path",
",",
"Path",
")",
":",
"raw_manifest",
"=",
"file_path",
".",
"read_text",
"(",
")",
"validate_raw... | Returns a ``Package`` instantiated by a manifest located at the provided Path.
``file_path`` arg must be a ``pathlib.Path`` instance.
A valid ``Web3`` instance is required to instantiate a ``Package``. | [
"Returns",
"a",
"Package",
"instantiated",
"by",
"a",
"manifest",
"located",
"at",
"the",
"provided",
"Path",
".",
"file_path",
"arg",
"must",
"be",
"a",
"pathlib",
".",
"Path",
"instance",
".",
"A",
"valid",
"Web3",
"instance",
"is",
"required",
"to",
"in... | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/package.py#L142-L157 |
ethpm/py-ethpm | ethpm/package.py | Package.from_uri | def from_uri(cls, uri: URI, w3: Web3) -> "Package":
"""
Returns a Package object instantiated by a manifest located at a content-addressed URI.
A valid ``Web3`` instance is also required.
URI schemes supported:
- IPFS `ipfs://Qm...`
- HTTP `https://api.g... | python | def from_uri(cls, uri: URI, w3: Web3) -> "Package":
"""
Returns a Package object instantiated by a manifest located at a content-addressed URI.
A valid ``Web3`` instance is also required.
URI schemes supported:
- IPFS `ipfs://Qm...`
- HTTP `https://api.g... | [
"def",
"from_uri",
"(",
"cls",
",",
"uri",
":",
"URI",
",",
"w3",
":",
"Web3",
")",
"->",
"\"Package\"",
":",
"contents",
"=",
"to_text",
"(",
"resolve_uri_contents",
"(",
"uri",
")",
")",
"validate_raw_manifest_format",
"(",
"contents",
")",
"manifest",
"... | Returns a Package object instantiated by a manifest located at a content-addressed URI.
A valid ``Web3`` instance is also required.
URI schemes supported:
- IPFS `ipfs://Qm...`
- HTTP `https://api.github.com/repos/:owner/:repo/git/blobs/:file_sha`
- Registry ... | [
"Returns",
"a",
"Package",
"object",
"instantiated",
"by",
"a",
"manifest",
"located",
"at",
"a",
"content",
"-",
"addressed",
"URI",
".",
"A",
"valid",
"Web3",
"instance",
"is",
"also",
"required",
".",
"URI",
"schemes",
"supported",
":",
"-",
"IPFS",
"ip... | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/package.py#L160-L176 |
ethpm/py-ethpm | ethpm/package.py | Package.get_contract_factory | def get_contract_factory(self, name: ContractName) -> Contract:
"""
Return the contract factory for a given contract type, generated from the data vailable
in ``Package.manifest``. Contract factories are accessible from the package class.
.. code:: python
Owned = OwnedPackag... | python | def get_contract_factory(self, name: ContractName) -> Contract:
"""
Return the contract factory for a given contract type, generated from the data vailable
in ``Package.manifest``. Contract factories are accessible from the package class.
.. code:: python
Owned = OwnedPackag... | [
"def",
"get_contract_factory",
"(",
"self",
",",
"name",
":",
"ContractName",
")",
"->",
"Contract",
":",
"validate_contract_name",
"(",
"name",
")",
"if",
"\"contract_types\"",
"not",
"in",
"self",
".",
"manifest",
":",
"raise",
"InsufficientAssetsError",
"(",
... | Return the contract factory for a given contract type, generated from the data vailable
in ``Package.manifest``. Contract factories are accessible from the package class.
.. code:: python
Owned = OwnedPackage.get_contract_factory('owned')
In cases where a contract uses a library, t... | [
"Return",
"the",
"contract",
"factory",
"for",
"a",
"given",
"contract",
"type",
"generated",
"from",
"the",
"data",
"vailable",
"in",
"Package",
".",
"manifest",
".",
"Contract",
"factories",
"are",
"accessible",
"from",
"the",
"package",
"class",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/package.py#L182-L224 |
ethpm/py-ethpm | ethpm/package.py | Package.get_contract_instance | def get_contract_instance(self, name: ContractName, address: Address) -> Contract:
"""
Will return a ``Web3.contract`` instance generated from the contract type data available
in ``Package.manifest`` and the provided ``address``. The provided ``address`` must be
valid on the connected ch... | python | def get_contract_instance(self, name: ContractName, address: Address) -> Contract:
"""
Will return a ``Web3.contract`` instance generated from the contract type data available
in ``Package.manifest`` and the provided ``address``. The provided ``address`` must be
valid on the connected ch... | [
"def",
"get_contract_instance",
"(",
"self",
",",
"name",
":",
"ContractName",
",",
"address",
":",
"Address",
")",
"->",
"Contract",
":",
"validate_address",
"(",
"address",
")",
"validate_contract_name",
"(",
"name",
")",
"try",
":",
"self",
".",
"manifest",... | Will return a ``Web3.contract`` instance generated from the contract type data available
in ``Package.manifest`` and the provided ``address``. The provided ``address`` must be
valid on the connected chain available through ``Package.w3``. | [
"Will",
"return",
"a",
"Web3",
".",
"contract",
"instance",
"generated",
"from",
"the",
"contract",
"type",
"data",
"available",
"in",
"Package",
".",
"manifest",
"and",
"the",
"provided",
"address",
".",
"The",
"provided",
"address",
"must",
"be",
"valid",
... | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/package.py#L226-L248 |
ethpm/py-ethpm | ethpm/package.py | Package.build_dependencies | def build_dependencies(self) -> "Dependencies":
"""
Return `Dependencies` instance containing the build dependencies available on this Package.
The ``Package`` class should provide access to the full dependency tree.
.. code:: python
>>> owned_package.build_dependencies['zep... | python | def build_dependencies(self) -> "Dependencies":
"""
Return `Dependencies` instance containing the build dependencies available on this Package.
The ``Package`` class should provide access to the full dependency tree.
.. code:: python
>>> owned_package.build_dependencies['zep... | [
"def",
"build_dependencies",
"(",
"self",
")",
"->",
"\"Dependencies\"",
":",
"validate_build_dependencies_are_present",
"(",
"self",
".",
"manifest",
")",
"dependencies",
"=",
"self",
".",
"manifest",
"[",
"\"build_dependencies\"",
"]",
"dependency_packages",
"=",
"{... | Return `Dependencies` instance containing the build dependencies available on this Package.
The ``Package`` class should provide access to the full dependency tree.
.. code:: python
>>> owned_package.build_dependencies['zeppelin']
<ZeppelinPackage> | [
"Return",
"Dependencies",
"instance",
"containing",
"the",
"build",
"dependencies",
"available",
"on",
"this",
"Package",
".",
"The",
"Package",
"class",
"should",
"provide",
"access",
"to",
"the",
"full",
"dependency",
"tree",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/package.py#L255-L281 |
ethpm/py-ethpm | ethpm/package.py | Package.deployments | def deployments(self) -> Union["Deployments", Dict[None, None]]:
"""
Returns a ``Deployments`` object containing all the deployment data and contract
factories of a ``Package``'s `contract_types`. Automatically filters deployments
to only expose those available on the current ``Package.w... | python | def deployments(self) -> Union["Deployments", Dict[None, None]]:
"""
Returns a ``Deployments`` object containing all the deployment data and contract
factories of a ``Package``'s `contract_types`. Automatically filters deployments
to only expose those available on the current ``Package.w... | [
"def",
"deployments",
"(",
"self",
")",
"->",
"Union",
"[",
"\"Deployments\"",
",",
"Dict",
"[",
"None",
",",
"None",
"]",
"]",
":",
"if",
"not",
"check_for_deployments",
"(",
"self",
".",
"manifest",
")",
":",
"return",
"{",
"}",
"all_blockchain_uris",
... | Returns a ``Deployments`` object containing all the deployment data and contract
factories of a ``Package``'s `contract_types`. Automatically filters deployments
to only expose those available on the current ``Package.w3`` instance.
.. code:: python
package.deployments.get_instance(... | [
"Returns",
"a",
"Deployments",
"object",
"containing",
"all",
"the",
"deployment",
"data",
"and",
"contract",
"factories",
"of",
"a",
"Package",
"s",
"contract_types",
".",
"Automatically",
"filters",
"deployments",
"to",
"only",
"expose",
"those",
"available",
"o... | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/package.py#L288-L328 |
ethpm/py-ethpm | ethpm/utils/ipfs.py | dummy_ipfs_pin | def dummy_ipfs_pin(path: Path) -> Dict[str, str]:
"""
Return IPFS data as if file was pinned to an actual node.
"""
ipfs_return = {
"Hash": generate_file_hash(path.read_bytes()),
"Name": path.name,
"Size": str(path.stat().st_size),
}
return ipfs_return | python | def dummy_ipfs_pin(path: Path) -> Dict[str, str]:
"""
Return IPFS data as if file was pinned to an actual node.
"""
ipfs_return = {
"Hash": generate_file_hash(path.read_bytes()),
"Name": path.name,
"Size": str(path.stat().st_size),
}
return ipfs_return | [
"def",
"dummy_ipfs_pin",
"(",
"path",
":",
"Path",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"ipfs_return",
"=",
"{",
"\"Hash\"",
":",
"generate_file_hash",
"(",
"path",
".",
"read_bytes",
"(",
")",
")",
",",
"\"Name\"",
":",
"path",
".",
... | Return IPFS data as if file was pinned to an actual node. | [
"Return",
"IPFS",
"data",
"as",
"if",
"file",
"was",
"pinned",
"to",
"an",
"actual",
"node",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/ipfs.py#L12-L21 |
ethpm/py-ethpm | ethpm/utils/ipfs.py | extract_ipfs_path_from_uri | def extract_ipfs_path_from_uri(value: str) -> str:
"""
Return the path from an IPFS URI.
Path = IPFS hash & following path.
"""
parse_result = parse.urlparse(value)
if parse_result.netloc:
if parse_result.path:
return "".join((parse_result.netloc, parse_result.path.rstrip("/... | python | def extract_ipfs_path_from_uri(value: str) -> str:
"""
Return the path from an IPFS URI.
Path = IPFS hash & following path.
"""
parse_result = parse.urlparse(value)
if parse_result.netloc:
if parse_result.path:
return "".join((parse_result.netloc, parse_result.path.rstrip("/... | [
"def",
"extract_ipfs_path_from_uri",
"(",
"value",
":",
"str",
")",
"->",
"str",
":",
"parse_result",
"=",
"parse",
".",
"urlparse",
"(",
"value",
")",
"if",
"parse_result",
".",
"netloc",
":",
"if",
"parse_result",
".",
"path",
":",
"return",
"\"\"",
".",... | Return the path from an IPFS URI.
Path = IPFS hash & following path. | [
"Return",
"the",
"path",
"from",
"an",
"IPFS",
"URI",
".",
"Path",
"=",
"IPFS",
"hash",
"&",
"following",
"path",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/ipfs.py#L28-L41 |
ethpm/py-ethpm | ethpm/utils/ipfs.py | is_ipfs_uri | def is_ipfs_uri(value: str) -> bool:
"""
Return a bool indicating whether or not the value is a valid IPFS URI.
"""
parse_result = parse.urlparse(value)
if parse_result.scheme != "ipfs":
return False
if not parse_result.netloc and not parse_result.path:
return False
return T... | python | def is_ipfs_uri(value: str) -> bool:
"""
Return a bool indicating whether or not the value is a valid IPFS URI.
"""
parse_result = parse.urlparse(value)
if parse_result.scheme != "ipfs":
return False
if not parse_result.netloc and not parse_result.path:
return False
return T... | [
"def",
"is_ipfs_uri",
"(",
"value",
":",
"str",
")",
"->",
"bool",
":",
"parse_result",
"=",
"parse",
".",
"urlparse",
"(",
"value",
")",
"if",
"parse_result",
".",
"scheme",
"!=",
"\"ipfs\"",
":",
"return",
"False",
"if",
"not",
"parse_result",
".",
"ne... | Return a bool indicating whether or not the value is a valid IPFS URI. | [
"Return",
"a",
"bool",
"indicating",
"whether",
"or",
"not",
"the",
"value",
"is",
"a",
"valid",
"IPFS",
"URI",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/ipfs.py#L44-L54 |
ethpm/py-ethpm | ethpm/deployments.py | Deployments.get_instance | def get_instance(self, contract_name: str) -> None:
"""
Fetches a contract instance belonging to deployment
after validating contract name.
"""
self._validate_name_and_references(contract_name)
# Use a deployment's "contract_type" to lookup contract factory
# in c... | python | def get_instance(self, contract_name: str) -> None:
"""
Fetches a contract instance belonging to deployment
after validating contract name.
"""
self._validate_name_and_references(contract_name)
# Use a deployment's "contract_type" to lookup contract factory
# in c... | [
"def",
"get_instance",
"(",
"self",
",",
"contract_name",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"_validate_name_and_references",
"(",
"contract_name",
")",
"# Use a deployment's \"contract_type\" to lookup contract factory",
"# in case the deployment uses a contract ... | Fetches a contract instance belonging to deployment
after validating contract name. | [
"Fetches",
"a",
"contract",
"instance",
"belonging",
"to",
"deployment",
"after",
"validating",
"contract",
"name",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/deployments.py#L45-L61 |
ethpm/py-ethpm | ethpm/validation.py | validate_address | def validate_address(address: Any) -> None:
"""
Raise a ValidationError if an address is not canonicalized.
"""
if not is_address(address):
raise ValidationError(f"Expected an address, got: {address}")
if not is_canonical_address(address):
raise ValidationError(
"Py-EthPM... | python | def validate_address(address: Any) -> None:
"""
Raise a ValidationError if an address is not canonicalized.
"""
if not is_address(address):
raise ValidationError(f"Expected an address, got: {address}")
if not is_canonical_address(address):
raise ValidationError(
"Py-EthPM... | [
"def",
"validate_address",
"(",
"address",
":",
"Any",
")",
"->",
"None",
":",
"if",
"not",
"is_address",
"(",
"address",
")",
":",
"raise",
"ValidationError",
"(",
"f\"Expected an address, got: {address}\"",
")",
"if",
"not",
"is_canonical_address",
"(",
"address... | Raise a ValidationError if an address is not canonicalized. | [
"Raise",
"a",
"ValidationError",
"if",
"an",
"address",
"is",
"not",
"canonicalized",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/validation.py#L15-L25 |
ethpm/py-ethpm | ethpm/validation.py | validate_empty_bytes | def validate_empty_bytes(offset: int, length: int, bytecode: bytes) -> None:
"""
Validates that segment [`offset`:`offset`+`length`] of
`bytecode` is comprised of empty bytes (b'\00').
"""
slot_length = offset + length
slot = bytecode[offset:slot_length]
if slot != bytearray(length):
... | python | def validate_empty_bytes(offset: int, length: int, bytecode: bytes) -> None:
"""
Validates that segment [`offset`:`offset`+`length`] of
`bytecode` is comprised of empty bytes (b'\00').
"""
slot_length = offset + length
slot = bytecode[offset:slot_length]
if slot != bytearray(length):
... | [
"def",
"validate_empty_bytes",
"(",
"offset",
":",
"int",
",",
"length",
":",
"int",
",",
"bytecode",
":",
"bytes",
")",
"->",
"None",
":",
"slot_length",
"=",
"offset",
"+",
"length",
"slot",
"=",
"bytecode",
"[",
"offset",
":",
"slot_length",
"]",
"if"... | Validates that segment [`offset`:`offset`+`length`] of
`bytecode` is comprised of empty bytes (b'\00'). | [
"Validates",
"that",
"segment",
"[",
"offset",
":",
"offset",
"+",
"length",
"]",
"of",
"bytecode",
"is",
"comprised",
"of",
"empty",
"bytes",
"(",
"b",
"\\",
"00",
")",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/validation.py#L38-L49 |
ethpm/py-ethpm | ethpm/validation.py | validate_package_name | def validate_package_name(pkg_name: str) -> None:
"""
Raise an exception if the value is not a valid package name
as defined in the EthPM-Spec.
"""
if not bool(re.match(PACKAGE_NAME_REGEX, pkg_name)):
raise ValidationError(f"{pkg_name} is not a valid package name.") | python | def validate_package_name(pkg_name: str) -> None:
"""
Raise an exception if the value is not a valid package name
as defined in the EthPM-Spec.
"""
if not bool(re.match(PACKAGE_NAME_REGEX, pkg_name)):
raise ValidationError(f"{pkg_name} is not a valid package name.") | [
"def",
"validate_package_name",
"(",
"pkg_name",
":",
"str",
")",
"->",
"None",
":",
"if",
"not",
"bool",
"(",
"re",
".",
"match",
"(",
"PACKAGE_NAME_REGEX",
",",
"pkg_name",
")",
")",
":",
"raise",
"ValidationError",
"(",
"f\"{pkg_name} is not a valid package n... | Raise an exception if the value is not a valid package name
as defined in the EthPM-Spec. | [
"Raise",
"an",
"exception",
"if",
"the",
"value",
"is",
"not",
"a",
"valid",
"package",
"name",
"as",
"defined",
"in",
"the",
"EthPM",
"-",
"Spec",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/validation.py#L52-L58 |
ethpm/py-ethpm | ethpm/validation.py | validate_registry_uri | def validate_registry_uri(uri: str) -> None:
"""
Raise an exception if the URI does not conform to the registry URI scheme.
"""
parsed = parse.urlparse(uri)
scheme, authority, pkg_name, query = (
parsed.scheme,
parsed.netloc,
parsed.path,
parsed.query,
)
valid... | python | def validate_registry_uri(uri: str) -> None:
"""
Raise an exception if the URI does not conform to the registry URI scheme.
"""
parsed = parse.urlparse(uri)
scheme, authority, pkg_name, query = (
parsed.scheme,
parsed.netloc,
parsed.path,
parsed.query,
)
valid... | [
"def",
"validate_registry_uri",
"(",
"uri",
":",
"str",
")",
"->",
"None",
":",
"parsed",
"=",
"parse",
".",
"urlparse",
"(",
"uri",
")",
"scheme",
",",
"authority",
",",
"pkg_name",
",",
"query",
"=",
"(",
"parsed",
".",
"scheme",
",",
"parsed",
".",
... | Raise an exception if the URI does not conform to the registry URI scheme. | [
"Raise",
"an",
"exception",
"if",
"the",
"URI",
"does",
"not",
"conform",
"to",
"the",
"registry",
"URI",
"scheme",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/validation.py#L101-L116 |
ethpm/py-ethpm | ethpm/validation.py | validate_registry_uri_authority | def validate_registry_uri_authority(auth: str) -> None:
"""
Raise an exception if the authority is not a valid ENS domain
or a valid checksummed contract address.
"""
if is_ens_domain(auth) is False and not is_checksum_address(auth):
raise ValidationError(f"{auth} is not a valid registry URI... | python | def validate_registry_uri_authority(auth: str) -> None:
"""
Raise an exception if the authority is not a valid ENS domain
or a valid checksummed contract address.
"""
if is_ens_domain(auth) is False and not is_checksum_address(auth):
raise ValidationError(f"{auth} is not a valid registry URI... | [
"def",
"validate_registry_uri_authority",
"(",
"auth",
":",
"str",
")",
"->",
"None",
":",
"if",
"is_ens_domain",
"(",
"auth",
")",
"is",
"False",
"and",
"not",
"is_checksum_address",
"(",
"auth",
")",
":",
"raise",
"ValidationError",
"(",
"f\"{auth} is not a va... | Raise an exception if the authority is not a valid ENS domain
or a valid checksummed contract address. | [
"Raise",
"an",
"exception",
"if",
"the",
"authority",
"is",
"not",
"a",
"valid",
"ENS",
"domain",
"or",
"a",
"valid",
"checksummed",
"contract",
"address",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/validation.py#L119-L125 |
ethpm/py-ethpm | ethpm/validation.py | validate_registry_uri_version | def validate_registry_uri_version(query: str) -> None:
"""
Raise an exception if the version param is malformed.
"""
query_dict = parse.parse_qs(query, keep_blank_values=True)
if "version" not in query_dict:
raise ValidationError(f"{query} is not a correctly formatted version param.") | python | def validate_registry_uri_version(query: str) -> None:
"""
Raise an exception if the version param is malformed.
"""
query_dict = parse.parse_qs(query, keep_blank_values=True)
if "version" not in query_dict:
raise ValidationError(f"{query} is not a correctly formatted version param.") | [
"def",
"validate_registry_uri_version",
"(",
"query",
":",
"str",
")",
"->",
"None",
":",
"query_dict",
"=",
"parse",
".",
"parse_qs",
"(",
"query",
",",
"keep_blank_values",
"=",
"True",
")",
"if",
"\"version\"",
"not",
"in",
"query_dict",
":",
"raise",
"Va... | Raise an exception if the version param is malformed. | [
"Raise",
"an",
"exception",
"if",
"the",
"version",
"param",
"is",
"malformed",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/validation.py#L136-L142 |
ethpm/py-ethpm | ethpm/validation.py | validate_single_matching_uri | def validate_single_matching_uri(all_blockchain_uris: List[str], w3: Web3) -> str:
"""
Return a single block URI after validating that it is the *only* URI in
all_blockchain_uris that matches the w3 instance.
"""
matching_uris = [
uri for uri in all_blockchain_uris if check_if_chain_matches_... | python | def validate_single_matching_uri(all_blockchain_uris: List[str], w3: Web3) -> str:
"""
Return a single block URI after validating that it is the *only* URI in
all_blockchain_uris that matches the w3 instance.
"""
matching_uris = [
uri for uri in all_blockchain_uris if check_if_chain_matches_... | [
"def",
"validate_single_matching_uri",
"(",
"all_blockchain_uris",
":",
"List",
"[",
"str",
"]",
",",
"w3",
":",
"Web3",
")",
"->",
"str",
":",
"matching_uris",
"=",
"[",
"uri",
"for",
"uri",
"in",
"all_blockchain_uris",
"if",
"check_if_chain_matches_chain_uri",
... | Return a single block URI after validating that it is the *only* URI in
all_blockchain_uris that matches the w3 instance. | [
"Return",
"a",
"single",
"block",
"URI",
"after",
"validating",
"that",
"it",
"is",
"the",
"*",
"only",
"*",
"URI",
"in",
"all_blockchain_uris",
"that",
"matches",
"the",
"w3",
"instance",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/validation.py#L145-L160 |
ethpm/py-ethpm | ethpm/utils/manifest_validation.py | validate_meta_object | def validate_meta_object(meta: Dict[str, Any], allow_extra_meta_fields: bool) -> None:
"""
Validates that every key is one of `META_FIELDS` and has a value of the expected type.
"""
for key, value in meta.items():
if key in META_FIELDS:
if type(value) is not META_FIELDS[key]:
... | python | def validate_meta_object(meta: Dict[str, Any], allow_extra_meta_fields: bool) -> None:
"""
Validates that every key is one of `META_FIELDS` and has a value of the expected type.
"""
for key, value in meta.items():
if key in META_FIELDS:
if type(value) is not META_FIELDS[key]:
... | [
"def",
"validate_meta_object",
"(",
"meta",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"allow_extra_meta_fields",
":",
"bool",
")",
"->",
"None",
":",
"for",
"key",
",",
"value",
"in",
"meta",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"META... | Validates that every key is one of `META_FIELDS` and has a value of the expected type. | [
"Validates",
"that",
"every",
"key",
"is",
"one",
"of",
"META_FIELDS",
"and",
"has",
"a",
"value",
"of",
"the",
"expected",
"type",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/manifest_validation.py#L21-L42 |
ethpm/py-ethpm | ethpm/utils/manifest_validation.py | validate_manifest_against_schema | def validate_manifest_against_schema(manifest: Dict[str, Any]) -> None:
"""
Load and validate manifest against schema
located at MANIFEST_SCHEMA_PATH.
"""
schema_data = _load_schema_data()
try:
validate(manifest, schema_data)
except jsonValidationError as e:
raise ValidationE... | python | def validate_manifest_against_schema(manifest: Dict[str, Any]) -> None:
"""
Load and validate manifest against schema
located at MANIFEST_SCHEMA_PATH.
"""
schema_data = _load_schema_data()
try:
validate(manifest, schema_data)
except jsonValidationError as e:
raise ValidationE... | [
"def",
"validate_manifest_against_schema",
"(",
"manifest",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"None",
":",
"schema_data",
"=",
"_load_schema_data",
"(",
")",
"try",
":",
"validate",
"(",
"manifest",
",",
"schema_data",
")",
"except",
"json... | Load and validate manifest against schema
located at MANIFEST_SCHEMA_PATH. | [
"Load",
"and",
"validate",
"manifest",
"against",
"schema",
"located",
"at",
"MANIFEST_SCHEMA_PATH",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/manifest_validation.py#L59-L71 |
ethpm/py-ethpm | ethpm/utils/manifest_validation.py | validate_manifest_deployments | def validate_manifest_deployments(manifest: Dict[str, Any]) -> None:
"""
Validate that a manifest's deployments contracts reference existing contract_types.
"""
if set(("contract_types", "deployments")).issubset(manifest):
all_contract_types = list(manifest["contract_types"].keys())
all_... | python | def validate_manifest_deployments(manifest: Dict[str, Any]) -> None:
"""
Validate that a manifest's deployments contracts reference existing contract_types.
"""
if set(("contract_types", "deployments")).issubset(manifest):
all_contract_types = list(manifest["contract_types"].keys())
all_... | [
"def",
"validate_manifest_deployments",
"(",
"manifest",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"None",
":",
"if",
"set",
"(",
"(",
"\"contract_types\"",
",",
"\"deployments\"",
")",
")",
".",
"issubset",
"(",
"manifest",
")",
":",
"all_contr... | Validate that a manifest's deployments contracts reference existing contract_types. | [
"Validate",
"that",
"a",
"manifest",
"s",
"deployments",
"contracts",
"reference",
"existing",
"contract_types",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/manifest_validation.py#L88-L102 |
ethpm/py-ethpm | ethpm/utils/manifest_validation.py | validate_raw_manifest_format | def validate_raw_manifest_format(raw_manifest: str) -> None:
"""
Raise a ValidationError if a manifest ...
- is not tightly packed (i.e. no linebreaks or extra whitespace)
- does not have alphabetically sorted keys
- has duplicate keys
- is not UTF-8 encoded
- has a trailing newline
"""
... | python | def validate_raw_manifest_format(raw_manifest: str) -> None:
"""
Raise a ValidationError if a manifest ...
- is not tightly packed (i.e. no linebreaks or extra whitespace)
- does not have alphabetically sorted keys
- has duplicate keys
- is not UTF-8 encoded
- has a trailing newline
"""
... | [
"def",
"validate_raw_manifest_format",
"(",
"raw_manifest",
":",
"str",
")",
"->",
"None",
":",
"try",
":",
"manifest_dict",
"=",
"json",
".",
"loads",
"(",
"raw_manifest",
",",
"encoding",
"=",
"\"UTF-8\"",
")",
"except",
"json",
".",
"JSONDecodeError",
"as",... | Raise a ValidationError if a manifest ...
- is not tightly packed (i.e. no linebreaks or extra whitespace)
- does not have alphabetically sorted keys
- has duplicate keys
- is not UTF-8 encoded
- has a trailing newline | [
"Raise",
"a",
"ValidationError",
"if",
"a",
"manifest",
"...",
"-",
"is",
"not",
"tightly",
"packed",
"(",
"i",
".",
"e",
".",
"no",
"linebreaks",
"or",
"extra",
"whitespace",
")",
"-",
"does",
"not",
"have",
"alphabetically",
"sorted",
"keys",
"-",
"has... | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/manifest_validation.py#L121-L144 |
ethpm/py-ethpm | ethpm/tools/builder.py | build | def build(obj: Dict[str, Any], *fns: Callable[..., Any]) -> Dict[str, Any]:
"""
Wrapper function to pipe manifest through build functions.
Does not validate the manifest by default.
"""
return pipe(obj, *fns) | python | def build(obj: Dict[str, Any], *fns: Callable[..., Any]) -> Dict[str, Any]:
"""
Wrapper function to pipe manifest through build functions.
Does not validate the manifest by default.
"""
return pipe(obj, *fns) | [
"def",
"build",
"(",
"obj",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"*",
"fns",
":",
"Callable",
"[",
"...",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"pipe",
"(",
"obj",
",",
"*",
"fns",
")"
] | Wrapper function to pipe manifest through build functions.
Does not validate the manifest by default. | [
"Wrapper",
"function",
"to",
"pipe",
"manifest",
"through",
"build",
"functions",
".",
"Does",
"not",
"validate",
"the",
"manifest",
"by",
"default",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L32-L37 |
ethpm/py-ethpm | ethpm/tools/builder.py | get_names_and_paths | def get_names_and_paths(compiler_output: Dict[str, Any]) -> Dict[str, str]:
"""
Return a mapping of contract name to relative path as defined in compiler output.
"""
return {
contract_name: make_path_relative(path)
for path in compiler_output
for contract_name in compiler_output[... | python | def get_names_and_paths(compiler_output: Dict[str, Any]) -> Dict[str, str]:
"""
Return a mapping of contract name to relative path as defined in compiler output.
"""
return {
contract_name: make_path_relative(path)
for path in compiler_output
for contract_name in compiler_output[... | [
"def",
"get_names_and_paths",
"(",
"compiler_output",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"return",
"{",
"contract_name",
":",
"make_path_relative",
"(",
"path",
")",
"for",
"path",
"in",
"compil... | Return a mapping of contract name to relative path as defined in compiler output. | [
"Return",
"a",
"mapping",
"of",
"contract",
"name",
"to",
"relative",
"path",
"as",
"defined",
"in",
"compiler",
"output",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L134-L142 |
ethpm/py-ethpm | ethpm/tools/builder.py | make_path_relative | def make_path_relative(path: str) -> str:
"""
Returns the given path prefixed with "./" if the path
is not already relative in the compiler output.
"""
if "../" in path:
raise ManifestBuildingError(
f"Path: {path} appears to be outside of the virtual source tree. "
"P... | python | def make_path_relative(path: str) -> str:
"""
Returns the given path prefixed with "./" if the path
is not already relative in the compiler output.
"""
if "../" in path:
raise ManifestBuildingError(
f"Path: {path} appears to be outside of the virtual source tree. "
"P... | [
"def",
"make_path_relative",
"(",
"path",
":",
"str",
")",
"->",
"str",
":",
"if",
"\"../\"",
"in",
"path",
":",
"raise",
"ManifestBuildingError",
"(",
"f\"Path: {path} appears to be outside of the virtual source tree. \"",
"\"Please make sure all sources are within the virtual... | Returns the given path prefixed with "./" if the path
is not already relative in the compiler output. | [
"Returns",
"the",
"given",
"path",
"prefixed",
"with",
".",
"/",
"if",
"the",
"path",
"is",
"not",
"already",
"relative",
"in",
"the",
"compiler",
"output",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L145-L158 |
ethpm/py-ethpm | ethpm/tools/builder.py | contract_type | def contract_type(
name: str,
compiler_output: Dict[str, Any],
alias: Optional[str] = None,
abi: Optional[bool] = False,
compiler: Optional[bool] = False,
contract_type: Optional[bool] = False,
deployment_bytecode: Optional[bool] = False,
natspec: Optional[bool] = False,
runtime_byte... | python | def contract_type(
name: str,
compiler_output: Dict[str, Any],
alias: Optional[str] = None,
abi: Optional[bool] = False,
compiler: Optional[bool] = False,
contract_type: Optional[bool] = False,
deployment_bytecode: Optional[bool] = False,
natspec: Optional[bool] = False,
runtime_byte... | [
"def",
"contract_type",
"(",
"name",
":",
"str",
",",
"compiler_output",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"alias",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"abi",
":",
"Optional",
"[",
"bool",
"]",
"=",
"False",
",",
"compi... | Returns a copy of manifest with added contract_data field as specified by kwargs.
If no kwargs are present, all available contract_data found in the compiler output
will be included.
To include specific contract_data fields, add kwarg set to True (i.e. `abi=True`)
To alias a contract_type, include a kw... | [
"Returns",
"a",
"copy",
"of",
"manifest",
"with",
"added",
"contract_data",
"field",
"as",
"specified",
"by",
"kwargs",
".",
"If",
"no",
"kwargs",
"are",
"present",
"all",
"available",
"contract_data",
"found",
"in",
"the",
"compiler",
"output",
"will",
"be",
... | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L298-L329 |
ethpm/py-ethpm | ethpm/tools/builder.py | filter_all_data_by_selected_fields | def filter_all_data_by_selected_fields(
all_type_data: Dict[str, Any], selected_fields: List[str]
) -> Iterable[Tuple[str, Any]]:
"""
Raises exception if selected field data is not available in the contract type data
automatically gathered by normalize_compiler_output. Otherwise, returns the data.
"... | python | def filter_all_data_by_selected_fields(
all_type_data: Dict[str, Any], selected_fields: List[str]
) -> Iterable[Tuple[str, Any]]:
"""
Raises exception if selected field data is not available in the contract type data
automatically gathered by normalize_compiler_output. Otherwise, returns the data.
"... | [
"def",
"filter_all_data_by_selected_fields",
"(",
"all_type_data",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"selected_fields",
":",
"List",
"[",
"str",
"]",
")",
"->",
"Iterable",
"[",
"Tuple",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"for",
"field",... | Raises exception if selected field data is not available in the contract type data
automatically gathered by normalize_compiler_output. Otherwise, returns the data. | [
"Raises",
"exception",
"if",
"selected",
"field",
"data",
"is",
"not",
"available",
"in",
"the",
"contract",
"type",
"data",
"automatically",
"gathered",
"by",
"normalize_compiler_output",
".",
"Otherwise",
"returns",
"the",
"data",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L364-L379 |
ethpm/py-ethpm | ethpm/tools/builder.py | normalize_compiler_output | def normalize_compiler_output(compiler_output: Dict[str, Any]) -> Dict[str, Any]:
"""
Return compiler output with normalized fields for each contract type,
as specified in `normalize_contract_type`.
"""
paths_and_names = [
(path, contract_name)
for path in compiler_output
for... | python | def normalize_compiler_output(compiler_output: Dict[str, Any]) -> Dict[str, Any]:
"""
Return compiler output with normalized fields for each contract type,
as specified in `normalize_contract_type`.
"""
paths_and_names = [
(path, contract_name)
for path in compiler_output
for... | [
"def",
"normalize_compiler_output",
"(",
"compiler_output",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"paths_and_names",
"=",
"[",
"(",
"path",
",",
"contract_name",
")",
"for",
"path",
"in",
"compiler... | Return compiler output with normalized fields for each contract type,
as specified in `normalize_contract_type`. | [
"Return",
"compiler",
"output",
"with",
"normalized",
"fields",
"for",
"each",
"contract",
"type",
"as",
"specified",
"in",
"normalize_contract_type",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L382-L400 |
ethpm/py-ethpm | ethpm/tools/builder.py | normalize_contract_type | def normalize_contract_type(
contract_type_data: Dict[str, Any]
) -> Iterable[Tuple[str, Any]]:
"""
Serialize contract_data found in compiler output to the defined fields.
"""
yield "abi", contract_type_data["abi"]
if "evm" in contract_type_data:
if "bytecode" in contract_type_data["evm"... | python | def normalize_contract_type(
contract_type_data: Dict[str, Any]
) -> Iterable[Tuple[str, Any]]:
"""
Serialize contract_data found in compiler output to the defined fields.
"""
yield "abi", contract_type_data["abi"]
if "evm" in contract_type_data:
if "bytecode" in contract_type_data["evm"... | [
"def",
"normalize_contract_type",
"(",
"contract_type_data",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Iterable",
"[",
"Tuple",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"yield",
"\"abi\"",
",",
"contract_type_data",
"[",
"\"abi\"",
"]",
"if",
"... | Serialize contract_data found in compiler output to the defined fields. | [
"Serialize",
"contract_data",
"found",
"in",
"compiler",
"output",
"to",
"the",
"defined",
"fields",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L407-L432 |
ethpm/py-ethpm | ethpm/tools/builder.py | process_bytecode | def process_bytecode(link_refs: Dict[str, Any], bytecode: bytes) -> str:
"""
Replace link_refs in bytecode with 0's.
"""
all_offsets = [y for x in link_refs.values() for y in x.values()]
# Link ref validation.
validate_link_ref_fns = (
validate_link_ref(ref["start"] * 2, ref["length"] * ... | python | def process_bytecode(link_refs: Dict[str, Any], bytecode: bytes) -> str:
"""
Replace link_refs in bytecode with 0's.
"""
all_offsets = [y for x in link_refs.values() for y in x.values()]
# Link ref validation.
validate_link_ref_fns = (
validate_link_ref(ref["start"] * 2, ref["length"] * ... | [
"def",
"process_bytecode",
"(",
"link_refs",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"bytecode",
":",
"bytes",
")",
"->",
"str",
":",
"all_offsets",
"=",
"[",
"y",
"for",
"x",
"in",
"link_refs",
".",
"values",
"(",
")",
"for",
"y",
"in",
"x"... | Replace link_refs in bytecode with 0's. | [
"Replace",
"link_refs",
"in",
"bytecode",
"with",
"0",
"s",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L462-L479 |
ethpm/py-ethpm | ethpm/tools/builder.py | deployment_type | def deployment_type(
*,
contract_instance: str,
contract_type: str,
deployment_bytecode: Dict[str, Any] = None,
runtime_bytecode: Dict[str, Any] = None,
compiler: Dict[str, Any] = None,
) -> Manifest:
"""
Returns a callable that allows the user to add deployments of the same type
acr... | python | def deployment_type(
*,
contract_instance: str,
contract_type: str,
deployment_bytecode: Dict[str, Any] = None,
runtime_bytecode: Dict[str, Any] = None,
compiler: Dict[str, Any] = None,
) -> Manifest:
"""
Returns a callable that allows the user to add deployments of the same type
acr... | [
"def",
"deployment_type",
"(",
"*",
",",
"contract_instance",
":",
"str",
",",
"contract_type",
":",
"str",
",",
"deployment_bytecode",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"None",
",",
"runtime_bytecode",
":",
"Dict",
"[",
"str",
",",
"Any",
"... | Returns a callable that allows the user to add deployments of the same type
across multiple chains. | [
"Returns",
"a",
"callable",
"that",
"allows",
"the",
"user",
"to",
"add",
"deployments",
"of",
"the",
"same",
"type",
"across",
"multiple",
"chains",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L532-L550 |
ethpm/py-ethpm | ethpm/tools/builder.py | deployment | def deployment(
*,
block_uri: URI,
contract_instance: str,
contract_type: str,
address: HexStr,
transaction: HexStr = None,
block: HexStr = None,
deployment_bytecode: Dict[str, Any] = None,
runtime_bytecode: Dict[str, Any] = None,
compiler: Dict[str, Any] = None,
) -> Manifest:
... | python | def deployment(
*,
block_uri: URI,
contract_instance: str,
contract_type: str,
address: HexStr,
transaction: HexStr = None,
block: HexStr = None,
deployment_bytecode: Dict[str, Any] = None,
runtime_bytecode: Dict[str, Any] = None,
compiler: Dict[str, Any] = None,
) -> Manifest:
... | [
"def",
"deployment",
"(",
"*",
",",
"block_uri",
":",
"URI",
",",
"contract_instance",
":",
"str",
",",
"contract_type",
":",
"str",
",",
"address",
":",
"HexStr",
",",
"transaction",
":",
"HexStr",
"=",
"None",
",",
"block",
":",
"HexStr",
"=",
"None",
... | Returns a manifest, with the newly included deployment. Requires a valid blockchain URI,
however no validation is provided that this URI is unique amongst the other deployment
URIs, so the user must take care that each blockchain URI represents a unique blockchain. | [
"Returns",
"a",
"manifest",
"with",
"the",
"newly",
"included",
"deployment",
".",
"Requires",
"a",
"valid",
"blockchain",
"URI",
"however",
"no",
"validation",
"is",
"provided",
"that",
"this",
"URI",
"is",
"unique",
"amongst",
"the",
"other",
"deployment",
"... | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L553-L580 |
ethpm/py-ethpm | ethpm/tools/builder.py | _build_deployments_object | def _build_deployments_object(
contract_type: str,
deployment_bytecode: Dict[str, Any],
runtime_bytecode: Dict[str, Any],
compiler: Dict[str, Any],
address: HexStr,
tx: HexStr,
block: HexStr,
manifest: Dict[str, Any],
) -> Iterable[Tuple[str, Any]]:
"""
Returns a dict with proper... | python | def _build_deployments_object(
contract_type: str,
deployment_bytecode: Dict[str, Any],
runtime_bytecode: Dict[str, Any],
compiler: Dict[str, Any],
address: HexStr,
tx: HexStr,
block: HexStr,
manifest: Dict[str, Any],
) -> Iterable[Tuple[str, Any]]:
"""
Returns a dict with proper... | [
"def",
"_build_deployments_object",
"(",
"contract_type",
":",
"str",
",",
"deployment_bytecode",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"runtime_bytecode",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"compiler",
":",
"Dict",
"[",
"str",
",",
... | Returns a dict with properly formatted deployment data. | [
"Returns",
"a",
"dict",
"with",
"properly",
"formatted",
"deployment",
"data",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L652-L676 |
ethpm/py-ethpm | ethpm/tools/builder.py | init_manifest | def init_manifest(
package_name: str, version: str, manifest_version: Optional[str] = "2"
) -> Dict[str, Any]:
"""
Returns an initial dict with the minimal requried fields for a valid manifest.
Should only be used as the first fn to be piped into a `build()` pipeline.
"""
return {
"packa... | python | def init_manifest(
package_name: str, version: str, manifest_version: Optional[str] = "2"
) -> Dict[str, Any]:
"""
Returns an initial dict with the minimal requried fields for a valid manifest.
Should only be used as the first fn to be piped into a `build()` pipeline.
"""
return {
"packa... | [
"def",
"init_manifest",
"(",
"package_name",
":",
"str",
",",
"version",
":",
"str",
",",
"manifest_version",
":",
"Optional",
"[",
"str",
"]",
"=",
"\"2\"",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"{",
"\"package_name\"",
":",
"... | Returns an initial dict with the minimal requried fields for a valid manifest.
Should only be used as the first fn to be piped into a `build()` pipeline. | [
"Returns",
"an",
"initial",
"dict",
"with",
"the",
"minimal",
"requried",
"fields",
"for",
"a",
"valid",
"manifest",
".",
"Should",
"only",
"be",
"used",
"as",
"the",
"first",
"fn",
"to",
"be",
"piped",
"into",
"a",
"build",
"()",
"pipeline",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L685-L696 |
ethpm/py-ethpm | ethpm/tools/builder.py | write_to_disk | def write_to_disk(
manifest_root_dir: Optional[Path] = None,
manifest_name: Optional[str] = None,
prettify: Optional[bool] = False,
) -> Manifest:
"""
Write the active manifest to disk
Defaults
- Writes manifest to cwd unless Path is provided as manifest_root_dir.
- Writes manifest with ... | python | def write_to_disk(
manifest_root_dir: Optional[Path] = None,
manifest_name: Optional[str] = None,
prettify: Optional[bool] = False,
) -> Manifest:
"""
Write the active manifest to disk
Defaults
- Writes manifest to cwd unless Path is provided as manifest_root_dir.
- Writes manifest with ... | [
"def",
"write_to_disk",
"(",
"manifest_root_dir",
":",
"Optional",
"[",
"Path",
"]",
"=",
"None",
",",
"manifest_name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"prettify",
":",
"Optional",
"[",
"bool",
"]",
"=",
"False",
",",
")",
"->",
"Ma... | Write the active manifest to disk
Defaults
- Writes manifest to cwd unless Path is provided as manifest_root_dir.
- Writes manifest with a filename of Manifest[version].json unless a desired
manifest name (which must end in json) is provided as manifest_name.
- Writes the minified manifest version t... | [
"Write",
"the",
"active",
"manifest",
"to",
"disk",
"Defaults",
"-",
"Writes",
"manifest",
"to",
"cwd",
"unless",
"Path",
"is",
"provided",
"as",
"manifest_root_dir",
".",
"-",
"Writes",
"manifest",
"with",
"a",
"filename",
"of",
"Manifest",
"[",
"version",
... | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L721-L734 |
ethpm/py-ethpm | ethpm/tools/builder.py | pin_to_ipfs | def pin_to_ipfs(
manifest: Manifest, *, backend: BaseIPFSBackend, prettify: Optional[bool] = False
) -> List[Dict[str, str]]:
"""
Returns the IPFS pin data after pinning the manifest to the provided IPFS Backend.
`pin_to_ipfs()` Should *always* be the last argument in a builder, as it will return the p... | python | def pin_to_ipfs(
manifest: Manifest, *, backend: BaseIPFSBackend, prettify: Optional[bool] = False
) -> List[Dict[str, str]]:
"""
Returns the IPFS pin data after pinning the manifest to the provided IPFS Backend.
`pin_to_ipfs()` Should *always* be the last argument in a builder, as it will return the p... | [
"def",
"pin_to_ipfs",
"(",
"manifest",
":",
"Manifest",
",",
"*",
",",
"backend",
":",
"BaseIPFSBackend",
",",
"prettify",
":",
"Optional",
"[",
"bool",
"]",
"=",
"False",
")",
"->",
"List",
"[",
"Dict",
"[",
"str",
",",
"str",
"]",
"]",
":",
"conten... | Returns the IPFS pin data after pinning the manifest to the provided IPFS Backend.
`pin_to_ipfs()` Should *always* be the last argument in a builder, as it will return the pin
data and not the manifest. | [
"Returns",
"the",
"IPFS",
"pin",
"data",
"after",
"pinning",
"the",
"manifest",
"to",
"the",
"provided",
"IPFS",
"Backend",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L776-L790 |
BrewBlox/brewblox-service | brewblox_service/service.py | create_parser | def create_parser(default_name: str) -> argparse.ArgumentParser:
"""
Creates the default brewblox_service ArgumentParser.
Service-agnostic arguments are added.
The parser allows calling code to add additional arguments before using it in create_app()
Args:
default_name (str):
d... | python | def create_parser(default_name: str) -> argparse.ArgumentParser:
"""
Creates the default brewblox_service ArgumentParser.
Service-agnostic arguments are added.
The parser allows calling code to add additional arguments before using it in create_app()
Args:
default_name (str):
d... | [
"def",
"create_parser",
"(",
"default_name",
":",
"str",
")",
"->",
"argparse",
".",
"ArgumentParser",
":",
"argparser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"fromfile_prefix_chars",
"=",
"'@'",
")",
"argparser",
".",
"add_argument",
"(",
"'-H'",
",",
... | Creates the default brewblox_service ArgumentParser.
Service-agnostic arguments are added.
The parser allows calling code to add additional arguments before using it in create_app()
Args:
default_name (str):
default value for the --name commandline argument.
Returns:
argpa... | [
"Creates",
"the",
"default",
"brewblox_service",
"ArgumentParser",
".",
"Service",
"-",
"agnostic",
"arguments",
"are",
"added",
"."
] | train | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/service.py#L68-L106 |
BrewBlox/brewblox-service | brewblox_service/service.py | create_app | def create_app(
default_name: str = None,
parser: argparse.ArgumentParser = None,
raw_args: List[str] = None
) -> web.Application:
"""
Creates and configures an Aiohttp application.
Args:
default_name (str, optional):
Default value for the --name commandline argu... | python | def create_app(
default_name: str = None,
parser: argparse.ArgumentParser = None,
raw_args: List[str] = None
) -> web.Application:
"""
Creates and configures an Aiohttp application.
Args:
default_name (str, optional):
Default value for the --name commandline argu... | [
"def",
"create_app",
"(",
"default_name",
":",
"str",
"=",
"None",
",",
"parser",
":",
"argparse",
".",
"ArgumentParser",
"=",
"None",
",",
"raw_args",
":",
"List",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"web",
".",
"Application",
":",
"if",
"parser"... | Creates and configures an Aiohttp application.
Args:
default_name (str, optional):
Default value for the --name commandline argument.
This value is required if `parser` is not provided.
This value will be ignored if `parser` is provided.
parser (argparse.Argumen... | [
"Creates",
"and",
"configures",
"an",
"Aiohttp",
"application",
"."
] | train | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/service.py#L109-L147 |
BrewBlox/brewblox-service | brewblox_service/service.py | furnish | def furnish(app: web.Application):
"""
Configures Application routes, readying it for running.
This function modifies routes and resources that were added by calling code,
and must be called immediately prior to `run(app)`.
Args:
app (web.Application):
The Aiohttp Application a... | python | def furnish(app: web.Application):
"""
Configures Application routes, readying it for running.
This function modifies routes and resources that were added by calling code,
and must be called immediately prior to `run(app)`.
Args:
app (web.Application):
The Aiohttp Application a... | [
"def",
"furnish",
"(",
"app",
":",
"web",
".",
"Application",
")",
":",
"app_name",
"=",
"app",
"[",
"'config'",
"]",
"[",
"'name'",
"]",
"prefix",
"=",
"'/'",
"+",
"app_name",
".",
"lstrip",
"(",
"'/'",
")",
"app",
".",
"router",
".",
"add_routes",
... | Configures Application routes, readying it for running.
This function modifies routes and resources that were added by calling code,
and must be called immediately prior to `run(app)`.
Args:
app (web.Application):
The Aiohttp Application as created by `create_app()` | [
"Configures",
"Application",
"routes",
"readying",
"it",
"for",
"running",
"."
] | train | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/service.py#L150-L189 |
BrewBlox/brewblox-service | brewblox_service/service.py | run | def run(app: web.Application):
"""
Runs the application in an async context.
This function will block indefinitely until the application is shut down.
Args:
app (web.Application):
The Aiohttp Application as created by `create_app()`
"""
host = app['config']['host']
port ... | python | def run(app: web.Application):
"""
Runs the application in an async context.
This function will block indefinitely until the application is shut down.
Args:
app (web.Application):
The Aiohttp Application as created by `create_app()`
"""
host = app['config']['host']
port ... | [
"def",
"run",
"(",
"app",
":",
"web",
".",
"Application",
")",
":",
"host",
"=",
"app",
"[",
"'config'",
"]",
"[",
"'host'",
"]",
"port",
"=",
"app",
"[",
"'config'",
"]",
"[",
"'port'",
"]",
"# starts app. run_app() will automatically start the async context.... | Runs the application in an async context.
This function will block indefinitely until the application is shut down.
Args:
app (web.Application):
The Aiohttp Application as created by `create_app()` | [
"Runs",
"the",
"application",
"in",
"an",
"async",
"context",
".",
"This",
"function",
"will",
"block",
"indefinitely",
"until",
"the",
"application",
"is",
"shut",
"down",
"."
] | train | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/service.py#L192-L205 |
ethpm/py-ethpm | ethpm/utils/deployments.py | get_linked_deployments | def get_linked_deployments(deployments: Dict[str, Any]) -> Dict[str, Any]:
"""
Returns all deployments found in a chain URI's deployment data that contain link dependencies.
"""
linked_deployments = {
dep: data
for dep, data in deployments.items()
if get_in(("runtime_bytecode", "... | python | def get_linked_deployments(deployments: Dict[str, Any]) -> Dict[str, Any]:
"""
Returns all deployments found in a chain URI's deployment data that contain link dependencies.
"""
linked_deployments = {
dep: data
for dep, data in deployments.items()
if get_in(("runtime_bytecode", "... | [
"def",
"get_linked_deployments",
"(",
"deployments",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"linked_deployments",
"=",
"{",
"dep",
":",
"data",
"for",
"dep",
",",
"data",
"in",
"deployments",
".",... | Returns all deployments found in a chain URI's deployment data that contain link dependencies. | [
"Returns",
"all",
"deployments",
"found",
"in",
"a",
"chain",
"URI",
"s",
"deployment",
"data",
"that",
"contain",
"link",
"dependencies",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/deployments.py#L10-L28 |
ethpm/py-ethpm | ethpm/utils/deployments.py | validate_linked_references | def validate_linked_references(
link_deps: Tuple[Tuple[int, bytes], ...], bytecode: bytes
) -> None:
"""
Validates that normalized linked_references (offset, expected_bytes)
match the corresponding bytecode.
"""
offsets, values = zip(*link_deps)
for idx, offset in enumerate(offsets):
... | python | def validate_linked_references(
link_deps: Tuple[Tuple[int, bytes], ...], bytecode: bytes
) -> None:
"""
Validates that normalized linked_references (offset, expected_bytes)
match the corresponding bytecode.
"""
offsets, values = zip(*link_deps)
for idx, offset in enumerate(offsets):
... | [
"def",
"validate_linked_references",
"(",
"link_deps",
":",
"Tuple",
"[",
"Tuple",
"[",
"int",
",",
"bytes",
"]",
",",
"...",
"]",
",",
"bytecode",
":",
"bytes",
")",
"->",
"None",
":",
"offsets",
",",
"values",
"=",
"zip",
"(",
"*",
"link_deps",
")",
... | Validates that normalized linked_references (offset, expected_bytes)
match the corresponding bytecode. | [
"Validates",
"that",
"normalized",
"linked_references",
"(",
"offset",
"expected_bytes",
")",
"match",
"the",
"corresponding",
"bytecode",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/deployments.py#L31-L53 |
ethpm/py-ethpm | ethpm/utils/deployments.py | normalize_linked_references | def normalize_linked_references(
data: List[Dict[str, Any]]
) -> Generator[Tuple[int, str, str], None, None]:
"""
Return a tuple of information representing all insertions of a linked reference.
(offset, type, value)
"""
for deployment in data:
for offset in deployment["offsets"]:
... | python | def normalize_linked_references(
data: List[Dict[str, Any]]
) -> Generator[Tuple[int, str, str], None, None]:
"""
Return a tuple of information representing all insertions of a linked reference.
(offset, type, value)
"""
for deployment in data:
for offset in deployment["offsets"]:
... | [
"def",
"normalize_linked_references",
"(",
"data",
":",
"List",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
")",
"->",
"Generator",
"[",
"Tuple",
"[",
"int",
",",
"str",
",",
"str",
"]",
",",
"None",
",",
"None",
"]",
":",
"for",
"deployment",
"... | Return a tuple of information representing all insertions of a linked reference.
(offset, type, value) | [
"Return",
"a",
"tuple",
"of",
"information",
"representing",
"all",
"insertions",
"of",
"a",
"linked",
"reference",
".",
"(",
"offset",
"type",
"value",
")"
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/deployments.py#L57-L66 |
ethpm/py-ethpm | ethpm/utils/deployments.py | validate_deployments_tx_receipt | def validate_deployments_tx_receipt(
deployments: Dict[str, Any], w3: Web3, allow_missing_data: bool = False
) -> None:
"""
Validate that address and block hash found in deployment data match what is found on-chain.
:allow_missing_data: by default, enforces validation of address and blockHash.
"""
... | python | def validate_deployments_tx_receipt(
deployments: Dict[str, Any], w3: Web3, allow_missing_data: bool = False
) -> None:
"""
Validate that address and block hash found in deployment data match what is found on-chain.
:allow_missing_data: by default, enforces validation of address and blockHash.
"""
... | [
"def",
"validate_deployments_tx_receipt",
"(",
"deployments",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"w3",
":",
"Web3",
",",
"allow_missing_data",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"# todo: provide hook to lazily look up tx receipt via binar... | Validate that address and block hash found in deployment data match what is found on-chain.
:allow_missing_data: by default, enforces validation of address and blockHash. | [
"Validate",
"that",
"address",
"and",
"block",
"hash",
"found",
"in",
"deployment",
"data",
"match",
"what",
"is",
"found",
"on",
"-",
"chain",
".",
":",
"allow_missing_data",
":",
"by",
"default",
"enforces",
"validation",
"of",
"address",
"and",
"blockHash",... | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/deployments.py#L69-L118 |
ethpm/py-ethpm | ethpm/contract.py | is_prelinked_bytecode | def is_prelinked_bytecode(bytecode: bytes, link_refs: List[Dict[str, Any]]) -> bool:
"""
Returns False if all expected link_refs are unlinked, otherwise returns True.
todo support partially pre-linked bytecode (currently all or nothing)
"""
for link_ref in link_refs:
for offset in link_ref["... | python | def is_prelinked_bytecode(bytecode: bytes, link_refs: List[Dict[str, Any]]) -> bool:
"""
Returns False if all expected link_refs are unlinked, otherwise returns True.
todo support partially pre-linked bytecode (currently all or nothing)
"""
for link_ref in link_refs:
for offset in link_ref["... | [
"def",
"is_prelinked_bytecode",
"(",
"bytecode",
":",
"bytes",
",",
"link_refs",
":",
"List",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
")",
"->",
"bool",
":",
"for",
"link_ref",
"in",
"link_refs",
":",
"for",
"offset",
"in",
"link_ref",
"[",
"\"o... | Returns False if all expected link_refs are unlinked, otherwise returns True.
todo support partially pre-linked bytecode (currently all or nothing) | [
"Returns",
"False",
"if",
"all",
"expected",
"link_refs",
"are",
"unlinked",
"otherwise",
"returns",
"True",
".",
"todo",
"support",
"partially",
"pre",
"-",
"linked",
"bytecode",
"(",
"currently",
"all",
"or",
"nothing",
")"
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/contract.py#L111-L122 |
ethpm/py-ethpm | ethpm/contract.py | apply_all_link_refs | def apply_all_link_refs(
bytecode: bytes, link_refs: List[Dict[str, Any]], attr_dict: Dict[str, str]
) -> bytes:
"""
Applies all link references corresponding to a valid attr_dict to the bytecode.
"""
if link_refs is None:
return bytecode
link_fns = (
apply_link_ref(offset, ref["... | python | def apply_all_link_refs(
bytecode: bytes, link_refs: List[Dict[str, Any]], attr_dict: Dict[str, str]
) -> bytes:
"""
Applies all link references corresponding to a valid attr_dict to the bytecode.
"""
if link_refs is None:
return bytecode
link_fns = (
apply_link_ref(offset, ref["... | [
"def",
"apply_all_link_refs",
"(",
"bytecode",
":",
"bytes",
",",
"link_refs",
":",
"List",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
",",
"attr_dict",
":",
"Dict",
"[",
"str",
",",
"str",
"]",
")",
"->",
"bytes",
":",
"if",
"link_refs",
"is",
... | Applies all link references corresponding to a valid attr_dict to the bytecode. | [
"Applies",
"all",
"link",
"references",
"corresponding",
"to",
"a",
"valid",
"attr_dict",
"to",
"the",
"bytecode",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/contract.py#L125-L139 |
ethpm/py-ethpm | ethpm/contract.py | apply_link_ref | def apply_link_ref(offset: int, length: int, value: bytes, bytecode: bytes) -> bytes:
"""
Returns the new bytecode with `value` put into the location indicated by `offset` and `length`.
"""
try:
validate_empty_bytes(offset, length, bytecode)
except ValidationError:
raise BytecodeLink... | python | def apply_link_ref(offset: int, length: int, value: bytes, bytecode: bytes) -> bytes:
"""
Returns the new bytecode with `value` put into the location indicated by `offset` and `length`.
"""
try:
validate_empty_bytes(offset, length, bytecode)
except ValidationError:
raise BytecodeLink... | [
"def",
"apply_link_ref",
"(",
"offset",
":",
"int",
",",
"length",
":",
"int",
",",
"value",
":",
"bytes",
",",
"bytecode",
":",
"bytes",
")",
"->",
"bytes",
":",
"try",
":",
"validate_empty_bytes",
"(",
"offset",
",",
"length",
",",
"bytecode",
")",
"... | Returns the new bytecode with `value` put into the location indicated by `offset` and `length`. | [
"Returns",
"the",
"new",
"bytecode",
"with",
"value",
"put",
"into",
"the",
"location",
"indicated",
"by",
"offset",
"and",
"length",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/contract.py#L143-L158 |
ethpm/py-ethpm | ethpm/contract.py | LinkableContract.link_bytecode | def link_bytecode(cls, attr_dict: Dict[str, str]) -> Type["LinkableContract"]:
"""
Return a cloned contract factory with the deployment / runtime bytecode linked.
:attr_dict: Dict[`ContractType`: `Address`] for all deployment and runtime link references.
"""
if not cls.unlinked_... | python | def link_bytecode(cls, attr_dict: Dict[str, str]) -> Type["LinkableContract"]:
"""
Return a cloned contract factory with the deployment / runtime bytecode linked.
:attr_dict: Dict[`ContractType`: `Address`] for all deployment and runtime link references.
"""
if not cls.unlinked_... | [
"def",
"link_bytecode",
"(",
"cls",
",",
"attr_dict",
":",
"Dict",
"[",
"str",
",",
"str",
"]",
")",
"->",
"Type",
"[",
"\"LinkableContract\"",
"]",
":",
"if",
"not",
"cls",
".",
"unlinked_references",
"and",
"not",
"cls",
".",
"linked_references",
":",
... | Return a cloned contract factory with the deployment / runtime bytecode linked.
:attr_dict: Dict[`ContractType`: `Address`] for all deployment and runtime link references. | [
"Return",
"a",
"cloned",
"contract",
"factory",
"with",
"the",
"deployment",
"/",
"runtime",
"bytecode",
"linked",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/contract.py#L55-L79 |
ethpm/py-ethpm | ethpm/contract.py | LinkableContract.validate_attr_dict | def validate_attr_dict(self, attr_dict: Dict[str, str]) -> None:
"""
Validates that ContractType keys in attr_dict reference existing manifest ContractTypes.
"""
attr_dict_names = list(attr_dict.keys())
if not self.unlinked_references and not self.linked_references:
... | python | def validate_attr_dict(self, attr_dict: Dict[str, str]) -> None:
"""
Validates that ContractType keys in attr_dict reference existing manifest ContractTypes.
"""
attr_dict_names = list(attr_dict.keys())
if not self.unlinked_references and not self.linked_references:
... | [
"def",
"validate_attr_dict",
"(",
"self",
",",
"attr_dict",
":",
"Dict",
"[",
"str",
",",
"str",
"]",
")",
"->",
"None",
":",
"attr_dict_names",
"=",
"list",
"(",
"attr_dict",
".",
"keys",
"(",
")",
")",
"if",
"not",
"self",
".",
"unlinked_references",
... | Validates that ContractType keys in attr_dict reference existing manifest ContractTypes. | [
"Validates",
"that",
"ContractType",
"keys",
"in",
"attr_dict",
"reference",
"existing",
"manifest",
"ContractTypes",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/contract.py#L82-L108 |
ethpm/py-ethpm | ethpm/dependencies.py | Dependencies.items | def items(self) -> Tuple[Tuple[str, "Package"], ...]: # type: ignore
"""
Return an iterable containing package name and
corresponding `Package` instance that are available.
"""
item_dict = {
name: self.build_dependencies.get(name) for name in self.build_dependencies
... | python | def items(self) -> Tuple[Tuple[str, "Package"], ...]: # type: ignore
"""
Return an iterable containing package name and
corresponding `Package` instance that are available.
"""
item_dict = {
name: self.build_dependencies.get(name) for name in self.build_dependencies
... | [
"def",
"items",
"(",
"self",
")",
"->",
"Tuple",
"[",
"Tuple",
"[",
"str",
",",
"\"Package\"",
"]",
",",
"...",
"]",
":",
"# type: ignore",
"item_dict",
"=",
"{",
"name",
":",
"self",
".",
"build_dependencies",
".",
"get",
"(",
"name",
")",
"for",
"n... | Return an iterable containing package name and
corresponding `Package` instance that are available. | [
"Return",
"an",
"iterable",
"containing",
"package",
"name",
"and",
"corresponding",
"Package",
"instance",
"that",
"are",
"available",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/dependencies.py#L28-L36 |
ethpm/py-ethpm | ethpm/dependencies.py | Dependencies.values | def values(self) -> List["Package"]: # type: ignore
"""
Return an iterable of the available `Package` instances.
"""
values = [self.build_dependencies.get(name) for name in self.build_dependencies]
return values | python | def values(self) -> List["Package"]: # type: ignore
"""
Return an iterable of the available `Package` instances.
"""
values = [self.build_dependencies.get(name) for name in self.build_dependencies]
return values | [
"def",
"values",
"(",
"self",
")",
"->",
"List",
"[",
"\"Package\"",
"]",
":",
"# type: ignore",
"values",
"=",
"[",
"self",
".",
"build_dependencies",
".",
"get",
"(",
"name",
")",
"for",
"name",
"in",
"self",
".",
"build_dependencies",
"]",
"return",
"... | Return an iterable of the available `Package` instances. | [
"Return",
"an",
"iterable",
"of",
"the",
"available",
"Package",
"instances",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/dependencies.py#L38-L43 |
ethpm/py-ethpm | ethpm/dependencies.py | Dependencies.get_dependency_package | def get_dependency_package(
self, package_name: str
) -> "Package": # type: ignore # noqa: F821
"""
Return the dependency Package for a given package name.
"""
self._validate_name(package_name)
return self.build_dependencies.get(package_name) | python | def get_dependency_package(
self, package_name: str
) -> "Package": # type: ignore # noqa: F821
"""
Return the dependency Package for a given package name.
"""
self._validate_name(package_name)
return self.build_dependencies.get(package_name) | [
"def",
"get_dependency_package",
"(",
"self",
",",
"package_name",
":",
"str",
")",
"->",
"\"Package\"",
":",
"# type: ignore # noqa: F821",
"self",
".",
"_validate_name",
"(",
"package_name",
")",
"return",
"self",
".",
"build_dependencies",
".",
"get",
"(",
"pac... | Return the dependency Package for a given package name. | [
"Return",
"the",
"dependency",
"Package",
"for",
"a",
"given",
"package",
"name",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/dependencies.py#L45-L52 |
BrewBlox/brewblox-service | brewblox_service/features.py | add | def add(app: web.Application,
feature: Any,
key: Hashable = None,
exist_ok: bool = False
):
"""
Adds a new feature to the app.
Features can either be registered as the default feature for the class,
or be given an explicit name.
Args:
app (web.Application):
... | python | def add(app: web.Application,
feature: Any,
key: Hashable = None,
exist_ok: bool = False
):
"""
Adds a new feature to the app.
Features can either be registered as the default feature for the class,
or be given an explicit name.
Args:
app (web.Application):
... | [
"def",
"add",
"(",
"app",
":",
"web",
".",
"Application",
",",
"feature",
":",
"Any",
",",
"key",
":",
"Hashable",
"=",
"None",
",",
"exist_ok",
":",
"bool",
"=",
"False",
")",
":",
"if",
"FEATURES_KEY",
"not",
"in",
"app",
":",
"app",
"[",
"FEATUR... | Adds a new feature to the app.
Features can either be registered as the default feature for the class,
or be given an explicit name.
Args:
app (web.Application):
The current Aiohttp application.
feature (Any):
The new feature that should be registered.
... | [
"Adds",
"a",
"new",
"feature",
"to",
"the",
"app",
"."
] | train | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/features.py#L14-L53 |
BrewBlox/brewblox-service | brewblox_service/features.py | get | def get(app: web.Application,
feature_type: Type[Any] = None,
key: Hashable = None
) -> Any:
"""
Finds declared feature.
Identification is done based on feature type and key.
Args:
app (web.Application):
The current Aiohttp application.
feature_type ... | python | def get(app: web.Application,
feature_type: Type[Any] = None,
key: Hashable = None
) -> Any:
"""
Finds declared feature.
Identification is done based on feature type and key.
Args:
app (web.Application):
The current Aiohttp application.
feature_type ... | [
"def",
"get",
"(",
"app",
":",
"web",
".",
"Application",
",",
"feature_type",
":",
"Type",
"[",
"Any",
"]",
"=",
"None",
",",
"key",
":",
"Hashable",
"=",
"None",
")",
"->",
"Any",
":",
"key",
"=",
"key",
"or",
"feature_type",
"if",
"not",
"key",
... | Finds declared feature.
Identification is done based on feature type and key.
Args:
app (web.Application):
The current Aiohttp application.
feature_type (Type[Any]):
The Python type of the desired feature.
If specified, it will be checked against the found f... | [
"Finds",
"declared",
"feature",
".",
"Identification",
"is",
"done",
"based",
"on",
"feature",
"type",
"and",
"key",
"."
] | train | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/features.py#L56-L92 |
ethpm/py-ethpm | ethpm/utils/contract.py | validate_minimal_contract_factory_data | def validate_minimal_contract_factory_data(contract_data: Dict[str, str]) -> None:
"""
Validate that contract data in a package contains at least an "abi" and
"deployment_bytecode" necessary to generate a deployable contract factory.
"""
if not all(key in contract_data.keys() for key in ("abi", "dep... | python | def validate_minimal_contract_factory_data(contract_data: Dict[str, str]) -> None:
"""
Validate that contract data in a package contains at least an "abi" and
"deployment_bytecode" necessary to generate a deployable contract factory.
"""
if not all(key in contract_data.keys() for key in ("abi", "dep... | [
"def",
"validate_minimal_contract_factory_data",
"(",
"contract_data",
":",
"Dict",
"[",
"str",
",",
"str",
"]",
")",
"->",
"None",
":",
"if",
"not",
"all",
"(",
"key",
"in",
"contract_data",
".",
"keys",
"(",
")",
"for",
"key",
"in",
"(",
"\"abi\"",
","... | Validate that contract data in a package contains at least an "abi" and
"deployment_bytecode" necessary to generate a deployable contract factory. | [
"Validate",
"that",
"contract",
"data",
"in",
"a",
"package",
"contains",
"at",
"least",
"an",
"abi",
"and",
"deployment_bytecode",
"necessary",
"to",
"generate",
"a",
"deployable",
"contract",
"factory",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/contract.py#L10-L19 |
ethpm/py-ethpm | ethpm/utils/contract.py | generate_contract_factory_kwargs | def generate_contract_factory_kwargs(
contract_data: Dict[str, Any]
) -> Generator[Tuple[str, Any], None, None]:
"""
Build a dictionary of kwargs to be passed into contract factory.
"""
if "abi" in contract_data:
yield "abi", contract_data["abi"]
if "deployment_bytecode" in contract_dat... | python | def generate_contract_factory_kwargs(
contract_data: Dict[str, Any]
) -> Generator[Tuple[str, Any], None, None]:
"""
Build a dictionary of kwargs to be passed into contract factory.
"""
if "abi" in contract_data:
yield "abi", contract_data["abi"]
if "deployment_bytecode" in contract_dat... | [
"def",
"generate_contract_factory_kwargs",
"(",
"contract_data",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Generator",
"[",
"Tuple",
"[",
"str",
",",
"Any",
"]",
",",
"None",
",",
"None",
"]",
":",
"if",
"\"abi\"",
"in",
"contract_data",
":",... | Build a dictionary of kwargs to be passed into contract factory. | [
"Build",
"a",
"dictionary",
"of",
"kwargs",
"to",
"be",
"passed",
"into",
"contract",
"factory",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/contract.py#L36-L57 |
BrewBlox/brewblox-service | brewblox_service/events.py | post_publish | async def post_publish(request):
"""
---
tags:
- Events
summary: Publish event.
description: Publish a new event message to the event bus.
operationId: events.publish
produces:
- text/plain
parameters:
-
in: body
name: body
description: Event message
... | python | async def post_publish(request):
"""
---
tags:
- Events
summary: Publish event.
description: Publish a new event message to the event bus.
operationId: events.publish
produces:
- text/plain
parameters:
-
in: body
name: body
description: Event message
... | [
"async",
"def",
"post_publish",
"(",
"request",
")",
":",
"args",
"=",
"await",
"request",
".",
"json",
"(",
")",
"try",
":",
"await",
"get_publisher",
"(",
"request",
".",
"app",
")",
".",
"publish",
"(",
"args",
"[",
"'exchange'",
"]",
",",
"args",
... | ---
tags:
- Events
summary: Publish event.
description: Publish a new event message to the event bus.
operationId: events.publish
produces:
- text/plain
parameters:
-
in: body
name: body
description: Event message
required: true
schema:
... | [
"---",
"tags",
":",
"-",
"Events",
"summary",
":",
"Publish",
"event",
".",
"description",
":",
"Publish",
"a",
"new",
"event",
"message",
"to",
"the",
"event",
"bus",
".",
"operationId",
":",
"events",
".",
"publish",
"produces",
":",
"-",
"text",
"/",
... | train | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/events.py#L462-L499 |
BrewBlox/brewblox-service | brewblox_service/events.py | post_subscribe | async def post_subscribe(request):
"""
---
tags:
- Events
summary: Subscribe to events.
operationId: events.subscribe
produces:
- text/plain
parameters:
-
in: body
name: body
description: Event message
required: true
schema:
typ... | python | async def post_subscribe(request):
"""
---
tags:
- Events
summary: Subscribe to events.
operationId: events.subscribe
produces:
- text/plain
parameters:
-
in: body
name: body
description: Event message
required: true
schema:
typ... | [
"async",
"def",
"post_subscribe",
"(",
"request",
")",
":",
"args",
"=",
"await",
"request",
".",
"json",
"(",
")",
"get_listener",
"(",
"request",
".",
"app",
")",
".",
"subscribe",
"(",
"args",
"[",
"'exchange'",
"]",
",",
"args",
"[",
"'routing'",
"... | ---
tags:
- Events
summary: Subscribe to events.
operationId: events.subscribe
produces:
- text/plain
parameters:
-
in: body
name: body
description: Event message
required: true
schema:
type: object
properties:
... | [
"---",
"tags",
":",
"-",
"Events",
"summary",
":",
"Subscribe",
"to",
"events",
".",
"operationId",
":",
"events",
".",
"subscribe",
"produces",
":",
"-",
"text",
"/",
"plain",
"parameters",
":",
"-",
"in",
":",
"body",
"name",
":",
"body",
"description"... | train | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/events.py#L503-L531 |
BrewBlox/brewblox-service | brewblox_service/events.py | EventSubscription._relay | async def _relay(self,
channel: aioamqp.channel.Channel,
body: str,
envelope: aioamqp.envelope.Envelope,
properties: aioamqp.properties.Properties):
"""Relays incoming messages between the queue and the user callback"""
... | python | async def _relay(self,
channel: aioamqp.channel.Channel,
body: str,
envelope: aioamqp.envelope.Envelope,
properties: aioamqp.properties.Properties):
"""Relays incoming messages between the queue and the user callback"""
... | [
"async",
"def",
"_relay",
"(",
"self",
",",
"channel",
":",
"aioamqp",
".",
"channel",
".",
"Channel",
",",
"body",
":",
"str",
",",
"envelope",
":",
"aioamqp",
".",
"envelope",
".",
"Envelope",
",",
"properties",
":",
"aioamqp",
".",
"properties",
".",
... | Relays incoming messages between the queue and the user callback | [
"Relays",
"incoming",
"messages",
"between",
"the",
"queue",
"and",
"the",
"user",
"callback"
] | train | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/events.py#L122-L132 |
BrewBlox/brewblox-service | brewblox_service/events.py | EventListener._lazy_listen | def _lazy_listen(self):
"""
Ensures that the listener task only runs when actually needed.
This function is a no-op if any of the preconditions is not met.
Preconditions are:
* The application is running (self._loop is set)
* The task is not already running
* The... | python | def _lazy_listen(self):
"""
Ensures that the listener task only runs when actually needed.
This function is a no-op if any of the preconditions is not met.
Preconditions are:
* The application is running (self._loop is set)
* The task is not already running
* The... | [
"def",
"_lazy_listen",
"(",
"self",
")",
":",
"if",
"all",
"(",
"[",
"self",
".",
"_loop",
",",
"not",
"self",
".",
"running",
",",
"self",
".",
"_subscriptions",
"or",
"(",
"self",
".",
"_pending",
"and",
"not",
"self",
".",
"_pending",
".",
"empty"... | Ensures that the listener task only runs when actually needed.
This function is a no-op if any of the preconditions is not met.
Preconditions are:
* The application is running (self._loop is set)
* The task is not already running
* There are subscriptions: either pending, or act... | [
"Ensures",
"that",
"the",
"listener",
"task",
"only",
"runs",
"when",
"actually",
"needed",
".",
"This",
"function",
"is",
"a",
"no",
"-",
"op",
"if",
"any",
"of",
"the",
"preconditions",
"is",
"not",
"met",
"."
] | train | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/events.py#L169-L184 |
BrewBlox/brewblox-service | brewblox_service/events.py | EventListener.subscribe | def subscribe(self,
exchange_name: str,
routing: str,
exchange_type: ExchangeType_ = 'topic',
on_message: EVENT_CALLBACK_ = None
) -> EventSubscription:
"""Adds a new event subscription to the listener.
Actual que... | python | def subscribe(self,
exchange_name: str,
routing: str,
exchange_type: ExchangeType_ = 'topic',
on_message: EVENT_CALLBACK_ = None
) -> EventSubscription:
"""Adds a new event subscription to the listener.
Actual que... | [
"def",
"subscribe",
"(",
"self",
",",
"exchange_name",
":",
"str",
",",
"routing",
":",
"str",
",",
"exchange_type",
":",
"ExchangeType_",
"=",
"'topic'",
",",
"on_message",
":",
"EVENT_CALLBACK_",
"=",
"None",
")",
"->",
"EventSubscription",
":",
"sub",
"="... | Adds a new event subscription to the listener.
Actual queue declaration to the remote message server is done when connected.
If the listener is not currently connected, it defers declaration.
All existing subscriptions are redeclared on the remote if `EventListener`
loses and recreates... | [
"Adds",
"a",
"new",
"event",
"subscription",
"to",
"the",
"listener",
"."
] | train | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/events.py#L275-L324 |
BrewBlox/brewblox-service | brewblox_service/events.py | EventPublisher.publish | async def publish(self,
exchange: str,
routing: str,
message: Union[str, dict],
exchange_type: ExchangeType_ = 'topic'):
"""
Publish a new event message.
Connections are created automatically when calling `p... | python | async def publish(self,
exchange: str,
routing: str,
message: Union[str, dict],
exchange_type: ExchangeType_ = 'topic'):
"""
Publish a new event message.
Connections are created automatically when calling `p... | [
"async",
"def",
"publish",
"(",
"self",
",",
"exchange",
":",
"str",
",",
"routing",
":",
"str",
",",
"message",
":",
"Union",
"[",
"str",
",",
"dict",
"]",
",",
"exchange_type",
":",
"ExchangeType_",
"=",
"'topic'",
")",
":",
"try",
":",
"await",
"s... | Publish a new event message.
Connections are created automatically when calling `publish()`,
and will attempt to reconnect if connection was lost.
For more information on publishing AMQP messages,
see https://www.rabbitmq.com/tutorials/tutorial-three-python.html
Args:
... | [
"Publish",
"a",
"new",
"event",
"message",
"."
] | train | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/events.py#L396-L454 |
ethpm/py-ethpm | ethpm/utils/registry.py | is_ens_domain | def is_ens_domain(authority: str) -> bool:
"""
Return false if authority is not a valid ENS domain.
"""
# check that authority ends with the tld '.eth'
# check that there are either 2 or 3 subdomains in the authority
# i.e. zeppelinos.eth or packages.zeppelinos.eth
if authority[-4:] != ".eth... | python | def is_ens_domain(authority: str) -> bool:
"""
Return false if authority is not a valid ENS domain.
"""
# check that authority ends with the tld '.eth'
# check that there are either 2 or 3 subdomains in the authority
# i.e. zeppelinos.eth or packages.zeppelinos.eth
if authority[-4:] != ".eth... | [
"def",
"is_ens_domain",
"(",
"authority",
":",
"str",
")",
"->",
"bool",
":",
"# check that authority ends with the tld '.eth'",
"# check that there are either 2 or 3 subdomains in the authority",
"# i.e. zeppelinos.eth or packages.zeppelinos.eth",
"if",
"authority",
"[",
"-",
"4",... | Return false if authority is not a valid ENS domain. | [
"Return",
"false",
"if",
"authority",
"is",
"not",
"a",
"valid",
"ENS",
"domain",
"."
] | train | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/registry.py#L5-L14 |
heroku/sf-suds | suds/sax/__init__.py | splitPrefix | def splitPrefix(name):
"""
Split the name into a tuple (I{prefix}, I{name}). The first element in
the tuple is I{None} when the name does't have a prefix.
@param name: A node name containing an optional prefix.
@type name: basestring
@return: A tuple containing the (2) parts of I{name}
@rty... | python | def splitPrefix(name):
"""
Split the name into a tuple (I{prefix}, I{name}). The first element in
the tuple is I{None} when the name does't have a prefix.
@param name: A node name containing an optional prefix.
@type name: basestring
@return: A tuple containing the (2) parts of I{name}
@rty... | [
"def",
"splitPrefix",
"(",
"name",
")",
":",
"if",
"isinstance",
"(",
"name",
",",
"basestring",
")",
"and",
"':'",
"in",
"name",
":",
"return",
"tuple",
"(",
"name",
".",
"split",
"(",
"':'",
",",
"1",
")",
")",
"else",
":",
"return",
"(",
"None",... | Split the name into a tuple (I{prefix}, I{name}). The first element in
the tuple is I{None} when the name does't have a prefix.
@param name: A node name containing an optional prefix.
@type name: basestring
@return: A tuple containing the (2) parts of I{name}
@rtype: (I{prefix}, I{name}) | [
"Split",
"the",
"name",
"into",
"a",
"tuple",
"(",
"I",
"{",
"prefix",
"}",
"I",
"{",
"name",
"}",
")",
".",
"The",
"first",
"element",
"in",
"the",
"tuple",
"is",
"I",
"{",
"None",
"}",
"when",
"the",
"name",
"does",
"t",
"have",
"a",
"prefix",
... | train | https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/sax/__init__.py#L40-L53 |
heroku/sf-suds | suds/sudsobject.py | Printer.unwrap | def unwrap(self, d, item):
""" translate (unwrap) using an optional wrapper function """
nopt = ( lambda x: x )
try:
md = d.__metadata__
pmd = getattr(md, '__print__', None)
if pmd is None:
return item
wrappers = getattr(pmd, 'wrapp... | python | def unwrap(self, d, item):
""" translate (unwrap) using an optional wrapper function """
nopt = ( lambda x: x )
try:
md = d.__metadata__
pmd = getattr(md, '__print__', None)
if pmd is None:
return item
wrappers = getattr(pmd, 'wrapp... | [
"def",
"unwrap",
"(",
"self",
",",
"d",
",",
"item",
")",
":",
"nopt",
"=",
"(",
"lambda",
"x",
":",
"x",
")",
"try",
":",
"md",
"=",
"d",
".",
"__metadata__",
"pmd",
"=",
"getattr",
"(",
"md",
",",
"'__print__'",
",",
"None",
")",
"if",
"pmd",... | translate (unwrap) using an optional wrapper function | [
"translate",
"(",
"unwrap",
")",
"using",
"an",
"optional",
"wrapper",
"function"
] | train | https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/sudsobject.py#L364-L377 |
heroku/sf-suds | suds/sudsobject.py | Printer.exclude | def exclude(self, d, item):
""" check metadata for excluded items """
try:
md = d.__metadata__
pmd = getattr(md, '__print__', None)
if pmd is None:
return False
excludes = getattr(pmd, 'excludes', [])
return ( item[0] in exclude... | python | def exclude(self, d, item):
""" check metadata for excluded items """
try:
md = d.__metadata__
pmd = getattr(md, '__print__', None)
if pmd is None:
return False
excludes = getattr(pmd, 'excludes', [])
return ( item[0] in exclude... | [
"def",
"exclude",
"(",
"self",
",",
"d",
",",
"item",
")",
":",
"try",
":",
"md",
"=",
"d",
".",
"__metadata__",
"pmd",
"=",
"getattr",
"(",
"md",
",",
"'__print__'",
",",
"None",
")",
"if",
"pmd",
"is",
"None",
":",
"return",
"False",
"excludes",
... | check metadata for excluded items | [
"check",
"metadata",
"for",
"excluded",
"items"
] | train | https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/sudsobject.py#L379-L390 |
heroku/sf-suds | suds/reader.py | Reader.mangle | def mangle(self, name, x):
"""
Mangle the name by hashing the I{name} and appending I{x}.
@return: the mangled name.
"""
h = abs(hash(name))
return '%s-%s' % (h, x) | python | def mangle(self, name, x):
"""
Mangle the name by hashing the I{name} and appending I{x}.
@return: the mangled name.
"""
h = abs(hash(name))
return '%s-%s' % (h, x) | [
"def",
"mangle",
"(",
"self",
",",
"name",
",",
"x",
")",
":",
"h",
"=",
"abs",
"(",
"hash",
"(",
"name",
")",
")",
"return",
"'%s-%s'",
"%",
"(",
"h",
",",
"x",
")"
] | Mangle the name by hashing the I{name} and appending I{x}.
@return: the mangled name. | [
"Mangle",
"the",
"name",
"by",
"hashing",
"the",
"I",
"{",
"name",
"}",
"and",
"appending",
"I",
"{",
"x",
"}",
"."
] | train | https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/reader.py#L48-L54 |
heroku/sf-suds | suds/resolver.py | Resolver.find | def find(self, name, resolved=True):
"""
Get the definition object for the schema object by name.
@param name: The name of a schema object.
@type name: basestring
@param resolved: A flag indicating that the fully resolved type
should be returned.
@type resolve... | python | def find(self, name, resolved=True):
"""
Get the definition object for the schema object by name.
@param name: The name of a schema object.
@type name: basestring
@param resolved: A flag indicating that the fully resolved type
should be returned.
@type resolve... | [
"def",
"find",
"(",
"self",
",",
"name",
",",
"resolved",
"=",
"True",
")",
":",
"#log.debug('searching schema for (%s)', name)",
"qref",
"=",
"qualify",
"(",
"name",
",",
"self",
".",
"schema",
".",
"root",
",",
"self",
".",
"schema",
".",
"tns",
")",
"... | Get the definition object for the schema object by name.
@param name: The name of a schema object.
@type name: basestring
@param resolved: A flag indicating that the fully resolved type
should be returned.
@type resolved: boolean
@return: The found schema I{type}
... | [
"Get",
"the",
"definition",
"object",
"for",
"the",
"schema",
"object",
"by",
"name",
"."
] | train | https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/resolver.py#L47-L68 |
heroku/sf-suds | suds/resolver.py | TreeResolver.push | def push(self, x):
"""
Push an I{object} onto the stack.
@param x: An object to push.
@type x: L{Frame}
@return: The pushed frame.
@rtype: L{Frame}
"""
if isinstance(x, Frame):
frame = x
else:
frame = Frame(x)
self.s... | python | def push(self, x):
"""
Push an I{object} onto the stack.
@param x: An object to push.
@type x: L{Frame}
@return: The pushed frame.
@rtype: L{Frame}
"""
if isinstance(x, Frame):
frame = x
else:
frame = Frame(x)
self.s... | [
"def",
"push",
"(",
"self",
",",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"Frame",
")",
":",
"frame",
"=",
"x",
"else",
":",
"frame",
"=",
"Frame",
"(",
"x",
")",
"self",
".",
"stack",
".",
"append",
"(",
"frame",
")",
"#log.debug('push:... | Push an I{object} onto the stack.
@param x: An object to push.
@type x: L{Frame}
@return: The pushed frame.
@rtype: L{Frame} | [
"Push",
"an",
"I",
"{",
"object",
"}",
"onto",
"the",
"stack",
"."
] | train | https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/resolver.py#L247-L261 |
heroku/sf-suds | suds/resolver.py | TreeResolver.pop | def pop(self):
"""
Pop the frame at the top of the stack.
@return: The popped frame, else None.
@rtype: L{Frame}
"""
if len(self.stack):
popped = self.stack.pop()
#log.debug('pop: (%s)\n%s', Repr(popped), Repr(self.stack))
return ... | python | def pop(self):
"""
Pop the frame at the top of the stack.
@return: The popped frame, else None.
@rtype: L{Frame}
"""
if len(self.stack):
popped = self.stack.pop()
#log.debug('pop: (%s)\n%s', Repr(popped), Repr(self.stack))
return ... | [
"def",
"pop",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"stack",
")",
":",
"popped",
"=",
"self",
".",
"stack",
".",
"pop",
"(",
")",
"#log.debug('pop: (%s)\\n%s', Repr(popped), Repr(self.stack))",
"return",
"popped",
"else",
":",
"#log.debug('stac... | Pop the frame at the top of the stack.
@return: The popped frame, else None.
@rtype: L{Frame} | [
"Pop",
"the",
"frame",
"at",
"the",
"top",
"of",
"the",
"stack",
"."
] | train | https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/resolver.py#L274-L287 |
heroku/sf-suds | suds/resolver.py | TreeResolver.getchild | def getchild(self, name, parent):
""" get a child by name """
#log.debug('searching parent (%s) for (%s)', Repr(parent), name)
if name.startswith('@'):
return parent.get_attribute(name[1:])
else:
return parent.get_child(name) | python | def getchild(self, name, parent):
""" get a child by name """
#log.debug('searching parent (%s) for (%s)', Repr(parent), name)
if name.startswith('@'):
return parent.get_attribute(name[1:])
else:
return parent.get_child(name) | [
"def",
"getchild",
"(",
"self",
",",
"name",
",",
"parent",
")",
":",
"#log.debug('searching parent (%s) for (%s)', Repr(parent), name)",
"if",
"name",
".",
"startswith",
"(",
"'@'",
")",
":",
"return",
"parent",
".",
"get_attribute",
"(",
"name",
"[",
"1",
":",... | get a child by name | [
"get",
"a",
"child",
"by",
"name"
] | train | https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/resolver.py#L297-L303 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.