repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
OSSOS/MOP | src/jjk/preproc/MOPplot.py | plot.coord_grid | def coord_grid(self):
"""Draw a grid of RA/DEC on Canvas."""
import math,ephem
ra2=math.pi*2
ra1=0
dec1=-1*math.pi/2.0
dec2=math.pi/2.0
## grid space choices
## ra space in hours
ra_grids=["06:00:00",
"03:00:00",
... | python | def coord_grid(self):
"""Draw a grid of RA/DEC on Canvas."""
import math,ephem
ra2=math.pi*2
ra1=0
dec1=-1*math.pi/2.0
dec2=math.pi/2.0
## grid space choices
## ra space in hours
ra_grids=["06:00:00",
"03:00:00",
... | [
"def",
"coord_grid",
"(",
"self",
")",
":",
"import",
"math",
",",
"ephem",
"ra2",
"=",
"math",
".",
"pi",
"*",
"2",
"ra1",
"=",
"0",
"dec1",
"=",
"-",
"1",
"*",
"math",
".",
"pi",
"/",
"2.0",
"dec2",
"=",
"math",
".",
"pi",
"/",
"2.0",
"## g... | Draw a grid of RA/DEC on Canvas. | [
"Draw",
"a",
"grid",
"of",
"RA",
"/",
"DEC",
"on",
"Canvas",
"."
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPplot.py#L286-L355 |
OSSOS/MOP | src/jjk/preproc/MOPplot.py | plot.label | def label(self,x,y,label,offset=[0,0]):
"""Write label at plot coordinates (x,y)"""
(xc,yc)=self.p2c([x,y])
return self.create_text(xc-offset[0],yc-offset[1],text=label) | python | def label(self,x,y,label,offset=[0,0]):
"""Write label at plot coordinates (x,y)"""
(xc,yc)=self.p2c([x,y])
return self.create_text(xc-offset[0],yc-offset[1],text=label) | [
"def",
"label",
"(",
"self",
",",
"x",
",",
"y",
",",
"label",
",",
"offset",
"=",
"[",
"0",
",",
"0",
"]",
")",
":",
"(",
"xc",
",",
"yc",
")",
"=",
"self",
".",
"p2c",
"(",
"[",
"x",
",",
"y",
"]",
")",
"return",
"self",
".",
"create_te... | Write label at plot coordinates (x,y) | [
"Write",
"label",
"at",
"plot",
"coordinates",
"(",
"x",
"y",
")"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPplot.py#L416-L419 |
OSSOS/MOP | src/jjk/preproc/MOPplot.py | plot.limits | def limits(self,x1,x2,y1,y2):
"""Set the coordinate boundaries of plot"""
import math
self.x1=x1
self.x2=x2
self.y1=y1
self.y2=y2
self.xscale=(self.cx2-self.cx1)/(self.x2-self.x1)
self.yscale=(self.cy2-self.cy1)/(self.y2-self.y1)
ra1=self.x1
ra2=self.x2... | python | def limits(self,x1,x2,y1,y2):
"""Set the coordinate boundaries of plot"""
import math
self.x1=x1
self.x2=x2
self.y1=y1
self.y2=y2
self.xscale=(self.cx2-self.cx1)/(self.x2-self.x1)
self.yscale=(self.cy2-self.cy1)/(self.y2-self.y1)
ra1=self.x1
ra2=self.x2... | [
"def",
"limits",
"(",
"self",
",",
"x1",
",",
"x2",
",",
"y1",
",",
"y2",
")",
":",
"import",
"math",
"self",
".",
"x1",
"=",
"x1",
"self",
".",
"x2",
"=",
"x2",
"self",
".",
"y1",
"=",
"y1",
"self",
".",
"y2",
"=",
"y2",
"self",
".",
"xsca... | Set the coordinate boundaries of plot | [
"Set",
"the",
"coordinate",
"boundaries",
"of",
"plot"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPplot.py#L422-L440 |
OSSOS/MOP | src/jjk/preproc/MOPplot.py | plot.reset | def reset(self):
"""Expand to the full scale"""
import ephem, MOPcoord
sun=ephem.Sun()
sun.compute(self.date.get())
self.sun=MOPcoord.coord((sun.ra,sun.dec))
doplot(kbos)
self.plot_pointings() | python | def reset(self):
"""Expand to the full scale"""
import ephem, MOPcoord
sun=ephem.Sun()
sun.compute(self.date.get())
self.sun=MOPcoord.coord((sun.ra,sun.dec))
doplot(kbos)
self.plot_pointings() | [
"def",
"reset",
"(",
"self",
")",
":",
"import",
"ephem",
",",
"MOPcoord",
"sun",
"=",
"ephem",
".",
"Sun",
"(",
")",
"sun",
".",
"compute",
"(",
"self",
".",
"date",
".",
"get",
"(",
")",
")",
"self",
".",
"sun",
"=",
"MOPcoord",
".",
"coord",
... | Expand to the full scale | [
"Expand",
"to",
"the",
"full",
"scale"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPplot.py#L442-L452 |
OSSOS/MOP | src/jjk/preproc/MOPplot.py | plot.updateObj | def updateObj(self,event):
"""Put this object in the search box"""
name=w.objList.get("active")
w.SearchVar.set(name)
w.ObjInfo.set(objInfoDict[name])
return | python | def updateObj(self,event):
"""Put this object in the search box"""
name=w.objList.get("active")
w.SearchVar.set(name)
w.ObjInfo.set(objInfoDict[name])
return | [
"def",
"updateObj",
"(",
"self",
",",
"event",
")",
":",
"name",
"=",
"w",
".",
"objList",
".",
"get",
"(",
"\"active\"",
")",
"w",
".",
"SearchVar",
".",
"set",
"(",
"name",
")",
"w",
".",
"ObjInfo",
".",
"set",
"(",
"objInfoDict",
"[",
"name",
... | Put this object in the search box | [
"Put",
"this",
"object",
"in",
"the",
"search",
"box"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPplot.py#L454-L460 |
OSSOS/MOP | src/jjk/preproc/MOPplot.py | plot.relocate | def relocate(self):
"""Move to the postion of self.SearchVar"""
name=self.SearchVar.get()
if kbos.has_key(name):
import orbfit,ephem,math
jdate=ephem.julian_date(w.date.get())
try:
(ra,dec,a,b,ang)=orbfit.predict(kbos[name],jdate,568)
except:
return
ra=math... | python | def relocate(self):
"""Move to the postion of self.SearchVar"""
name=self.SearchVar.get()
if kbos.has_key(name):
import orbfit,ephem,math
jdate=ephem.julian_date(w.date.get())
try:
(ra,dec,a,b,ang)=orbfit.predict(kbos[name],jdate,568)
except:
return
ra=math... | [
"def",
"relocate",
"(",
"self",
")",
":",
"name",
"=",
"self",
".",
"SearchVar",
".",
"get",
"(",
")",
"if",
"kbos",
".",
"has_key",
"(",
"name",
")",
":",
"import",
"orbfit",
",",
"ephem",
",",
"math",
"jdate",
"=",
"ephem",
".",
"julian_date",
"(... | Move to the postion of self.SearchVar | [
"Move",
"to",
"the",
"postion",
"of",
"self",
".",
"SearchVar"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPplot.py#L462-L480 |
OSSOS/MOP | src/jjk/preproc/MOPplot.py | plot.__zoom | def __zoom(self,event,scale=2.0):
"""Zoom in"""
import Tkinter,math
## compute the x,y of the center of the screen
sx1=self.cx1+(self.cx2-self.cx1+1.0)/2.0
sy1=self.cy1+(self.cy2-self.cy1+1.0)/2.0
#print sx1,sy1
if not event is None:
sx1=event.x
sy1=event.y
#print sx1,sy1... | python | def __zoom(self,event,scale=2.0):
"""Zoom in"""
import Tkinter,math
## compute the x,y of the center of the screen
sx1=self.cx1+(self.cx2-self.cx1+1.0)/2.0
sy1=self.cy1+(self.cy2-self.cy1+1.0)/2.0
#print sx1,sy1
if not event is None:
sx1=event.x
sy1=event.y
#print sx1,sy1... | [
"def",
"__zoom",
"(",
"self",
",",
"event",
",",
"scale",
"=",
"2.0",
")",
":",
"import",
"Tkinter",
",",
"math",
"## compute the x,y of the center of the screen",
"sx1",
"=",
"self",
".",
"cx1",
"+",
"(",
"self",
".",
"cx2",
"-",
"self",
".",
"cx1",
"+"... | Zoom in | [
"Zoom",
"in"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPplot.py#L505-L530 |
OSSOS/MOP | src/jjk/preproc/MOPplot.py | plot.create_ellipse | def create_ellipse(self,xcen,ycen,a,b,ang,resolution=40.0):
"""Plot ellipse at x,y with size a,b and orientation ang"""
import math
e1=[]
e2=[]
ang=ang-math.radians(90)
for i in range(0,int(resolution)+1):
x=(-1*a+2*a*float(i)/resolution)
y=1-(x/a... | python | def create_ellipse(self,xcen,ycen,a,b,ang,resolution=40.0):
"""Plot ellipse at x,y with size a,b and orientation ang"""
import math
e1=[]
e2=[]
ang=ang-math.radians(90)
for i in range(0,int(resolution)+1):
x=(-1*a+2*a*float(i)/resolution)
y=1-(x/a... | [
"def",
"create_ellipse",
"(",
"self",
",",
"xcen",
",",
"ycen",
",",
"a",
",",
"b",
",",
"ang",
",",
"resolution",
"=",
"40.0",
")",
":",
"import",
"math",
"e1",
"=",
"[",
"]",
"e2",
"=",
"[",
"]",
"ang",
"=",
"ang",
"-",
"math",
".",
"radians"... | Plot ellipse at x,y with size a,b and orientation ang | [
"Plot",
"ellipse",
"at",
"x",
"y",
"with",
"size",
"a",
"b",
"and",
"orientation",
"ang"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPplot.py#L532-L552 |
OSSOS/MOP | src/jjk/preproc/MOPplot.py | plot.get_pointings | def get_pointings(self):
"""Query for some pointings, given a block name"""
import MOPdbaccess,ephem,math
import tkSimpleDialog
result = tkSimpleDialog.askstring("Block Load", "Which Block do you want to plot?")
db = MOPdbaccess.connect('bucket','cfhls',dbSystem='MYSQL')
SQL = "... | python | def get_pointings(self):
"""Query for some pointings, given a block name"""
import MOPdbaccess,ephem,math
import tkSimpleDialog
result = tkSimpleDialog.askstring("Block Load", "Which Block do you want to plot?")
db = MOPdbaccess.connect('bucket','cfhls',dbSystem='MYSQL')
SQL = "... | [
"def",
"get_pointings",
"(",
"self",
")",
":",
"import",
"MOPdbaccess",
",",
"ephem",
",",
"math",
"import",
"tkSimpleDialog",
"result",
"=",
"tkSimpleDialog",
".",
"askstring",
"(",
"\"Block Load\"",
",",
"\"Which Block do you want to plot?\"",
")",
"db",
"=",
"M... | Query for some pointings, given a block name | [
"Query",
"for",
"some",
"pointings",
"given",
"a",
"block",
"name"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPplot.py#L586-L632 |
OSSOS/MOP | src/jjk/preproc/MOPplot.py | plot.load_pointings | def load_pointings(self):
"""Load some pointings"""
import os,re,ephem
import tkFileDialog,tkMessageBox
filename=tkFileDialog.askopenfilename()
if filename is None:
return
f=open(filename)
lines=f.readlines()
f.close()
points=[]
if lines[0][0:5]=="<?xml":
#... | python | def load_pointings(self):
"""Load some pointings"""
import os,re,ephem
import tkFileDialog,tkMessageBox
filename=tkFileDialog.askopenfilename()
if filename is None:
return
f=open(filename)
lines=f.readlines()
f.close()
points=[]
if lines[0][0:5]=="<?xml":
#... | [
"def",
"load_pointings",
"(",
"self",
")",
":",
"import",
"os",
",",
"re",
",",
"ephem",
"import",
"tkFileDialog",
",",
"tkMessageBox",
"filename",
"=",
"tkFileDialog",
".",
"askopenfilename",
"(",
")",
"if",
"filename",
"is",
"None",
":",
"return",
"f",
"... | Load some pointings | [
"Load",
"some",
"pointings"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPplot.py#L634-L695 |
OSSOS/MOP | src/jjk/preproc/MOPplot.py | plot.create_pointing | def create_pointing(self,event):
"""Plot the sky coverage of pointing at event.x,event.y on the canavas"""
import math
(ra,dec)=self.c2p((self.canvasx(event.x),
self.canvasy(event.y)))
this_camera=camera(camera=self.camera.get())
ccds=this_camera.getGe... | python | def create_pointing(self,event):
"""Plot the sky coverage of pointing at event.x,event.y on the canavas"""
import math
(ra,dec)=self.c2p((self.canvasx(event.x),
self.canvasy(event.y)))
this_camera=camera(camera=self.camera.get())
ccds=this_camera.getGe... | [
"def",
"create_pointing",
"(",
"self",
",",
"event",
")",
":",
"import",
"math",
"(",
"ra",
",",
"dec",
")",
"=",
"self",
".",
"c2p",
"(",
"(",
"self",
".",
"canvasx",
"(",
"event",
".",
"x",
")",
",",
"self",
".",
"canvasy",
"(",
"event",
".",
... | Plot the sky coverage of pointing at event.x,event.y on the canavas | [
"Plot",
"the",
"sky",
"coverage",
"of",
"pointing",
"at",
"event",
".",
"x",
"event",
".",
"y",
"on",
"the",
"canavas"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPplot.py#L712-L733 |
OSSOS/MOP | src/jjk/preproc/MOPplot.py | plot.plot_pointings | def plot_pointings(self,pointings=None):
"""Plot pointings on canavs"""
if pointings is None:
pointings=self.pointings
i=0
for pointing in pointings:
items=[]
i=i+1
label={}
label['text']=pointing['label']['text']
for ccd in pointing["camera"... | python | def plot_pointings(self,pointings=None):
"""Plot pointings on canavs"""
if pointings is None:
pointings=self.pointings
i=0
for pointing in pointings:
items=[]
i=i+1
label={}
label['text']=pointing['label']['text']
for ccd in pointing["camera"... | [
"def",
"plot_pointings",
"(",
"self",
",",
"pointings",
"=",
"None",
")",
":",
"if",
"pointings",
"is",
"None",
":",
"pointings",
"=",
"self",
".",
"pointings",
"i",
"=",
"0",
"for",
"pointing",
"in",
"pointings",
":",
"items",
"=",
"[",
"]",
"i",
"=... | Plot pointings on canavs | [
"Plot",
"pointings",
"on",
"canavs"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPplot.py#L735-L755 |
OSSOS/MOP | src/jjk/preproc/MOPplot.py | plot.set_pointing_label | def set_pointing_label(self):
"""Let the label of the current pointing to the value in the plabel box"""
self.pointings[self.current]['label']['text']=w.plabel.get()
self.reset() | python | def set_pointing_label(self):
"""Let the label of the current pointing to the value in the plabel box"""
self.pointings[self.current]['label']['text']=w.plabel.get()
self.reset() | [
"def",
"set_pointing_label",
"(",
"self",
")",
":",
"self",
".",
"pointings",
"[",
"self",
".",
"current",
"]",
"[",
"'label'",
"]",
"[",
"'text'",
"]",
"=",
"w",
".",
"plabel",
".",
"get",
"(",
")",
"self",
".",
"reset",
"(",
")"
] | Let the label of the current pointing to the value in the plabel box | [
"Let",
"the",
"label",
"of",
"the",
"current",
"pointing",
"to",
"the",
"value",
"in",
"the",
"plabel",
"box"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPplot.py#L758-L762 |
OSSOS/MOP | src/jjk/preproc/MOPplot.py | plot.save_pointings | def save_pointings(self):
"""Print the currently defined FOVs"""
import tkFileDialog
f=tkFileDialog.asksaveasfile()
i=0
if self.pointing_format.get()=='CFHT PH':
f.write("""<?xml version = "1.0"?>
<!DOCTYPE ASTRO SYSTEM "http://vizier.u-strasbg.fr/xml/astrores.dtd">
<ASTRO ... | python | def save_pointings(self):
"""Print the currently defined FOVs"""
import tkFileDialog
f=tkFileDialog.asksaveasfile()
i=0
if self.pointing_format.get()=='CFHT PH':
f.write("""<?xml version = "1.0"?>
<!DOCTYPE ASTRO SYSTEM "http://vizier.u-strasbg.fr/xml/astrores.dtd">
<ASTRO ... | [
"def",
"save_pointings",
"(",
"self",
")",
":",
"import",
"tkFileDialog",
"f",
"=",
"tkFileDialog",
".",
"asksaveasfile",
"(",
")",
"i",
"=",
"0",
"if",
"self",
".",
"pointing_format",
".",
"get",
"(",
")",
"==",
"'CFHT PH'",
":",
"f",
".",
"write",
"(... | Print the currently defined FOVs | [
"Print",
"the",
"currently",
"defined",
"FOVs"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPplot.py#L803-L881 |
OSSOS/MOP | src/jjk/preproc/MOPplot.py | camera.getGeometry | def getGeometry(self,ra=None,dec=None):
"""Return an array of rectangles that represent the 'ra,dec' corners of the FOV"""
import math,ephem
ccds=[]
if ra is None:
ra=self.ra
if dec is None:
dec=self.dec
self.ra=ephem.hours(ra)
self.dec=e... | python | def getGeometry(self,ra=None,dec=None):
"""Return an array of rectangles that represent the 'ra,dec' corners of the FOV"""
import math,ephem
ccds=[]
if ra is None:
ra=self.ra
if dec is None:
dec=self.dec
self.ra=ephem.hours(ra)
self.dec=e... | [
"def",
"getGeometry",
"(",
"self",
",",
"ra",
"=",
"None",
",",
"dec",
"=",
"None",
")",
":",
"import",
"math",
",",
"ephem",
"ccds",
"=",
"[",
"]",
"if",
"ra",
"is",
"None",
":",
"ra",
"=",
"self",
".",
"ra",
"if",
"dec",
"is",
"None",
":",
... | Return an array of rectangles that represent the 'ra,dec' corners of the FOV | [
"Return",
"an",
"array",
"of",
"rectangles",
"that",
"represent",
"the",
"ra",
"dec",
"corners",
"of",
"the",
"FOV"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPplot.py#L1017-L1036 |
OSSOS/MOP | src/jjk/preproc/MOPplot.py | camera.separation | def separation(self,ra,dec):
"""Compute the separation between self and (ra,dec)"""
import ephem
return ephem.separation((self.ra,self.dec),(ra,dec)) | python | def separation(self,ra,dec):
"""Compute the separation between self and (ra,dec)"""
import ephem
return ephem.separation((self.ra,self.dec),(ra,dec)) | [
"def",
"separation",
"(",
"self",
",",
"ra",
",",
"dec",
")",
":",
"import",
"ephem",
"return",
"ephem",
".",
"separation",
"(",
"(",
"self",
".",
"ra",
",",
"self",
".",
"dec",
")",
",",
"(",
"ra",
",",
"dec",
")",
")"
] | Compute the separation between self and (ra,dec) | [
"Compute",
"the",
"separation",
"between",
"self",
"and",
"(",
"ra",
"dec",
")"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPplot.py#L1039-L1043 |
JohnVinyard/zounds | examples/hamming_index.py | produce_fake_hash | def produce_fake_hash(x):
"""
Produce random, binary features, totally irrespective of the content of
x, but in the same shape as x.
"""
h = np.random.binomial(1, 0.5, (x.shape[0], 1024))
packed = np.packbits(h, axis=-1).view(np.uint64)
return zounds.ArrayWithUnits(
packed, [x.dimens... | python | def produce_fake_hash(x):
"""
Produce random, binary features, totally irrespective of the content of
x, but in the same shape as x.
"""
h = np.random.binomial(1, 0.5, (x.shape[0], 1024))
packed = np.packbits(h, axis=-1).view(np.uint64)
return zounds.ArrayWithUnits(
packed, [x.dimens... | [
"def",
"produce_fake_hash",
"(",
"x",
")",
":",
"h",
"=",
"np",
".",
"random",
".",
"binomial",
"(",
"1",
",",
"0.5",
",",
"(",
"x",
".",
"shape",
"[",
"0",
"]",
",",
"1024",
")",
")",
"packed",
"=",
"np",
".",
"packbits",
"(",
"h",
",",
"axi... | Produce random, binary features, totally irrespective of the content of
x, but in the same shape as x. | [
"Produce",
"random",
"binary",
"features",
"totally",
"irrespective",
"of",
"the",
"content",
"of",
"x",
"but",
"in",
"the",
"same",
"shape",
"as",
"x",
"."
] | train | https://github.com/JohnVinyard/zounds/blob/337b3f98753d09eaab1c72dcd37bb852a3fa5ac6/examples/hamming_index.py#L16-L24 |
openstack/python-scciclient | scciclient/irmc/ipmi.py | _parse_raw_bytes | def _parse_raw_bytes(raw_bytes):
"""Convert a string of hexadecimal values to decimal values parameters
Example: '0x2E 0xF1 0x80 0x28 0x00 0x1A 0x01 0x00' is converted to:
46, 241, [128, 40, 0, 26, 1, 0]
:param raw_bytes: string of hexadecimal values
:returns: 3 decimal values
"""
... | python | def _parse_raw_bytes(raw_bytes):
"""Convert a string of hexadecimal values to decimal values parameters
Example: '0x2E 0xF1 0x80 0x28 0x00 0x1A 0x01 0x00' is converted to:
46, 241, [128, 40, 0, 26, 1, 0]
:param raw_bytes: string of hexadecimal values
:returns: 3 decimal values
"""
... | [
"def",
"_parse_raw_bytes",
"(",
"raw_bytes",
")",
":",
"bytes_list",
"=",
"[",
"int",
"(",
"x",
",",
"base",
"=",
"16",
")",
"for",
"x",
"in",
"raw_bytes",
".",
"split",
"(",
")",
"]",
"return",
"bytes_list",
"[",
"0",
"]",
",",
"bytes_list",
"[",
... | Convert a string of hexadecimal values to decimal values parameters
Example: '0x2E 0xF1 0x80 0x28 0x00 0x1A 0x01 0x00' is converted to:
46, 241, [128, 40, 0, 26, 1, 0]
:param raw_bytes: string of hexadecimal values
:returns: 3 decimal values | [
"Convert",
"a",
"string",
"of",
"hexadecimal",
"values",
"to",
"decimal",
"values",
"parameters"
] | train | https://github.com/openstack/python-scciclient/blob/4585ce2f76853b9773fb190ca0cfff0aa04a7cf8/scciclient/irmc/ipmi.py#L47-L57 |
openstack/python-scciclient | scciclient/irmc/ipmi.py | _send_raw_command | def _send_raw_command(ipmicmd, raw_bytes):
"""Use IPMI command object to send raw ipmi command to BMC
:param ipmicmd: IPMI command object
:param raw_bytes: string of hexadecimal values. This is commonly used
for certain vendor specific commands.
:returns: dict -- The response from IPMI device
... | python | def _send_raw_command(ipmicmd, raw_bytes):
"""Use IPMI command object to send raw ipmi command to BMC
:param ipmicmd: IPMI command object
:param raw_bytes: string of hexadecimal values. This is commonly used
for certain vendor specific commands.
:returns: dict -- The response from IPMI device
... | [
"def",
"_send_raw_command",
"(",
"ipmicmd",
",",
"raw_bytes",
")",
":",
"netfn",
",",
"command",
",",
"data",
"=",
"_parse_raw_bytes",
"(",
"raw_bytes",
")",
"response",
"=",
"ipmicmd",
".",
"raw_command",
"(",
"netfn",
",",
"command",
",",
"data",
"=",
"d... | Use IPMI command object to send raw ipmi command to BMC
:param ipmicmd: IPMI command object
:param raw_bytes: string of hexadecimal values. This is commonly used
for certain vendor specific commands.
:returns: dict -- The response from IPMI device | [
"Use",
"IPMI",
"command",
"object",
"to",
"send",
"raw",
"ipmi",
"command",
"to",
"BMC"
] | train | https://github.com/openstack/python-scciclient/blob/4585ce2f76853b9773fb190ca0cfff0aa04a7cf8/scciclient/irmc/ipmi.py#L60-L72 |
openstack/python-scciclient | scciclient/irmc/ipmi.py | get_tpm_status | def get_tpm_status(d_info):
"""Get the TPM support status.
Get the TPM support status of the node.
:param d_info: the list of ipmitool parameters for accessing a node.
:returns: TPM support status
"""
# note:
# Get TPM support status : ipmi cmd '0xF5', valid flags '0xC0'
#
# $ ipm... | python | def get_tpm_status(d_info):
"""Get the TPM support status.
Get the TPM support status of the node.
:param d_info: the list of ipmitool parameters for accessing a node.
:returns: TPM support status
"""
# note:
# Get TPM support status : ipmi cmd '0xF5', valid flags '0xC0'
#
# $ ipm... | [
"def",
"get_tpm_status",
"(",
"d_info",
")",
":",
"# note:",
"# Get TPM support status : ipmi cmd '0xF5', valid flags '0xC0'",
"#",
"# $ ipmitool raw 0x2E 0xF5 0x80 0x28 0x00 0x81 0xC0",
"#",
"# Raw response:",
"# 80 28 00 C0 C0: True",
"# 80 28 00 -- --: False (other values than 'C0 C0')"... | Get the TPM support status.
Get the TPM support status of the node.
:param d_info: the list of ipmitool parameters for accessing a node.
:returns: TPM support status | [
"Get",
"the",
"TPM",
"support",
"status",
"."
] | train | https://github.com/openstack/python-scciclient/blob/4585ce2f76853b9773fb190ca0cfff0aa04a7cf8/scciclient/irmc/ipmi.py#L75-L109 |
openstack/python-scciclient | scciclient/irmc/ipmi.py | _pci_seq | def _pci_seq(ipmicmd):
"""Get output of ipmiraw command and the ordinal numbers.
:param ipmicmd: IPMI command object.
:returns: List of tuple contain ordinal number and output of ipmiraw
command.
"""
for i in range(1, 0xff + 1):
try:
res = _send_raw_command(ipmicmd, GET_PCI ... | python | def _pci_seq(ipmicmd):
"""Get output of ipmiraw command and the ordinal numbers.
:param ipmicmd: IPMI command object.
:returns: List of tuple contain ordinal number and output of ipmiraw
command.
"""
for i in range(1, 0xff + 1):
try:
res = _send_raw_command(ipmicmd, GET_PCI ... | [
"def",
"_pci_seq",
"(",
"ipmicmd",
")",
":",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"0xff",
"+",
"1",
")",
":",
"try",
":",
"res",
"=",
"_send_raw_command",
"(",
"ipmicmd",
",",
"GET_PCI",
"%",
"hex",
"(",
"i",
")",
")",
"yield",
"i",
",",
"... | Get output of ipmiraw command and the ordinal numbers.
:param ipmicmd: IPMI command object.
:returns: List of tuple contain ordinal number and output of ipmiraw
command. | [
"Get",
"output",
"of",
"ipmiraw",
"command",
"and",
"the",
"ordinal",
"numbers",
"."
] | train | https://github.com/openstack/python-scciclient/blob/4585ce2f76853b9773fb190ca0cfff0aa04a7cf8/scciclient/irmc/ipmi.py#L112-L126 |
openstack/python-scciclient | scciclient/irmc/ipmi.py | get_pci_device | def get_pci_device(d_info, pci_device_ids):
"""Get quantity of PCI devices.
Get quantity of PCI devices of the node.
:param d_info: the list of ipmitool parameters for accessing a node.
:param pci_device_ids: the list contains pairs of <vendorID>/<deviceID> for
PCI devices.
:returns: the numbe... | python | def get_pci_device(d_info, pci_device_ids):
"""Get quantity of PCI devices.
Get quantity of PCI devices of the node.
:param d_info: the list of ipmitool parameters for accessing a node.
:param pci_device_ids: the list contains pairs of <vendorID>/<deviceID> for
PCI devices.
:returns: the numbe... | [
"def",
"get_pci_device",
"(",
"d_info",
",",
"pci_device_ids",
")",
":",
"# note:",
"# Get quantity of PCI devices:",
"# ipmi cmd '0xF1'",
"#",
"# $ ipmitool raw 0x2E 0xF1 0x80 0x28 0x00 0x1A 0x01 0x00",
"#",
"# Raw response:",
"# 80 28 00 00 00 05 data1 data2 34 17 76 11 00 04",
"# ... | Get quantity of PCI devices.
Get quantity of PCI devices of the node.
:param d_info: the list of ipmitool parameters for accessing a node.
:param pci_device_ids: the list contains pairs of <vendorID>/<deviceID> for
PCI devices.
:returns: the number of PCI devices. | [
"Get",
"quantity",
"of",
"PCI",
"devices",
"."
] | train | https://github.com/openstack/python-scciclient/blob/4585ce2f76853b9773fb190ca0cfff0aa04a7cf8/scciclient/irmc/ipmi.py#L129-L170 |
playpauseandstop/rororo | rororo/schemas/utils.py | defaults | def defaults(current: dict, *args: AnyMapping) -> dict:
r"""Override current dict with defaults values.
:param current: Current dict.
:param \*args: Sequence with default data dicts.
"""
for data in args:
for key, value in data.items():
current.setdefault(key, value)
return ... | python | def defaults(current: dict, *args: AnyMapping) -> dict:
r"""Override current dict with defaults values.
:param current: Current dict.
:param \*args: Sequence with default data dicts.
"""
for data in args:
for key, value in data.items():
current.setdefault(key, value)
return ... | [
"def",
"defaults",
"(",
"current",
":",
"dict",
",",
"*",
"args",
":",
"AnyMapping",
")",
"->",
"dict",
":",
"for",
"data",
"in",
"args",
":",
"for",
"key",
",",
"value",
"in",
"data",
".",
"items",
"(",
")",
":",
"current",
".",
"setdefault",
"(",... | r"""Override current dict with defaults values.
:param current: Current dict.
:param \*args: Sequence with default data dicts. | [
"r",
"Override",
"current",
"dict",
"with",
"defaults",
"values",
"."
] | train | https://github.com/playpauseandstop/rororo/blob/28a04e8028c29647941e727116335e9d6fd64c27/rororo/schemas/utils.py#L17-L26 |
playpauseandstop/rororo | rororo/schemas/utils.py | validate_func_factory | def validate_func_factory(validator_class: Any) -> ValidateFunc:
"""Provide default function for Schema validation.
:param validator_class: JSONSchema suitable validator class.
"""
def validate_func(schema: AnyMapping, pure_data: AnyMapping) -> AnyMapping:
"""Validate schema with given data.
... | python | def validate_func_factory(validator_class: Any) -> ValidateFunc:
"""Provide default function for Schema validation.
:param validator_class: JSONSchema suitable validator class.
"""
def validate_func(schema: AnyMapping, pure_data: AnyMapping) -> AnyMapping:
"""Validate schema with given data.
... | [
"def",
"validate_func_factory",
"(",
"validator_class",
":",
"Any",
")",
"->",
"ValidateFunc",
":",
"def",
"validate_func",
"(",
"schema",
":",
"AnyMapping",
",",
"pure_data",
":",
"AnyMapping",
")",
"->",
"AnyMapping",
":",
"\"\"\"Validate schema with given data.\n\n... | Provide default function for Schema validation.
:param validator_class: JSONSchema suitable validator class. | [
"Provide",
"default",
"function",
"for",
"Schema",
"validation",
"."
] | train | https://github.com/playpauseandstop/rororo/blob/28a04e8028c29647941e727116335e9d6fd64c27/rororo/schemas/utils.py#L29-L41 |
OSSOS/MOP | src/jjk/preproc/MOPdisplay.py | moreData | def moreData(ra,dec,box):
"""Search the CFHT archive for more images of this location"""
import cfhtCutout
cdata={'ra_deg': ra, 'dec_deg': dec, 'radius_deg': 0.2}
inter=cfhtCutout.find_images(cdata,0.2) | python | def moreData(ra,dec,box):
"""Search the CFHT archive for more images of this location"""
import cfhtCutout
cdata={'ra_deg': ra, 'dec_deg': dec, 'radius_deg': 0.2}
inter=cfhtCutout.find_images(cdata,0.2) | [
"def",
"moreData",
"(",
"ra",
",",
"dec",
",",
"box",
")",
":",
"import",
"cfhtCutout",
"cdata",
"=",
"{",
"'ra_deg'",
":",
"ra",
",",
"'dec_deg'",
":",
"dec",
",",
"'radius_deg'",
":",
"0.2",
"}",
"inter",
"=",
"cfhtCutout",
".",
"find_images",
"(",
... | Search the CFHT archive for more images of this location | [
"Search",
"the",
"CFHT",
"archive",
"for",
"more",
"images",
"of",
"this",
"location"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPdisplay.py#L33-L38 |
OSSOS/MOP | src/jjk/preproc/MOPdisplay.py | xpacheck | def xpacheck():
"""Check if xpa is running"""
import os
f=os.popen('xpaaccess ds9')
l=f.readline()
f.close()
if l.strip()!='yes':
logger.debug("\t Can't get ds9 access, xpaccess said: %s" % ( l.strip()))
return (False)
return(True) | python | def xpacheck():
"""Check if xpa is running"""
import os
f=os.popen('xpaaccess ds9')
l=f.readline()
f.close()
if l.strip()!='yes':
logger.debug("\t Can't get ds9 access, xpaccess said: %s" % ( l.strip()))
return (False)
return(True) | [
"def",
"xpacheck",
"(",
")",
":",
"import",
"os",
"f",
"=",
"os",
".",
"popen",
"(",
"'xpaaccess ds9'",
")",
"l",
"=",
"f",
".",
"readline",
"(",
")",
"f",
".",
"close",
"(",
")",
"if",
"l",
".",
"strip",
"(",
")",
"!=",
"'yes'",
":",
"logger",... | Check if xpa is running | [
"Check",
"if",
"xpa",
"is",
"running"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPdisplay.py#L40-L49 |
OSSOS/MOP | src/jjk/preproc/MOPdisplay.py | mark | def mark(x,y,label=None):
"""Mark a circle on the current image"""
if label is not None:
os.system("xpaset -p ds9 regions color red ")
cmd="echo 'image; text %d %d # text={%s}' | xpaset ds9 regions " % ( x,y,label)
else:
os.system("xpaset -p ds9 regions color blue")
cmd="echo 'image; circle %d ... | python | def mark(x,y,label=None):
"""Mark a circle on the current image"""
if label is not None:
os.system("xpaset -p ds9 regions color red ")
cmd="echo 'image; text %d %d # text={%s}' | xpaset ds9 regions " % ( x,y,label)
else:
os.system("xpaset -p ds9 regions color blue")
cmd="echo 'image; circle %d ... | [
"def",
"mark",
"(",
"x",
",",
"y",
",",
"label",
"=",
"None",
")",
":",
"if",
"label",
"is",
"not",
"None",
":",
"os",
".",
"system",
"(",
"\"xpaset -p ds9 regions color red \"",
")",
"cmd",
"=",
"\"echo 'image; text %d %d # text={%s}' | xpaset ds9 regions \"",
... | Mark a circle on the current image | [
"Mark",
"a",
"circle",
"on",
"the",
"current",
"image"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPdisplay.py#L72-L81 |
OSSOS/MOP | src/jjk/preproc/MOPdisplay.py | display | def display(url):
"""Display a file in ds9"""
import os
oscmd="curl --silent -g --fail --max-time 1800 --user jkavelaars '%s'" % (url)
logger.debug(oscmd)
os.system(oscmd+' | xpaset ds9 fits')
return | python | def display(url):
"""Display a file in ds9"""
import os
oscmd="curl --silent -g --fail --max-time 1800 --user jkavelaars '%s'" % (url)
logger.debug(oscmd)
os.system(oscmd+' | xpaset ds9 fits')
return | [
"def",
"display",
"(",
"url",
")",
":",
"import",
"os",
"oscmd",
"=",
"\"curl --silent -g --fail --max-time 1800 --user jkavelaars '%s'\"",
"%",
"(",
"url",
")",
"logger",
".",
"debug",
"(",
"oscmd",
")",
"os",
".",
"system",
"(",
"oscmd",
"+",
"' | xpaset ds9 f... | Display a file in ds9 | [
"Display",
"a",
"file",
"in",
"ds9"
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPdisplay.py#L84-L90 |
eelregit/mcfit | mcfit/mcfit.py | mcfit.inv | def inv(self):
"""Invert the transform.
After calling this method, calling the instance will do the inverse
transform. Calling this twice return the instance to the original
transform.
"""
self.x, self.y = self.y, self.x
self._x_, self._y_ = self._y_, self._x_
... | python | def inv(self):
"""Invert the transform.
After calling this method, calling the instance will do the inverse
transform. Calling this twice return the instance to the original
transform.
"""
self.x, self.y = self.y, self.x
self._x_, self._y_ = self._y_, self._x_
... | [
"def",
"inv",
"(",
"self",
")",
":",
"self",
".",
"x",
",",
"self",
".",
"y",
"=",
"self",
".",
"y",
",",
"self",
".",
"x",
"self",
".",
"_x_",
",",
"self",
".",
"_y_",
"=",
"self",
".",
"_y_",
",",
"self",
".",
"_x_",
"self",
".",
"xfac",
... | Invert the transform.
After calling this method, calling the instance will do the inverse
transform. Calling this twice return the instance to the original
transform. | [
"Invert",
"the",
"transform",
"."
] | train | https://github.com/eelregit/mcfit/blob/ef04b92df929425c44c62743c1ce7e0b81a26815/mcfit/mcfit.py#L248-L260 |
eelregit/mcfit | mcfit/mcfit.py | mcfit.matrix | def matrix(self, full=False, keeppads=True):
"""Return matrix form of the integral transform.
Parameters
----------
full : bool, optional
when False return two vector factors and convolution matrix
separately, otherwise return full transformation matrix
k... | python | def matrix(self, full=False, keeppads=True):
"""Return matrix form of the integral transform.
Parameters
----------
full : bool, optional
when False return two vector factors and convolution matrix
separately, otherwise return full transformation matrix
k... | [
"def",
"matrix",
"(",
"self",
",",
"full",
"=",
"False",
",",
"keeppads",
"=",
"True",
")",
":",
"v",
"=",
"np",
".",
"fft",
".",
"hfft",
"(",
"self",
".",
"_u",
",",
"n",
"=",
"self",
".",
"N",
")",
"/",
"self",
".",
"N",
"idx",
"=",
"sum"... | Return matrix form of the integral transform.
Parameters
----------
full : bool, optional
when False return two vector factors and convolution matrix
separately, otherwise return full transformation matrix
keeppads : bool, optional
whether to keep the... | [
"Return",
"matrix",
"form",
"of",
"the",
"integral",
"transform",
"."
] | train | https://github.com/eelregit/mcfit/blob/ef04b92df929425c44c62743c1ce7e0b81a26815/mcfit/mcfit.py#L263-L325 |
eelregit/mcfit | mcfit/mcfit.py | mcfit._pad | def _pad(self, a, axis, extrap, out):
"""Add padding to an array.
Parameters
----------
a : (..., Nin, ...) ndarray
array to be padded to size `N`
axis : int
axis along which to pad
extrap : {bool, 'const'} or 2-tuple
Method to extrapo... | python | def _pad(self, a, axis, extrap, out):
"""Add padding to an array.
Parameters
----------
a : (..., Nin, ...) ndarray
array to be padded to size `N`
axis : int
axis along which to pad
extrap : {bool, 'const'} or 2-tuple
Method to extrapo... | [
"def",
"_pad",
"(",
"self",
",",
"a",
",",
"axis",
",",
"extrap",
",",
"out",
")",
":",
"assert",
"a",
".",
"shape",
"[",
"axis",
"]",
"==",
"self",
".",
"Nin",
"axis",
"%=",
"a",
".",
"ndim",
"# to fix the indexing below with axis+1",
"to_axis",
"=",
... | Add padding to an array.
Parameters
----------
a : (..., Nin, ...) ndarray
array to be padded to size `N`
axis : int
axis along which to pad
extrap : {bool, 'const'} or 2-tuple
Method to extrapolate `a`.
For a 2-tuple, the two elem... | [
"Add",
"padding",
"to",
"an",
"array",
"."
] | train | https://github.com/eelregit/mcfit/blob/ef04b92df929425c44c62743c1ce7e0b81a26815/mcfit/mcfit.py#L328-L395 |
eelregit/mcfit | mcfit/mcfit.py | mcfit._unpad | def _unpad(self, a, axis, out):
"""Undo padding in an array.
Parameters
----------
a : (..., N, ...) ndarray
array to be trimmed to size `Nin`
axis : int
axis along which to unpad
out : bool
trim the output if True, otherwise the input... | python | def _unpad(self, a, axis, out):
"""Undo padding in an array.
Parameters
----------
a : (..., N, ...) ndarray
array to be trimmed to size `Nin`
axis : int
axis along which to unpad
out : bool
trim the output if True, otherwise the input... | [
"def",
"_unpad",
"(",
"self",
",",
"a",
",",
"axis",
",",
"out",
")",
":",
"assert",
"a",
".",
"shape",
"[",
"axis",
"]",
"==",
"self",
".",
"N",
"Npad",
"=",
"self",
".",
"N",
"-",
"self",
".",
"Nin",
"if",
"out",
":",
"_Npad",
",",
"Npad_",... | Undo padding in an array.
Parameters
----------
a : (..., N, ...) ndarray
array to be trimmed to size `Nin`
axis : int
axis along which to unpad
out : bool
trim the output if True, otherwise the input; the two cases have
their left... | [
"Undo",
"padding",
"in",
"an",
"array",
"."
] | train | https://github.com/eelregit/mcfit/blob/ef04b92df929425c44c62743c1ce7e0b81a26815/mcfit/mcfit.py#L398-L420 |
eelregit/mcfit | mcfit/mcfit.py | mcfit.check | def check(self, F):
"""Rough sanity checks on the input function.
"""
assert F.ndim == 1, "checker only supports 1D"
f = self.xfac * F
fabs = np.abs(f)
iQ1, iQ3 = np.searchsorted(fabs.cumsum(), np.array([0.25, 0.75]) * fabs.sum())
assert 0 != iQ1 != iQ3 != self... | python | def check(self, F):
"""Rough sanity checks on the input function.
"""
assert F.ndim == 1, "checker only supports 1D"
f = self.xfac * F
fabs = np.abs(f)
iQ1, iQ3 = np.searchsorted(fabs.cumsum(), np.array([0.25, 0.75]) * fabs.sum())
assert 0 != iQ1 != iQ3 != self... | [
"def",
"check",
"(",
"self",
",",
"F",
")",
":",
"assert",
"F",
".",
"ndim",
"==",
"1",
",",
"\"checker only supports 1D\"",
"f",
"=",
"self",
".",
"xfac",
"*",
"F",
"fabs",
"=",
"np",
".",
"abs",
"(",
"f",
")",
"iQ1",
",",
"iQ3",
"=",
"np",
".... | Rough sanity checks on the input function. | [
"Rough",
"sanity",
"checks",
"on",
"the",
"input",
"function",
"."
] | train | https://github.com/eelregit/mcfit/blob/ef04b92df929425c44c62743c1ce7e0b81a26815/mcfit/mcfit.py#L423-L457 |
JohnVinyard/zounds | zounds/spectral/functional.py | fft | def fft(x, axis=-1, padding_samples=0):
"""
Apply an FFT along the given dimension, and with the specified amount of
zero-padding
Args:
x (ArrayWithUnits): an :class:`~zounds.core.ArrayWithUnits` instance
which has one or more :class:`~zounds.timeseries.TimeDimension`
ax... | python | def fft(x, axis=-1, padding_samples=0):
"""
Apply an FFT along the given dimension, and with the specified amount of
zero-padding
Args:
x (ArrayWithUnits): an :class:`~zounds.core.ArrayWithUnits` instance
which has one or more :class:`~zounds.timeseries.TimeDimension`
ax... | [
"def",
"fft",
"(",
"x",
",",
"axis",
"=",
"-",
"1",
",",
"padding_samples",
"=",
"0",
")",
":",
"if",
"padding_samples",
">",
"0",
":",
"padded",
"=",
"np",
".",
"concatenate",
"(",
"[",
"x",
",",
"np",
".",
"zeros",
"(",
"(",
"len",
"(",
"x",
... | Apply an FFT along the given dimension, and with the specified amount of
zero-padding
Args:
x (ArrayWithUnits): an :class:`~zounds.core.ArrayWithUnits` instance
which has one or more :class:`~zounds.timeseries.TimeDimension`
axes
axis (int): The axis along which the fft ... | [
"Apply",
"an",
"FFT",
"along",
"the",
"given",
"dimension",
"and",
"with",
"the",
"specified",
"amount",
"of",
"zero",
"-",
"padding"
] | train | https://github.com/JohnVinyard/zounds/blob/337b3f98753d09eaab1c72dcd37bb852a3fa5ac6/zounds/spectral/functional.py#L20-L46 |
JohnVinyard/zounds | zounds/spectral/functional.py | morlet_filter_bank | def morlet_filter_bank(
samplerate,
kernel_size,
scale,
scaling_factor,
normalize=True):
"""
Create a :class:`~zounds.core.ArrayWithUnits` instance with a
:class:`~zounds.timeseries.TimeDimension` and a
:class:`~zounds.spectral.FrequencyDimension` representing a b... | python | def morlet_filter_bank(
samplerate,
kernel_size,
scale,
scaling_factor,
normalize=True):
"""
Create a :class:`~zounds.core.ArrayWithUnits` instance with a
:class:`~zounds.timeseries.TimeDimension` and a
:class:`~zounds.spectral.FrequencyDimension` representing a b... | [
"def",
"morlet_filter_bank",
"(",
"samplerate",
",",
"kernel_size",
",",
"scale",
",",
"scaling_factor",
",",
"normalize",
"=",
"True",
")",
":",
"basis_size",
"=",
"len",
"(",
"scale",
")",
"basis",
"=",
"np",
".",
"zeros",
"(",
"(",
"basis_size",
",",
... | Create a :class:`~zounds.core.ArrayWithUnits` instance with a
:class:`~zounds.timeseries.TimeDimension` and a
:class:`~zounds.spectral.FrequencyDimension` representing a bank of morlet
wavelets centered on the sub-bands of the scale.
Args:
samplerate (SampleRate): the samplerate of the input si... | [
"Create",
"a",
":",
"class",
":",
"~zounds",
".",
"core",
".",
"ArrayWithUnits",
"instance",
"with",
"a",
":",
"class",
":",
"~zounds",
".",
"timeseries",
".",
"TimeDimension",
"and",
"a",
":",
"class",
":",
"~zounds",
".",
"spectral",
".",
"FrequencyDimen... | train | https://github.com/JohnVinyard/zounds/blob/337b3f98753d09eaab1c72dcd37bb852a3fa5ac6/zounds/spectral/functional.py#L271-L326 |
OSSOS/MOP | src/ossos/core/ossos/fitsviewer/colormap.py | GrayscaleColorMap.set_bias | def set_bias(self, bias):
"""
Adjusts the image bias.
Bias determines where the color changes start. At low bias, low
intensities (i.e., low pixel values) will have non-zero color
differences, while at high bias only high pixel values will have
non-zero differences
... | python | def set_bias(self, bias):
"""
Adjusts the image bias.
Bias determines where the color changes start. At low bias, low
intensities (i.e., low pixel values) will have non-zero color
differences, while at high bias only high pixel values will have
non-zero differences
... | [
"def",
"set_bias",
"(",
"self",
",",
"bias",
")",
":",
"self",
".",
"x_offset",
"+=",
"(",
"bias",
"-",
"self",
".",
"_bias",
")",
"self",
".",
"_bias",
"=",
"bias",
"self",
".",
"_build_cdict",
"(",
")"
] | Adjusts the image bias.
Bias determines where the color changes start. At low bias, low
intensities (i.e., low pixel values) will have non-zero color
differences, while at high bias only high pixel values will have
non-zero differences
Args:
bias: float
A... | [
"Adjusts",
"the",
"image",
"bias",
"."
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/fitsviewer/colormap.py#L59-L78 |
OSSOS/MOP | src/ossos/core/ossos/fitsviewer/colormap.py | GrayscaleColorMap.set_contrast | def set_contrast(self, contrast):
"""
Adjusts the image contrast.
Contrast refers to the rate of change of color with color level.
At low contrast, color changes gradually over many intensity
levels, while at high contrast it can change rapidly within a
few levels
... | python | def set_contrast(self, contrast):
"""
Adjusts the image contrast.
Contrast refers to the rate of change of color with color level.
At low contrast, color changes gradually over many intensity
levels, while at high contrast it can change rapidly within a
few levels
... | [
"def",
"set_contrast",
"(",
"self",
",",
"contrast",
")",
":",
"self",
".",
"_contrast",
"=",
"contrast",
"self",
".",
"x_spread",
"=",
"2",
"*",
"(",
"1.0",
"-",
"contrast",
")",
"self",
".",
"y_spread",
"=",
"2.0",
"-",
"2",
"*",
"(",
"1.0",
"-",... | Adjusts the image contrast.
Contrast refers to the rate of change of color with color level.
At low contrast, color changes gradually over many intensity
levels, while at high contrast it can change rapidly within a
few levels
Args:
contrast: float
A numbe... | [
"Adjusts",
"the",
"image",
"contrast",
"."
] | train | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/fitsviewer/colormap.py#L83-L104 |
Accelize/pycosio | pycosio/_core/functions_shutil.py | _copy | def _copy(src, dst, src_is_storage, dst_is_storage):
"""
Copies file from source to destination
Args:
src (str or file-like object): Source file.
dst (str or file-like object): Destination file.
src_is_storage (bool): Source is storage.
dst_is_storage (bool): Destination is ... | python | def _copy(src, dst, src_is_storage, dst_is_storage):
"""
Copies file from source to destination
Args:
src (str or file-like object): Source file.
dst (str or file-like object): Destination file.
src_is_storage (bool): Source is storage.
dst_is_storage (bool): Destination is ... | [
"def",
"_copy",
"(",
"src",
",",
"dst",
",",
"src_is_storage",
",",
"dst_is_storage",
")",
":",
"# If both storage: Tries to perform same storage direct copy",
"if",
"src_is_storage",
"and",
"dst_is_storage",
":",
"system_src",
"=",
"get_instance",
"(",
"src",
")",
"s... | Copies file from source to destination
Args:
src (str or file-like object): Source file.
dst (str or file-like object): Destination file.
src_is_storage (bool): Source is storage.
dst_is_storage (bool): Destination is storage. | [
"Copies",
"file",
"from",
"source",
"to",
"destination"
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_shutil.py#L17-L73 |
Accelize/pycosio | pycosio/_core/functions_shutil.py | copy | def copy(src, dst):
"""
Copies a source file to a destination file or directory.
Equivalent to "shutil.copy".
Source and destination can also be binary opened file-like objects.
Args:
src (path-like object or file-like object): Source file.
dst (path-like object or file-like objec... | python | def copy(src, dst):
"""
Copies a source file to a destination file or directory.
Equivalent to "shutil.copy".
Source and destination can also be binary opened file-like objects.
Args:
src (path-like object or file-like object): Source file.
dst (path-like object or file-like objec... | [
"def",
"copy",
"(",
"src",
",",
"dst",
")",
":",
"# Handles path-like objects and checks if storage",
"src",
",",
"src_is_storage",
"=",
"format_and_is_storage",
"(",
"src",
")",
"dst",
",",
"dst_is_storage",
"=",
"format_and_is_storage",
"(",
"dst",
")",
"# Local f... | Copies a source file to a destination file or directory.
Equivalent to "shutil.copy".
Source and destination can also be binary opened file-like objects.
Args:
src (path-like object or file-like object): Source file.
dst (path-like object or file-like object):
Destination file... | [
"Copies",
"a",
"source",
"file",
"to",
"a",
"destination",
"file",
"or",
"directory",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_shutil.py#L76-L118 |
Accelize/pycosio | pycosio/_core/functions_shutil.py | copyfile | def copyfile(src, dst, follow_symlinks=True):
"""
Copies a source file to a destination file.
Equivalent to "shutil.copyfile".
Source and destination can also be binary opened file-like objects.
Args:
src (path-like object or file-like object): Source file.
dst (path-like object o... | python | def copyfile(src, dst, follow_symlinks=True):
"""
Copies a source file to a destination file.
Equivalent to "shutil.copyfile".
Source and destination can also be binary opened file-like objects.
Args:
src (path-like object or file-like object): Source file.
dst (path-like object o... | [
"def",
"copyfile",
"(",
"src",
",",
"dst",
",",
"follow_symlinks",
"=",
"True",
")",
":",
"# Handles path-like objects and checks if storage",
"src",
",",
"src_is_storage",
"=",
"format_and_is_storage",
"(",
"src",
")",
"dst",
",",
"dst_is_storage",
"=",
"format_and... | Copies a source file to a destination file.
Equivalent to "shutil.copyfile".
Source and destination can also be binary opened file-like objects.
Args:
src (path-like object or file-like object): Source file.
dst (path-like object or file-like object): Destination file.
follow_syml... | [
"Copies",
"a",
"source",
"file",
"to",
"a",
"destination",
"file",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_shutil.py#L121-L158 |
Accelize/pycosio | pycosio/storage/s3.py | _handle_client_error | def _handle_client_error():
"""
Handle boto exception and convert to class
IO exceptions
Raises:
OSError subclasses: IO error.
"""
try:
yield
except _ClientError as exception:
error = exception.response['Error']
if error['Code'] in _ERROR_CODES:
... | python | def _handle_client_error():
"""
Handle boto exception and convert to class
IO exceptions
Raises:
OSError subclasses: IO error.
"""
try:
yield
except _ClientError as exception:
error = exception.response['Error']
if error['Code'] in _ERROR_CODES:
... | [
"def",
"_handle_client_error",
"(",
")",
":",
"try",
":",
"yield",
"except",
"_ClientError",
"as",
"exception",
":",
"error",
"=",
"exception",
".",
"response",
"[",
"'Error'",
"]",
"if",
"error",
"[",
"'Code'",
"]",
"in",
"_ERROR_CODES",
":",
"raise",
"_E... | Handle boto exception and convert to class
IO exceptions
Raises:
OSError subclasses: IO error. | [
"Handle",
"boto",
"exception",
"and",
"convert",
"to",
"class",
"IO",
"exceptions"
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/s3.py#L29-L44 |
Accelize/pycosio | pycosio/storage/s3.py | _S3System.copy | def copy(self, src, dst, other_system=None):
"""
Copy object of the same storage.
Args:
src (str): Path or URL.
dst (str): Path or URL.
other_system (pycosio._core.io_system.SystemBase subclass): Unused.
"""
copy_source = self.get_client_kwarg... | python | def copy(self, src, dst, other_system=None):
"""
Copy object of the same storage.
Args:
src (str): Path or URL.
dst (str): Path or URL.
other_system (pycosio._core.io_system.SystemBase subclass): Unused.
"""
copy_source = self.get_client_kwarg... | [
"def",
"copy",
"(",
"self",
",",
"src",
",",
"dst",
",",
"other_system",
"=",
"None",
")",
":",
"copy_source",
"=",
"self",
".",
"get_client_kwargs",
"(",
"src",
")",
"copy_destination",
"=",
"self",
".",
"get_client_kwargs",
"(",
"dst",
")",
"with",
"_h... | Copy object of the same storage.
Args:
src (str): Path or URL.
dst (str): Path or URL.
other_system (pycosio._core.io_system.SystemBase subclass): Unused. | [
"Copy",
"object",
"of",
"the",
"same",
"storage",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/s3.py#L70-L82 |
Accelize/pycosio | pycosio/storage/s3.py | _S3System.get_client_kwargs | def get_client_kwargs(self, path):
"""
Get base keyword arguments for client for a
specific path.
Args:
path (str): Absolute path or URL.
Returns:
dict: client args
"""
bucket_name, key = self.split_locator(path)
kwargs = dict(Buc... | python | def get_client_kwargs(self, path):
"""
Get base keyword arguments for client for a
specific path.
Args:
path (str): Absolute path or URL.
Returns:
dict: client args
"""
bucket_name, key = self.split_locator(path)
kwargs = dict(Buc... | [
"def",
"get_client_kwargs",
"(",
"self",
",",
"path",
")",
":",
"bucket_name",
",",
"key",
"=",
"self",
".",
"split_locator",
"(",
"path",
")",
"kwargs",
"=",
"dict",
"(",
"Bucket",
"=",
"bucket_name",
")",
"if",
"key",
":",
"kwargs",
"[",
"'Key'",
"]"... | Get base keyword arguments for client for a
specific path.
Args:
path (str): Absolute path or URL.
Returns:
dict: client args | [
"Get",
"base",
"keyword",
"arguments",
"for",
"client",
"for",
"a",
"specific",
"path",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/s3.py#L84-L99 |
Accelize/pycosio | pycosio/storage/s3.py | _S3System._get_session | def _get_session(self):
"""
S3 Boto3 Session.
Returns:
boto3.session.Session: session
"""
if self._session is None:
self._session = _boto3.session.Session(
**self._storage_parameters.get('session', dict()))
return self._session | python | def _get_session(self):
"""
S3 Boto3 Session.
Returns:
boto3.session.Session: session
"""
if self._session is None:
self._session = _boto3.session.Session(
**self._storage_parameters.get('session', dict()))
return self._session | [
"def",
"_get_session",
"(",
"self",
")",
":",
"if",
"self",
".",
"_session",
"is",
"None",
":",
"self",
".",
"_session",
"=",
"_boto3",
".",
"session",
".",
"Session",
"(",
"*",
"*",
"self",
".",
"_storage_parameters",
".",
"get",
"(",
"'session'",
","... | S3 Boto3 Session.
Returns:
boto3.session.Session: session | [
"S3",
"Boto3",
"Session",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/s3.py#L101-L111 |
Accelize/pycosio | pycosio/storage/s3.py | _S3System._get_client | def _get_client(self):
"""
S3 Boto3 client
Returns:
boto3.session.Session.client: client
"""
client_kwargs = self._storage_parameters.get('client', dict())
# Handles unsecure mode
if self._unsecure:
client_kwargs = client_kwargs.copy()
... | python | def _get_client(self):
"""
S3 Boto3 client
Returns:
boto3.session.Session.client: client
"""
client_kwargs = self._storage_parameters.get('client', dict())
# Handles unsecure mode
if self._unsecure:
client_kwargs = client_kwargs.copy()
... | [
"def",
"_get_client",
"(",
"self",
")",
":",
"client_kwargs",
"=",
"self",
".",
"_storage_parameters",
".",
"get",
"(",
"'client'",
",",
"dict",
"(",
")",
")",
"# Handles unsecure mode",
"if",
"self",
".",
"_unsecure",
":",
"client_kwargs",
"=",
"client_kwargs... | S3 Boto3 client
Returns:
boto3.session.Session.client: client | [
"S3",
"Boto3",
"client"
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/s3.py#L113-L127 |
Accelize/pycosio | pycosio/storage/s3.py | _S3System._get_roots | def _get_roots(self):
"""
Return URL roots for this storage.
Returns:
tuple of str or re.Pattern: URL roots
"""
region = self._get_session().region_name or r'[\w-]+'
return (
# S3 scheme
# - s3://<bucket>/<key>
... | python | def _get_roots(self):
"""
Return URL roots for this storage.
Returns:
tuple of str or re.Pattern: URL roots
"""
region = self._get_session().region_name or r'[\w-]+'
return (
# S3 scheme
# - s3://<bucket>/<key>
... | [
"def",
"_get_roots",
"(",
"self",
")",
":",
"region",
"=",
"self",
".",
"_get_session",
"(",
")",
".",
"region_name",
"or",
"r'[\\w-]+'",
"return",
"(",
"# S3 scheme",
"# - s3://<bucket>/<key>",
"'s3://'",
",",
"# Virtual-hosted–style URL",
"# - http://<bucket>.s3.ama... | Return URL roots for this storage.
Returns:
tuple of str or re.Pattern: URL roots | [
"Return",
"URL",
"roots",
"for",
"this",
"storage",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/s3.py#L129-L168 |
Accelize/pycosio | pycosio/storage/s3.py | _S3System._get_time | def _get_time(header, keys, name):
"""
Get time from header
Args:
header (dict): Object header.
keys (tuple of str): Header keys.
name (str): Method name.
Returns:
float: The number of seconds since the epoch
"""
for key i... | python | def _get_time(header, keys, name):
"""
Get time from header
Args:
header (dict): Object header.
keys (tuple of str): Header keys.
name (str): Method name.
Returns:
float: The number of seconds since the epoch
"""
for key i... | [
"def",
"_get_time",
"(",
"header",
",",
"keys",
",",
"name",
")",
":",
"for",
"key",
"in",
"keys",
":",
"try",
":",
"return",
"_to_timestamp",
"(",
"header",
".",
"pop",
"(",
"key",
")",
")",
"except",
"KeyError",
":",
"continue",
"raise",
"_Unsupporte... | Get time from header
Args:
header (dict): Object header.
keys (tuple of str): Header keys.
name (str): Method name.
Returns:
float: The number of seconds since the epoch | [
"Get",
"time",
"from",
"header"
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/s3.py#L171-L188 |
Accelize/pycosio | pycosio/storage/s3.py | _S3System._head | def _head(self, client_kwargs):
"""
Returns object or bucket HTTP header.
Args:
client_kwargs (dict): Client arguments.
Returns:
dict: HTTP header.
"""
with _handle_client_error():
# Object
if 'Key' in client_kwargs:
... | python | def _head(self, client_kwargs):
"""
Returns object or bucket HTTP header.
Args:
client_kwargs (dict): Client arguments.
Returns:
dict: HTTP header.
"""
with _handle_client_error():
# Object
if 'Key' in client_kwargs:
... | [
"def",
"_head",
"(",
"self",
",",
"client_kwargs",
")",
":",
"with",
"_handle_client_error",
"(",
")",
":",
"# Object",
"if",
"'Key'",
"in",
"client_kwargs",
":",
"header",
"=",
"self",
".",
"client",
".",
"head_object",
"(",
"*",
"*",
"client_kwargs",
")"... | Returns object or bucket HTTP header.
Args:
client_kwargs (dict): Client arguments.
Returns:
dict: HTTP header. | [
"Returns",
"object",
"or",
"bucket",
"HTTP",
"header",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/s3.py#L205-L227 |
Accelize/pycosio | pycosio/storage/s3.py | _S3System._make_dir | def _make_dir(self, client_kwargs):
"""
Make a directory.
args:
client_kwargs (dict): Client arguments.
"""
with _handle_client_error():
# Object
if 'Key' in client_kwargs:
return self.client.put_object(Body=b'', **client_kwarg... | python | def _make_dir(self, client_kwargs):
"""
Make a directory.
args:
client_kwargs (dict): Client arguments.
"""
with _handle_client_error():
# Object
if 'Key' in client_kwargs:
return self.client.put_object(Body=b'', **client_kwarg... | [
"def",
"_make_dir",
"(",
"self",
",",
"client_kwargs",
")",
":",
"with",
"_handle_client_error",
"(",
")",
":",
"# Object",
"if",
"'Key'",
"in",
"client_kwargs",
":",
"return",
"self",
".",
"client",
".",
"put_object",
"(",
"Body",
"=",
"b''",
",",
"*",
... | Make a directory.
args:
client_kwargs (dict): Client arguments. | [
"Make",
"a",
"directory",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/s3.py#L229-L245 |
Accelize/pycosio | pycosio/storage/s3.py | _S3System._remove | def _remove(self, client_kwargs):
"""
Remove an object.
args:
client_kwargs (dict): Client arguments.
"""
with _handle_client_error():
# Object
if 'Key' in client_kwargs:
return self.client.delete_object(**client_kwargs)
... | python | def _remove(self, client_kwargs):
"""
Remove an object.
args:
client_kwargs (dict): Client arguments.
"""
with _handle_client_error():
# Object
if 'Key' in client_kwargs:
return self.client.delete_object(**client_kwargs)
... | [
"def",
"_remove",
"(",
"self",
",",
"client_kwargs",
")",
":",
"with",
"_handle_client_error",
"(",
")",
":",
"# Object",
"if",
"'Key'",
"in",
"client_kwargs",
":",
"return",
"self",
".",
"client",
".",
"delete_object",
"(",
"*",
"*",
"client_kwargs",
")",
... | Remove an object.
args:
client_kwargs (dict): Client arguments. | [
"Remove",
"an",
"object",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/s3.py#L247-L260 |
Accelize/pycosio | pycosio/storage/s3.py | _S3System._list_locators | def _list_locators(self):
"""
Lists locators.
Returns:
generator of tuple: locator name str, locator header dict
"""
with _handle_client_error():
response = self.client.list_buckets()
for bucket in response['Buckets']:
yield bucket.po... | python | def _list_locators(self):
"""
Lists locators.
Returns:
generator of tuple: locator name str, locator header dict
"""
with _handle_client_error():
response = self.client.list_buckets()
for bucket in response['Buckets']:
yield bucket.po... | [
"def",
"_list_locators",
"(",
"self",
")",
":",
"with",
"_handle_client_error",
"(",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"list_buckets",
"(",
")",
"for",
"bucket",
"in",
"response",
"[",
"'Buckets'",
"]",
":",
"yield",
"bucket",
".",
"... | Lists locators.
Returns:
generator of tuple: locator name str, locator header dict | [
"Lists",
"locators",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/s3.py#L262-L273 |
Accelize/pycosio | pycosio/storage/s3.py | _S3System._list_objects | def _list_objects(self, client_kwargs, path, max_request_entries):
"""
Lists objects.
args:
client_kwargs (dict): Client arguments.
path (str): Path relative to current locator.
max_request_entries (int): If specified, maximum entries returned
... | python | def _list_objects(self, client_kwargs, path, max_request_entries):
"""
Lists objects.
args:
client_kwargs (dict): Client arguments.
path (str): Path relative to current locator.
max_request_entries (int): If specified, maximum entries returned
... | [
"def",
"_list_objects",
"(",
"self",
",",
"client_kwargs",
",",
"path",
",",
"max_request_entries",
")",
":",
"client_kwargs",
"=",
"client_kwargs",
".",
"copy",
"(",
")",
"if",
"max_request_entries",
":",
"client_kwargs",
"[",
"'MaxKeys'",
"]",
"=",
"max_reques... | Lists objects.
args:
client_kwargs (dict): Client arguments.
path (str): Path relative to current locator.
max_request_entries (int): If specified, maximum entries returned
by request.
Returns:
generator of tuple: object name str, object ... | [
"Lists",
"objects",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/s3.py#L275-L309 |
Accelize/pycosio | pycosio/storage/s3.py | S3RawIO._read_range | def _read_range(self, start, end=0):
"""
Read a range of bytes in stream.
Args:
start (int): Start stream position.
end (int): End stream position.
0 To not specify end.
Returns:
bytes: number of bytes read
"""
# Get o... | python | def _read_range(self, start, end=0):
"""
Read a range of bytes in stream.
Args:
start (int): Start stream position.
end (int): End stream position.
0 To not specify end.
Returns:
bytes: number of bytes read
"""
# Get o... | [
"def",
"_read_range",
"(",
"self",
",",
"start",
",",
"end",
"=",
"0",
")",
":",
"# Get object part from S3",
"try",
":",
"with",
"_handle_client_error",
"(",
")",
":",
"response",
"=",
"self",
".",
"_client",
".",
"get_object",
"(",
"Range",
"=",
"self",
... | Read a range of bytes in stream.
Args:
start (int): Start stream position.
end (int): End stream position.
0 To not specify end.
Returns:
bytes: number of bytes read | [
"Read",
"a",
"range",
"of",
"bytes",
"in",
"stream",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/s3.py#L331-L357 |
Accelize/pycosio | pycosio/storage/s3.py | S3RawIO._flush | def _flush(self, buffer):
"""
Flush the write buffers of the stream if applicable.
Args:
buffer (memoryview): Buffer content.
"""
with _handle_client_error():
self._client.put_object(
Body=buffer.tobytes(), **self._client_kwargs) | python | def _flush(self, buffer):
"""
Flush the write buffers of the stream if applicable.
Args:
buffer (memoryview): Buffer content.
"""
with _handle_client_error():
self._client.put_object(
Body=buffer.tobytes(), **self._client_kwargs) | [
"def",
"_flush",
"(",
"self",
",",
"buffer",
")",
":",
"with",
"_handle_client_error",
"(",
")",
":",
"self",
".",
"_client",
".",
"put_object",
"(",
"Body",
"=",
"buffer",
".",
"tobytes",
"(",
")",
",",
"*",
"*",
"self",
".",
"_client_kwargs",
")"
] | Flush the write buffers of the stream if applicable.
Args:
buffer (memoryview): Buffer content. | [
"Flush",
"the",
"write",
"buffers",
"of",
"the",
"stream",
"if",
"applicable",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/s3.py#L369-L378 |
Accelize/pycosio | pycosio/storage/s3.py | S3BufferedIO._flush | def _flush(self):
"""
Flush the write buffers of the stream.
"""
# Initialize multi-part upload
if 'UploadId' not in self._upload_args:
with _handle_client_error():
self._upload_args[
'UploadId'] = self._client.create_multipart_uplo... | python | def _flush(self):
"""
Flush the write buffers of the stream.
"""
# Initialize multi-part upload
if 'UploadId' not in self._upload_args:
with _handle_client_error():
self._upload_args[
'UploadId'] = self._client.create_multipart_uplo... | [
"def",
"_flush",
"(",
"self",
")",
":",
"# Initialize multi-part upload",
"if",
"'UploadId'",
"not",
"in",
"self",
".",
"_upload_args",
":",
"with",
"_handle_client_error",
"(",
")",
":",
"self",
".",
"_upload_args",
"[",
"'UploadId'",
"]",
"=",
"self",
".",
... | Flush the write buffers of the stream. | [
"Flush",
"the",
"write",
"buffers",
"of",
"the",
"stream",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/s3.py#L416-L434 |
Accelize/pycosio | pycosio/storage/s3.py | S3BufferedIO._close_writable | def _close_writable(self):
"""
Close the object in write mode.
"""
# Wait parts upload completion
for part in self._write_futures:
part['ETag'] = part.pop('response').result()['ETag']
# Complete multipart upload
with _handle_client_error():
... | python | def _close_writable(self):
"""
Close the object in write mode.
"""
# Wait parts upload completion
for part in self._write_futures:
part['ETag'] = part.pop('response').result()['ETag']
# Complete multipart upload
with _handle_client_error():
... | [
"def",
"_close_writable",
"(",
"self",
")",
":",
"# Wait parts upload completion",
"for",
"part",
"in",
"self",
".",
"_write_futures",
":",
"part",
"[",
"'ETag'",
"]",
"=",
"part",
".",
"pop",
"(",
"'response'",
")",
".",
"result",
"(",
")",
"[",
"'ETag'",... | Close the object in write mode. | [
"Close",
"the",
"object",
"in",
"write",
"mode",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/s3.py#L436-L456 |
Accelize/pycosio | pycosio/storage/azure.py | _handle_azure_exception | def _handle_azure_exception():
"""
Handles Azure exception and convert to class IO exceptions
Raises:
OSError subclasses: IO error.
"""
try:
yield
except _AzureHttpError as exception:
if exception.status_code in _ERROR_CODES:
raise _ERROR_CODES[exception.sta... | python | def _handle_azure_exception():
"""
Handles Azure exception and convert to class IO exceptions
Raises:
OSError subclasses: IO error.
"""
try:
yield
except _AzureHttpError as exception:
if exception.status_code in _ERROR_CODES:
raise _ERROR_CODES[exception.sta... | [
"def",
"_handle_azure_exception",
"(",
")",
":",
"try",
":",
"yield",
"except",
"_AzureHttpError",
"as",
"exception",
":",
"if",
"exception",
".",
"status_code",
"in",
"_ERROR_CODES",
":",
"raise",
"_ERROR_CODES",
"[",
"exception",
".",
"status_code",
"]",
"(",
... | Handles Azure exception and convert to class IO exceptions
Raises:
OSError subclasses: IO error. | [
"Handles",
"Azure",
"exception",
"and",
"convert",
"to",
"class",
"IO",
"exceptions"
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure.py#L32-L45 |
Accelize/pycosio | pycosio/storage/azure.py | _properties_model_to_dict | def _properties_model_to_dict(properties):
"""
Convert properties model to dict.
Args:
properties: Properties model.
Returns:
dict: Converted model.
"""
result = {}
for attr in properties.__dict__:
value = getattr(properties, attr)
if hasattr(value, '__modu... | python | def _properties_model_to_dict(properties):
"""
Convert properties model to dict.
Args:
properties: Properties model.
Returns:
dict: Converted model.
"""
result = {}
for attr in properties.__dict__:
value = getattr(properties, attr)
if hasattr(value, '__modu... | [
"def",
"_properties_model_to_dict",
"(",
"properties",
")",
":",
"result",
"=",
"{",
"}",
"for",
"attr",
"in",
"properties",
".",
"__dict__",
":",
"value",
"=",
"getattr",
"(",
"properties",
",",
"attr",
")",
"if",
"hasattr",
"(",
"value",
",",
"'__module_... | Convert properties model to dict.
Args:
properties: Properties model.
Returns:
dict: Converted model. | [
"Convert",
"properties",
"model",
"to",
"dict",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure.py#L48-L68 |
Accelize/pycosio | pycosio/storage/azure.py | _AzureBaseSystem._get_endpoint | def _get_endpoint(self, sub_domain):
"""
Get endpoint information from storage parameters.
Update system with endpoint information and return information required
to define roots.
Args:
self (pycosio._core.io_system.SystemBase subclass): System.
sub_doma... | python | def _get_endpoint(self, sub_domain):
"""
Get endpoint information from storage parameters.
Update system with endpoint information and return information required
to define roots.
Args:
self (pycosio._core.io_system.SystemBase subclass): System.
sub_doma... | [
"def",
"_get_endpoint",
"(",
"self",
",",
"sub_domain",
")",
":",
"storage_parameters",
"=",
"self",
".",
"_storage_parameters",
"or",
"dict",
"(",
")",
"account_name",
"=",
"storage_parameters",
".",
"get",
"(",
"'account_name'",
")",
"if",
"not",
"account_name... | Get endpoint information from storage parameters.
Update system with endpoint information and return information required
to define roots.
Args:
self (pycosio._core.io_system.SystemBase subclass): System.
sub_domain (str): Azure storage sub-domain.
Returns:
... | [
"Get",
"endpoint",
"information",
"from",
"storage",
"parameters",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure.py#L112-L138 |
Accelize/pycosio | pycosio/storage/azure.py | _AzureBaseSystem._secured_storage_parameters | def _secured_storage_parameters(self):
"""
Updates storage parameters with unsecure mode.
Returns:
dict: Updated storage_parameters.
"""
parameters = self._storage_parameters or dict()
# Handles unsecure mode
if self._unsecure:
parameters... | python | def _secured_storage_parameters(self):
"""
Updates storage parameters with unsecure mode.
Returns:
dict: Updated storage_parameters.
"""
parameters = self._storage_parameters or dict()
# Handles unsecure mode
if self._unsecure:
parameters... | [
"def",
"_secured_storage_parameters",
"(",
"self",
")",
":",
"parameters",
"=",
"self",
".",
"_storage_parameters",
"or",
"dict",
"(",
")",
"# Handles unsecure mode",
"if",
"self",
".",
"_unsecure",
":",
"parameters",
"=",
"parameters",
".",
"copy",
"(",
")",
... | Updates storage parameters with unsecure mode.
Returns:
dict: Updated storage_parameters. | [
"Updates",
"storage",
"parameters",
"with",
"unsecure",
"mode",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure.py#L140-L154 |
Accelize/pycosio | pycosio/storage/azure.py | _AzureBaseSystem._format_src_url | def _format_src_url(self, path, caller_system):
"""
Ensure path is absolute and use the correct URL format for use with
cross Azure storage account copy function.
Args:
path (str): Path or URL.
caller_system (pycosio.storage.azure._AzureBaseSystem subclass):
... | python | def _format_src_url(self, path, caller_system):
"""
Ensure path is absolute and use the correct URL format for use with
cross Azure storage account copy function.
Args:
path (str): Path or URL.
caller_system (pycosio.storage.azure._AzureBaseSystem subclass):
... | [
"def",
"_format_src_url",
"(",
"self",
",",
"path",
",",
"caller_system",
")",
":",
"path",
"=",
"'%s/%s'",
"%",
"(",
"self",
".",
"_endpoint",
",",
"self",
".",
"relpath",
"(",
"path",
")",
")",
"# If SAS token available, use it to give cross account copy access.... | Ensure path is absolute and use the correct URL format for use with
cross Azure storage account copy function.
Args:
path (str): Path or URL.
caller_system (pycosio.storage.azure._AzureBaseSystem subclass):
System calling this method (Can be another Azure system)... | [
"Ensure",
"path",
"is",
"absolute",
"and",
"use",
"the",
"correct",
"URL",
"format",
"for",
"use",
"with",
"cross",
"Azure",
"storage",
"account",
"copy",
"function",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure.py#L156-L178 |
Accelize/pycosio | pycosio/storage/azure.py | _AzureBaseSystem._update_listing_client_kwargs | def _update_listing_client_kwargs(client_kwargs, max_request_entries):
"""
Updates client kwargs for listing functions.
Args:
client_kwargs (dict): Client arguments.
max_request_entries (int): If specified, maximum entries returned
by request.
Re... | python | def _update_listing_client_kwargs(client_kwargs, max_request_entries):
"""
Updates client kwargs for listing functions.
Args:
client_kwargs (dict): Client arguments.
max_request_entries (int): If specified, maximum entries returned
by request.
Re... | [
"def",
"_update_listing_client_kwargs",
"(",
"client_kwargs",
",",
"max_request_entries",
")",
":",
"client_kwargs",
"=",
"client_kwargs",
".",
"copy",
"(",
")",
"if",
"max_request_entries",
":",
"client_kwargs",
"[",
"'num_results'",
"]",
"=",
"max_request_entries",
... | Updates client kwargs for listing functions.
Args:
client_kwargs (dict): Client arguments.
max_request_entries (int): If specified, maximum entries returned
by request.
Returns:
dict: Updated client_kwargs | [
"Updates",
"client",
"kwargs",
"for",
"listing",
"functions",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure.py#L181-L196 |
Accelize/pycosio | pycosio/storage/azure.py | _AzureBaseSystem._model_to_dict | def _model_to_dict(obj):
"""
Convert object model to dict.
Args:
obj: Object model.
Returns:
dict: Converted model.
"""
result = _properties_model_to_dict(obj.properties)
for attribute in ('metadata', 'snapshot'):
try:
... | python | def _model_to_dict(obj):
"""
Convert object model to dict.
Args:
obj: Object model.
Returns:
dict: Converted model.
"""
result = _properties_model_to_dict(obj.properties)
for attribute in ('metadata', 'snapshot'):
try:
... | [
"def",
"_model_to_dict",
"(",
"obj",
")",
":",
"result",
"=",
"_properties_model_to_dict",
"(",
"obj",
".",
"properties",
")",
"for",
"attribute",
"in",
"(",
"'metadata'",
",",
"'snapshot'",
")",
":",
"try",
":",
"value",
"=",
"getattr",
"(",
"obj",
",",
... | Convert object model to dict.
Args:
obj: Object model.
Returns:
dict: Converted model. | [
"Convert",
"object",
"model",
"to",
"dict",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure.py#L199-L217 |
Accelize/pycosio | pycosio/storage/azure.py | _AzureStorageRawIOBase._read_range | def _read_range(self, start, end=0):
"""
Read a range of bytes in stream.
Args:
start (int): Start stream position.
end (int): End stream position.
0 To not specify end.
Returns:
bytes: number of bytes read
"""
stream ... | python | def _read_range(self, start, end=0):
"""
Read a range of bytes in stream.
Args:
start (int): Start stream position.
end (int): End stream position.
0 To not specify end.
Returns:
bytes: number of bytes read
"""
stream ... | [
"def",
"_read_range",
"(",
"self",
",",
"start",
",",
"end",
"=",
"0",
")",
":",
"stream",
"=",
"_BytesIO",
"(",
")",
"try",
":",
"with",
"_handle_azure_exception",
"(",
")",
":",
"self",
".",
"_get_to_stream",
"(",
"stream",
"=",
"stream",
",",
"start... | Read a range of bytes in stream.
Args:
start (int): Start stream position.
end (int): End stream position.
0 To not specify end.
Returns:
bytes: number of bytes read | [
"Read",
"a",
"range",
"of",
"bytes",
"in",
"stream",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure.py#L235-L261 |
Accelize/pycosio | pycosio/storage/azure.py | _AzureStorageRawIOBase._readall | def _readall(self):
"""
Read and return all the bytes from the stream until EOF.
Returns:
bytes: Object content
"""
stream = _BytesIO()
with _handle_azure_exception():
self._get_to_stream(stream=stream, **self._client_kwargs)
return stream... | python | def _readall(self):
"""
Read and return all the bytes from the stream until EOF.
Returns:
bytes: Object content
"""
stream = _BytesIO()
with _handle_azure_exception():
self._get_to_stream(stream=stream, **self._client_kwargs)
return stream... | [
"def",
"_readall",
"(",
"self",
")",
":",
"stream",
"=",
"_BytesIO",
"(",
")",
"with",
"_handle_azure_exception",
"(",
")",
":",
"self",
".",
"_get_to_stream",
"(",
"stream",
"=",
"stream",
",",
"*",
"*",
"self",
".",
"_client_kwargs",
")",
"return",
"st... | Read and return all the bytes from the stream until EOF.
Returns:
bytes: Object content | [
"Read",
"and",
"return",
"all",
"the",
"bytes",
"from",
"the",
"stream",
"until",
"EOF",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure.py#L263-L273 |
Accelize/pycosio | pycosio/storage/azure.py | _AzureStorageRawIORangeWriteBase._init_append | def _init_append(self):
"""
Initializes file on 'a' mode.
"""
if self._content_length:
# Adjust size if content length specified
with _handle_azure_exception():
self._resize(
content_length=self._content_length, **self._client_k... | python | def _init_append(self):
"""
Initializes file on 'a' mode.
"""
if self._content_length:
# Adjust size if content length specified
with _handle_azure_exception():
self._resize(
content_length=self._content_length, **self._client_k... | [
"def",
"_init_append",
"(",
"self",
")",
":",
"if",
"self",
".",
"_content_length",
":",
"# Adjust size if content length specified",
"with",
"_handle_azure_exception",
"(",
")",
":",
"self",
".",
"_resize",
"(",
"content_length",
"=",
"self",
".",
"_content_length"... | Initializes file on 'a' mode. | [
"Initializes",
"file",
"on",
"a",
"mode",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure.py#L317-L329 |
Accelize/pycosio | pycosio/storage/azure.py | _AzureStorageRawIORangeWriteBase._create | def _create(self):
"""
Create the file if not exists.
"""
# Create new file
with _handle_azure_exception():
self._create_from_size(
content_length=self._content_length, **self._client_kwargs) | python | def _create(self):
"""
Create the file if not exists.
"""
# Create new file
with _handle_azure_exception():
self._create_from_size(
content_length=self._content_length, **self._client_kwargs) | [
"def",
"_create",
"(",
"self",
")",
":",
"# Create new file",
"with",
"_handle_azure_exception",
"(",
")",
":",
"self",
".",
"_create_from_size",
"(",
"content_length",
"=",
"self",
".",
"_content_length",
",",
"*",
"*",
"self",
".",
"_client_kwargs",
")"
] | Create the file if not exists. | [
"Create",
"the",
"file",
"if",
"not",
"exists",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure.py#L331-L338 |
Accelize/pycosio | pycosio/storage/azure.py | _AzureStorageRawIORangeWriteBase._flush | def _flush(self, buffer, start, end):
"""
Flush the write buffer of the stream if applicable.
Args:
buffer (memoryview): Buffer content.
start (int): Start of buffer position to flush.
Supported only with page blobs.
end (int): End of buffer p... | python | def _flush(self, buffer, start, end):
"""
Flush the write buffer of the stream if applicable.
Args:
buffer (memoryview): Buffer content.
start (int): Start of buffer position to flush.
Supported only with page blobs.
end (int): End of buffer p... | [
"def",
"_flush",
"(",
"self",
",",
"buffer",
",",
"start",
",",
"end",
")",
":",
"buffer_size",
"=",
"len",
"(",
"buffer",
")",
"if",
"not",
"buffer_size",
":",
"return",
"# Write range normally",
"with",
"self",
".",
"_size_lock",
":",
"if",
"end",
">",... | Flush the write buffer of the stream if applicable.
Args:
buffer (memoryview): Buffer content.
start (int): Start of buffer position to flush.
Supported only with page blobs.
end (int): End of buffer position to flush.
Supported only with page... | [
"Flush",
"the",
"write",
"buffer",
"of",
"the",
"stream",
"if",
"applicable",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure.py#L349-L402 |
Accelize/pycosio | pycosio/_core/io_base.py | memoizedmethod | def memoizedmethod(method):
"""
Decorator that caches method result.
Args:
method (function): Method
Returns:
function: Memoized method.
Notes:
Target method class needs as "_cache" attribute (dict).
It is the case of "ObjectIOBase" and all its subclasses.
"""... | python | def memoizedmethod(method):
"""
Decorator that caches method result.
Args:
method (function): Method
Returns:
function: Memoized method.
Notes:
Target method class needs as "_cache" attribute (dict).
It is the case of "ObjectIOBase" and all its subclasses.
"""... | [
"def",
"memoizedmethod",
"(",
"method",
")",
":",
"method_name",
"=",
"method",
".",
"__name__",
"@",
"wraps",
"(",
"method",
")",
"def",
"patched",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Patched method\"\"\"",
"# Gets val... | Decorator that caches method result.
Args:
method (function): Method
Returns:
function: Memoized method.
Notes:
Target method class needs as "_cache" attribute (dict).
It is the case of "ObjectIOBase" and all its subclasses. | [
"Decorator",
"that",
"caches",
"method",
"result",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base.py#L120-L150 |
Accelize/pycosio | pycosio/_core/io_base.py | WorkerPoolBase._generate_async | def _generate_async(self, generator):
"""
Return the previous generator object after having run the first element
evaluation as a background task.
Args:
generator (iterable): A generator function.
Returns:
iterable: The generator function with first elem... | python | def _generate_async(self, generator):
"""
Return the previous generator object after having run the first element
evaluation as a background task.
Args:
generator (iterable): A generator function.
Returns:
iterable: The generator function with first elem... | [
"def",
"_generate_async",
"(",
"self",
",",
"generator",
")",
":",
"first_value_future",
"=",
"self",
".",
"_workers",
".",
"submit",
"(",
"next",
",",
"generator",
")",
"def",
"get_first_element",
"(",
"future",
"=",
"first_value_future",
")",
":",
"\"\"\"\n ... | Return the previous generator object after having run the first element
evaluation as a background task.
Args:
generator (iterable): A generator function.
Returns:
iterable: The generator function with first element evaluated
in background. | [
"Return",
"the",
"previous",
"generator",
"object",
"after",
"having",
"run",
"the",
"first",
"element",
"evaluation",
"as",
"a",
"background",
"task",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base.py#L174-L203 |
Accelize/pycosio | pycosio/storage/swift.py | _handle_client_exception | def _handle_client_exception():
"""
Handle Swift exception and convert to class
IO exceptions
Raises:
OSError subclasses: IO error.
"""
try:
yield
except _ClientException as exception:
if exception.http_status in _ERROR_CODES:
raise _ERROR_CODES[exceptio... | python | def _handle_client_exception():
"""
Handle Swift exception and convert to class
IO exceptions
Raises:
OSError subclasses: IO error.
"""
try:
yield
except _ClientException as exception:
if exception.http_status in _ERROR_CODES:
raise _ERROR_CODES[exceptio... | [
"def",
"_handle_client_exception",
"(",
")",
":",
"try",
":",
"yield",
"except",
"_ClientException",
"as",
"exception",
":",
"if",
"exception",
".",
"http_status",
"in",
"_ERROR_CODES",
":",
"raise",
"_ERROR_CODES",
"[",
"exception",
".",
"http_status",
"]",
"("... | Handle Swift exception and convert to class
IO exceptions
Raises:
OSError subclasses: IO error. | [
"Handle",
"Swift",
"exception",
"and",
"convert",
"to",
"class",
"IO",
"exceptions"
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/swift.py#L24-L39 |
Accelize/pycosio | pycosio/storage/swift.py | _SwiftSystem.copy | def copy(self, src, dst, other_system=None):
"""
Copy object of the same storage.
Args:
src (str): Path or URL.
dst (str): Path or URL.
other_system (pycosio._core.io_system.SystemBase subclass): Unused.
"""
container, obj = self.split_locator... | python | def copy(self, src, dst, other_system=None):
"""
Copy object of the same storage.
Args:
src (str): Path or URL.
dst (str): Path or URL.
other_system (pycosio._core.io_system.SystemBase subclass): Unused.
"""
container, obj = self.split_locator... | [
"def",
"copy",
"(",
"self",
",",
"src",
",",
"dst",
",",
"other_system",
"=",
"None",
")",
":",
"container",
",",
"obj",
"=",
"self",
".",
"split_locator",
"(",
"src",
")",
"with",
"_handle_client_exception",
"(",
")",
":",
"self",
".",
"client",
".",
... | Copy object of the same storage.
Args:
src (str): Path or URL.
dst (str): Path or URL.
other_system (pycosio._core.io_system.SystemBase subclass): Unused. | [
"Copy",
"object",
"of",
"the",
"same",
"storage",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/swift.py#L56-L68 |
Accelize/pycosio | pycosio/storage/swift.py | _SwiftSystem.get_client_kwargs | def get_client_kwargs(self, path):
"""
Get base keyword arguments for client for a
specific path.
Args:
path (str): Absolute path or URL.
Returns:
dict: client args
"""
container, obj = self.split_locator(path)
kwargs = dict(conta... | python | def get_client_kwargs(self, path):
"""
Get base keyword arguments for client for a
specific path.
Args:
path (str): Absolute path or URL.
Returns:
dict: client args
"""
container, obj = self.split_locator(path)
kwargs = dict(conta... | [
"def",
"get_client_kwargs",
"(",
"self",
",",
"path",
")",
":",
"container",
",",
"obj",
"=",
"self",
".",
"split_locator",
"(",
"path",
")",
"kwargs",
"=",
"dict",
"(",
"container",
"=",
"container",
")",
"if",
"obj",
":",
"kwargs",
"[",
"'obj'",
"]",... | Get base keyword arguments for client for a
specific path.
Args:
path (str): Absolute path or URL.
Returns:
dict: client args | [
"Get",
"base",
"keyword",
"arguments",
"for",
"client",
"for",
"a",
"specific",
"path",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/swift.py#L70-L85 |
Accelize/pycosio | pycosio/storage/swift.py | _SwiftSystem._get_client | def _get_client(self):
"""
Swift client
Returns:
swiftclient.client.Connection: client
"""
kwargs = self._storage_parameters
# Handles unsecure mode
if self._unsecure:
kwargs = kwargs.copy()
kwargs['ssl_compression'] = False
... | python | def _get_client(self):
"""
Swift client
Returns:
swiftclient.client.Connection: client
"""
kwargs = self._storage_parameters
# Handles unsecure mode
if self._unsecure:
kwargs = kwargs.copy()
kwargs['ssl_compression'] = False
... | [
"def",
"_get_client",
"(",
"self",
")",
":",
"kwargs",
"=",
"self",
".",
"_storage_parameters",
"# Handles unsecure mode",
"if",
"self",
".",
"_unsecure",
":",
"kwargs",
"=",
"kwargs",
".",
"copy",
"(",
")",
"kwargs",
"[",
"'ssl_compression'",
"]",
"=",
"Fal... | Swift client
Returns:
swiftclient.client.Connection: client | [
"Swift",
"client"
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/swift.py#L87-L101 |
Accelize/pycosio | pycosio/storage/swift.py | _SwiftSystem._head | def _head(self, client_kwargs):
"""
Returns object HTTP header.
Args:
client_kwargs (dict): Client arguments.
Returns:
dict: HTTP header.
"""
with _handle_client_exception():
# Object
if 'obj' in client_kwargs:
... | python | def _head(self, client_kwargs):
"""
Returns object HTTP header.
Args:
client_kwargs (dict): Client arguments.
Returns:
dict: HTTP header.
"""
with _handle_client_exception():
# Object
if 'obj' in client_kwargs:
... | [
"def",
"_head",
"(",
"self",
",",
"client_kwargs",
")",
":",
"with",
"_handle_client_exception",
"(",
")",
":",
"# Object",
"if",
"'obj'",
"in",
"client_kwargs",
":",
"return",
"self",
".",
"client",
".",
"head_object",
"(",
"*",
"*",
"client_kwargs",
")",
... | Returns object HTTP header.
Args:
client_kwargs (dict): Client arguments.
Returns:
dict: HTTP header. | [
"Returns",
"object",
"HTTP",
"header",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/swift.py#L115-L131 |
Accelize/pycosio | pycosio/storage/swift.py | _SwiftSystem._make_dir | def _make_dir(self, client_kwargs):
"""
Make a directory.
args:
client_kwargs (dict): Client arguments.
"""
with _handle_client_exception():
# Object
if 'obj' in client_kwargs:
return self.client.put_object(
... | python | def _make_dir(self, client_kwargs):
"""
Make a directory.
args:
client_kwargs (dict): Client arguments.
"""
with _handle_client_exception():
# Object
if 'obj' in client_kwargs:
return self.client.put_object(
... | [
"def",
"_make_dir",
"(",
"self",
",",
"client_kwargs",
")",
":",
"with",
"_handle_client_exception",
"(",
")",
":",
"# Object",
"if",
"'obj'",
"in",
"client_kwargs",
":",
"return",
"self",
".",
"client",
".",
"put_object",
"(",
"client_kwargs",
"[",
"'containe... | Make a directory.
args:
client_kwargs (dict): Client arguments. | [
"Make",
"a",
"directory",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/swift.py#L133-L147 |
Accelize/pycosio | pycosio/storage/swift.py | _SwiftSystem._remove | def _remove(self, client_kwargs):
"""
Remove an object.
args:
client_kwargs (dict): Client arguments.
"""
with _handle_client_exception():
# Object
if 'obj' in client_kwargs:
return self.client.delete_object(
... | python | def _remove(self, client_kwargs):
"""
Remove an object.
args:
client_kwargs (dict): Client arguments.
"""
with _handle_client_exception():
# Object
if 'obj' in client_kwargs:
return self.client.delete_object(
... | [
"def",
"_remove",
"(",
"self",
",",
"client_kwargs",
")",
":",
"with",
"_handle_client_exception",
"(",
")",
":",
"# Object",
"if",
"'obj'",
"in",
"client_kwargs",
":",
"return",
"self",
".",
"client",
".",
"delete_object",
"(",
"client_kwargs",
"[",
"'contain... | Remove an object.
args:
client_kwargs (dict): Client arguments. | [
"Remove",
"an",
"object",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/swift.py#L149-L163 |
Accelize/pycosio | pycosio/storage/swift.py | _SwiftSystem._list_locators | def _list_locators(self):
"""
Lists locators.
Returns:
generator of tuple: locator name str, locator header dict
"""
with _handle_client_exception():
response = self.client.get_account()
for container in response[1]:
yield container.p... | python | def _list_locators(self):
"""
Lists locators.
Returns:
generator of tuple: locator name str, locator header dict
"""
with _handle_client_exception():
response = self.client.get_account()
for container in response[1]:
yield container.p... | [
"def",
"_list_locators",
"(",
"self",
")",
":",
"with",
"_handle_client_exception",
"(",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"get_account",
"(",
")",
"for",
"container",
"in",
"response",
"[",
"1",
"]",
":",
"yield",
"container",
".",
... | Lists locators.
Returns:
generator of tuple: locator name str, locator header dict | [
"Lists",
"locators",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/swift.py#L165-L176 |
Accelize/pycosio | pycosio/storage/swift.py | _SwiftSystem._list_objects | def _list_objects(self, client_kwargs, path, max_request_entries):
"""
Lists objects.
args:
client_kwargs (dict): Client arguments.
path (str): Path relative to current locator.
max_request_entries (int): If specified, maximum entries returned
... | python | def _list_objects(self, client_kwargs, path, max_request_entries):
"""
Lists objects.
args:
client_kwargs (dict): Client arguments.
path (str): Path relative to current locator.
max_request_entries (int): If specified, maximum entries returned
... | [
"def",
"_list_objects",
"(",
"self",
",",
"client_kwargs",
",",
"path",
",",
"max_request_entries",
")",
":",
"kwargs",
"=",
"dict",
"(",
"prefix",
"=",
"path",
")",
"if",
"max_request_entries",
":",
"kwargs",
"[",
"'limit'",
"]",
"=",
"max_request_entries",
... | Lists objects.
args:
client_kwargs (dict): Client arguments.
path (str): Path relative to current locator.
max_request_entries (int): If specified, maximum entries returned
by request.
Returns:
generator of tuple: object name str, object ... | [
"Lists",
"objects",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/swift.py#L178-L202 |
Accelize/pycosio | pycosio/storage/swift.py | SwiftRawIO._read_range | def _read_range(self, start, end=0):
"""
Read a range of bytes in stream.
Args:
start (int): Start stream position.
end (int): End stream position.
0 To not specify end.
Returns:
bytes: number of bytes read
"""
try:
... | python | def _read_range(self, start, end=0):
"""
Read a range of bytes in stream.
Args:
start (int): Start stream position.
end (int): End stream position.
0 To not specify end.
Returns:
bytes: number of bytes read
"""
try:
... | [
"def",
"_read_range",
"(",
"self",
",",
"start",
",",
"end",
"=",
"0",
")",
":",
"try",
":",
"with",
"_handle_client_exception",
"(",
")",
":",
"return",
"self",
".",
"_client",
".",
"get_object",
"(",
"*",
"self",
".",
"_client_args",
",",
"headers",
... | Read a range of bytes in stream.
Args:
start (int): Start stream position.
end (int): End stream position.
0 To not specify end.
Returns:
bytes: number of bytes read | [
"Read",
"a",
"range",
"of",
"bytes",
"in",
"stream",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/swift.py#L235-L256 |
Accelize/pycosio | pycosio/storage/swift.py | SwiftRawIO._flush | def _flush(self, buffer):
"""
Flush the write buffers of the stream if applicable.
Args:
buffer (memoryview): Buffer content.
"""
container, obj = self._client_args
with _handle_client_exception():
self._client.put_object(container, obj, buffer) | python | def _flush(self, buffer):
"""
Flush the write buffers of the stream if applicable.
Args:
buffer (memoryview): Buffer content.
"""
container, obj = self._client_args
with _handle_client_exception():
self._client.put_object(container, obj, buffer) | [
"def",
"_flush",
"(",
"self",
",",
"buffer",
")",
":",
"container",
",",
"obj",
"=",
"self",
".",
"_client_args",
"with",
"_handle_client_exception",
"(",
")",
":",
"self",
".",
"_client",
".",
"put_object",
"(",
"container",
",",
"obj",
",",
"buffer",
"... | Flush the write buffers of the stream if applicable.
Args:
buffer (memoryview): Buffer content. | [
"Flush",
"the",
"write",
"buffers",
"of",
"the",
"stream",
"if",
"applicable",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/swift.py#L268-L277 |
Accelize/pycosio | pycosio/storage/swift.py | SwiftBufferedIO._flush | def _flush(self):
"""
Flush the write buffers of the stream.
"""
# Upload segment with workers
name = self._segment_name % self._seek
response = self._workers.submit(
self._client.put_object, self._container, name,
self._get_buffer())
# Sa... | python | def _flush(self):
"""
Flush the write buffers of the stream.
"""
# Upload segment with workers
name = self._segment_name % self._seek
response = self._workers.submit(
self._client.put_object, self._container, name,
self._get_buffer())
# Sa... | [
"def",
"_flush",
"(",
"self",
")",
":",
"# Upload segment with workers",
"name",
"=",
"self",
".",
"_segment_name",
"%",
"self",
".",
"_seek",
"response",
"=",
"self",
".",
"_workers",
".",
"submit",
"(",
"self",
".",
"_client",
".",
"put_object",
",",
"se... | Flush the write buffers of the stream. | [
"Flush",
"the",
"write",
"buffers",
"of",
"the",
"stream",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/swift.py#L306-L318 |
Accelize/pycosio | pycosio/storage/swift.py | SwiftBufferedIO._close_writable | def _close_writable(self):
"""
Close the object in write mode.
"""
# Wait segments upload completion
for segment in self._write_futures:
segment['etag'] = segment['etag'].result()
# Upload manifest file
with _handle_client_exception():
sel... | python | def _close_writable(self):
"""
Close the object in write mode.
"""
# Wait segments upload completion
for segment in self._write_futures:
segment['etag'] = segment['etag'].result()
# Upload manifest file
with _handle_client_exception():
sel... | [
"def",
"_close_writable",
"(",
"self",
")",
":",
"# Wait segments upload completion",
"for",
"segment",
"in",
"self",
".",
"_write_futures",
":",
"segment",
"[",
"'etag'",
"]",
"=",
"segment",
"[",
"'etag'",
"]",
".",
"result",
"(",
")",
"# Upload manifest file"... | Close the object in write mode. | [
"Close",
"the",
"object",
"in",
"write",
"mode",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/swift.py#L320-L331 |
Accelize/pycosio | pycosio/_core/io_base_raw.py | ObjectRawIOBase._init_append | def _init_append(self):
"""
Initializes file on 'a' mode.
"""
# Require to load the full file content in buffer
self._write_buffer[:] = self._readall()
# Make initial seek position to current end of file
self._seek = self._size | python | def _init_append(self):
"""
Initializes file on 'a' mode.
"""
# Require to load the full file content in buffer
self._write_buffer[:] = self._readall()
# Make initial seek position to current end of file
self._seek = self._size | [
"def",
"_init_append",
"(",
"self",
")",
":",
"# Require to load the full file content in buffer",
"self",
".",
"_write_buffer",
"[",
":",
"]",
"=",
"self",
".",
"_readall",
"(",
")",
"# Make initial seek position to current end of file",
"self",
".",
"_seek",
"=",
"s... | Initializes file on 'a' mode. | [
"Initializes",
"file",
"on",
"a",
"mode",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_raw.py#L117-L125 |
Accelize/pycosio | pycosio/_core/io_base_raw.py | ObjectRawIOBase.close | def close(self):
"""
Flush the write buffers of the stream if applicable and
close the object.
"""
if self._writable and not self._is_raw_of_buffered and not self._closed:
self._closed = True
if self._write_buffer:
self.flush() | python | def close(self):
"""
Flush the write buffers of the stream if applicable and
close the object.
"""
if self._writable and not self._is_raw_of_buffered and not self._closed:
self._closed = True
if self._write_buffer:
self.flush() | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_writable",
"and",
"not",
"self",
".",
"_is_raw_of_buffered",
"and",
"not",
"self",
".",
"_closed",
":",
"self",
".",
"_closed",
"=",
"True",
"if",
"self",
".",
"_write_buffer",
":",
"self",
".... | Flush the write buffers of the stream if applicable and
close the object. | [
"Flush",
"the",
"write",
"buffers",
"of",
"the",
"stream",
"if",
"applicable",
"and",
"close",
"the",
"object",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_raw.py#L137-L145 |
Accelize/pycosio | pycosio/_core/io_base_raw.py | ObjectRawIOBase._peek | def _peek(self, size=-1):
"""
Return bytes from the stream without advancing the position.
Args:
size (int): Number of bytes to read. -1 to read the full
stream.
Returns:
bytes: bytes read
"""
with self._seek_lock:
see... | python | def _peek(self, size=-1):
"""
Return bytes from the stream without advancing the position.
Args:
size (int): Number of bytes to read. -1 to read the full
stream.
Returns:
bytes: bytes read
"""
with self._seek_lock:
see... | [
"def",
"_peek",
"(",
"self",
",",
"size",
"=",
"-",
"1",
")",
":",
"with",
"self",
".",
"_seek_lock",
":",
"seek",
"=",
"self",
".",
"_seek",
"with",
"handle_os_exceptions",
"(",
")",
":",
"return",
"self",
".",
"_read_range",
"(",
"seek",
",",
"seek... | Return bytes from the stream without advancing the position.
Args:
size (int): Number of bytes to read. -1 to read the full
stream.
Returns:
bytes: bytes read | [
"Return",
"bytes",
"from",
"the",
"stream",
"without",
"advancing",
"the",
"position",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_raw.py#L246-L260 |
Accelize/pycosio | pycosio/_core/io_base_raw.py | ObjectRawIOBase.readall | def readall(self):
"""
Read and return all the bytes from the stream until EOF.
Returns:
bytes: Object content
"""
if not self._readable:
raise UnsupportedOperation('read')
with self._seek_lock:
# Get data starting from seek
... | python | def readall(self):
"""
Read and return all the bytes from the stream until EOF.
Returns:
bytes: Object content
"""
if not self._readable:
raise UnsupportedOperation('read')
with self._seek_lock:
# Get data starting from seek
... | [
"def",
"readall",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_readable",
":",
"raise",
"UnsupportedOperation",
"(",
"'read'",
")",
"with",
"self",
".",
"_seek_lock",
":",
"# Get data starting from seek",
"with",
"handle_os_exceptions",
"(",
")",
":",
"i... | Read and return all the bytes from the stream until EOF.
Returns:
bytes: Object content | [
"Read",
"and",
"return",
"all",
"the",
"bytes",
"from",
"the",
"stream",
"until",
"EOF",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_raw.py#L262-L284 |
Accelize/pycosio | pycosio/_core/io_base_raw.py | ObjectRawIOBase.readinto | def readinto(self, b):
"""
Read bytes into a pre-allocated, writable bytes-like object b,
and return the number of bytes read.
Args:
b (bytes-like object): buffer.
Returns:
int: number of bytes read
"""
if not self._readable:
... | python | def readinto(self, b):
"""
Read bytes into a pre-allocated, writable bytes-like object b,
and return the number of bytes read.
Args:
b (bytes-like object): buffer.
Returns:
int: number of bytes read
"""
if not self._readable:
... | [
"def",
"readinto",
"(",
"self",
",",
"b",
")",
":",
"if",
"not",
"self",
".",
"_readable",
":",
"raise",
"UnsupportedOperation",
"(",
"'read'",
")",
"# Get and update stream positions",
"size",
"=",
"len",
"(",
"b",
")",
"with",
"self",
".",
"_seek_lock",
... | Read bytes into a pre-allocated, writable bytes-like object b,
and return the number of bytes read.
Args:
b (bytes-like object): buffer.
Returns:
int: number of bytes read | [
"Read",
"bytes",
"into",
"a",
"pre",
"-",
"allocated",
"writable",
"bytes",
"-",
"like",
"object",
"b",
"and",
"return",
"the",
"number",
"of",
"bytes",
"read",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_raw.py#L295-L331 |
Accelize/pycosio | pycosio/_core/io_base_raw.py | ObjectRawIOBase.seek | def seek(self, offset, whence=SEEK_SET):
"""
Change the stream position to the given byte offset.
Args:
offset (int): Offset is interpreted relative to the position
indicated by whence.
whence (int): The default value for whence is SEEK_SET.
... | python | def seek(self, offset, whence=SEEK_SET):
"""
Change the stream position to the given byte offset.
Args:
offset (int): Offset is interpreted relative to the position
indicated by whence.
whence (int): The default value for whence is SEEK_SET.
... | [
"def",
"seek",
"(",
"self",
",",
"offset",
",",
"whence",
"=",
"SEEK_SET",
")",
":",
"if",
"not",
"self",
".",
"_seekable",
":",
"raise",
"UnsupportedOperation",
"(",
"'seek'",
")",
"seek",
"=",
"self",
".",
"_update_seek",
"(",
"offset",
",",
"whence",
... | Change the stream position to the given byte offset.
Args:
offset (int): Offset is interpreted relative to the position
indicated by whence.
whence (int): The default value for whence is SEEK_SET.
Values for whence are:
SEEK_SET or 0 – sta... | [
"Change",
"the",
"stream",
"position",
"to",
"the",
"given",
"byte",
"offset",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_raw.py#L347-L377 |
Accelize/pycosio | pycosio/_core/io_base_raw.py | ObjectRawIOBase._update_seek | def _update_seek(self, offset, whence):
"""
Update seek value.
Args:
offset (int): Offset.
whence (int): Whence.
Returns:
int: Seek position.
"""
with self._seek_lock:
if whence == SEEK_SET:
self._seek = of... | python | def _update_seek(self, offset, whence):
"""
Update seek value.
Args:
offset (int): Offset.
whence (int): Whence.
Returns:
int: Seek position.
"""
with self._seek_lock:
if whence == SEEK_SET:
self._seek = of... | [
"def",
"_update_seek",
"(",
"self",
",",
"offset",
",",
"whence",
")",
":",
"with",
"self",
".",
"_seek_lock",
":",
"if",
"whence",
"==",
"SEEK_SET",
":",
"self",
".",
"_seek",
"=",
"offset",
"elif",
"whence",
"==",
"SEEK_CUR",
":",
"self",
".",
"_seek... | Update seek value.
Args:
offset (int): Offset.
whence (int): Whence.
Returns:
int: Seek position. | [
"Update",
"seek",
"value",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_raw.py#L379-L399 |
Accelize/pycosio | pycosio/_core/io_base_raw.py | ObjectRawIOBase.write | def write(self, b):
"""
Write the given bytes-like object, b, to the underlying raw stream,
and return the number of bytes written.
Args:
b (bytes-like object): Bytes to write.
Returns:
int: The number of bytes written.
"""
if not self._w... | python | def write(self, b):
"""
Write the given bytes-like object, b, to the underlying raw stream,
and return the number of bytes written.
Args:
b (bytes-like object): Bytes to write.
Returns:
int: The number of bytes written.
"""
if not self._w... | [
"def",
"write",
"(",
"self",
",",
"b",
")",
":",
"if",
"not",
"self",
".",
"_writable",
":",
"raise",
"UnsupportedOperation",
"(",
"'write'",
")",
"# This function write data in a buffer",
"# \"flush()\" need to be called to really write content on",
"# Cloud Storage",
"s... | Write the given bytes-like object, b, to the underlying raw stream,
and return the number of bytes written.
Args:
b (bytes-like object): Bytes to write.
Returns:
int: The number of bytes written. | [
"Write",
"the",
"given",
"bytes",
"-",
"like",
"object",
"b",
"to",
"the",
"underlying",
"raw",
"stream",
"and",
"return",
"the",
"number",
"of",
"bytes",
"written",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_raw.py#L401-L428 |
Accelize/pycosio | pycosio/storage/http.py | _handle_http_errors | def _handle_http_errors(response):
"""
Check for HTTP errors and raise
OSError if relevant.
Args:
response (requests.Response):
Returns:
requests.Response: response
"""
code = response.status_code
if 200 <= code < 400:
return response
elif code in (403, 404)... | python | def _handle_http_errors(response):
"""
Check for HTTP errors and raise
OSError if relevant.
Args:
response (requests.Response):
Returns:
requests.Response: response
"""
code = response.status_code
if 200 <= code < 400:
return response
elif code in (403, 404)... | [
"def",
"_handle_http_errors",
"(",
"response",
")",
":",
"code",
"=",
"response",
".",
"status_code",
"if",
"200",
"<=",
"code",
"<",
"400",
":",
"return",
"response",
"elif",
"code",
"in",
"(",
"403",
",",
"404",
")",
":",
"raise",
"{",
"403",
":",
... | Check for HTTP errors and raise
OSError if relevant.
Args:
response (requests.Response):
Returns:
requests.Response: response | [
"Check",
"for",
"HTTP",
"errors",
"and",
"raise",
"OSError",
"if",
"relevant",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/http.py#L16-L33 |
Accelize/pycosio | pycosio/storage/http.py | _HTTPSystem._head | def _head(self, client_kwargs):
"""
Returns object HTTP header.
Args:
client_kwargs (dict): Client arguments.
Returns:
dict: HTTP header.
"""
return _handle_http_errors(
self.client.request(
'HEAD', timeout=self._TIMEO... | python | def _head(self, client_kwargs):
"""
Returns object HTTP header.
Args:
client_kwargs (dict): Client arguments.
Returns:
dict: HTTP header.
"""
return _handle_http_errors(
self.client.request(
'HEAD', timeout=self._TIMEO... | [
"def",
"_head",
"(",
"self",
",",
"client_kwargs",
")",
":",
"return",
"_handle_http_errors",
"(",
"self",
".",
"client",
".",
"request",
"(",
"'HEAD'",
",",
"timeout",
"=",
"self",
".",
"_TIMEOUT",
",",
"*",
"*",
"client_kwargs",
")",
")",
".",
"headers... | Returns object HTTP header.
Args:
client_kwargs (dict): Client arguments.
Returns:
dict: HTTP header. | [
"Returns",
"object",
"HTTP",
"header",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/http.py#L75-L87 |
Accelize/pycosio | pycosio/storage/http.py | HTTPRawIO._read_range | def _read_range(self, start, end=0):
"""
Read a range of bytes in stream.
Args:
start (int): Start stream position.
end (int): End stream position.
0 To not specify end.
Returns:
bytes: number of bytes read
"""
# Get o... | python | def _read_range(self, start, end=0):
"""
Read a range of bytes in stream.
Args:
start (int): Start stream position.
end (int): End stream position.
0 To not specify end.
Returns:
bytes: number of bytes read
"""
# Get o... | [
"def",
"_read_range",
"(",
"self",
",",
"start",
",",
"end",
"=",
"0",
")",
":",
"# Get object part",
"response",
"=",
"self",
".",
"_client",
".",
"request",
"(",
"'GET'",
",",
"self",
".",
"name",
",",
"headers",
"=",
"dict",
"(",
"Range",
"=",
"se... | Read a range of bytes in stream.
Args:
start (int): Start stream position.
end (int): End stream position.
0 To not specify end.
Returns:
bytes: number of bytes read | [
"Read",
"a",
"range",
"of",
"bytes",
"in",
"stream",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/http.py#L111-L133 |
Accelize/pycosio | pycosio/storage/http.py | HTTPRawIO._readall | def _readall(self):
"""
Read and return all the bytes from the stream until EOF.
Returns:
bytes: Object content
"""
return _handle_http_errors(
self._client.request(
'GET', self.name, timeout=self._TIMEOUT)).content | python | def _readall(self):
"""
Read and return all the bytes from the stream until EOF.
Returns:
bytes: Object content
"""
return _handle_http_errors(
self._client.request(
'GET', self.name, timeout=self._TIMEOUT)).content | [
"def",
"_readall",
"(",
"self",
")",
":",
"return",
"_handle_http_errors",
"(",
"self",
".",
"_client",
".",
"request",
"(",
"'GET'",
",",
"self",
".",
"name",
",",
"timeout",
"=",
"self",
".",
"_TIMEOUT",
")",
")",
".",
"content"
] | Read and return all the bytes from the stream until EOF.
Returns:
bytes: Object content | [
"Read",
"and",
"return",
"all",
"the",
"bytes",
"from",
"the",
"stream",
"until",
"EOF",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/http.py#L135-L144 |
Accelize/pycosio | pycosio/_core/io_random_write.py | ObjectRawIORandomWriteBase.flush | def flush(self):
"""
Flush the write buffers of the stream if applicable and
save the object on the cloud.
"""
if self._writable:
with self._seek_lock:
buffer = self._get_buffer()
# Flush that part of the file
end = sel... | python | def flush(self):
"""
Flush the write buffers of the stream if applicable and
save the object on the cloud.
"""
if self._writable:
with self._seek_lock:
buffer = self._get_buffer()
# Flush that part of the file
end = sel... | [
"def",
"flush",
"(",
"self",
")",
":",
"if",
"self",
".",
"_writable",
":",
"with",
"self",
".",
"_seek_lock",
":",
"buffer",
"=",
"self",
".",
"_get_buffer",
"(",
")",
"# Flush that part of the file",
"end",
"=",
"self",
".",
"_seek",
"start",
"=",
"end... | Flush the write buffers of the stream if applicable and
save the object on the cloud. | [
"Flush",
"the",
"write",
"buffers",
"of",
"the",
"stream",
"if",
"applicable",
"and",
"save",
"the",
"object",
"on",
"the",
"cloud",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_random_write.py#L26-L44 |
Accelize/pycosio | pycosio/_core/io_random_write.py | ObjectRawIORandomWriteBase.seek | def seek(self, offset, whence=SEEK_SET):
"""
Change the stream position to the given byte offset.
Args:
offset (int): Offset is interpreted relative to the position
indicated by whence.
whence (int): The default value for whence is SEEK_SET.
... | python | def seek(self, offset, whence=SEEK_SET):
"""
Change the stream position to the given byte offset.
Args:
offset (int): Offset is interpreted relative to the position
indicated by whence.
whence (int): The default value for whence is SEEK_SET.
... | [
"def",
"seek",
"(",
"self",
",",
"offset",
",",
"whence",
"=",
"SEEK_SET",
")",
":",
"if",
"not",
"self",
".",
"_seekable",
":",
"raise",
"UnsupportedOperation",
"(",
"'seek'",
")",
"# Flush before moving position",
"self",
".",
"flush",
"(",
")",
"return",
... | Change the stream position to the given byte offset.
Args:
offset (int): Offset is interpreted relative to the position
indicated by whence.
whence (int): The default value for whence is SEEK_SET.
Values for whence are:
SEEK_SET or 0 – sta... | [
"Change",
"the",
"stream",
"position",
"to",
"the",
"given",
"byte",
"offset",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_random_write.py#L65-L90 |
Accelize/pycosio | pycosio/_core/io_random_write.py | ObjectBufferedIORandomWriteBase._flush | def _flush(self):
"""
Flush the write buffers of the stream if applicable.
In write mode, send the buffer content to the cloud object.
"""
# Flush buffer to specified range
buffer = self._get_buffer()
start = self._buffer_size * (self._seek - 1)
end = sta... | python | def _flush(self):
"""
Flush the write buffers of the stream if applicable.
In write mode, send the buffer content to the cloud object.
"""
# Flush buffer to specified range
buffer = self._get_buffer()
start = self._buffer_size * (self._seek - 1)
end = sta... | [
"def",
"_flush",
"(",
"self",
")",
":",
"# Flush buffer to specified range",
"buffer",
"=",
"self",
".",
"_get_buffer",
"(",
")",
"start",
"=",
"self",
".",
"_buffer_size",
"*",
"(",
"self",
".",
"_seek",
"-",
"1",
")",
"end",
"=",
"start",
"+",
"len",
... | Flush the write buffers of the stream if applicable.
In write mode, send the buffer content to the cloud object. | [
"Flush",
"the",
"write",
"buffers",
"of",
"the",
"stream",
"if",
"applicable",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_random_write.py#L101-L115 |
Accelize/pycosio | pycosio/_core/io_random_write.py | ObjectBufferedIORandomWriteBase._update_size | def _update_size(self, size, future):
"""
Keep track of the file size during writing.
If specified size value is greater than the current size, update the
current size using specified value.
Used as callback in default "_flush" implementation for files supporting
random... | python | def _update_size(self, size, future):
"""
Keep track of the file size during writing.
If specified size value is greater than the current size, update the
current size using specified value.
Used as callback in default "_flush" implementation for files supporting
random... | [
"def",
"_update_size",
"(",
"self",
",",
"size",
",",
"future",
")",
":",
"with",
"self",
".",
"_size_lock",
":",
"# Update value",
"if",
"size",
">",
"self",
".",
"_size",
"and",
"future",
".",
"done",
":",
"# Size can be lower if seek down on an 'a' mode open ... | Keep track of the file size during writing.
If specified size value is greater than the current size, update the
current size using specified value.
Used as callback in default "_flush" implementation for files supporting
random write access.
Args:
size (int): Size... | [
"Keep",
"track",
"of",
"the",
"file",
"size",
"during",
"writing",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_random_write.py#L117-L135 |
Accelize/pycosio | pycosio/_core/io_random_write.py | ObjectBufferedIORandomWriteBase._flush_range | def _flush_range(self, buffer, start, end):
"""
Flush a buffer to a range of the file.
Meant to be used asynchronously, used to provides parallel flushing of
file parts when applicable.
Args:
buffer (memoryview): Buffer content.
start (int): Start of buf... | python | def _flush_range(self, buffer, start, end):
"""
Flush a buffer to a range of the file.
Meant to be used asynchronously, used to provides parallel flushing of
file parts when applicable.
Args:
buffer (memoryview): Buffer content.
start (int): Start of buf... | [
"def",
"_flush_range",
"(",
"self",
",",
"buffer",
",",
"start",
",",
"end",
")",
":",
"# On first call, Get file size if exists",
"with",
"self",
".",
"_size_lock",
":",
"if",
"not",
"self",
".",
"_size_synched",
":",
"self",
".",
"_size_synched",
"=",
"True"... | Flush a buffer to a range of the file.
Meant to be used asynchronously, used to provides parallel flushing of
file parts when applicable.
Args:
buffer (memoryview): Buffer content.
start (int): Start of buffer position to flush.
end (int): End of buffer posi... | [
"Flush",
"a",
"buffer",
"to",
"a",
"range",
"of",
"the",
"file",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_random_write.py#L137-L165 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.