repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
spacetelescope/drizzlepac | drizzlepac/tweakutils.py | gauss | def gauss(x, sigma):
""" Compute 1-D value of gaussian at position x relative to center."""
return (np.exp(-np.power(x, 2) / (2 * np.power(sigma, 2))) /
(sigma * np.sqrt(2 * np.pi))) | python | def gauss(x, sigma):
""" Compute 1-D value of gaussian at position x relative to center."""
return (np.exp(-np.power(x, 2) / (2 * np.power(sigma, 2))) /
(sigma * np.sqrt(2 * np.pi))) | [
"def",
"gauss",
"(",
"x",
",",
"sigma",
")",
":",
"return",
"(",
"np",
".",
"exp",
"(",
"-",
"np",
".",
"power",
"(",
"x",
",",
"2",
")",
"/",
"(",
"2",
"*",
"np",
".",
"power",
"(",
"sigma",
",",
"2",
")",
")",
")",
"/",
"(",
"sigma",
... | Compute 1-D value of gaussian at position x relative to center. | [
"Compute",
"1",
"-",
"D",
"value",
"of",
"gaussian",
"at",
"position",
"x",
"relative",
"to",
"center",
"."
] | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/tweakutils.py#L721-L724 | train |
spacetelescope/drizzlepac | drizzlepac/tweakutils.py | find_xy_peak | def find_xy_peak(img, center=None, sigma=3.0):
""" Find the center of the peak of offsets """
# find level of noise in histogram
istats = imagestats.ImageStats(img.astype(np.float32), nclip=1,
fields='stddev,mode,mean,max,min')
if istats.stddev == 0.0:
istats =... | python | def find_xy_peak(img, center=None, sigma=3.0):
""" Find the center of the peak of offsets """
# find level of noise in histogram
istats = imagestats.ImageStats(img.astype(np.float32), nclip=1,
fields='stddev,mode,mean,max,min')
if istats.stddev == 0.0:
istats =... | [
"def",
"find_xy_peak",
"(",
"img",
",",
"center",
"=",
"None",
",",
"sigma",
"=",
"3.0",
")",
":",
"istats",
"=",
"imagestats",
".",
"ImageStats",
"(",
"img",
".",
"astype",
"(",
"np",
".",
"float32",
")",
",",
"nclip",
"=",
"1",
",",
"fields",
"="... | Find the center of the peak of offsets | [
"Find",
"the",
"center",
"of",
"the",
"peak",
"of",
"offsets"
] | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/tweakutils.py#L1000-L1054 | train |
spacetelescope/drizzlepac | drizzlepac/tweakutils.py | plot_zeropoint | def plot_zeropoint(pars):
""" Plot 2d histogram.
Pars will be a dictionary containing:
data, figure_id, vmax, title_str, xp,yp, searchrad
"""
from matplotlib import pyplot as plt
xp = pars['xp']
yp = pars['yp']
searchrad = int(pars['searchrad'] + 0.5)
plt.figure(num=pars['figu... | python | def plot_zeropoint(pars):
""" Plot 2d histogram.
Pars will be a dictionary containing:
data, figure_id, vmax, title_str, xp,yp, searchrad
"""
from matplotlib import pyplot as plt
xp = pars['xp']
yp = pars['yp']
searchrad = int(pars['searchrad'] + 0.5)
plt.figure(num=pars['figu... | [
"def",
"plot_zeropoint",
"(",
"pars",
")",
":",
"from",
"matplotlib",
"import",
"pyplot",
"as",
"plt",
"xp",
"=",
"pars",
"[",
"'xp'",
"]",
"yp",
"=",
"pars",
"[",
"'yp'",
"]",
"searchrad",
"=",
"int",
"(",
"pars",
"[",
"'searchrad'",
"]",
"+",
"0.5"... | Plot 2d histogram.
Pars will be a dictionary containing:
data, figure_id, vmax, title_str, xp,yp, searchrad | [
"Plot",
"2d",
"histogram",
"."
] | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/tweakutils.py#L1057-L1101 | train |
spacetelescope/drizzlepac | drizzlepac/tweakutils.py | build_xy_zeropoint | def build_xy_zeropoint(imgxy, refxy, searchrad=3.0, histplot=False,
figure_id=1, plotname=None, interactive=True):
""" Create a matrix which contains the delta between each XY position and
each UV position.
"""
print('Computing initial guess for X and Y shifts...')
# run ... | python | def build_xy_zeropoint(imgxy, refxy, searchrad=3.0, histplot=False,
figure_id=1, plotname=None, interactive=True):
""" Create a matrix which contains the delta between each XY position and
each UV position.
"""
print('Computing initial guess for X and Y shifts...')
# run ... | [
"def",
"build_xy_zeropoint",
"(",
"imgxy",
",",
"refxy",
",",
"searchrad",
"=",
"3.0",
",",
"histplot",
"=",
"False",
",",
"figure_id",
"=",
"1",
",",
"plotname",
"=",
"None",
",",
"interactive",
"=",
"True",
")",
":",
"print",
"(",
"'Computing initial gue... | Create a matrix which contains the delta between each XY position and
each UV position. | [
"Create",
"a",
"matrix",
"which",
"contains",
"the",
"delta",
"between",
"each",
"XY",
"position",
"and",
"each",
"UV",
"position",
"."
] | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/tweakutils.py#L1105-L1154 | train |
spacetelescope/drizzlepac | drizzlepac/tweakutils.py | build_pos_grid | def build_pos_grid(start, end, nstep, mesh=False):
"""
Return a grid of positions starting at X,Y given by 'start', and ending
at X,Y given by 'end'. The grid will be completely filled in X and Y by
every 'step' interval.
"""
# Build X and Y arrays
dx = end[0] - start[0]
if dx < 0:
... | python | def build_pos_grid(start, end, nstep, mesh=False):
"""
Return a grid of positions starting at X,Y given by 'start', and ending
at X,Y given by 'end'. The grid will be completely filled in X and Y by
every 'step' interval.
"""
# Build X and Y arrays
dx = end[0] - start[0]
if dx < 0:
... | [
"def",
"build_pos_grid",
"(",
"start",
",",
"end",
",",
"nstep",
",",
"mesh",
"=",
"False",
")",
":",
"dx",
"=",
"end",
"[",
"0",
"]",
"-",
"start",
"[",
"0",
"]",
"if",
"dx",
"<",
"0",
":",
"nstart",
"=",
"end",
"end",
"=",
"start",
"start",
... | Return a grid of positions starting at X,Y given by 'start', and ending
at X,Y given by 'end'. The grid will be completely filled in X and Y by
every 'step' interval. | [
"Return",
"a",
"grid",
"of",
"positions",
"starting",
"at",
"X",
"Y",
"given",
"by",
"start",
"and",
"ending",
"at",
"X",
"Y",
"given",
"by",
"end",
".",
"The",
"grid",
"will",
"be",
"completely",
"filled",
"in",
"X",
"and",
"Y",
"by",
"every",
"step... | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/tweakutils.py#L1158-L1182 | train |
spacetelescope/drizzlepac | drizzlepac/wfpc2Data.py | WFPC2InputImage.doUnitConversions | def doUnitConversions(self):
""" Apply unit conversions to all the chips, ignoring the group parameter.
This insures that all the chips get the same conversions when this
gets done, even if only 1 chip was specified to be processed.
"""
# Image information
_handl... | python | def doUnitConversions(self):
""" Apply unit conversions to all the chips, ignoring the group parameter.
This insures that all the chips get the same conversions when this
gets done, even if only 1 chip was specified to be processed.
"""
# Image information
_handl... | [
"def",
"doUnitConversions",
"(",
"self",
")",
":",
"_handle",
"=",
"fileutil",
".",
"openImage",
"(",
"self",
".",
"_filename",
",",
"mode",
"=",
"'readonly'",
",",
"memmap",
"=",
"False",
")",
"for",
"det",
"in",
"range",
"(",
"1",
",",
"self",
".",
... | Apply unit conversions to all the chips, ignoring the group parameter.
This insures that all the chips get the same conversions when this
gets done, even if only 1 chip was specified to be processed. | [
"Apply",
"unit",
"conversions",
"to",
"all",
"the",
"chips",
"ignoring",
"the",
"group",
"parameter",
".",
"This",
"insures",
"that",
"all",
"the",
"chips",
"get",
"the",
"same",
"conversions",
"when",
"this",
"gets",
"done",
"even",
"if",
"only",
"1",
"ch... | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/wfpc2Data.py#L182-L227 | train |
spacetelescope/drizzlepac | drizzlepac/wfpc2Data.py | WFPC2InputImage.getdarkcurrent | def getdarkcurrent(self,exten):
"""
Return the dark current for the WFPC2 detector. This value
will be contained within an instrument specific keyword.
The value in the image header will be converted to units
of electrons.
Returns
-------
darkcurrent : f... | python | def getdarkcurrent(self,exten):
"""
Return the dark current for the WFPC2 detector. This value
will be contained within an instrument specific keyword.
The value in the image header will be converted to units
of electrons.
Returns
-------
darkcurrent : f... | [
"def",
"getdarkcurrent",
"(",
"self",
",",
"exten",
")",
":",
"darkrate",
"=",
"0.005",
"if",
"self",
".",
"proc_unit",
"==",
"'native'",
":",
"darkrate",
"=",
"darkrate",
"/",
"self",
".",
"getGain",
"(",
"exten",
")",
"try",
":",
"chip",
"=",
"self",... | Return the dark current for the WFPC2 detector. This value
will be contained within an instrument specific keyword.
The value in the image header will be converted to units
of electrons.
Returns
-------
darkcurrent : float
Dark current for the WFPC3 detector... | [
"Return",
"the",
"dark",
"current",
"for",
"the",
"WFPC2",
"detector",
".",
"This",
"value",
"will",
"be",
"contained",
"within",
"an",
"instrument",
"specific",
"keyword",
".",
"The",
"value",
"in",
"the",
"image",
"header",
"will",
"be",
"converted",
"to",... | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/wfpc2Data.py#L229-L264 | train |
spacetelescope/drizzlepac | drizzlepac/catalogs.py | generateCatalog | def generateCatalog(wcs, mode='automatic', catalog=None,
src_find_filters=None, **kwargs):
""" Function which determines what type of catalog object needs to be
instantiated based on what type of source selection algorithm the user
specified.
Parameters
----------
wcs : obj
... | python | def generateCatalog(wcs, mode='automatic', catalog=None,
src_find_filters=None, **kwargs):
""" Function which determines what type of catalog object needs to be
instantiated based on what type of source selection algorithm the user
specified.
Parameters
----------
wcs : obj
... | [
"def",
"generateCatalog",
"(",
"wcs",
",",
"mode",
"=",
"'automatic'",
",",
"catalog",
"=",
"None",
",",
"src_find_filters",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"catalog",
",",
"Catalog",
")",
":",
"if",
"mode",
... | Function which determines what type of catalog object needs to be
instantiated based on what type of source selection algorithm the user
specified.
Parameters
----------
wcs : obj
WCS object generated by STWCS or PyWCS
catalog : str or ndarray
Filename of existing catalog or nd... | [
"Function",
"which",
"determines",
"what",
"type",
"of",
"catalog",
"object",
"needs",
"to",
"be",
"instantiated",
"based",
"on",
"what",
"type",
"of",
"source",
"selection",
"algorithm",
"the",
"user",
"specified",
"."
] | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/catalogs.py#L43-L76 | train |
spacetelescope/drizzlepac | drizzlepac/catalogs.py | Catalog.generateRaDec | def generateRaDec(self):
""" Convert XY positions into sky coordinates using STWCS methods. """
self.prefix = self.PAR_PREFIX
if not isinstance(self.wcs,pywcs.WCS):
print(
textutil.textbox(
'WCS not a valid PyWCS object. '
'Con... | python | def generateRaDec(self):
""" Convert XY positions into sky coordinates using STWCS methods. """
self.prefix = self.PAR_PREFIX
if not isinstance(self.wcs,pywcs.WCS):
print(
textutil.textbox(
'WCS not a valid PyWCS object. '
'Con... | [
"def",
"generateRaDec",
"(",
"self",
")",
":",
"self",
".",
"prefix",
"=",
"self",
".",
"PAR_PREFIX",
"if",
"not",
"isinstance",
"(",
"self",
".",
"wcs",
",",
"pywcs",
".",
"WCS",
")",
":",
"print",
"(",
"textutil",
".",
"textbox",
"(",
"'WCS not a val... | Convert XY positions into sky coordinates using STWCS methods. | [
"Convert",
"XY",
"positions",
"into",
"sky",
"coordinates",
"using",
"STWCS",
"methods",
"."
] | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/catalogs.py#L162-L197 | train |
spacetelescope/drizzlepac | drizzlepac/catalogs.py | Catalog.apply_exclusions | def apply_exclusions(self,exclusions):
""" Trim sky catalog to remove any sources within regions specified by
exclusions file.
"""
# parse exclusion file into list of positions and distances
exclusion_coords = tweakutils.parse_exclusions(exclusions)
if exclusion_coord... | python | def apply_exclusions(self,exclusions):
""" Trim sky catalog to remove any sources within regions specified by
exclusions file.
"""
# parse exclusion file into list of positions and distances
exclusion_coords = tweakutils.parse_exclusions(exclusions)
if exclusion_coord... | [
"def",
"apply_exclusions",
"(",
"self",
",",
"exclusions",
")",
":",
"exclusion_coords",
"=",
"tweakutils",
".",
"parse_exclusions",
"(",
"exclusions",
")",
"if",
"exclusion_coords",
"is",
"None",
":",
"return",
"excluded_list",
"=",
"[",
"]",
"radec_indx",
"=",... | Trim sky catalog to remove any sources within regions specified by
exclusions file. | [
"Trim",
"sky",
"catalog",
"to",
"remove",
"any",
"sources",
"within",
"regions",
"specified",
"by",
"exclusions",
"file",
"."
] | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/catalogs.py#L199-L241 | train |
spacetelescope/drizzlepac | drizzlepac/catalogs.py | Catalog.buildCatalogs | def buildCatalogs(self, exclusions=None, **kwargs):
""" Primary interface to build catalogs based on user inputs.
"""
self.generateXY(**kwargs)
self.generateRaDec()
if exclusions:
self.apply_exclusions(exclusions)
# apply selection limits as specified by the ... | python | def buildCatalogs(self, exclusions=None, **kwargs):
""" Primary interface to build catalogs based on user inputs.
"""
self.generateXY(**kwargs)
self.generateRaDec()
if exclusions:
self.apply_exclusions(exclusions)
# apply selection limits as specified by the ... | [
"def",
"buildCatalogs",
"(",
"self",
",",
"exclusions",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"generateXY",
"(",
"**",
"kwargs",
")",
"self",
".",
"generateRaDec",
"(",
")",
"if",
"exclusions",
":",
"self",
".",
"apply_exclusions",
"("... | Primary interface to build catalogs based on user inputs. | [
"Primary",
"interface",
"to",
"build",
"catalogs",
"based",
"on",
"user",
"inputs",
"."
] | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/catalogs.py#L339-L348 | train |
spacetelescope/drizzlepac | drizzlepac/catalogs.py | Catalog.plotXYCatalog | def plotXYCatalog(self, **kwargs):
"""
Method which displays the original image and overlays the positions
of the detected sources from this image's catalog.
Plotting `kwargs` that can be provided are:
vmin, vmax, cmap, marker
Default colormap is `summer`.
... | python | def plotXYCatalog(self, **kwargs):
"""
Method which displays the original image and overlays the positions
of the detected sources from this image's catalog.
Plotting `kwargs` that can be provided are:
vmin, vmax, cmap, marker
Default colormap is `summer`.
... | [
"def",
"plotXYCatalog",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"try",
":",
"from",
"matplotlib",
"import",
"pyplot",
"as",
"pl",
"except",
":",
"pl",
"=",
"None",
"if",
"pl",
"is",
"not",
"None",
":",
"pl",
".",
"clf",
"(",
")",
"pars",
"=",
... | Method which displays the original image and overlays the positions
of the detected sources from this image's catalog.
Plotting `kwargs` that can be provided are:
vmin, vmax, cmap, marker
Default colormap is `summer`. | [
"Method",
"which",
"displays",
"the",
"original",
"image",
"and",
"overlays",
"the",
"positions",
"of",
"the",
"detected",
"sources",
"from",
"this",
"image",
"s",
"catalog",
"."
] | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/catalogs.py#L350-L389 | train |
spacetelescope/drizzlepac | drizzlepac/catalogs.py | Catalog.writeXYCatalog | def writeXYCatalog(self,filename):
""" Write out the X,Y catalog to a file
"""
if self.xypos is None:
warnstr = textutil.textbox(
'WARNING: \n No X,Y source catalog to write to file. ')
for line in warnstr.split('\n'):
log.warning(line)
... | python | def writeXYCatalog(self,filename):
""" Write out the X,Y catalog to a file
"""
if self.xypos is None:
warnstr = textutil.textbox(
'WARNING: \n No X,Y source catalog to write to file. ')
for line in warnstr.split('\n'):
log.warning(line)
... | [
"def",
"writeXYCatalog",
"(",
"self",
",",
"filename",
")",
":",
"if",
"self",
".",
"xypos",
"is",
"None",
":",
"warnstr",
"=",
"textutil",
".",
"textbox",
"(",
"'WARNING: \\n No X,Y source catalog to write to file. '",
")",
"for",
"line",
"in",
"warnstr",
".... | Write out the X,Y catalog to a file | [
"Write",
"out",
"the",
"X",
"Y",
"catalog",
"to",
"a",
"file"
] | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/catalogs.py#L391-L416 | train |
spacetelescope/drizzlepac | drizzlepac/catalogs.py | UserCatalog.generateXY | def generateXY(self, **kwargs):
"""
Method to interpret input catalog file as columns of positions and fluxes.
"""
self.num_objects = 0
xycols = self._readCatalog()
if xycols is not None:
# convert the catalog into attribute
self.xypos = xycols[:3... | python | def generateXY(self, **kwargs):
"""
Method to interpret input catalog file as columns of positions and fluxes.
"""
self.num_objects = 0
xycols = self._readCatalog()
if xycols is not None:
# convert the catalog into attribute
self.xypos = xycols[:3... | [
"def",
"generateXY",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"num_objects",
"=",
"0",
"xycols",
"=",
"self",
".",
"_readCatalog",
"(",
")",
"if",
"xycols",
"is",
"not",
"None",
":",
"self",
".",
"xypos",
"=",
"xycols",
"[",
":",
"3... | Method to interpret input catalog file as columns of positions and fluxes. | [
"Method",
"to",
"interpret",
"input",
"catalog",
"file",
"as",
"columns",
"of",
"positions",
"and",
"fluxes",
"."
] | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/catalogs.py#L694-L730 | train |
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",... | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/ablot.py#L329-L419 | train |
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",
")",
":",
"_indx",
"=",
"asnfile",
".",
"find",
"(",
"'_asn.fits'",
")",
"_new_asn",
"=",
"asnfile",
"[",
":",
"_indx",
"]",
"+",
"'_pipeline'",
"+",
"asnfile",
"[",
"_indx",
":",
"]",
"if",
"os",
".",
"path",
".",... | 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",
"."
] | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/runastrodriz.py#L520-L538 | train |
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",
"ftrl",
"=",
"open",
"(",
"trlfile",
",",
"'a'",
")",
"fdriz",
"=",
"open",
"(",
"drizfile",
")",
... | Append drizfile to already existing trlfile from CALXXX. | [
"Append",
"drizfile",
"to",
"already",
"existing",
"trlfile",
"from",
"CALXXX",
"."
] | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/runastrodriz.py#L540-L561 | train |
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",
"."
] | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/runastrodriz.py#L564-L568 | train |
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",
")",
":",
"rootname",
"=",
"input",
"[",
":",
"input",
".",
"find",
"(",
"'_'",
")",
"]",
"newdir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"rootdir",
",",
"rootname",
")",
"if",
"not",
"o... | 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"
] | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/runastrodriz.py#L578-L587 | train |
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",
"."
] | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/runastrodriz.py#L589-L607 | train |
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",
":",
"raise... | Create a median image from the seperately drizzled images. | [
"Create",
"a",
"median",
"image",
"from",
"the",
"seperately",
"drizzled",
"images",
"."
] | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/createMedian.py#L37-L52 | train |
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",
"."
] | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/createMedian.py#L67-L102 | train |
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",
"."
] | 15bec3c929a6a869d9e71b9398ced43ede0620f1 | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/createMedian.py#L454-L472 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/backends/registry.py#L35-L43 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/backends/ipfs.py#L158-L170 | train |
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",
"."
] | f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/scheduler.py#L121-L130 | train |
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",
"."
] | f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/scheduler.py#L132-L151 | train |
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",
"."
] | f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/scheduler.py#L153-L180 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/uri.py#L112-L119 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/package.py#L70-L83 | train |
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... | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/package.py#L142-L157 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/package.py#L182-L224 | train |
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",
... | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/package.py#L226-L248 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/package.py#L255-L281 | train |
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... | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/package.py#L288-L328 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/ipfs.py#L12-L21 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/ipfs.py#L28-L41 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/ipfs.py#L44-L54 | train |
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",
")",
"contract_type",
"=",
"self",
".",
"deployment_data",
"[",
"contract_name",
"]",
"[",
"\"contra... | Fetches a contract instance belonging to deployment
after validating contract name. | [
"Fetches",
"a",
"contract",
"instance",
"belonging",
"to",
"deployment",
"after",
"validating",
"contract",
"name",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/deployments.py#L45-L61 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/validation.py#L15-L25 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/validation.py#L52-L58 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/validation.py#L101-L116 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/validation.py#L119-L125 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/validation.py#L136-L142 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/manifest_validation.py#L21-L42 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/manifest_validation.py#L59-L71 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/manifest_validation.py#L88-L102 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L32-L37 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L134-L142 | train |
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",
... | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L298-L329 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L364-L379 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L382-L400 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L407-L432 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L462-L479 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L532-L550 | train |
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",
"... | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L553-L580 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L652-L676 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/tools/builder.py#L776-L790 | train |
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",
"."
] | f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/service.py#L68-L106 | train |
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",
"."
] | f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/service.py#L109-L147 | train |
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",
"."
] | f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/service.py#L150-L189 | train |
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'",
"]",
"web",
".",
"run_app",
"(",
"app",
",",
"host",
"=",
... | 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",
"."
] | f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/service.py#L192-L205 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/deployments.py#L10-L28 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/contract.py#L125-L139 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/contract.py#L143-L158 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/contract.py#L82-L108 | train |
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\"",
"]",
",",
"...",
"]",
":",
"item_dict",
"=",
"{",
"name",
":",
"self",
".",
"build_dependencies",
".",
"get",
"(",
"name",
")",
"for",
"name",
"in",
"sel... | 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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/dependencies.py#L28-L36 | train |
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\"",
"]",
":",
"values",
"=",
"[",
"self",
".",
"build_dependencies",
".",
"get",
"(",
"name",
")",
"for",
"name",
"in",
"self",
".",
"build_dependencies",
"]",
"return",
"values"
] | Return an iterable of the available `Package` instances. | [
"Return",
"an",
"iterable",
"of",
"the",
"available",
"Package",
"instances",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/dependencies.py#L38-L43 | train |
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\"",
":",
"self",
".",
"_validate_name",
"(",
"package_name",
")",
"return",
"self",
".",
"build_dependencies",
".",
"get",
"(",
"package_name",
")"
] | Return the dependency Package for a given package name. | [
"Return",
"the",
"dependency",
"Package",
"for",
"a",
"given",
"package",
"name",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/dependencies.py#L45-L52 | train |
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",
"."
] | f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/features.py#L14-L53 | train |
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",
"."
] | f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/features.py#L56-L92 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/contract.py#L10-L19 | train |
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",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/contract.py#L36-L57 | train |
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"
] | f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/events.py#L122-L132 | train |
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",
"."
] | f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/events.py#L169-L184 | train |
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",
"."
] | f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/events.py#L275-L324 | train |
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",
"."
] | f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb | https://github.com/BrewBlox/brewblox-service/blob/f2572fcb5ea337c24aa5a28c2b0b19ebcfc076eb/brewblox_service/events.py#L396-L454 | train |
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",
":",
"if",
"authority",
"[",
"-",
"4",
":",
"]",
"!=",
"\".eth\"",
"or",
"len",
"(",
"authority",
".",
"split",
"(",
"\".\"",
")",
")",
"not",
"in",
"[",
"2",
",",
"3",
"]",... | Return false if authority is not a valid ENS domain. | [
"Return",
"false",
"if",
"authority",
"is",
"not",
"a",
"valid",
"ENS",
"domain",
"."
] | 81ed58d7c636fe00c6770edeb0401812b1a5e8fc | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/registry.py#L5-L14 | train |
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"
] | 44b6743a45ff4447157605d6fecc9bf5922ce68a | https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/sudsobject.py#L379-L390 | train |
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",
")",
":",
"qref",
"=",
"qualify",
"(",
"name",
",",
"self",
".",
"schema",
".",
"root",
",",
"self",
".",
"schema",
".",
"tns",
")",
"query",
"=",
"BlindQuery",
"(",
"qref",
"... | 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",
"."
] | 44b6743a45ff4447157605d6fecc9bf5922ce68a | https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/resolver.py#L47-L68 | train |
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",
")",
":",
"if",
"name",
".",
"startswith",
"(",
"'@'",
")",
":",
"return",
"parent",
".",
"get_attribute",
"(",
"name",
"[",
"1",
":",
"]",
")",
"else",
":",
"return",
"parent",
".",
"get_... | get a child by name | [
"get",
"a",
"child",
"by",
"name"
] | 44b6743a45ff4447157605d6fecc9bf5922ce68a | https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/resolver.py#L297-L303 | train |
heroku/sf-suds | suds/store.py | DocumentStore.find | def find(self, location):
"""
Find the specified location in the store.
@param location: The I{location} part of a URL.
@type location: str
@return: An input stream to the document.
@rtype: StringIO
"""
try:
content = self.store[location]
... | python | def find(self, location):
"""
Find the specified location in the store.
@param location: The I{location} part of a URL.
@type location: str
@return: An input stream to the document.
@rtype: StringIO
"""
try:
content = self.store[location]
... | [
"def",
"find",
"(",
"self",
",",
"location",
")",
":",
"try",
":",
"content",
"=",
"self",
".",
"store",
"[",
"location",
"]",
"return",
"StringIO",
"(",
"content",
")",
"except",
":",
"reason",
"=",
"'location \"%s\" not in document store'",
"%",
"location"... | Find the specified location in the store.
@param location: The I{location} part of a URL.
@type location: str
@return: An input stream to the document.
@rtype: StringIO | [
"Find",
"the",
"specified",
"location",
"in",
"the",
"store",
"."
] | 44b6743a45ff4447157605d6fecc9bf5922ce68a | https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/store.py#L567-L580 | train |
heroku/sf-suds | suds/bindings/binding.py | Binding.get_message | def get_message(self, method, args, kwargs, options=None):
"""
Get the soap message for the specified method, args and soapheaders.
This is the entry point for creating the outbound soap message.
@param method: The method being invoked.
@type method: I{service.Method}
@pa... | python | def get_message(self, method, args, kwargs, options=None):
"""
Get the soap message for the specified method, args and soapheaders.
This is the entry point for creating the outbound soap message.
@param method: The method being invoked.
@type method: I{service.Method}
@pa... | [
"def",
"get_message",
"(",
"self",
",",
"method",
",",
"args",
",",
"kwargs",
",",
"options",
"=",
"None",
")",
":",
"content",
"=",
"self",
".",
"headercontent",
"(",
"method",
",",
"options",
"=",
"options",
")",
"header",
"=",
"self",
".",
"header",... | Get the soap message for the specified method, args and soapheaders.
This is the entry point for creating the outbound soap message.
@param method: The method being invoked.
@type method: I{service.Method}
@param args: A list of args for the method invoked.
@type args: list
... | [
"Get",
"the",
"soap",
"message",
"for",
"the",
"specified",
"method",
"args",
"and",
"soapheaders",
".",
"This",
"is",
"the",
"entry",
"point",
"for",
"creating",
"the",
"outbound",
"soap",
"message",
"."
] | 44b6743a45ff4447157605d6fecc9bf5922ce68a | https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/bindings/binding.py#L104-L128 | train |
heroku/sf-suds | suds/client.py | SoapClient.send | def send(self, soapenv):
"""
Send soap message.
@param soapenv: A soap envelope to send.
@type soapenv: L{Document}
@return: The reply to the sent message.
@rtype: I{builtin} or I{subclass of} L{Object}
"""
result = None
location = self.location()
... | python | def send(self, soapenv):
"""
Send soap message.
@param soapenv: A soap envelope to send.
@type soapenv: L{Document}
@return: The reply to the sent message.
@rtype: I{builtin} or I{subclass of} L{Object}
"""
result = None
location = self.location()
... | [
"def",
"send",
"(",
"self",
",",
"soapenv",
")",
":",
"result",
"=",
"None",
"location",
"=",
"self",
".",
"location",
"(",
")",
"binding",
"=",
"self",
".",
"method",
".",
"binding",
".",
"input",
"transport",
"=",
"self",
".",
"options",
".",
"tran... | Send soap message.
@param soapenv: A soap envelope to send.
@type soapenv: L{Document}
@return: The reply to the sent message.
@rtype: I{builtin} or I{subclass of} L{Object} | [
"Send",
"soap",
"message",
"."
] | 44b6743a45ff4447157605d6fecc9bf5922ce68a | https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/client.py#L624-L671 | train |
heroku/sf-suds | suds/client.py | SoapClient.succeeded | def succeeded(self, binding, reply):
"""
Request succeeded, process the reply
@param binding: The binding to be used to process the reply.
@type binding: L{bindings.binding.Binding}
@param reply: The raw reply text.
@type reply: str
@return: The method result.
... | python | def succeeded(self, binding, reply):
"""
Request succeeded, process the reply
@param binding: The binding to be used to process the reply.
@type binding: L{bindings.binding.Binding}
@param reply: The raw reply text.
@type reply: str
@return: The method result.
... | [
"def",
"succeeded",
"(",
"self",
",",
"binding",
",",
"reply",
")",
":",
"log",
".",
"debug",
"(",
"'http succeeded:\\n%s'",
",",
"reply",
")",
"plugins",
"=",
"PluginContainer",
"(",
"self",
".",
"options",
".",
"plugins",
")",
"if",
"len",
"(",
"reply"... | Request succeeded, process the reply
@param binding: The binding to be used to process the reply.
@type binding: L{bindings.binding.Binding}
@param reply: The raw reply text.
@type reply: str
@return: The method result.
@rtype: I{builtin}, L{Object}
@raise WebFaul... | [
"Request",
"succeeded",
"process",
"the",
"reply"
] | 44b6743a45ff4447157605d6fecc9bf5922ce68a | https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/client.py#L685-L710 | train |
heroku/sf-suds | suds/client.py | SoapClient.failed | def failed(self, binding, error):
"""
Request failed, process reply based on reason
@param binding: The binding to be used to process the reply.
@type binding: L{suds.bindings.binding.Binding}
@param error: The http error message
@type error: L{transport.TransportError}
... | python | def failed(self, binding, error):
"""
Request failed, process reply based on reason
@param binding: The binding to be used to process the reply.
@type binding: L{suds.bindings.binding.Binding}
@param error: The http error message
@type error: L{transport.TransportError}
... | [
"def",
"failed",
"(",
"self",
",",
"binding",
",",
"error",
")",
":",
"status",
",",
"reason",
"=",
"(",
"error",
".",
"httpcode",
",",
"tostr",
"(",
"error",
")",
")",
"reply",
"=",
"error",
".",
"fp",
".",
"read",
"(",
")",
"log",
".",
"debug",... | Request failed, process reply based on reason
@param binding: The binding to be used to process the reply.
@type binding: L{suds.bindings.binding.Binding}
@param error: The http error message
@type error: L{transport.TransportError} | [
"Request",
"failed",
"process",
"reply",
"based",
"on",
"reason"
] | 44b6743a45ff4447157605d6fecc9bf5922ce68a | https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/client.py#L712-L733 | train |
asottile/cheetah_lint | cheetah_lint/flake.py | _get_line_no_from_comments | def _get_line_no_from_comments(py_line):
"""Return the line number parsed from the comment or 0."""
matched = LINECOL_COMMENT_RE.match(py_line)
if matched:
return int(matched.group(1))
else:
return 0 | python | def _get_line_no_from_comments(py_line):
"""Return the line number parsed from the comment or 0."""
matched = LINECOL_COMMENT_RE.match(py_line)
if matched:
return int(matched.group(1))
else:
return 0 | [
"def",
"_get_line_no_from_comments",
"(",
"py_line",
")",
":",
"matched",
"=",
"LINECOL_COMMENT_RE",
".",
"match",
"(",
"py_line",
")",
"if",
"matched",
":",
"return",
"int",
"(",
"matched",
".",
"group",
"(",
"1",
")",
")",
"else",
":",
"return",
"0"
] | Return the line number parsed from the comment or 0. | [
"Return",
"the",
"line",
"number",
"parsed",
"from",
"the",
"comment",
"or",
"0",
"."
] | 1ecd54933e63073a7e77d65c8a2514a21e145c34 | https://github.com/asottile/cheetah_lint/blob/1ecd54933e63073a7e77d65c8a2514a21e145c34/cheetah_lint/flake.py#L131-L137 | train |
asottile/cheetah_lint | cheetah_lint/flake.py | _find_fuzzy_line | def _find_fuzzy_line(
py_line_no, py_by_line_no, cheetah_by_line_no, prefer_first
):
"""Attempt to fuzzily find matching lines."""
stripped_line = _fuzz_py_line(py_by_line_no[py_line_no])
cheetah_lower_bound, cheetah_upper_bound = _find_bounds(
py_line_no, py_by_line_no, cheetah_by_line_no,
... | python | def _find_fuzzy_line(
py_line_no, py_by_line_no, cheetah_by_line_no, prefer_first
):
"""Attempt to fuzzily find matching lines."""
stripped_line = _fuzz_py_line(py_by_line_no[py_line_no])
cheetah_lower_bound, cheetah_upper_bound = _find_bounds(
py_line_no, py_by_line_no, cheetah_by_line_no,
... | [
"def",
"_find_fuzzy_line",
"(",
"py_line_no",
",",
"py_by_line_no",
",",
"cheetah_by_line_no",
",",
"prefer_first",
")",
":",
"stripped_line",
"=",
"_fuzz_py_line",
"(",
"py_by_line_no",
"[",
"py_line_no",
"]",
")",
"cheetah_lower_bound",
",",
"cheetah_upper_bound",
"... | Attempt to fuzzily find matching lines. | [
"Attempt",
"to",
"fuzzily",
"find",
"matching",
"lines",
"."
] | 1ecd54933e63073a7e77d65c8a2514a21e145c34 | https://github.com/asottile/cheetah_lint/blob/1ecd54933e63073a7e77d65c8a2514a21e145c34/cheetah_lint/flake.py#L184-L204 | train |
asottile/cheetah_lint | cheetah_lint/reorder_imports.py | perform_step | def perform_step(file_contents, step):
"""Performs a step of the transformation.
:param text file_contents: Contends of the cheetah template
:param function step: Function taking xmldoc and returning new contents
:returns: new contents of the file.
"""
assert type(file_contents) is not bytes
... | python | def perform_step(file_contents, step):
"""Performs a step of the transformation.
:param text file_contents: Contends of the cheetah template
:param function step: Function taking xmldoc and returning new contents
:returns: new contents of the file.
"""
assert type(file_contents) is not bytes
... | [
"def",
"perform_step",
"(",
"file_contents",
",",
"step",
")",
":",
"assert",
"type",
"(",
"file_contents",
")",
"is",
"not",
"bytes",
"xmldoc",
"=",
"parse",
"(",
"file_contents",
")",
"return",
"step",
"(",
"xmldoc",
")"
] | Performs a step of the transformation.
:param text file_contents: Contends of the cheetah template
:param function step: Function taking xmldoc and returning new contents
:returns: new contents of the file. | [
"Performs",
"a",
"step",
"of",
"the",
"transformation",
"."
] | 1ecd54933e63073a7e77d65c8a2514a21e145c34 | https://github.com/asottile/cheetah_lint/blob/1ecd54933e63073a7e77d65c8a2514a21e145c34/cheetah_lint/reorder_imports.py#L110-L119 | train |
Aloomaio/python-sdk | alooma_pysdk/alooma_pysdk.py | _get_sender | def _get_sender(*sender_params, **kwargs):
"""
Utility function acting as a Sender factory - ensures senders don't get
created twice of more for the same target server
"""
notify_func = kwargs['notify_func']
with _sender_instances_lock:
existing_sender = _sender_instances.get(sender_para... | python | def _get_sender(*sender_params, **kwargs):
"""
Utility function acting as a Sender factory - ensures senders don't get
created twice of more for the same target server
"""
notify_func = kwargs['notify_func']
with _sender_instances_lock:
existing_sender = _sender_instances.get(sender_para... | [
"def",
"_get_sender",
"(",
"*",
"sender_params",
",",
"**",
"kwargs",
")",
":",
"notify_func",
"=",
"kwargs",
"[",
"'notify_func'",
"]",
"with",
"_sender_instances_lock",
":",
"existing_sender",
"=",
"_sender_instances",
".",
"get",
"(",
"sender_params",
",",
"N... | Utility function acting as a Sender factory - ensures senders don't get
created twice of more for the same target server | [
"Utility",
"function",
"acting",
"as",
"a",
"Sender",
"factory",
"-",
"ensures",
"senders",
"don",
"t",
"get",
"created",
"twice",
"of",
"more",
"for",
"the",
"same",
"target",
"server"
] | e6e7322d0b23d90b1ff0320e9a9c431c82c0c277 | https://github.com/Aloomaio/python-sdk/blob/e6e7322d0b23d90b1ff0320e9a9c431c82c0c277/alooma_pysdk/alooma_pysdk.py#L642-L656 | train |
Aloomaio/python-sdk | alooma_pysdk/alooma_pysdk.py | terminate | def terminate():
"""
Stops all the active Senders by flushing the buffers and closing the
underlying sockets
"""
with _sender_instances_lock:
for sender_key, sender in _sender_instances.items():
sender.close()
_sender_instances.clear() | python | def terminate():
"""
Stops all the active Senders by flushing the buffers and closing the
underlying sockets
"""
with _sender_instances_lock:
for sender_key, sender in _sender_instances.items():
sender.close()
_sender_instances.clear() | [
"def",
"terminate",
"(",
")",
":",
"with",
"_sender_instances_lock",
":",
"for",
"sender_key",
",",
"sender",
"in",
"_sender_instances",
".",
"items",
"(",
")",
":",
"sender",
".",
"close",
"(",
")",
"_sender_instances",
".",
"clear",
"(",
")"
] | Stops all the active Senders by flushing the buffers and closing the
underlying sockets | [
"Stops",
"all",
"the",
"active",
"Senders",
"by",
"flushing",
"the",
"buffers",
"and",
"closing",
"the",
"underlying",
"sockets"
] | e6e7322d0b23d90b1ff0320e9a9c431c82c0c277 | https://github.com/Aloomaio/python-sdk/blob/e6e7322d0b23d90b1ff0320e9a9c431c82c0c277/alooma_pysdk/alooma_pysdk.py#L659-L667 | train |
Aloomaio/python-sdk | alooma_pysdk/alooma_pysdk.py | _Sender._send_batch | def _send_batch(self, batch):
"""
Sends a batch to the destination server via HTTP REST API
"""
try:
json_batch = '[' + ','.join(batch) + ']' # Make JSON array string
logger.debug(consts.LOG_MSG_SENDING_BATCH, len(batch),
len(json_batch),... | python | def _send_batch(self, batch):
"""
Sends a batch to the destination server via HTTP REST API
"""
try:
json_batch = '[' + ','.join(batch) + ']' # Make JSON array string
logger.debug(consts.LOG_MSG_SENDING_BATCH, len(batch),
len(json_batch),... | [
"def",
"_send_batch",
"(",
"self",
",",
"batch",
")",
":",
"try",
":",
"json_batch",
"=",
"'['",
"+",
"','",
".",
"join",
"(",
"batch",
")",
"+",
"']'",
"logger",
".",
"debug",
"(",
"consts",
".",
"LOG_MSG_SENDING_BATCH",
",",
"len",
"(",
"batch",
")... | Sends a batch to the destination server via HTTP REST API | [
"Sends",
"a",
"batch",
"to",
"the",
"destination",
"server",
"via",
"HTTP",
"REST",
"API"
] | e6e7322d0b23d90b1ff0320e9a9c431c82c0c277 | https://github.com/Aloomaio/python-sdk/blob/e6e7322d0b23d90b1ff0320e9a9c431c82c0c277/alooma_pysdk/alooma_pysdk.py#L457-L479 | train |
Aloomaio/python-sdk | alooma_pysdk/alooma_pysdk.py | _Sender.__get_event | def __get_event(self, block=True, timeout=1):
"""
Retrieves an event. If self._exceeding_event is not None, it'll be
returned. Otherwise, an event is dequeued from the event buffer. If
The event which was retrieved is bigger than the permitted batch size,
it'll be omitted, and th... | python | def __get_event(self, block=True, timeout=1):
"""
Retrieves an event. If self._exceeding_event is not None, it'll be
returned. Otherwise, an event is dequeued from the event buffer. If
The event which was retrieved is bigger than the permitted batch size,
it'll be omitted, and th... | [
"def",
"__get_event",
"(",
"self",
",",
"block",
"=",
"True",
",",
"timeout",
"=",
"1",
")",
":",
"while",
"True",
":",
"if",
"self",
".",
"_exceeding_event",
":",
"event",
"=",
"self",
".",
"_exceeding_event",
"self",
".",
"_exceeding_event",
"=",
"None... | Retrieves an event. If self._exceeding_event is not None, it'll be
returned. Otherwise, an event is dequeued from the event buffer. If
The event which was retrieved is bigger than the permitted batch size,
it'll be omitted, and the next event in the event buffer is returned | [
"Retrieves",
"an",
"event",
".",
"If",
"self",
".",
"_exceeding_event",
"is",
"not",
"None",
"it",
"ll",
"be",
"returned",
".",
"Otherwise",
"an",
"event",
"is",
"dequeued",
"from",
"the",
"event",
"buffer",
".",
"If",
"The",
"event",
"which",
"was",
"re... | e6e7322d0b23d90b1ff0320e9a9c431c82c0c277 | https://github.com/Aloomaio/python-sdk/blob/e6e7322d0b23d90b1ff0320e9a9c431c82c0c277/alooma_pysdk/alooma_pysdk.py#L591-L614 | train |
limdauto/drf_openapi | drf_openapi/entities.py | OpenApiSchemaGenerator.get_links | def get_links(self, request=None):
"""
Return a dictionary containing all the links that should be
included in the API schema.
"""
links = LinkNode()
# Generate (path, method, view) given (path, method, callback).
paths = []
view_endpoints = []
fo... | python | def get_links(self, request=None):
"""
Return a dictionary containing all the links that should be
included in the API schema.
"""
links = LinkNode()
# Generate (path, method, view) given (path, method, callback).
paths = []
view_endpoints = []
fo... | [
"def",
"get_links",
"(",
"self",
",",
"request",
"=",
"None",
")",
":",
"links",
"=",
"LinkNode",
"(",
")",
"paths",
"=",
"[",
"]",
"view_endpoints",
"=",
"[",
"]",
"for",
"path",
",",
"method",
",",
"callback",
"in",
"self",
".",
"endpoints",
":",
... | Return a dictionary containing all the links that should be
included in the API schema. | [
"Return",
"a",
"dictionary",
"containing",
"all",
"the",
"links",
"that",
"should",
"be",
"included",
"in",
"the",
"API",
"schema",
"."
] | 1673c6e039eec7f089336a83bdc31613f32f7e21 | https://github.com/limdauto/drf_openapi/blob/1673c6e039eec7f089336a83bdc31613f32f7e21/drf_openapi/entities.py#L111-L144 | train |
limdauto/drf_openapi | drf_openapi/entities.py | OpenApiSchemaGenerator.get_path_fields | def get_path_fields(self, path, method, view):
"""
Return a list of `coreapi.Field` instances corresponding to any
templated path variables.
"""
model = getattr(getattr(view, 'queryset', None), 'model', None)
fields = []
for variable in uritemplate.variables(path... | python | def get_path_fields(self, path, method, view):
"""
Return a list of `coreapi.Field` instances corresponding to any
templated path variables.
"""
model = getattr(getattr(view, 'queryset', None), 'model', None)
fields = []
for variable in uritemplate.variables(path... | [
"def",
"get_path_fields",
"(",
"self",
",",
"path",
",",
"method",
",",
"view",
")",
":",
"model",
"=",
"getattr",
"(",
"getattr",
"(",
"view",
",",
"'queryset'",
",",
"None",
")",
",",
"'model'",
",",
"None",
")",
"fields",
"=",
"[",
"]",
"for",
"... | Return a list of `coreapi.Field` instances corresponding to any
templated path variables. | [
"Return",
"a",
"list",
"of",
"coreapi",
".",
"Field",
"instances",
"corresponding",
"to",
"any",
"templated",
"path",
"variables",
"."
] | 1673c6e039eec7f089336a83bdc31613f32f7e21 | https://github.com/limdauto/drf_openapi/blob/1673c6e039eec7f089336a83bdc31613f32f7e21/drf_openapi/entities.py#L231-L276 | train |
limdauto/drf_openapi | drf_openapi/entities.py | OpenApiSchemaGenerator.get_serializer_class | def get_serializer_class(self, view, method_func):
"""
Try to get the serializer class from view method.
If view method don't have request serializer, fallback to serializer_class on view class
"""
if hasattr(method_func, 'request_serializer'):
return getattr(method_f... | python | def get_serializer_class(self, view, method_func):
"""
Try to get the serializer class from view method.
If view method don't have request serializer, fallback to serializer_class on view class
"""
if hasattr(method_func, 'request_serializer'):
return getattr(method_f... | [
"def",
"get_serializer_class",
"(",
"self",
",",
"view",
",",
"method_func",
")",
":",
"if",
"hasattr",
"(",
"method_func",
",",
"'request_serializer'",
")",
":",
"return",
"getattr",
"(",
"method_func",
",",
"'request_serializer'",
")",
"if",
"hasattr",
"(",
... | Try to get the serializer class from view method.
If view method don't have request serializer, fallback to serializer_class on view class | [
"Try",
"to",
"get",
"the",
"serializer",
"class",
"from",
"view",
"method",
".",
"If",
"view",
"method",
"don",
"t",
"have",
"request",
"serializer",
"fallback",
"to",
"serializer_class",
"on",
"view",
"class"
] | 1673c6e039eec7f089336a83bdc31613f32f7e21 | https://github.com/limdauto/drf_openapi/blob/1673c6e039eec7f089336a83bdc31613f32f7e21/drf_openapi/entities.py#L278-L292 | train |
limdauto/drf_openapi | drf_openapi/entities.py | OpenApiSchemaGenerator.fallback_schema_from_field | def fallback_schema_from_field(self, field):
""" Fallback schema for field that isn't inspected properly by DRF
and probably won't land in upstream canon due to its hacky nature only for doc purposes
"""
title = force_text(field.label) if field.label else ''
description = force_t... | python | def fallback_schema_from_field(self, field):
""" Fallback schema for field that isn't inspected properly by DRF
and probably won't land in upstream canon due to its hacky nature only for doc purposes
"""
title = force_text(field.label) if field.label else ''
description = force_t... | [
"def",
"fallback_schema_from_field",
"(",
"self",
",",
"field",
")",
":",
"title",
"=",
"force_text",
"(",
"field",
".",
"label",
")",
"if",
"field",
".",
"label",
"else",
"''",
"description",
"=",
"force_text",
"(",
"field",
".",
"help_text",
")",
"if",
... | Fallback schema for field that isn't inspected properly by DRF
and probably won't land in upstream canon due to its hacky nature only for doc purposes | [
"Fallback",
"schema",
"for",
"field",
"that",
"isn",
"t",
"inspected",
"properly",
"by",
"DRF",
"and",
"probably",
"won",
"t",
"land",
"in",
"upstream",
"canon",
"due",
"to",
"its",
"hacky",
"nature",
"only",
"for",
"doc",
"purposes"
] | 1673c6e039eec7f089336a83bdc31613f32f7e21 | https://github.com/limdauto/drf_openapi/blob/1673c6e039eec7f089336a83bdc31613f32f7e21/drf_openapi/entities.py#L294-L308 | train |
limdauto/drf_openapi | examples/snippets/serializers.py | SnippetSerializerV1.update | def update(self, instance, validated_data):
"""
Update and return an existing `Snippet` instance, given the validated data.
"""
instance.title = validated_data.get('title', instance.title)
instance.code = validated_data.get('code', instance.code)
instance.linenos = valida... | python | def update(self, instance, validated_data):
"""
Update and return an existing `Snippet` instance, given the validated data.
"""
instance.title = validated_data.get('title', instance.title)
instance.code = validated_data.get('code', instance.code)
instance.linenos = valida... | [
"def",
"update",
"(",
"self",
",",
"instance",
",",
"validated_data",
")",
":",
"instance",
".",
"title",
"=",
"validated_data",
".",
"get",
"(",
"'title'",
",",
"instance",
".",
"title",
")",
"instance",
".",
"code",
"=",
"validated_data",
".",
"get",
"... | Update and return an existing `Snippet` instance, given the validated data. | [
"Update",
"and",
"return",
"an",
"existing",
"Snippet",
"instance",
"given",
"the",
"validated",
"data",
"."
] | 1673c6e039eec7f089336a83bdc31613f32f7e21 | https://github.com/limdauto/drf_openapi/blob/1673c6e039eec7f089336a83bdc31613f32f7e21/examples/snippets/serializers.py#L39-L49 | train |
limdauto/drf_openapi | drf_openapi/codec.py | _generate_openapi_object | def _generate_openapi_object(document):
"""
Generates root of the Swagger spec.
"""
parsed_url = urlparse.urlparse(document.url)
swagger = OrderedDict()
swagger['swagger'] = '2.0'
swagger['info'] = OrderedDict()
swagger['info']['title'] = document.title
swagger['info']['description... | python | def _generate_openapi_object(document):
"""
Generates root of the Swagger spec.
"""
parsed_url = urlparse.urlparse(document.url)
swagger = OrderedDict()
swagger['swagger'] = '2.0'
swagger['info'] = OrderedDict()
swagger['info']['title'] = document.title
swagger['info']['description... | [
"def",
"_generate_openapi_object",
"(",
"document",
")",
":",
"parsed_url",
"=",
"urlparse",
".",
"urlparse",
"(",
"document",
".",
"url",
")",
"swagger",
"=",
"OrderedDict",
"(",
")",
"swagger",
"[",
"'swagger'",
"]",
"=",
"'2.0'",
"swagger",
"[",
"'info'",... | Generates root of the Swagger spec. | [
"Generates",
"root",
"of",
"the",
"Swagger",
"spec",
"."
] | 1673c6e039eec7f089336a83bdc31613f32f7e21 | https://github.com/limdauto/drf_openapi/blob/1673c6e039eec7f089336a83bdc31613f32f7e21/drf_openapi/codec.py#L120-L141 | train |
limdauto/drf_openapi | drf_openapi/codec.py | _get_responses | def _get_responses(link):
""" Returns an OpenApi-compliant response
"""
template = link.response_schema
template.update({'description': 'Success'})
res = {200: template}
res.update(link.error_status_codes)
return res | python | def _get_responses(link):
""" Returns an OpenApi-compliant response
"""
template = link.response_schema
template.update({'description': 'Success'})
res = {200: template}
res.update(link.error_status_codes)
return res | [
"def",
"_get_responses",
"(",
"link",
")",
":",
"template",
"=",
"link",
".",
"response_schema",
"template",
".",
"update",
"(",
"{",
"'description'",
":",
"'Success'",
"}",
")",
"res",
"=",
"{",
"200",
":",
"template",
"}",
"res",
".",
"update",
"(",
... | Returns an OpenApi-compliant response | [
"Returns",
"an",
"OpenApi",
"-",
"compliant",
"response"
] | 1673c6e039eec7f089336a83bdc31613f32f7e21 | https://github.com/limdauto/drf_openapi/blob/1673c6e039eec7f089336a83bdc31613f32f7e21/drf_openapi/codec.py#L183-L190 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.