partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | EventEmitter._dispatch_coroutine | Schedule a coroutine for execution.
Args:
event (str): The name of the event that triggered this call.
listener (async def): The async def that needs to be executed.
*args: Any number of positional arguments.
**kwargs: Any number of keyword arguments.
Th... | eventemitter/emitter.py | def _dispatch_coroutine(self, event, listener, *args, **kwargs):
"""Schedule a coroutine for execution.
Args:
event (str): The name of the event that triggered this call.
listener (async def): The async def that needs to be executed.
*args: Any number of positional a... | def _dispatch_coroutine(self, event, listener, *args, **kwargs):
"""Schedule a coroutine for execution.
Args:
event (str): The name of the event that triggered this call.
listener (async def): The async def that needs to be executed.
*args: Any number of positional a... | [
"Schedule",
"a",
"coroutine",
"for",
"execution",
"."
] | asyncdef/eventemitter | python | https://github.com/asyncdef/eventemitter/blob/148b700c5846d8fdafc562d4326587da5447223f/eventemitter/emitter.py#L159-L190 | [
"def",
"_dispatch_coroutine",
"(",
"self",
",",
"event",
",",
"listener",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"coro",
"=",
"listener",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
"Exception",
"as",
"exc",
... | 148b700c5846d8fdafc562d4326587da5447223f |
valid | EventEmitter._dispatch_function | Execute a sync function.
Args:
event (str): The name of the event that triggered this call.
listener (def): The def that needs to be executed.
*args: Any number of positional arguments.
**kwargs: Any number of keyword arguments.
The values of *args and *... | eventemitter/emitter.py | def _dispatch_function(self, event, listener, *args, **kwargs):
"""Execute a sync function.
Args:
event (str): The name of the event that triggered this call.
listener (def): The def that needs to be executed.
*args: Any number of positional arguments.
**... | def _dispatch_function(self, event, listener, *args, **kwargs):
"""Execute a sync function.
Args:
event (str): The name of the event that triggered this call.
listener (def): The def that needs to be executed.
*args: Any number of positional arguments.
**... | [
"Execute",
"a",
"sync",
"function",
"."
] | asyncdef/eventemitter | python | https://github.com/asyncdef/eventemitter/blob/148b700c5846d8fdafc562d4326587da5447223f/eventemitter/emitter.py#L192-L218 | [
"def",
"_dispatch_function",
"(",
"self",
",",
"event",
",",
"listener",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"listener",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
"Exception",
"as",
"exc",
":",
... | 148b700c5846d8fdafc562d4326587da5447223f |
valid | EventEmitter._dispatch | Dispatch an event to a listener.
Args:
event (str): The name of the event that triggered this call.
listener (def or async def): The listener to trigger.
*args: Any number of positional arguments.
**kwargs: Any number of keyword arguments.
This method in... | eventemitter/emitter.py | def _dispatch(self, event, listener, *args, **kwargs):
"""Dispatch an event to a listener.
Args:
event (str): The name of the event that triggered this call.
listener (def or async def): The listener to trigger.
*args: Any number of positional arguments.
... | def _dispatch(self, event, listener, *args, **kwargs):
"""Dispatch an event to a listener.
Args:
event (str): The name of the event that triggered this call.
listener (def or async def): The listener to trigger.
*args: Any number of positional arguments.
... | [
"Dispatch",
"an",
"event",
"to",
"a",
"listener",
"."
] | asyncdef/eventemitter | python | https://github.com/asyncdef/eventemitter/blob/148b700c5846d8fdafc562d4326587da5447223f/eventemitter/emitter.py#L220-L242 | [
"def",
"_dispatch",
"(",
"self",
",",
"event",
",",
"listener",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"(",
"asyncio",
".",
"iscoroutinefunction",
"(",
"listener",
")",
"or",
"isinstance",
"(",
"listener",
",",
"functools",
".",
"pa... | 148b700c5846d8fdafc562d4326587da5447223f |
valid | EventEmitter.emit | Call each listener for the event with the given arguments.
Args:
event (str): The event to trigger listeners on.
*args: Any number of positional arguments.
**kwargs: Any number of keyword arguments.
This method passes all arguments other than the event name directly... | eventemitter/emitter.py | def emit(self, event, *args, **kwargs):
"""Call each listener for the event with the given arguments.
Args:
event (str): The event to trigger listeners on.
*args: Any number of positional arguments.
**kwargs: Any number of keyword arguments.
This method pass... | def emit(self, event, *args, **kwargs):
"""Call each listener for the event with the given arguments.
Args:
event (str): The event to trigger listeners on.
*args: Any number of positional arguments.
**kwargs: Any number of keyword arguments.
This method pass... | [
"Call",
"each",
"listener",
"for",
"the",
"event",
"with",
"the",
"given",
"arguments",
"."
] | asyncdef/eventemitter | python | https://github.com/asyncdef/eventemitter/blob/148b700c5846d8fdafc562d4326587da5447223f/eventemitter/emitter.py#L244-L277 | [
"def",
"emit",
"(",
"self",
",",
"event",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"listeners",
"=",
"self",
".",
"_listeners",
"[",
"event",
"]",
"listeners",
"=",
"itertools",
".",
"chain",
"(",
"listeners",
",",
"self",
".",
"_once",
... | 148b700c5846d8fdafc562d4326587da5447223f |
valid | EventEmitter.count | Get the number of listeners for the event.
Args:
event (str): The event for which to count all listeners.
The resulting count is a combination of listeners added using
'on'/'add_listener' and 'once'. | eventemitter/emitter.py | def count(self, event):
"""Get the number of listeners for the event.
Args:
event (str): The event for which to count all listeners.
The resulting count is a combination of listeners added using
'on'/'add_listener' and 'once'.
"""
return len(self._listeners[... | def count(self, event):
"""Get the number of listeners for the event.
Args:
event (str): The event for which to count all listeners.
The resulting count is a combination of listeners added using
'on'/'add_listener' and 'once'.
"""
return len(self._listeners[... | [
"Get",
"the",
"number",
"of",
"listeners",
"for",
"the",
"event",
"."
] | asyncdef/eventemitter | python | https://github.com/asyncdef/eventemitter/blob/148b700c5846d8fdafc562d4326587da5447223f/eventemitter/emitter.py#L279-L288 | [
"def",
"count",
"(",
"self",
",",
"event",
")",
":",
"return",
"len",
"(",
"self",
".",
"_listeners",
"[",
"event",
"]",
")",
"+",
"len",
"(",
"self",
".",
"_once",
"[",
"event",
"]",
")"
] | 148b700c5846d8fdafc562d4326587da5447223f |
valid | ABF2.phasicTonic | let's keep the chunkMs as high as we reasonably can. 50ms is good.
Things get flakey at lower numbers like 10ms.
IMPORTANT! for this to work, prevent 0s from averaging in, so keep
bin sizes well above the data resolution. | doc/uses/EPSCs-and-IPSCs/variance method/2016-12-17 02 graphTime2.py | def phasicTonic(self,m1=None,m2=None,chunkMs=50,quietPercentile=10,
histResolution=.5,plotToo=False):
"""
let's keep the chunkMs as high as we reasonably can. 50ms is good.
Things get flakey at lower numbers like 10ms.
IMPORTANT! for this to work, prevent 0s... | def phasicTonic(self,m1=None,m2=None,chunkMs=50,quietPercentile=10,
histResolution=.5,plotToo=False):
"""
let's keep the chunkMs as high as we reasonably can. 50ms is good.
Things get flakey at lower numbers like 10ms.
IMPORTANT! for this to work, prevent 0s... | [
"let",
"s",
"keep",
"the",
"chunkMs",
"as",
"high",
"as",
"we",
"reasonably",
"can",
".",
"50ms",
"is",
"good",
".",
"Things",
"get",
"flakey",
"at",
"lower",
"numbers",
"like",
"10ms",
".",
"IMPORTANT!",
"for",
"this",
"to",
"work",
"prevent",
"0s",
"... | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/uses/EPSCs-and-IPSCs/variance method/2016-12-17 02 graphTime2.py#L10-L90 | [
"def",
"phasicTonic",
"(",
"self",
",",
"m1",
"=",
"None",
",",
"m2",
"=",
"None",
",",
"chunkMs",
"=",
"50",
",",
"quietPercentile",
"=",
"10",
",",
"histResolution",
"=",
".5",
",",
"plotToo",
"=",
"False",
")",
":",
"# prepare sectioning values to be us... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | genPNGs | Convert each TIF to PNG. Return filenames of new PNGs. | doc/oldcode/indexing/indexing.py | def genPNGs(folder,files=None):
"""Convert each TIF to PNG. Return filenames of new PNGs."""
if files is None:
files=glob.glob(folder+"/*.*")
new=[]
for fname in files:
ext=os.path.basename(fname).split(".")[-1].lower()
if ext in ['tif','tiff']:
if not os.path.exists(... | def genPNGs(folder,files=None):
"""Convert each TIF to PNG. Return filenames of new PNGs."""
if files is None:
files=glob.glob(folder+"/*.*")
new=[]
for fname in files:
ext=os.path.basename(fname).split(".")[-1].lower()
if ext in ['tif','tiff']:
if not os.path.exists(... | [
"Convert",
"each",
"TIF",
"to",
"PNG",
".",
"Return",
"filenames",
"of",
"new",
"PNGs",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/indexing/indexing.py#L23-L38 | [
"def",
"genPNGs",
"(",
"folder",
",",
"files",
"=",
"None",
")",
":",
"if",
"files",
"is",
"None",
":",
"files",
"=",
"glob",
".",
"glob",
"(",
"folder",
"+",
"\"/*.*\"",
")",
"new",
"=",
"[",
"]",
"for",
"fname",
"in",
"files",
":",
"ext",
"=",
... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | htmlABFcontent | generate text to go inside <body> for single ABF page. | doc/oldcode/indexing/indexing.py | def htmlABFcontent(ID,group,d):
"""generate text to go inside <body> for single ABF page."""
html=""
files=[]
for abfID in group:
files.extend(d[abfID])
files=sorted(files)
#start with root images
html+="<hr>"
for fname in files:
if ".png" in fname.lower() and not "swhla... | def htmlABFcontent(ID,group,d):
"""generate text to go inside <body> for single ABF page."""
html=""
files=[]
for abfID in group:
files.extend(d[abfID])
files=sorted(files)
#start with root images
html+="<hr>"
for fname in files:
if ".png" in fname.lower() and not "swhla... | [
"generate",
"text",
"to",
"go",
"inside",
"<body",
">",
"for",
"single",
"ABF",
"page",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/indexing/indexing.py#L40-L111 | [
"def",
"htmlABFcontent",
"(",
"ID",
",",
"group",
",",
"d",
")",
":",
"html",
"=",
"\"\"",
"files",
"=",
"[",
"]",
"for",
"abfID",
"in",
"group",
":",
"files",
".",
"extend",
"(",
"d",
"[",
"abfID",
"]",
")",
"files",
"=",
"sorted",
"(",
"files",... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | htmlABF | given an ID and the dict of files, generate a static html for that abf. | doc/oldcode/indexing/indexing.py | def htmlABF(ID,group,d,folder,overwrite=False):
"""given an ID and the dict of files, generate a static html for that abf."""
fname=folder+"/swhlab4/%s_index.html"%ID
if overwrite is False and os.path.exists(fname):
return
html=TEMPLATES['abf']
html=html.replace("~ID~",ID)
html=html.repl... | def htmlABF(ID,group,d,folder,overwrite=False):
"""given an ID and the dict of files, generate a static html for that abf."""
fname=folder+"/swhlab4/%s_index.html"%ID
if overwrite is False and os.path.exists(fname):
return
html=TEMPLATES['abf']
html=html.replace("~ID~",ID)
html=html.repl... | [
"given",
"an",
"ID",
"and",
"the",
"dict",
"of",
"files",
"generate",
"a",
"static",
"html",
"for",
"that",
"abf",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/indexing/indexing.py#L113-L124 | [
"def",
"htmlABF",
"(",
"ID",
",",
"group",
",",
"d",
",",
"folder",
",",
"overwrite",
"=",
"False",
")",
":",
"fname",
"=",
"folder",
"+",
"\"/swhlab4/%s_index.html\"",
"%",
"ID",
"if",
"overwrite",
"is",
"False",
"and",
"os",
".",
"path",
".",
"exists... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | expMenu | read experiment.txt and return a dict with [firstOfNewExp, color, star, comments]. | doc/oldcode/indexing/indexing.py | def expMenu(groups,folder):
"""read experiment.txt and return a dict with [firstOfNewExp, color, star, comments]."""
### GENERATE THE MENU DATA BASED ON EXPERIMENT FILE
orphans = sorted(list(groups.keys()))
menu=[]
if os.path.exists(folder+'/experiment.txt'):
with open(folder+'/experiment.tx... | def expMenu(groups,folder):
"""read experiment.txt and return a dict with [firstOfNewExp, color, star, comments]."""
### GENERATE THE MENU DATA BASED ON EXPERIMENT FILE
orphans = sorted(list(groups.keys()))
menu=[]
if os.path.exists(folder+'/experiment.txt'):
with open(folder+'/experiment.tx... | [
"read",
"experiment",
".",
"txt",
"and",
"return",
"a",
"dict",
"with",
"[",
"firstOfNewExp",
"color",
"star",
"comments",
"]",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/indexing/indexing.py#L184-L228 | [
"def",
"expMenu",
"(",
"groups",
",",
"folder",
")",
":",
"### GENERATE THE MENU DATA BASED ON EXPERIMENT FILE",
"orphans",
"=",
"sorted",
"(",
"list",
"(",
"groups",
".",
"keys",
"(",
")",
")",
")",
"menu",
"=",
"[",
"]",
"if",
"os",
".",
"path",
".",
"... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | genIndex | expects a folder of ABFs. | doc/oldcode/indexing/indexing.py | def genIndex(folder,forceIDs=[]):
"""expects a folder of ABFs."""
if not os.path.exists(folder+"/swhlab4/"):
print(" !! cannot index if no /swhlab4/")
return
timestart=cm.timethis()
files=glob.glob(folder+"/*.*") #ABF folder
files.extend(glob.glob(folder+"/swhlab4/*.*"))
print(" ... | def genIndex(folder,forceIDs=[]):
"""expects a folder of ABFs."""
if not os.path.exists(folder+"/swhlab4/"):
print(" !! cannot index if no /swhlab4/")
return
timestart=cm.timethis()
files=glob.glob(folder+"/*.*") #ABF folder
files.extend(glob.glob(folder+"/swhlab4/*.*"))
print(" ... | [
"expects",
"a",
"folder",
"of",
"ABFs",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/indexing/indexing.py#L279-L310 | [
"def",
"genIndex",
"(",
"folder",
",",
"forceIDs",
"=",
"[",
"]",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"folder",
"+",
"\"/swhlab4/\"",
")",
":",
"print",
"(",
"\" !! cannot index if no /swhlab4/\"",
")",
"return",
"timestart",
"=",... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | drawPhasePlot | Given an ABF object (SWHLab), draw its phase plot of the current sweep.
m1 and m2 are optional marks (in seconds) for plotting only a range of data.
Assume a matplotlib figure is already open and just draw on top if it. | doc/uses/phase_plot/phase.py | def drawPhasePlot(abf,m1=0,m2=None):
"""
Given an ABF object (SWHLab), draw its phase plot of the current sweep.
m1 and m2 are optional marks (in seconds) for plotting only a range of data.
Assume a matplotlib figure is already open and just draw on top if it.
"""
if not m2:
m2 = abf.sw... | def drawPhasePlot(abf,m1=0,m2=None):
"""
Given an ABF object (SWHLab), draw its phase plot of the current sweep.
m1 and m2 are optional marks (in seconds) for plotting only a range of data.
Assume a matplotlib figure is already open and just draw on top if it.
"""
if not m2:
m2 = abf.sw... | [
"Given",
"an",
"ABF",
"object",
"(",
"SWHLab",
")",
"draw",
"its",
"phase",
"plot",
"of",
"the",
"current",
"sweep",
".",
"m1",
"and",
"m2",
"are",
"optional",
"marks",
"(",
"in",
"seconds",
")",
"for",
"plotting",
"only",
"a",
"range",
"of",
"data",
... | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/uses/phase_plot/phase.py#L7-L58 | [
"def",
"drawPhasePlot",
"(",
"abf",
",",
"m1",
"=",
"0",
",",
"m2",
"=",
"None",
")",
":",
"if",
"not",
"m2",
":",
"m2",
"=",
"abf",
".",
"sweepLength",
"cm",
"=",
"plt",
".",
"get_cmap",
"(",
"'CMRmap'",
")",
"#cm = plt.get_cmap('CMRmap_r')",
"#cm = p... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | plotAllSweeps | simple example how to load an ABF file and plot every sweep. | doc/misc/neo demo.py | def plotAllSweeps(abfFile):
"""simple example how to load an ABF file and plot every sweep."""
r = io.AxonIO(filename=abfFile)
bl = r.read_block(lazy=False, cascade=True)
print(abfFile+"\nplotting %d sweeps..."%len(bl.segments))
plt.figure(figsize=(12,10))
plt.title(abfFile)
for sweep i... | def plotAllSweeps(abfFile):
"""simple example how to load an ABF file and plot every sweep."""
r = io.AxonIO(filename=abfFile)
bl = r.read_block(lazy=False, cascade=True)
print(abfFile+"\nplotting %d sweeps..."%len(bl.segments))
plt.figure(figsize=(12,10))
plt.title(abfFile)
for sweep i... | [
"simple",
"example",
"how",
"to",
"load",
"an",
"ABF",
"file",
"and",
"plot",
"every",
"sweep",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/misc/neo demo.py#L9-L22 | [
"def",
"plotAllSweeps",
"(",
"abfFile",
")",
":",
"r",
"=",
"io",
".",
"AxonIO",
"(",
"filename",
"=",
"abfFile",
")",
"bl",
"=",
"r",
".",
"read_block",
"(",
"lazy",
"=",
"False",
",",
"cascade",
"=",
"True",
")",
"print",
"(",
"abfFile",
"+",
"\"... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | TIF_to_jpg | given a TIF taken by our cameras, make it a pretty labeled JPG.
if the filename contains "f10" or "f20", add appropraite scale bars.
automatic contrast adjustment is different depending on if its a DIC
image or fluorescent image (which is detected automatically). | swhlab/indexing/imaging.py | def TIF_to_jpg(fnameTiff, overwrite=False, saveAs=""):
"""
given a TIF taken by our cameras, make it a pretty labeled JPG.
if the filename contains "f10" or "f20", add appropraite scale bars.
automatic contrast adjustment is different depending on if its a DIC
image or fluorescent image (which is ... | def TIF_to_jpg(fnameTiff, overwrite=False, saveAs=""):
"""
given a TIF taken by our cameras, make it a pretty labeled JPG.
if the filename contains "f10" or "f20", add appropraite scale bars.
automatic contrast adjustment is different depending on if its a DIC
image or fluorescent image (which is ... | [
"given",
"a",
"TIF",
"taken",
"by",
"our",
"cameras",
"make",
"it",
"a",
"pretty",
"labeled",
"JPG",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/indexing/imaging.py#L17-L105 | [
"def",
"TIF_to_jpg",
"(",
"fnameTiff",
",",
"overwrite",
"=",
"False",
",",
"saveAs",
"=",
"\"\"",
")",
":",
"if",
"saveAs",
"==",
"\"\"",
":",
"saveAs",
"=",
"fnameTiff",
"+",
"\".jpg\"",
"if",
"overwrite",
"is",
"False",
"and",
"os",
".",
"path",
"."... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | TIF_to_jpg_all | run TIF_to_jpg() on every TIF of a folder. | swhlab/indexing/imaging.py | def TIF_to_jpg_all(path):
"""run TIF_to_jpg() on every TIF of a folder."""
for fname in sorted(glob.glob(path+"/*.tif")):
print(fname)
TIF_to_jpg(fname) | def TIF_to_jpg_all(path):
"""run TIF_to_jpg() on every TIF of a folder."""
for fname in sorted(glob.glob(path+"/*.tif")):
print(fname)
TIF_to_jpg(fname) | [
"run",
"TIF_to_jpg",
"()",
"on",
"every",
"TIF",
"of",
"a",
"folder",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/indexing/imaging.py#L107-L111 | [
"def",
"TIF_to_jpg_all",
"(",
"path",
")",
":",
"for",
"fname",
"in",
"sorted",
"(",
"glob",
".",
"glob",
"(",
"path",
"+",
"\"/*.tif\"",
")",
")",
":",
"print",
"(",
"fname",
")",
"TIF_to_jpg",
"(",
"fname",
")"
] | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | analyzeSweep | m1 and m2, if given, are in seconds.
returns [# EPSCs, # IPSCs] | doc/uses/EPSCs-and-IPSCs/smooth histogram method/02.py | def analyzeSweep(abf,sweep,m1=None,m2=None,plotToo=False):
"""
m1 and m2, if given, are in seconds.
returns [# EPSCs, # IPSCs]
"""
abf.setsweep(sweep)
if m1 is None: m1=0
else: m1=m1*abf.pointsPerSec
if m2 is None: m2=-1
else: m2=m2*abf.pointsPerSec
# obtain X and Y
Yorig=ab... | def analyzeSweep(abf,sweep,m1=None,m2=None,plotToo=False):
"""
m1 and m2, if given, are in seconds.
returns [# EPSCs, # IPSCs]
"""
abf.setsweep(sweep)
if m1 is None: m1=0
else: m1=m1*abf.pointsPerSec
if m2 is None: m2=-1
else: m2=m2*abf.pointsPerSec
# obtain X and Y
Yorig=ab... | [
"m1",
"and",
"m2",
"if",
"given",
"are",
"in",
"seconds",
".",
"returns",
"[",
"#",
"EPSCs",
"#",
"IPSCs",
"]"
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/uses/EPSCs-and-IPSCs/smooth histogram method/02.py#L136-L190 | [
"def",
"analyzeSweep",
"(",
"abf",
",",
"sweep",
",",
"m1",
"=",
"None",
",",
"m2",
"=",
"None",
",",
"plotToo",
"=",
"False",
")",
":",
"abf",
".",
"setsweep",
"(",
"sweep",
")",
"if",
"m1",
"is",
"None",
":",
"m1",
"=",
"0",
"else",
":",
"m1"... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | convert | Convert weird TIF files into web-friendly versions.
Auto contrast is applied (saturating lower and upper 0.1%).
make saveAs True to save as .TIF.png
make saveAs False and it won't save at all
make saveAs "someFile.jpg" to save it as a different path/format | doc/oldcode/indexing/image.py | def convert(fname,saveAs=True,showToo=False):
"""
Convert weird TIF files into web-friendly versions.
Auto contrast is applied (saturating lower and upper 0.1%).
make saveAs True to save as .TIF.png
make saveAs False and it won't save at all
make saveAs "someFile.jpg" to save it as a... | def convert(fname,saveAs=True,showToo=False):
"""
Convert weird TIF files into web-friendly versions.
Auto contrast is applied (saturating lower and upper 0.1%).
make saveAs True to save as .TIF.png
make saveAs False and it won't save at all
make saveAs "someFile.jpg" to save it as a... | [
"Convert",
"weird",
"TIF",
"files",
"into",
"web",
"-",
"friendly",
"versions",
".",
"Auto",
"contrast",
"is",
"applied",
"(",
"saturating",
"lower",
"and",
"upper",
"0",
".",
"1%",
")",
".",
"make",
"saveAs",
"True",
"to",
"save",
"as",
".",
"TIF",
".... | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/indexing/image.py#L10-L51 | [
"def",
"convert",
"(",
"fname",
",",
"saveAs",
"=",
"True",
",",
"showToo",
"=",
"False",
")",
":",
"# load the image",
"#im = Image.open(fname) #PIL can't handle 12-bit TIFs well",
"im",
"=",
"ndimage",
".",
"imread",
"(",
"fname",
")",
"#scipy does better with it",
... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | plot_shaded_data | plot X and Y data, then shade its background by variance. | doc/uses/EPSCs-and-IPSCs/variance method/2016-12-15 noise sample.py | def plot_shaded_data(X,Y,variances,varianceX):
"""plot X and Y data, then shade its background by variance."""
plt.plot(X,Y,color='k',lw=2)
nChunks=int(len(Y)/CHUNK_POINTS)
for i in range(0,100,PERCENT_STEP):
varLimitLow=np.percentile(variances,i)
varLimitHigh=np.percentile(variances,i+P... | def plot_shaded_data(X,Y,variances,varianceX):
"""plot X and Y data, then shade its background by variance."""
plt.plot(X,Y,color='k',lw=2)
nChunks=int(len(Y)/CHUNK_POINTS)
for i in range(0,100,PERCENT_STEP):
varLimitLow=np.percentile(variances,i)
varLimitHigh=np.percentile(variances,i+P... | [
"plot",
"X",
"and",
"Y",
"data",
"then",
"shade",
"its",
"background",
"by",
"variance",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/uses/EPSCs-and-IPSCs/variance method/2016-12-15 noise sample.py#L21-L36 | [
"def",
"plot_shaded_data",
"(",
"X",
",",
"Y",
",",
"variances",
",",
"varianceX",
")",
":",
"plt",
".",
"plot",
"(",
"X",
",",
"Y",
",",
"color",
"=",
"'k'",
",",
"lw",
"=",
"2",
")",
"nChunks",
"=",
"int",
"(",
"len",
"(",
"Y",
")",
"/",
"C... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | show_variances | create some fancy graphs to show color-coded variances. | doc/uses/EPSCs-and-IPSCs/variance method/2016-12-15 noise sample.py | def show_variances(Y,variances,varianceX,logScale=False):
"""create some fancy graphs to show color-coded variances."""
plt.figure(1,figsize=(10,7))
plt.figure(2,figsize=(10,7))
varSorted=sorted(variances)
plt.figure(1)
plt.subplot(211)
plt.grid()
plt.title("chronological varia... | def show_variances(Y,variances,varianceX,logScale=False):
"""create some fancy graphs to show color-coded variances."""
plt.figure(1,figsize=(10,7))
plt.figure(2,figsize=(10,7))
varSorted=sorted(variances)
plt.figure(1)
plt.subplot(211)
plt.grid()
plt.title("chronological varia... | [
"create",
"some",
"fancy",
"graphs",
"to",
"show",
"color",
"-",
"coded",
"variances",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/uses/EPSCs-and-IPSCs/variance method/2016-12-15 noise sample.py#L39-L87 | [
"def",
"show_variances",
"(",
"Y",
",",
"variances",
",",
"varianceX",
",",
"logScale",
"=",
"False",
")",
":",
"plt",
".",
"figure",
"(",
"1",
",",
"figsize",
"=",
"(",
"10",
",",
"7",
")",
")",
"plt",
".",
"figure",
"(",
"2",
",",
"figsize",
"=... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | AP.ensureDetection | run this before analysis. Checks if event detection occured.
If not, runs AP detection on all sweeps. | swhlab/analysis/ap.py | def ensureDetection(self):
"""
run this before analysis. Checks if event detection occured.
If not, runs AP detection on all sweeps.
"""
if self.APs==False:
self.log.debug("analysis attempted before event detection...")
self.detect() | def ensureDetection(self):
"""
run this before analysis. Checks if event detection occured.
If not, runs AP detection on all sweeps.
"""
if self.APs==False:
self.log.debug("analysis attempted before event detection...")
self.detect() | [
"run",
"this",
"before",
"analysis",
".",
"Checks",
"if",
"event",
"detection",
"occured",
".",
"If",
"not",
"runs",
"AP",
"detection",
"on",
"all",
"sweeps",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/analysis/ap.py#L58-L65 | [
"def",
"ensureDetection",
"(",
"self",
")",
":",
"if",
"self",
".",
"APs",
"==",
"False",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"analysis attempted before event detection...\"",
")",
"self",
".",
"detect",
"(",
")"
] | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | AP.detect | runs AP detection on every sweep. | swhlab/analysis/ap.py | def detect(self):
"""runs AP detection on every sweep."""
self.log.info("initializing AP detection on all sweeps...")
t1=cm.timeit()
for sweep in range(self.abf.sweeps):
self.detectSweep(sweep)
self.log.info("AP analysis of %d sweeps found %d APs (completed in %s)",
... | def detect(self):
"""runs AP detection on every sweep."""
self.log.info("initializing AP detection on all sweeps...")
t1=cm.timeit()
for sweep in range(self.abf.sweeps):
self.detectSweep(sweep)
self.log.info("AP analysis of %d sweeps found %d APs (completed in %s)",
... | [
"runs",
"AP",
"detection",
"on",
"every",
"sweep",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/analysis/ap.py#L67-L74 | [
"def",
"detect",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"initializing AP detection on all sweeps...\"",
")",
"t1",
"=",
"cm",
".",
"timeit",
"(",
")",
"for",
"sweep",
"in",
"range",
"(",
"self",
".",
"abf",
".",
"sweeps",
")",
"... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | AP.detectSweep | perform AP detection on current sweep. | swhlab/analysis/ap.py | def detectSweep(self,sweep=0):
"""perform AP detection on current sweep."""
if self.APs is False: # indicates detection never happened
self.APs=[] # now indicates detection occured
# delete every AP from this sweep from the existing array
for i,ap in enumerate(self.APs):
... | def detectSweep(self,sweep=0):
"""perform AP detection on current sweep."""
if self.APs is False: # indicates detection never happened
self.APs=[] # now indicates detection occured
# delete every AP from this sweep from the existing array
for i,ap in enumerate(self.APs):
... | [
"perform",
"AP",
"detection",
"on",
"current",
"sweep",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/analysis/ap.py#L76-L199 | [
"def",
"detectSweep",
"(",
"self",
",",
"sweep",
"=",
"0",
")",
":",
"if",
"self",
".",
"APs",
"is",
"False",
":",
"# indicates detection never happened",
"self",
".",
"APs",
"=",
"[",
"]",
"# now indicates detection occured",
"# delete every AP from this sweep from... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | AP.get_times | return an array of times (in sec) of all APs. | swhlab/analysis/ap.py | def get_times(self):
"""return an array of times (in sec) of all APs."""
self.ensureDetection()
times=[]
for ap in self.APs:
times.append(ap["T"])
return np.array(sorted(times)) | def get_times(self):
"""return an array of times (in sec) of all APs."""
self.ensureDetection()
times=[]
for ap in self.APs:
times.append(ap["T"])
return np.array(sorted(times)) | [
"return",
"an",
"array",
"of",
"times",
"(",
"in",
"sec",
")",
"of",
"all",
"APs",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/analysis/ap.py#L203-L209 | [
"def",
"get_times",
"(",
"self",
")",
":",
"self",
".",
"ensureDetection",
"(",
")",
"times",
"=",
"[",
"]",
"for",
"ap",
"in",
"self",
".",
"APs",
":",
"times",
".",
"append",
"(",
"ap",
"[",
"\"T\"",
"]",
")",
"return",
"np",
".",
"array",
"(",... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | AP.get_bySweep | returns AP info by sweep arranged as a list (by sweep).
feature:
* "freqs" - list of instantaneous frequencies by sweep.
* "firsts" - list of first instantaneous frequency by sweep.
* "times" - list of times of each AP in the sweep.
* "count" - numer of APs per s... | swhlab/analysis/ap.py | def get_bySweep(self,feature="freqs"):
"""
returns AP info by sweep arranged as a list (by sweep).
feature:
* "freqs" - list of instantaneous frequencies by sweep.
* "firsts" - list of first instantaneous frequency by sweep.
* "times" - list of times of each ... | def get_bySweep(self,feature="freqs"):
"""
returns AP info by sweep arranged as a list (by sweep).
feature:
* "freqs" - list of instantaneous frequencies by sweep.
* "firsts" - list of first instantaneous frequency by sweep.
* "times" - list of times of each ... | [
"returns",
"AP",
"info",
"by",
"sweep",
"arranged",
"as",
"a",
"list",
"(",
"by",
"sweep",
")",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/analysis/ap.py#L211-L278 | [
"def",
"get_bySweep",
"(",
"self",
",",
"feature",
"=",
"\"freqs\"",
")",
":",
"self",
".",
"ensureDetection",
"(",
")",
"bySweepTimes",
"=",
"[",
"[",
"]",
"]",
"*",
"self",
".",
"abf",
".",
"sweeps",
"# determine AP spike times by sweep",
"for",
"sweep",
... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | get_author_and_version | Return package author and version as listed in `init.py`. | setup.py | def get_author_and_version(package):
"""
Return package author and version as listed in `init.py`.
"""
init_py = open(os.path.join(package, '__init__.py')).read()
author = re.search("__author__ = ['\"]([^'\"]+)['\"]", init_py).group(1)
version = re.search("__version__ = ['\"]([^'\"]+)['\"]", ini... | def get_author_and_version(package):
"""
Return package author and version as listed in `init.py`.
"""
init_py = open(os.path.join(package, '__init__.py')).read()
author = re.search("__author__ = ['\"]([^'\"]+)['\"]", init_py).group(1)
version = re.search("__version__ = ['\"]([^'\"]+)['\"]", ini... | [
"Return",
"package",
"author",
"and",
"version",
"as",
"listed",
"in",
"init",
".",
"py",
"."
] | jazzband/django-discover-jenkins | python | https://github.com/jazzband/django-discover-jenkins/blob/c0c859dfdd571de6e8f63865dfc8ebac6bab1d07/setup.py#L12-L19 | [
"def",
"get_author_and_version",
"(",
"package",
")",
":",
"init_py",
"=",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"package",
",",
"'__init__.py'",
")",
")",
".",
"read",
"(",
")",
"author",
"=",
"re",
".",
"search",
"(",
"\"__author__ = ['\\\"... | c0c859dfdd571de6e8f63865dfc8ebac6bab1d07 |
valid | api_subclass_factory | Create an API subclass with fewer methods than its base class.
Arguments:
name (:py:class:`str`): The name of the new class.
docstring (:py:class:`str`): The docstring for the new class.
remove_methods (:py:class:`dict`): The methods to remove from
the base class's :py:attr:`API_METHODS` ... | aslack/slack_api.py | def api_subclass_factory(name, docstring, remove_methods, base=SlackApi):
"""Create an API subclass with fewer methods than its base class.
Arguments:
name (:py:class:`str`): The name of the new class.
docstring (:py:class:`str`): The docstring for the new class.
remove_methods (:py:class:`di... | def api_subclass_factory(name, docstring, remove_methods, base=SlackApi):
"""Create an API subclass with fewer methods than its base class.
Arguments:
name (:py:class:`str`): The name of the new class.
docstring (:py:class:`str`): The docstring for the new class.
remove_methods (:py:class:`di... | [
"Create",
"an",
"API",
"subclass",
"with",
"fewer",
"methods",
"than",
"its",
"base",
"class",
"."
] | textbook/aslack | python | https://github.com/textbook/aslack/blob/9ac6a44e4464180109fa4be130ad7a980a9d1acc/aslack/slack_api.py#L225-L254 | [
"def",
"api_subclass_factory",
"(",
"name",
",",
"docstring",
",",
"remove_methods",
",",
"base",
"=",
"SlackApi",
")",
":",
"methods",
"=",
"deepcopy",
"(",
"base",
".",
"API_METHODS",
")",
"for",
"parent",
",",
"to_remove",
"in",
"remove_methods",
".",
"it... | 9ac6a44e4464180109fa4be130ad7a980a9d1acc |
valid | SlackApi.execute_method | Execute a specified Slack Web API method.
Arguments:
method (:py:class:`str`): The name of the method.
**params (:py:class:`dict`): Any additional parameters
required.
Returns:
:py:class:`dict`: The JSON data from the response.
Raises:
:py:c... | aslack/slack_api.py | async def execute_method(self, method, **params):
"""Execute a specified Slack Web API method.
Arguments:
method (:py:class:`str`): The name of the method.
**params (:py:class:`dict`): Any additional parameters
required.
Returns:
:py:class:`dict`: The ... | async def execute_method(self, method, **params):
"""Execute a specified Slack Web API method.
Arguments:
method (:py:class:`str`): The name of the method.
**params (:py:class:`dict`): Any additional parameters
required.
Returns:
:py:class:`dict`: The ... | [
"Execute",
"a",
"specified",
"Slack",
"Web",
"API",
"method",
"."
] | textbook/aslack | python | https://github.com/textbook/aslack/blob/9ac6a44e4464180109fa4be130ad7a980a9d1acc/aslack/slack_api.py#L172-L201 | [
"async",
"def",
"execute_method",
"(",
"self",
",",
"method",
",",
"*",
"*",
"params",
")",
":",
"url",
"=",
"self",
".",
"url_builder",
"(",
"method",
",",
"url_params",
"=",
"params",
")",
"logger",
".",
"info",
"(",
"'Executing method %r'",
",",
"meth... | 9ac6a44e4464180109fa4be130ad7a980a9d1acc |
valid | SlackApi.method_exists | Whether a given method exists in the known API.
Arguments:
method (:py:class:`str`): The name of the method.
Returns:
:py:class:`bool`: Whether the method is in the known API. | aslack/slack_api.py | def method_exists(cls, method):
"""Whether a given method exists in the known API.
Arguments:
method (:py:class:`str`): The name of the method.
Returns:
:py:class:`bool`: Whether the method is in the known API.
"""
methods = cls.API_METHODS
for key ... | def method_exists(cls, method):
"""Whether a given method exists in the known API.
Arguments:
method (:py:class:`str`): The name of the method.
Returns:
:py:class:`bool`: Whether the method is in the known API.
"""
methods = cls.API_METHODS
for key ... | [
"Whether",
"a",
"given",
"method",
"exists",
"in",
"the",
"known",
"API",
"."
] | textbook/aslack | python | https://github.com/textbook/aslack/blob/9ac6a44e4464180109fa4be130ad7a980a9d1acc/aslack/slack_api.py#L204-L222 | [
"def",
"method_exists",
"(",
"cls",
",",
"method",
")",
":",
"methods",
"=",
"cls",
".",
"API_METHODS",
"for",
"key",
"in",
"method",
".",
"split",
"(",
"'.'",
")",
":",
"methods",
"=",
"methods",
".",
"get",
"(",
"key",
")",
"if",
"methods",
"is",
... | 9ac6a44e4464180109fa4be130ad7a980a9d1acc |
valid | XPathSelectorHandler._add_parsley_ns | Extend XPath evaluation with Parsley extensions' namespace | parslepy/selectors.py | def _add_parsley_ns(cls, namespace_dict):
"""
Extend XPath evaluation with Parsley extensions' namespace
"""
namespace_dict.update({
'parslepy' : cls.LOCAL_NAMESPACE,
'parsley' : cls.LOCAL_NAMESPACE,
})
return namespace_dict | def _add_parsley_ns(cls, namespace_dict):
"""
Extend XPath evaluation with Parsley extensions' namespace
"""
namespace_dict.update({
'parslepy' : cls.LOCAL_NAMESPACE,
'parsley' : cls.LOCAL_NAMESPACE,
})
return namespace_dict | [
"Extend",
"XPath",
"evaluation",
"with",
"Parsley",
"extensions",
"namespace"
] | redapple/parslepy | python | https://github.com/redapple/parslepy/blob/a8bc4c0592824459629018c8f4c6ae3dad6cc3cc/parslepy/selectors.py#L222-L231 | [
"def",
"_add_parsley_ns",
"(",
"cls",
",",
"namespace_dict",
")",
":",
"namespace_dict",
".",
"update",
"(",
"{",
"'parslepy'",
":",
"cls",
".",
"LOCAL_NAMESPACE",
",",
"'parsley'",
":",
"cls",
".",
"LOCAL_NAMESPACE",
",",
"}",
")",
"return",
"namespace_dict"
... | a8bc4c0592824459629018c8f4c6ae3dad6cc3cc |
valid | XPathSelectorHandler.make | XPath expression can also use EXSLT functions (as long as they are
understood by libxslt) | parslepy/selectors.py | def make(self, selection):
"""
XPath expression can also use EXSLT functions (as long as they are
understood by libxslt)
"""
cached = self._selector_cache.get(selection)
if cached:
return cached
try:
selector = lxml.etree.XPath(selection,... | def make(self, selection):
"""
XPath expression can also use EXSLT functions (as long as they are
understood by libxslt)
"""
cached = self._selector_cache.get(selection)
if cached:
return cached
try:
selector = lxml.etree.XPath(selection,... | [
"XPath",
"expression",
"can",
"also",
"use",
"EXSLT",
"functions",
"(",
"as",
"long",
"as",
"they",
"are",
"understood",
"by",
"libxslt",
")"
] | redapple/parslepy | python | https://github.com/redapple/parslepy/blob/a8bc4c0592824459629018c8f4c6ae3dad6cc3cc/parslepy/selectors.py#L233-L262 | [
"def",
"make",
"(",
"self",
",",
"selection",
")",
":",
"cached",
"=",
"self",
".",
"_selector_cache",
".",
"get",
"(",
"selection",
")",
"if",
"cached",
":",
"return",
"cached",
"try",
":",
"selector",
"=",
"lxml",
".",
"etree",
".",
"XPath",
"(",
"... | a8bc4c0592824459629018c8f4c6ae3dad6cc3cc |
valid | XPathSelectorHandler.extract | Try and convert matching Elements to unicode strings.
If this fails, the selector evaluation probably already
returned some string(s) of some sort, or boolean value,
or int/float, so return that instead. | parslepy/selectors.py | def extract(self, document, selector, debug_offset=''):
"""
Try and convert matching Elements to unicode strings.
If this fails, the selector evaluation probably already
returned some string(s) of some sort, or boolean value,
or int/float, so return that instead.
"""
... | def extract(self, document, selector, debug_offset=''):
"""
Try and convert matching Elements to unicode strings.
If this fails, the selector evaluation probably already
returned some string(s) of some sort, or boolean value,
or int/float, so return that instead.
"""
... | [
"Try",
"and",
"convert",
"matching",
"Elements",
"to",
"unicode",
"strings",
"."
] | redapple/parslepy | python | https://github.com/redapple/parslepy/blob/a8bc4c0592824459629018c8f4c6ae3dad6cc3cc/parslepy/selectors.py#L273-L299 | [
"def",
"extract",
"(",
"self",
",",
"document",
",",
"selector",
",",
"debug_offset",
"=",
"''",
")",
":",
"selected",
"=",
"self",
".",
"select",
"(",
"document",
",",
"selector",
")",
"if",
"selected",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(... | a8bc4c0592824459629018c8f4c6ae3dad6cc3cc |
valid | DefaultSelectorHandler.make | Scopes and selectors are tested in this order:
* is this a CSS selector with an appended @something attribute?
* is this a regular CSS selector?
* is this an XPath expression?
XPath expression can also use EXSLT functions (as long as they are
understood by libxslt) | parslepy/selectors.py | def make(self, selection):
"""
Scopes and selectors are tested in this order:
* is this a CSS selector with an appended @something attribute?
* is this a regular CSS selector?
* is this an XPath expression?
XPath expression can also use EXSLT functions (as long as they a... | def make(self, selection):
"""
Scopes and selectors are tested in this order:
* is this a CSS selector with an appended @something attribute?
* is this a regular CSS selector?
* is this an XPath expression?
XPath expression can also use EXSLT functions (as long as they a... | [
"Scopes",
"and",
"selectors",
"are",
"tested",
"in",
"this",
"order",
":",
"*",
"is",
"this",
"a",
"CSS",
"selector",
"with",
"an",
"appended",
"@something",
"attribute?",
"*",
"is",
"this",
"a",
"regular",
"CSS",
"selector?",
"*",
"is",
"this",
"an",
"X... | redapple/parslepy | python | https://github.com/redapple/parslepy/blob/a8bc4c0592824459629018c8f4c6ae3dad6cc3cc/parslepy/selectors.py#L435-L510 | [
"def",
"make",
"(",
"self",
",",
"selection",
")",
":",
"cached",
"=",
"self",
".",
"_selector_cache",
".",
"get",
"(",
"selection",
")",
"if",
"cached",
":",
"return",
"cached",
"namespaces",
"=",
"self",
".",
"EXSLT_NAMESPACES",
"self",
".",
"_add_parsle... | a8bc4c0592824459629018c8f4c6ae3dad6cc3cc |
valid | SlackBot.join_rtm | Join the real-time messaging service.
Arguments:
filters (:py:class:`dict`, optional): Dictionary mapping
message filters to the functions they should dispatch to.
Use a :py:class:`collections.OrderedDict` if precedence is
important; only one filter, the first matc... | aslack/slack_bot/bot.py | async def join_rtm(self, filters=None):
"""Join the real-time messaging service.
Arguments:
filters (:py:class:`dict`, optional): Dictionary mapping
message filters to the functions they should dispatch to.
Use a :py:class:`collections.OrderedDict` if precedence is
... | async def join_rtm(self, filters=None):
"""Join the real-time messaging service.
Arguments:
filters (:py:class:`dict`, optional): Dictionary mapping
message filters to the functions they should dispatch to.
Use a :py:class:`collections.OrderedDict` if precedence is
... | [
"Join",
"the",
"real",
"-",
"time",
"messaging",
"service",
"."
] | textbook/aslack | python | https://github.com/textbook/aslack/blob/9ac6a44e4464180109fa4be130ad7a980a9d1acc/aslack/slack_bot/bot.py#L75-L102 | [
"async",
"def",
"join_rtm",
"(",
"self",
",",
"filters",
"=",
"None",
")",
":",
"if",
"filters",
"is",
"None",
":",
"filters",
"=",
"[",
"cls",
"(",
"self",
")",
"for",
"cls",
"in",
"self",
".",
"MESSAGE_FILTERS",
"]",
"url",
"=",
"await",
"self",
... | 9ac6a44e4464180109fa4be130ad7a980a9d1acc |
valid | SlackBot.handle_message | Handle an incoming message appropriately.
Arguments:
message (:py:class:`aiohttp.websocket.Message`): The incoming
message to handle.
filters (:py:class:`list`): The filters to apply to incoming
messages. | aslack/slack_bot/bot.py | async def handle_message(self, message, filters):
"""Handle an incoming message appropriately.
Arguments:
message (:py:class:`aiohttp.websocket.Message`): The incoming
message to handle.
filters (:py:class:`list`): The filters to apply to incoming
messages.
... | async def handle_message(self, message, filters):
"""Handle an incoming message appropriately.
Arguments:
message (:py:class:`aiohttp.websocket.Message`): The incoming
message to handle.
filters (:py:class:`list`): The filters to apply to incoming
messages.
... | [
"Handle",
"an",
"incoming",
"message",
"appropriately",
"."
] | textbook/aslack | python | https://github.com/textbook/aslack/blob/9ac6a44e4464180109fa4be130ad7a980a9d1acc/aslack/slack_bot/bot.py#L104-L136 | [
"async",
"def",
"handle_message",
"(",
"self",
",",
"message",
",",
"filters",
")",
":",
"data",
"=",
"self",
".",
"_unpack_message",
"(",
"message",
")",
"logger",
".",
"debug",
"(",
"data",
")",
"if",
"data",
".",
"get",
"(",
"'type'",
")",
"==",
"... | 9ac6a44e4464180109fa4be130ad7a980a9d1acc |
valid | SlackBot.message_is_to_me | If you send a message directly to me | aslack/slack_bot/bot.py | def message_is_to_me(self, data):
"""If you send a message directly to me"""
return (data.get('type') == 'message' and
data.get('text', '').startswith(self.address_as)) | def message_is_to_me(self, data):
"""If you send a message directly to me"""
return (data.get('type') == 'message' and
data.get('text', '').startswith(self.address_as)) | [
"If",
"you",
"send",
"a",
"message",
"directly",
"to",
"me"
] | textbook/aslack | python | https://github.com/textbook/aslack/blob/9ac6a44e4464180109fa4be130ad7a980a9d1acc/aslack/slack_bot/bot.py#L143-L146 | [
"def",
"message_is_to_me",
"(",
"self",
",",
"data",
")",
":",
"return",
"(",
"data",
".",
"get",
"(",
"'type'",
")",
"==",
"'message'",
"and",
"data",
".",
"get",
"(",
"'text'",
",",
"''",
")",
".",
"startswith",
"(",
"self",
".",
"address_as",
")",... | 9ac6a44e4464180109fa4be130ad7a980a9d1acc |
valid | SlackBot.from_api_token | Create a new instance from the API token.
Arguments:
token (:py:class:`str`, optional): The bot's API token
(defaults to ``None``, which means looking in the
environment).
api_cls (:py:class:`type`, optional): The class to create
as the ``api`` argument f... | aslack/slack_bot/bot.py | async def from_api_token(cls, token=None, api_cls=SlackBotApi):
"""Create a new instance from the API token.
Arguments:
token (:py:class:`str`, optional): The bot's API token
(defaults to ``None``, which means looking in the
environment).
api_cls (:py:class:`... | async def from_api_token(cls, token=None, api_cls=SlackBotApi):
"""Create a new instance from the API token.
Arguments:
token (:py:class:`str`, optional): The bot's API token
(defaults to ``None``, which means looking in the
environment).
api_cls (:py:class:`... | [
"Create",
"a",
"new",
"instance",
"from",
"the",
"API",
"token",
"."
] | textbook/aslack | python | https://github.com/textbook/aslack/blob/9ac6a44e4464180109fa4be130ad7a980a9d1acc/aslack/slack_bot/bot.py#L149-L166 | [
"async",
"def",
"from_api_token",
"(",
"cls",
",",
"token",
"=",
"None",
",",
"api_cls",
"=",
"SlackBotApi",
")",
":",
"api",
"=",
"api_cls",
".",
"from_env",
"(",
")",
"if",
"token",
"is",
"None",
"else",
"api_cls",
"(",
"api_token",
"=",
"token",
")"... | 9ac6a44e4464180109fa4be130ad7a980a9d1acc |
valid | SlackBot._format_message | Format an outgoing message for transmission.
Note:
Adds the message type (``'message'``) and incremental ID.
Arguments:
channel (:py:class:`str`): The channel to send to.
text (:py:class:`str`): The message text to send.
Returns:
:py:class:`str`: The JS... | aslack/slack_bot/bot.py | def _format_message(self, channel, text):
"""Format an outgoing message for transmission.
Note:
Adds the message type (``'message'``) and incremental ID.
Arguments:
channel (:py:class:`str`): The channel to send to.
text (:py:class:`str`): The message text to send... | def _format_message(self, channel, text):
"""Format an outgoing message for transmission.
Note:
Adds the message type (``'message'``) and incremental ID.
Arguments:
channel (:py:class:`str`): The channel to send to.
text (:py:class:`str`): The message text to send... | [
"Format",
"an",
"outgoing",
"message",
"for",
"transmission",
"."
] | textbook/aslack | python | https://github.com/textbook/aslack/blob/9ac6a44e4464180109fa4be130ad7a980a9d1acc/aslack/slack_bot/bot.py#L168-L184 | [
"def",
"_format_message",
"(",
"self",
",",
"channel",
",",
"text",
")",
":",
"payload",
"=",
"{",
"'type'",
":",
"'message'",
",",
"'id'",
":",
"next",
"(",
"self",
".",
"_msg_ids",
")",
"}",
"payload",
".",
"update",
"(",
"channel",
"=",
"channel",
... | 9ac6a44e4464180109fa4be130ad7a980a9d1acc |
valid | SlackBot._get_socket_url | Get the WebSocket URL for the RTM session.
Warning:
The URL expires if the session is not joined within 30
seconds of the API call to the start endpoint.
Returns:
:py:class:`str`: The socket URL. | aslack/slack_bot/bot.py | async def _get_socket_url(self):
"""Get the WebSocket URL for the RTM session.
Warning:
The URL expires if the session is not joined within 30
seconds of the API call to the start endpoint.
Returns:
:py:class:`str`: The socket URL.
"""
data = awai... | async def _get_socket_url(self):
"""Get the WebSocket URL for the RTM session.
Warning:
The URL expires if the session is not joined within 30
seconds of the API call to the start endpoint.
Returns:
:py:class:`str`: The socket URL.
"""
data = awai... | [
"Get",
"the",
"WebSocket",
"URL",
"for",
"the",
"RTM",
"session",
"."
] | textbook/aslack | python | https://github.com/textbook/aslack/blob/9ac6a44e4464180109fa4be130ad7a980a9d1acc/aslack/slack_bot/bot.py#L186-L202 | [
"async",
"def",
"_get_socket_url",
"(",
"self",
")",
":",
"data",
"=",
"await",
"self",
".",
"api",
".",
"execute_method",
"(",
"self",
".",
"RTM_START_ENDPOINT",
",",
"simple_latest",
"=",
"True",
",",
"no_unreads",
"=",
"True",
",",
")",
"return",
"data"... | 9ac6a44e4464180109fa4be130ad7a980a9d1acc |
valid | SlackBot._instruction_list | Generates the instructions for a bot and its filters.
Note:
The guidance for each filter is generated by combining the
docstrings of the predicate filter and resulting dispatch
function with a single space between. The class's
:py:attr:`INSTRUCTIONS` and the default help... | aslack/slack_bot/bot.py | def _instruction_list(self, filters):
"""Generates the instructions for a bot and its filters.
Note:
The guidance for each filter is generated by combining the
docstrings of the predicate filter and resulting dispatch
function with a single space between. The class's
... | def _instruction_list(self, filters):
"""Generates the instructions for a bot and its filters.
Note:
The guidance for each filter is generated by combining the
docstrings of the predicate filter and resulting dispatch
function with a single space between. The class's
... | [
"Generates",
"the",
"instructions",
"for",
"a",
"bot",
"and",
"its",
"filters",
"."
] | textbook/aslack | python | https://github.com/textbook/aslack/blob/9ac6a44e4464180109fa4be130ad7a980a9d1acc/aslack/slack_bot/bot.py#L204-L229 | [
"def",
"_instruction_list",
"(",
"self",
",",
"filters",
")",
":",
"return",
"'\\n\\n'",
".",
"join",
"(",
"[",
"self",
".",
"INSTRUCTIONS",
".",
"strip",
"(",
")",
",",
"'*Supported methods:*'",
",",
"'If you send \"@{}: help\" to me I reply with these '",
"'instru... | 9ac6a44e4464180109fa4be130ad7a980a9d1acc |
valid | SlackBot._respond | Respond to a message on the current socket.
Args:
channel (:py:class:`str`): The channel to send to.
text (:py:class:`str`): The message text to send. | aslack/slack_bot/bot.py | def _respond(self, channel, text):
"""Respond to a message on the current socket.
Args:
channel (:py:class:`str`): The channel to send to.
text (:py:class:`str`): The message text to send.
"""
result = self._format_message(channel, text)
if result is not Non... | def _respond(self, channel, text):
"""Respond to a message on the current socket.
Args:
channel (:py:class:`str`): The channel to send to.
text (:py:class:`str`): The message text to send.
"""
result = self._format_message(channel, text)
if result is not Non... | [
"Respond",
"to",
"a",
"message",
"on",
"the",
"current",
"socket",
"."
] | textbook/aslack | python | https://github.com/textbook/aslack/blob/9ac6a44e4464180109fa4be130ad7a980a9d1acc/aslack/slack_bot/bot.py#L231-L245 | [
"def",
"_respond",
"(",
"self",
",",
"channel",
",",
"text",
")",
":",
"result",
"=",
"self",
".",
"_format_message",
"(",
"channel",
",",
"text",
")",
"if",
"result",
"is",
"not",
"None",
":",
"logger",
".",
"info",
"(",
"'Sending message: %r'",
",",
... | 9ac6a44e4464180109fa4be130ad7a980a9d1acc |
valid | SlackBot._validate_first_message | Check the first message matches the expected handshake.
Note:
The handshake is provided as :py:attr:`RTM_HANDSHAKE`.
Arguments:
msg (:py:class:`aiohttp.Message`): The message to validate.
Raises:
:py:class:`SlackApiError`: If the data doesn't match the
... | aslack/slack_bot/bot.py | def _validate_first_message(cls, msg):
"""Check the first message matches the expected handshake.
Note:
The handshake is provided as :py:attr:`RTM_HANDSHAKE`.
Arguments:
msg (:py:class:`aiohttp.Message`): The message to validate.
Raises:
:py:class:`SlackA... | def _validate_first_message(cls, msg):
"""Check the first message matches the expected handshake.
Note:
The handshake is provided as :py:attr:`RTM_HANDSHAKE`.
Arguments:
msg (:py:class:`aiohttp.Message`): The message to validate.
Raises:
:py:class:`SlackA... | [
"Check",
"the",
"first",
"message",
"matches",
"the",
"expected",
"handshake",
"."
] | textbook/aslack | python | https://github.com/textbook/aslack/blob/9ac6a44e4464180109fa4be130ad7a980a9d1acc/aslack/slack_bot/bot.py#L267-L285 | [
"def",
"_validate_first_message",
"(",
"cls",
",",
"msg",
")",
":",
"data",
"=",
"cls",
".",
"_unpack_message",
"(",
"msg",
")",
"logger",
".",
"debug",
"(",
"data",
")",
"if",
"data",
"!=",
"cls",
".",
"RTM_HANDSHAKE",
":",
"raise",
"SlackApiError",
"("... | 9ac6a44e4464180109fa4be130ad7a980a9d1acc |
valid | find_first_existing_executable | Accepts list of [('executable_file_path', 'options')],
Returns first working executable_file_path | discover_jenkins/utils.py | def find_first_existing_executable(exe_list):
"""
Accepts list of [('executable_file_path', 'options')],
Returns first working executable_file_path
"""
for filepath, opts in exe_list:
try:
proc = subprocess.Popen([filepath, opts],
stdout=subpro... | def find_first_existing_executable(exe_list):
"""
Accepts list of [('executable_file_path', 'options')],
Returns first working executable_file_path
"""
for filepath, opts in exe_list:
try:
proc = subprocess.Popen([filepath, opts],
stdout=subpro... | [
"Accepts",
"list",
"of",
"[",
"(",
"executable_file_path",
"options",
")",
"]",
"Returns",
"first",
"working",
"executable_file_path"
] | jazzband/django-discover-jenkins | python | https://github.com/jazzband/django-discover-jenkins/blob/c0c859dfdd571de6e8f63865dfc8ebac6bab1d07/discover_jenkins/utils.py#L18-L32 | [
"def",
"find_first_existing_executable",
"(",
"exe_list",
")",
":",
"for",
"filepath",
",",
"opts",
"in",
"exe_list",
":",
"try",
":",
"proc",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"filepath",
",",
"opts",
"]",
",",
"stdout",
"=",
"subprocess",
".",
... | c0c859dfdd571de6e8f63865dfc8ebac6bab1d07 |
valid | get_app_locations | Returns list of paths to tested apps | discover_jenkins/utils.py | def get_app_locations():
"""
Returns list of paths to tested apps
"""
return [os.path.dirname(os.path.normpath(import_module(app_name).__file__))
for app_name in PROJECT_APPS] | def get_app_locations():
"""
Returns list of paths to tested apps
"""
return [os.path.dirname(os.path.normpath(import_module(app_name).__file__))
for app_name in PROJECT_APPS] | [
"Returns",
"list",
"of",
"paths",
"to",
"tested",
"apps"
] | jazzband/django-discover-jenkins | python | https://github.com/jazzband/django-discover-jenkins/blob/c0c859dfdd571de6e8f63865dfc8ebac6bab1d07/discover_jenkins/utils.py#L35-L40 | [
"def",
"get_app_locations",
"(",
")",
":",
"return",
"[",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"normpath",
"(",
"import_module",
"(",
"app_name",
")",
".",
"__file__",
")",
")",
"for",
"app_name",
"in",
"PROJECT_APPS",
"]"
] | c0c859dfdd571de6e8f63865dfc8ebac6bab1d07 |
valid | get_tasks | Get the imported task classes for each task that will be run | discover_jenkins/runner.py | def get_tasks():
"""Get the imported task classes for each task that will be run"""
task_classes = []
for task_path in TASKS:
try:
module, classname = task_path.rsplit('.', 1)
except ValueError:
raise ImproperlyConfigured('%s isn\'t a task module' % task_path)
... | def get_tasks():
"""Get the imported task classes for each task that will be run"""
task_classes = []
for task_path in TASKS:
try:
module, classname = task_path.rsplit('.', 1)
except ValueError:
raise ImproperlyConfigured('%s isn\'t a task module' % task_path)
... | [
"Get",
"the",
"imported",
"task",
"classes",
"for",
"each",
"task",
"that",
"will",
"be",
"run"
] | jazzband/django-discover-jenkins | python | https://github.com/jazzband/django-discover-jenkins/blob/c0c859dfdd571de6e8f63865dfc8ebac6bab1d07/discover_jenkins/runner.py#L13-L32 | [
"def",
"get_tasks",
"(",
")",
":",
"task_classes",
"=",
"[",
"]",
"for",
"task_path",
"in",
"TASKS",
":",
"try",
":",
"module",
",",
"classname",
"=",
"task_path",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"except",
"ValueError",
":",
"raise",
"Imprope... | c0c859dfdd571de6e8f63865dfc8ebac6bab1d07 |
valid | get_task_options | Get the options for each task that will be run | discover_jenkins/runner.py | def get_task_options():
"""Get the options for each task that will be run"""
options = ()
task_classes = get_tasks()
for cls in task_classes:
options += cls.option_list
return options | def get_task_options():
"""Get the options for each task that will be run"""
options = ()
task_classes = get_tasks()
for cls in task_classes:
options += cls.option_list
return options | [
"Get",
"the",
"options",
"for",
"each",
"task",
"that",
"will",
"be",
"run"
] | jazzband/django-discover-jenkins | python | https://github.com/jazzband/django-discover-jenkins/blob/c0c859dfdd571de6e8f63865dfc8ebac6bab1d07/discover_jenkins/runner.py#L35-L43 | [
"def",
"get_task_options",
"(",
")",
":",
"options",
"=",
"(",
")",
"task_classes",
"=",
"get_tasks",
"(",
")",
"for",
"cls",
"in",
"task_classes",
":",
"options",
"+=",
"cls",
".",
"option_list",
"return",
"options"
] | c0c859dfdd571de6e8f63865dfc8ebac6bab1d07 |
valid | Database.to_cldf | Write the data from the db to a CLDF dataset according to the metadata in `self.dataset`.
:param dest:
:param mdname:
:return: path of the metadata file | src/pycldf/db.py | def to_cldf(self, dest, mdname='cldf-metadata.json'):
"""
Write the data from the db to a CLDF dataset according to the metadata in `self.dataset`.
:param dest:
:param mdname:
:return: path of the metadata file
"""
dest = Path(dest)
if not dest.exists():
... | def to_cldf(self, dest, mdname='cldf-metadata.json'):
"""
Write the data from the db to a CLDF dataset according to the metadata in `self.dataset`.
:param dest:
:param mdname:
:return: path of the metadata file
"""
dest = Path(dest)
if not dest.exists():
... | [
"Write",
"the",
"data",
"from",
"the",
"db",
"to",
"a",
"CLDF",
"dataset",
"according",
"to",
"the",
"metadata",
"in",
"self",
".",
"dataset",
"."
] | cldf/pycldf | python | https://github.com/cldf/pycldf/blob/636f1eb3ea769394e14ad9e42a83b6096efa9728/src/pycldf/db.py#L181-L212 | [
"def",
"to_cldf",
"(",
"self",
",",
"dest",
",",
"mdname",
"=",
"'cldf-metadata.json'",
")",
":",
"dest",
"=",
"Path",
"(",
"dest",
")",
"if",
"not",
"dest",
".",
"exists",
"(",
")",
":",
"dest",
".",
"mkdir",
"(",
")",
"data",
"=",
"self",
".",
... | 636f1eb3ea769394e14ad9e42a83b6096efa9728 |
valid | validate | cldf validate <DATASET>
Validate a dataset against the CLDF specification, i.e. check
- whether required tables and columns are present
- whether values for required columns are present
- the referential integrity of the dataset | src/pycldf/__main__.py | def validate(args):
"""
cldf validate <DATASET>
Validate a dataset against the CLDF specification, i.e. check
- whether required tables and columns are present
- whether values for required columns are present
- the referential integrity of the dataset
"""
ds = _get_dataset(args)
ds... | def validate(args):
"""
cldf validate <DATASET>
Validate a dataset against the CLDF specification, i.e. check
- whether required tables and columns are present
- whether values for required columns are present
- the referential integrity of the dataset
"""
ds = _get_dataset(args)
ds... | [
"cldf",
"validate",
"<DATASET",
">"
] | cldf/pycldf | python | https://github.com/cldf/pycldf/blob/636f1eb3ea769394e14ad9e42a83b6096efa9728/src/pycldf/__main__.py#L37-L47 | [
"def",
"validate",
"(",
"args",
")",
":",
"ds",
"=",
"_get_dataset",
"(",
"args",
")",
"ds",
".",
"validate",
"(",
"log",
"=",
"args",
".",
"log",
")"
] | 636f1eb3ea769394e14ad9e42a83b6096efa9728 |
valid | stats | cldf stats <DATASET>
Print basic stats for CLDF dataset <DATASET>, where <DATASET> may be the path to
- a CLDF metadata file
- a CLDF core data file | src/pycldf/__main__.py | def stats(args):
"""
cldf stats <DATASET>
Print basic stats for CLDF dataset <DATASET>, where <DATASET> may be the path to
- a CLDF metadata file
- a CLDF core data file
"""
ds = _get_dataset(args)
print(ds)
md = Table('key', 'value')
md.extend(ds.properties.items())
print(m... | def stats(args):
"""
cldf stats <DATASET>
Print basic stats for CLDF dataset <DATASET>, where <DATASET> may be the path to
- a CLDF metadata file
- a CLDF core data file
"""
ds = _get_dataset(args)
print(ds)
md = Table('key', 'value')
md.extend(ds.properties.items())
print(m... | [
"cldf",
"stats",
"<DATASET",
">"
] | cldf/pycldf | python | https://github.com/cldf/pycldf/blob/636f1eb3ea769394e14ad9e42a83b6096efa9728/src/pycldf/__main__.py#L50-L67 | [
"def",
"stats",
"(",
"args",
")",
":",
"ds",
"=",
"_get_dataset",
"(",
"args",
")",
"print",
"(",
"ds",
")",
"md",
"=",
"Table",
"(",
"'key'",
",",
"'value'",
")",
"md",
".",
"extend",
"(",
"ds",
".",
"properties",
".",
"items",
"(",
")",
")",
... | 636f1eb3ea769394e14ad9e42a83b6096efa9728 |
valid | createdb | cldf createdb <DATASET> <SQLITE_DB_PATH>
Load CLDF dataset <DATASET> into a SQLite DB, where <DATASET> may be the path to
- a CLDF metadata file
- a CLDF core data file | src/pycldf/__main__.py | def createdb(args):
"""
cldf createdb <DATASET> <SQLITE_DB_PATH>
Load CLDF dataset <DATASET> into a SQLite DB, where <DATASET> may be the path to
- a CLDF metadata file
- a CLDF core data file
"""
if len(args.args) < 2:
raise ParserError('not enough arguments')
ds = _get_dataset... | def createdb(args):
"""
cldf createdb <DATASET> <SQLITE_DB_PATH>
Load CLDF dataset <DATASET> into a SQLite DB, where <DATASET> may be the path to
- a CLDF metadata file
- a CLDF core data file
"""
if len(args.args) < 2:
raise ParserError('not enough arguments')
ds = _get_dataset... | [
"cldf",
"createdb",
"<DATASET",
">",
"<SQLITE_DB_PATH",
">"
] | cldf/pycldf | python | https://github.com/cldf/pycldf/blob/636f1eb3ea769394e14ad9e42a83b6096efa9728/src/pycldf/__main__.py#L70-L83 | [
"def",
"createdb",
"(",
"args",
")",
":",
"if",
"len",
"(",
"args",
".",
"args",
")",
"<",
"2",
":",
"raise",
"ParserError",
"(",
"'not enough arguments'",
")",
"ds",
"=",
"_get_dataset",
"(",
"args",
")",
"db",
"=",
"Database",
"(",
"ds",
",",
"fnam... | 636f1eb3ea769394e14ad9e42a83b6096efa9728 |
valid | dumpdb | cldf dumpdb <DATASET> <SQLITE_DB_PATH> [<METADATA_PATH>] | src/pycldf/__main__.py | def dumpdb(args):
"""
cldf dumpdb <DATASET> <SQLITE_DB_PATH> [<METADATA_PATH>]
"""
if len(args.args) < 2:
raise ParserError('not enough arguments') # pragma: no cover
ds = _get_dataset(args)
db = Database(ds, fname=args.args[1])
mdpath = Path(args.args[2]) if len(args.args) > 2 else... | def dumpdb(args):
"""
cldf dumpdb <DATASET> <SQLITE_DB_PATH> [<METADATA_PATH>]
"""
if len(args.args) < 2:
raise ParserError('not enough arguments') # pragma: no cover
ds = _get_dataset(args)
db = Database(ds, fname=args.args[1])
mdpath = Path(args.args[2]) if len(args.args) > 2 else... | [
"cldf",
"dumpdb",
"<DATASET",
">",
"<SQLITE_DB_PATH",
">",
"[",
"<METADATA_PATH",
">",
"]"
] | cldf/pycldf | python | https://github.com/cldf/pycldf/blob/636f1eb3ea769394e14ad9e42a83b6096efa9728/src/pycldf/__main__.py#L86-L95 | [
"def",
"dumpdb",
"(",
"args",
")",
":",
"if",
"len",
"(",
"args",
".",
"args",
")",
"<",
"2",
":",
"raise",
"ParserError",
"(",
"'not enough arguments'",
")",
"# pragma: no cover",
"ds",
"=",
"_get_dataset",
"(",
"args",
")",
"db",
"=",
"Database",
"(",
... | 636f1eb3ea769394e14ad9e42a83b6096efa9728 |
valid | MessageHandler.description | A user-friendly description of the handler.
Returns:
:py:class:`str`: The handler's description. | aslack/slack_bot/handler.py | def description(self):
"""A user-friendly description of the handler.
Returns:
:py:class:`str`: The handler's description.
"""
if self._description is None:
text = '\n'.join(self.__doc__.splitlines()[1:]).strip()
lines = []
for line in map(... | def description(self):
"""A user-friendly description of the handler.
Returns:
:py:class:`str`: The handler's description.
"""
if self._description is None:
text = '\n'.join(self.__doc__.splitlines()[1:]).strip()
lines = []
for line in map(... | [
"A",
"user",
"-",
"friendly",
"description",
"of",
"the",
"handler",
"."
] | textbook/aslack | python | https://github.com/textbook/aslack/blob/9ac6a44e4464180109fa4be130ad7a980a9d1acc/aslack/slack_bot/handler.py#L22-L40 | [
"def",
"description",
"(",
"self",
")",
":",
"if",
"self",
".",
"_description",
"is",
"None",
":",
"text",
"=",
"'\\n'",
".",
"join",
"(",
"self",
".",
"__doc__",
".",
"splitlines",
"(",
")",
"[",
"1",
":",
"]",
")",
".",
"strip",
"(",
")",
"line... | 9ac6a44e4464180109fa4be130ad7a980a9d1acc |
valid | Parselet.from_jsonfile | Create a Parselet instance from a file containing
the Parsley script as a JSON object
>>> import parslepy
>>> with open('parselet.json') as fp:
... parslepy.Parselet.from_jsonfile(fp)
...
<parslepy.base.Parselet object at 0x2014e50>
:param file fp: an open f... | parslepy/base.py | def from_jsonfile(cls, fp, selector_handler=None, strict=False, debug=False):
"""
Create a Parselet instance from a file containing
the Parsley script as a JSON object
>>> import parslepy
>>> with open('parselet.json') as fp:
... parslepy.Parselet.from_jsonfile(fp)
... | def from_jsonfile(cls, fp, selector_handler=None, strict=False, debug=False):
"""
Create a Parselet instance from a file containing
the Parsley script as a JSON object
>>> import parslepy
>>> with open('parselet.json') as fp:
... parslepy.Parselet.from_jsonfile(fp)
... | [
"Create",
"a",
"Parselet",
"instance",
"from",
"a",
"file",
"containing",
"the",
"Parsley",
"script",
"as",
"a",
"JSON",
"object"
] | redapple/parslepy | python | https://github.com/redapple/parslepy/blob/a8bc4c0592824459629018c8f4c6ae3dad6cc3cc/parslepy/base.py#L182-L200 | [
"def",
"from_jsonfile",
"(",
"cls",
",",
"fp",
",",
"selector_handler",
"=",
"None",
",",
"strict",
"=",
"False",
",",
"debug",
"=",
"False",
")",
":",
"return",
"cls",
".",
"_from_jsonlines",
"(",
"fp",
",",
"selector_handler",
"=",
"selector_handler",
",... | a8bc4c0592824459629018c8f4c6ae3dad6cc3cc |
valid | Parselet.from_yamlfile | Create a Parselet instance from a file containing
the Parsley script as a YAML object
>>> import parslepy
>>> with open('parselet.yml') as fp:
... parslepy.Parselet.from_yamlfile(fp)
...
<parslepy.base.Parselet object at 0x2014e50>
:param file fp: an open fi... | parslepy/base.py | def from_yamlfile(cls, fp, selector_handler=None, strict=False, debug=False):
"""
Create a Parselet instance from a file containing
the Parsley script as a YAML object
>>> import parslepy
>>> with open('parselet.yml') as fp:
... parslepy.Parselet.from_yamlfile(fp)
... | def from_yamlfile(cls, fp, selector_handler=None, strict=False, debug=False):
"""
Create a Parselet instance from a file containing
the Parsley script as a YAML object
>>> import parslepy
>>> with open('parselet.yml') as fp:
... parslepy.Parselet.from_yamlfile(fp)
... | [
"Create",
"a",
"Parselet",
"instance",
"from",
"a",
"file",
"containing",
"the",
"Parsley",
"script",
"as",
"a",
"YAML",
"object"
] | redapple/parslepy | python | https://github.com/redapple/parslepy/blob/a8bc4c0592824459629018c8f4c6ae3dad6cc3cc/parslepy/base.py#L203-L220 | [
"def",
"from_yamlfile",
"(",
"cls",
",",
"fp",
",",
"selector_handler",
"=",
"None",
",",
"strict",
"=",
"False",
",",
"debug",
"=",
"False",
")",
":",
"return",
"cls",
".",
"from_yamlstring",
"(",
"fp",
".",
"read",
"(",
")",
",",
"selector_handler",
... | a8bc4c0592824459629018c8f4c6ae3dad6cc3cc |
valid | Parselet.from_yamlstring | Create a Parselet instance from s (str) containing
the Parsley script as YAML
>>> import parslepy
>>> parsley_string = '''---
title: h1
link: a @href
'''
>>> p = parslepy.Parselet.from_yamlstring(parsley_string)
>>> type(p)
<class 'parslep... | parslepy/base.py | def from_yamlstring(cls, s, selector_handler=None, strict=False, debug=False):
"""
Create a Parselet instance from s (str) containing
the Parsley script as YAML
>>> import parslepy
>>> parsley_string = '''---
title: h1
link: a @href
'''
>>... | def from_yamlstring(cls, s, selector_handler=None, strict=False, debug=False):
"""
Create a Parselet instance from s (str) containing
the Parsley script as YAML
>>> import parslepy
>>> parsley_string = '''---
title: h1
link: a @href
'''
>>... | [
"Create",
"a",
"Parselet",
"instance",
"from",
"s",
"(",
"str",
")",
"containing",
"the",
"Parsley",
"script",
"as",
"YAML"
] | redapple/parslepy | python | https://github.com/redapple/parslepy/blob/a8bc4c0592824459629018c8f4c6ae3dad6cc3cc/parslepy/base.py#L223-L245 | [
"def",
"from_yamlstring",
"(",
"cls",
",",
"s",
",",
"selector_handler",
"=",
"None",
",",
"strict",
"=",
"False",
",",
"debug",
"=",
"False",
")",
":",
"import",
"yaml",
"return",
"cls",
"(",
"yaml",
".",
"load",
"(",
"s",
")",
",",
"selector_handler"... | a8bc4c0592824459629018c8f4c6ae3dad6cc3cc |
valid | Parselet.from_jsonstring | Create a Parselet instance from s (str) containing
the Parsley script as JSON
>>> import parslepy
>>> parsley_string = '{ "title": "h1", "link": "a @href"}'
>>> p = parslepy.Parselet.from_jsonstring(parsley_string)
>>> type(p)
<class 'parslepy.base.Parselet'>
>>>... | parslepy/base.py | def from_jsonstring(cls, s, selector_handler=None, strict=False, debug=False):
"""
Create a Parselet instance from s (str) containing
the Parsley script as JSON
>>> import parslepy
>>> parsley_string = '{ "title": "h1", "link": "a @href"}'
>>> p = parslepy.Parselet.from_... | def from_jsonstring(cls, s, selector_handler=None, strict=False, debug=False):
"""
Create a Parselet instance from s (str) containing
the Parsley script as JSON
>>> import parslepy
>>> parsley_string = '{ "title": "h1", "link": "a @href"}'
>>> p = parslepy.Parselet.from_... | [
"Create",
"a",
"Parselet",
"instance",
"from",
"s",
"(",
"str",
")",
"containing",
"the",
"Parsley",
"script",
"as",
"JSON"
] | redapple/parslepy | python | https://github.com/redapple/parslepy/blob/a8bc4c0592824459629018c8f4c6ae3dad6cc3cc/parslepy/base.py#L248-L267 | [
"def",
"from_jsonstring",
"(",
"cls",
",",
"s",
",",
"selector_handler",
"=",
"None",
",",
"strict",
"=",
"False",
",",
"debug",
"=",
"False",
")",
":",
"return",
"cls",
".",
"_from_jsonlines",
"(",
"s",
".",
"split",
"(",
"\"\\n\"",
")",
",",
"selecto... | a8bc4c0592824459629018c8f4c6ae3dad6cc3cc |
valid | Parselet._from_jsonlines | Interpret input lines as a JSON Parsley script.
Python-style comment lines are skipped. | parslepy/base.py | def _from_jsonlines(cls, lines, selector_handler=None, strict=False, debug=False):
"""
Interpret input lines as a JSON Parsley script.
Python-style comment lines are skipped.
"""
return cls(json.loads(
"\n".join([l for l in lines if not cls.REGEX_COMMENT_LINE.mat... | def _from_jsonlines(cls, lines, selector_handler=None, strict=False, debug=False):
"""
Interpret input lines as a JSON Parsley script.
Python-style comment lines are skipped.
"""
return cls(json.loads(
"\n".join([l for l in lines if not cls.REGEX_COMMENT_LINE.mat... | [
"Interpret",
"input",
"lines",
"as",
"a",
"JSON",
"Parsley",
"script",
".",
"Python",
"-",
"style",
"comment",
"lines",
"are",
"skipped",
"."
] | redapple/parslepy | python | https://github.com/redapple/parslepy/blob/a8bc4c0592824459629018c8f4c6ae3dad6cc3cc/parslepy/base.py#L270-L278 | [
"def",
"_from_jsonlines",
"(",
"cls",
",",
"lines",
",",
"selector_handler",
"=",
"None",
",",
"strict",
"=",
"False",
",",
"debug",
"=",
"False",
")",
":",
"return",
"cls",
"(",
"json",
".",
"loads",
"(",
"\"\\n\"",
".",
"join",
"(",
"[",
"l",
"for"... | a8bc4c0592824459629018c8f4c6ae3dad6cc3cc |
valid | Parselet.parse | Parse an HTML or XML document and
return the extacted object following the Parsley rules give at instantiation.
:param fp: file-like object containing an HTML or XML document, or URL or filename
:param parser: *lxml.etree._FeedParser* instance (optional); defaults to lxml.etree.HTMLParser()
... | parslepy/base.py | def parse(self, fp, parser=None, context=None):
"""
Parse an HTML or XML document and
return the extacted object following the Parsley rules give at instantiation.
:param fp: file-like object containing an HTML or XML document, or URL or filename
:param parser: *lxml.etree._Feed... | def parse(self, fp, parser=None, context=None):
"""
Parse an HTML or XML document and
return the extacted object following the Parsley rules give at instantiation.
:param fp: file-like object containing an HTML or XML document, or URL or filename
:param parser: *lxml.etree._Feed... | [
"Parse",
"an",
"HTML",
"or",
"XML",
"document",
"and",
"return",
"the",
"extacted",
"object",
"following",
"the",
"Parsley",
"rules",
"give",
"at",
"instantiation",
"."
] | redapple/parslepy | python | https://github.com/redapple/parslepy/blob/a8bc4c0592824459629018c8f4c6ae3dad6cc3cc/parslepy/base.py#L280-L302 | [
"def",
"parse",
"(",
"self",
",",
"fp",
",",
"parser",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"if",
"parser",
"is",
"None",
":",
"parser",
"=",
"lxml",
".",
"etree",
".",
"HTMLParser",
"(",
")",
"doc",
"=",
"lxml",
".",
"etree",
".",... | a8bc4c0592824459629018c8f4c6ae3dad6cc3cc |
valid | Parselet.parse_fromstring | Parse an HTML or XML document and
return the extacted object following the Parsley rules give at instantiation.
:param string s: an HTML or XML document as a string
:param parser: *lxml.etree._FeedParser* instance (optional); defaults to lxml.etree.HTMLParser()
:param context: user-supp... | parslepy/base.py | def parse_fromstring(self, s, parser=None, context=None):
"""
Parse an HTML or XML document and
return the extacted object following the Parsley rules give at instantiation.
:param string s: an HTML or XML document as a string
:param parser: *lxml.etree._FeedParser* instance (op... | def parse_fromstring(self, s, parser=None, context=None):
"""
Parse an HTML or XML document and
return the extacted object following the Parsley rules give at instantiation.
:param string s: an HTML or XML document as a string
:param parser: *lxml.etree._FeedParser* instance (op... | [
"Parse",
"an",
"HTML",
"or",
"XML",
"document",
"and",
"return",
"the",
"extacted",
"object",
"following",
"the",
"Parsley",
"rules",
"give",
"at",
"instantiation",
"."
] | redapple/parslepy | python | https://github.com/redapple/parslepy/blob/a8bc4c0592824459629018c8f4c6ae3dad6cc3cc/parslepy/base.py#L304-L319 | [
"def",
"parse_fromstring",
"(",
"self",
",",
"s",
",",
"parser",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"if",
"parser",
"is",
"None",
":",
"parser",
"=",
"lxml",
".",
"etree",
".",
"HTMLParser",
"(",
")",
"doc",
"=",
"lxml",
".",
"etre... | a8bc4c0592824459629018c8f4c6ae3dad6cc3cc |
valid | Parselet.compile | Build the abstract Parsley tree starting from the root node
(recursive) | parslepy/base.py | def compile(self):
"""
Build the abstract Parsley tree starting from the root node
(recursive)
"""
if not isinstance(self.parselet, dict):
raise ValueError("Parselet must be a dict of some sort. Or use .from_jsonstring(), " \
".from_jsonfile(), .from_y... | def compile(self):
"""
Build the abstract Parsley tree starting from the root node
(recursive)
"""
if not isinstance(self.parselet, dict):
raise ValueError("Parselet must be a dict of some sort. Or use .from_jsonstring(), " \
".from_jsonfile(), .from_y... | [
"Build",
"the",
"abstract",
"Parsley",
"tree",
"starting",
"from",
"the",
"root",
"node",
"(",
"recursive",
")"
] | redapple/parslepy | python | https://github.com/redapple/parslepy/blob/a8bc4c0592824459629018c8f4c6ae3dad6cc3cc/parslepy/base.py#L321-L329 | [
"def",
"compile",
"(",
"self",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"parselet",
",",
"dict",
")",
":",
"raise",
"ValueError",
"(",
"\"Parselet must be a dict of some sort. Or use .from_jsonstring(), \"",
"\".from_jsonfile(), .from_yamlstring(), or .from_ya... | a8bc4c0592824459629018c8f4c6ae3dad6cc3cc |
valid | Parselet._compile | Build part of the abstract Parsley extraction tree
Arguments:
parselet_node (dict) -- part of the Parsley tree to compile
(can be the root dict/node)
level (int) -- current recursion depth (used for debug) | parslepy/base.py | def _compile(self, parselet_node, level=0):
"""
Build part of the abstract Parsley extraction tree
Arguments:
parselet_node (dict) -- part of the Parsley tree to compile
(can be the root dict/node)
level (int) -- current recursion depth (... | def _compile(self, parselet_node, level=0):
"""
Build part of the abstract Parsley extraction tree
Arguments:
parselet_node (dict) -- part of the Parsley tree to compile
(can be the root dict/node)
level (int) -- current recursion depth (... | [
"Build",
"part",
"of",
"the",
"abstract",
"Parsley",
"extraction",
"tree"
] | redapple/parslepy | python | https://github.com/redapple/parslepy/blob/a8bc4c0592824459629018c8f4c6ae3dad6cc3cc/parslepy/base.py#L338-L429 | [
"def",
"_compile",
"(",
"self",
",",
"parselet_node",
",",
"level",
"=",
"0",
")",
":",
"if",
"self",
".",
"DEBUG",
":",
"debug_offset",
"=",
"\"\"",
".",
"join",
"(",
"[",
"\" \"",
"for",
"x",
"in",
"range",
"(",
"level",
")",
"]",
")",
"if",
... | a8bc4c0592824459629018c8f4c6ae3dad6cc3cc |
valid | Parselet.extract | Extract values as a dict object following the structure
of the Parsley script (recursive)
:param document: lxml-parsed document
:param context: user-supplied context that will be passed to custom XPath extensions (as first argument)
:rtype: Python *dict* object with mapped extracted con... | parslepy/base.py | def extract(self, document, context=None):
"""
Extract values as a dict object following the structure
of the Parsley script (recursive)
:param document: lxml-parsed document
:param context: user-supplied context that will be passed to custom XPath extensions (as first argument)... | def extract(self, document, context=None):
"""
Extract values as a dict object following the structure
of the Parsley script (recursive)
:param document: lxml-parsed document
:param context: user-supplied context that will be passed to custom XPath extensions (as first argument)... | [
"Extract",
"values",
"as",
"a",
"dict",
"object",
"following",
"the",
"structure",
"of",
"the",
"Parsley",
"script",
"(",
"recursive",
")"
] | redapple/parslepy | python | https://github.com/redapple/parslepy/blob/a8bc4c0592824459629018c8f4c6ae3dad6cc3cc/parslepy/base.py#L431-L475 | [
"def",
"extract",
"(",
"self",
",",
"document",
",",
"context",
"=",
"None",
")",
":",
"if",
"context",
":",
"self",
".",
"selector_handler",
".",
"context",
"=",
"context",
"return",
"self",
".",
"_extract",
"(",
"self",
".",
"parselet_tree",
",",
"docu... | a8bc4c0592824459629018c8f4c6ae3dad6cc3cc |
valid | Parselet._extract | Extract values at this document node level
using the parselet_node instructions:
- go deeper in tree
- or call selector handler in case of a terminal selector leaf | parslepy/base.py | def _extract(self, parselet_node, document, level=0):
"""
Extract values at this document node level
using the parselet_node instructions:
- go deeper in tree
- or call selector handler in case of a terminal selector leaf
"""
if self.DEBUG:
debug_offs... | def _extract(self, parselet_node, document, level=0):
"""
Extract values at this document node level
using the parselet_node instructions:
- go deeper in tree
- or call selector handler in case of a terminal selector leaf
"""
if self.DEBUG:
debug_offs... | [
"Extract",
"values",
"at",
"this",
"document",
"node",
"level",
"using",
"the",
"parselet_node",
"instructions",
":",
"-",
"go",
"deeper",
"in",
"tree",
"-",
"or",
"call",
"selector",
"handler",
"in",
"case",
"of",
"a",
"terminal",
"selector",
"leaf"
] | redapple/parslepy | python | https://github.com/redapple/parslepy/blob/a8bc4c0592824459629018c8f4c6ae3dad6cc3cc/parslepy/base.py#L477-L614 | [
"def",
"_extract",
"(",
"self",
",",
"parselet_node",
",",
"document",
",",
"level",
"=",
"0",
")",
":",
"if",
"self",
".",
"DEBUG",
":",
"debug_offset",
"=",
"\"\"",
".",
"join",
"(",
"[",
"\" \"",
"for",
"x",
"in",
"range",
"(",
"level",
")",
... | a8bc4c0592824459629018c8f4c6ae3dad6cc3cc |
valid | Dataset.auto_constraints | Use CLDF reference properties to implicitely create foreign key constraints.
:param component: A Table object or `None`. | src/pycldf/dataset.py | def auto_constraints(self, component=None):
"""
Use CLDF reference properties to implicitely create foreign key constraints.
:param component: A Table object or `None`.
"""
if not component:
for table in self.tables:
self.auto_constraints(table)
... | def auto_constraints(self, component=None):
"""
Use CLDF reference properties to implicitely create foreign key constraints.
:param component: A Table object or `None`.
"""
if not component:
for table in self.tables:
self.auto_constraints(table)
... | [
"Use",
"CLDF",
"reference",
"properties",
"to",
"implicitely",
"create",
"foreign",
"key",
"constraints",
"."
] | cldf/pycldf | python | https://github.com/cldf/pycldf/blob/636f1eb3ea769394e14ad9e42a83b6096efa9728/src/pycldf/dataset.py#L161-L189 | [
"def",
"auto_constraints",
"(",
"self",
",",
"component",
"=",
"None",
")",
":",
"if",
"not",
"component",
":",
"for",
"table",
"in",
"self",
".",
"tables",
":",
"self",
".",
"auto_constraints",
"(",
"table",
")",
"return",
"if",
"not",
"component",
".",... | 636f1eb3ea769394e14ad9e42a83b6096efa9728 |
valid | Service.url_builder | Create a URL for the specified endpoint.
Arguments:
endpoint (:py:class:`str`): The API endpoint to access.
root: (:py:class:`str`, optional): The root URL for the
service API.
params: (:py:class:`dict`, optional): The values for format
into the created URL... | aslack/core.py | def url_builder(self, endpoint, *, root=None, params=None, url_params=None):
"""Create a URL for the specified endpoint.
Arguments:
endpoint (:py:class:`str`): The API endpoint to access.
root: (:py:class:`str`, optional): The root URL for the
service API.
para... | def url_builder(self, endpoint, *, root=None, params=None, url_params=None):
"""Create a URL for the specified endpoint.
Arguments:
endpoint (:py:class:`str`): The API endpoint to access.
root: (:py:class:`str`, optional): The root URL for the
service API.
para... | [
"Create",
"a",
"URL",
"for",
"the",
"specified",
"endpoint",
"."
] | textbook/aslack | python | https://github.com/textbook/aslack/blob/9ac6a44e4464180109fa4be130ad7a980a9d1acc/aslack/core.py#L37-L62 | [
"def",
"url_builder",
"(",
"self",
",",
"endpoint",
",",
"*",
",",
"root",
"=",
"None",
",",
"params",
"=",
"None",
",",
"url_params",
"=",
"None",
")",
":",
"if",
"root",
"is",
"None",
":",
"root",
"=",
"self",
".",
"ROOT",
"scheme",
",",
"netloc"... | 9ac6a44e4464180109fa4be130ad7a980a9d1acc |
valid | raise_for_status | Raise an appropriate error for a given response.
Arguments:
response (:py:class:`aiohttp.ClientResponse`): The API response.
Raises:
:py:class:`aiohttp.web_exceptions.HTTPException`: The appropriate
error for the response's status. | aslack/utils.py | def raise_for_status(response):
"""Raise an appropriate error for a given response.
Arguments:
response (:py:class:`aiohttp.ClientResponse`): The API response.
Raises:
:py:class:`aiohttp.web_exceptions.HTTPException`: The appropriate
error for the response's status.
"""
for er... | def raise_for_status(response):
"""Raise an appropriate error for a given response.
Arguments:
response (:py:class:`aiohttp.ClientResponse`): The API response.
Raises:
:py:class:`aiohttp.web_exceptions.HTTPException`: The appropriate
error for the response's status.
"""
for er... | [
"Raise",
"an",
"appropriate",
"error",
"for",
"a",
"given",
"response",
"."
] | textbook/aslack | python | https://github.com/textbook/aslack/blob/9ac6a44e4464180109fa4be130ad7a980a9d1acc/aslack/utils.py#L27-L47 | [
"def",
"raise_for_status",
"(",
"response",
")",
":",
"for",
"err_name",
"in",
"web_exceptions",
".",
"__all__",
":",
"err",
"=",
"getattr",
"(",
"web_exceptions",
",",
"err_name",
")",
"if",
"err",
".",
"status_code",
"==",
"response",
".",
"status",
":",
... | 9ac6a44e4464180109fa4be130ad7a980a9d1acc |
valid | truncate | Truncate the supplied text for display.
Arguments:
text (:py:class:`str`): The text to truncate.
max_len (:py:class:`int`, optional): The maximum length of the
text before truncation (defaults to 350 characters).
end (:py:class:`str`, optional): The ending to use to show that
the ... | aslack/utils.py | def truncate(text, max_len=350, end='...'):
"""Truncate the supplied text for display.
Arguments:
text (:py:class:`str`): The text to truncate.
max_len (:py:class:`int`, optional): The maximum length of the
text before truncation (defaults to 350 characters).
end (:py:class:`str`, opt... | def truncate(text, max_len=350, end='...'):
"""Truncate the supplied text for display.
Arguments:
text (:py:class:`str`): The text to truncate.
max_len (:py:class:`int`, optional): The maximum length of the
text before truncation (defaults to 350 characters).
end (:py:class:`str`, opt... | [
"Truncate",
"the",
"supplied",
"text",
"for",
"display",
"."
] | textbook/aslack | python | https://github.com/textbook/aslack/blob/9ac6a44e4464180109fa4be130ad7a980a9d1acc/aslack/utils.py#L50-L66 | [
"def",
"truncate",
"(",
"text",
",",
"max_len",
"=",
"350",
",",
"end",
"=",
"'...'",
")",
":",
"if",
"len",
"(",
"text",
")",
"<=",
"max_len",
":",
"return",
"text",
"return",
"text",
"[",
":",
"max_len",
"]",
".",
"rsplit",
"(",
"' '",
",",
"ma... | 9ac6a44e4464180109fa4be130ad7a980a9d1acc |
valid | Sources.add | Add a source, either specified by glottolog reference id, or as bibtex record. | src/pycldf/sources.py | def add(self, *entries):
"""
Add a source, either specified by glottolog reference id, or as bibtex record.
"""
for entry in entries:
if isinstance(entry, string_types):
self._add_entries(database.parse_string(entry, bib_format='bibtex'))
else:
... | def add(self, *entries):
"""
Add a source, either specified by glottolog reference id, or as bibtex record.
"""
for entry in entries:
if isinstance(entry, string_types):
self._add_entries(database.parse_string(entry, bib_format='bibtex'))
else:
... | [
"Add",
"a",
"source",
"either",
"specified",
"by",
"glottolog",
"reference",
"id",
"or",
"as",
"bibtex",
"record",
"."
] | cldf/pycldf | python | https://github.com/cldf/pycldf/blob/636f1eb3ea769394e14ad9e42a83b6096efa9728/src/pycldf/sources.py#L185-L193 | [
"def",
"add",
"(",
"self",
",",
"*",
"entries",
")",
":",
"for",
"entry",
"in",
"entries",
":",
"if",
"isinstance",
"(",
"entry",
",",
"string_types",
")",
":",
"self",
".",
"_add_entries",
"(",
"database",
".",
"parse_string",
"(",
"entry",
",",
"bib_... | 636f1eb3ea769394e14ad9e42a83b6096efa9728 |
valid | primary_avatar | This tag tries to get the default avatar for a user without doing any db
requests. It achieve this by linking to a special view that will do all the
work for us. If that special view is then cached by a CDN for instance,
we will avoid many db calls. | avatar/templatetags/avatar_tags.py | def primary_avatar(user, size=AVATAR_DEFAULT_SIZE):
"""
This tag tries to get the default avatar for a user without doing any db
requests. It achieve this by linking to a special view that will do all the
work for us. If that special view is then cached by a CDN for instance,
we will avoid many db ... | def primary_avatar(user, size=AVATAR_DEFAULT_SIZE):
"""
This tag tries to get the default avatar for a user without doing any db
requests. It achieve this by linking to a special view that will do all the
work for us. If that special view is then cached by a CDN for instance,
we will avoid many db ... | [
"This",
"tag",
"tries",
"to",
"get",
"the",
"default",
"avatar",
"for",
"a",
"user",
"without",
"doing",
"any",
"db",
"requests",
".",
"It",
"achieve",
"this",
"by",
"linking",
"to",
"a",
"special",
"view",
"that",
"will",
"do",
"all",
"the",
"work",
"... | GeoNode/geonode-avatar | python | https://github.com/GeoNode/geonode-avatar/blob/45f33be4e623d0e7a2b31a83eb68af48dfbb959b/avatar/templatetags/avatar_tags.py#L58-L68 | [
"def",
"primary_avatar",
"(",
"user",
",",
"size",
"=",
"AVATAR_DEFAULT_SIZE",
")",
":",
"alt",
"=",
"unicode",
"(",
"user",
")",
"url",
"=",
"reverse",
"(",
"'avatar_render_primary'",
",",
"kwargs",
"=",
"{",
"'user'",
":",
"user",
",",
"'size'",
":",
"... | 45f33be4e623d0e7a2b31a83eb68af48dfbb959b |
valid | get_cache_key | Returns a cache key consisten of a username and image size. | avatar/util.py | def get_cache_key(user_or_username, size, prefix):
"""
Returns a cache key consisten of a username and image size.
"""
if isinstance(user_or_username, get_user_model()):
user_or_username = user_or_username.username
return '%s_%s_%s' % (prefix, user_or_username, size) | def get_cache_key(user_or_username, size, prefix):
"""
Returns a cache key consisten of a username and image size.
"""
if isinstance(user_or_username, get_user_model()):
user_or_username = user_or_username.username
return '%s_%s_%s' % (prefix, user_or_username, size) | [
"Returns",
"a",
"cache",
"key",
"consisten",
"of",
"a",
"username",
"and",
"image",
"size",
"."
] | GeoNode/geonode-avatar | python | https://github.com/GeoNode/geonode-avatar/blob/45f33be4e623d0e7a2b31a83eb68af48dfbb959b/avatar/util.py#L11-L17 | [
"def",
"get_cache_key",
"(",
"user_or_username",
",",
"size",
",",
"prefix",
")",
":",
"if",
"isinstance",
"(",
"user_or_username",
",",
"get_user_model",
"(",
")",
")",
":",
"user_or_username",
"=",
"user_or_username",
".",
"username",
"return",
"'%s_%s_%s'",
"... | 45f33be4e623d0e7a2b31a83eb68af48dfbb959b |
valid | cache_result | Decorator to cache the result of functions that take a ``user`` and a
``size`` value. | avatar/util.py | def cache_result(func):
"""
Decorator to cache the result of functions that take a ``user`` and a
``size`` value.
"""
def cache_set(key, value):
cache.set(key, value, AVATAR_CACHE_TIMEOUT)
return value
def cached_func(user, size):
prefix = func.__name__
cached_fu... | def cache_result(func):
"""
Decorator to cache the result of functions that take a ``user`` and a
``size`` value.
"""
def cache_set(key, value):
cache.set(key, value, AVATAR_CACHE_TIMEOUT)
return value
def cached_func(user, size):
prefix = func.__name__
cached_fu... | [
"Decorator",
"to",
"cache",
"the",
"result",
"of",
"functions",
"that",
"take",
"a",
"user",
"and",
"a",
"size",
"value",
"."
] | GeoNode/geonode-avatar | python | https://github.com/GeoNode/geonode-avatar/blob/45f33be4e623d0e7a2b31a83eb68af48dfbb959b/avatar/util.py#L19-L33 | [
"def",
"cache_result",
"(",
"func",
")",
":",
"def",
"cache_set",
"(",
"key",
",",
"value",
")",
":",
"cache",
".",
"set",
"(",
"key",
",",
"value",
",",
"AVATAR_CACHE_TIMEOUT",
")",
"return",
"value",
"def",
"cached_func",
"(",
"user",
",",
"size",
")... | 45f33be4e623d0e7a2b31a83eb68af48dfbb959b |
valid | invalidate_cache | Function to be called when saving or changing an user's avatars. | avatar/util.py | def invalidate_cache(user, size=None):
"""
Function to be called when saving or changing an user's avatars.
"""
sizes = set(AUTO_GENERATE_AVATAR_SIZES)
if size is not None:
sizes.add(size)
for prefix in cached_funcs:
for size in sizes:
cache.delete(get_cache_key(user,... | def invalidate_cache(user, size=None):
"""
Function to be called when saving or changing an user's avatars.
"""
sizes = set(AUTO_GENERATE_AVATAR_SIZES)
if size is not None:
sizes.add(size)
for prefix in cached_funcs:
for size in sizes:
cache.delete(get_cache_key(user,... | [
"Function",
"to",
"be",
"called",
"when",
"saving",
"or",
"changing",
"an",
"user",
"s",
"avatars",
"."
] | GeoNode/geonode-avatar | python | https://github.com/GeoNode/geonode-avatar/blob/45f33be4e623d0e7a2b31a83eb68af48dfbb959b/avatar/util.py#L35-L44 | [
"def",
"invalidate_cache",
"(",
"user",
",",
"size",
"=",
"None",
")",
":",
"sizes",
"=",
"set",
"(",
"AUTO_GENERATE_AVATAR_SIZES",
")",
"if",
"size",
"is",
"not",
"None",
":",
"sizes",
".",
"add",
"(",
"size",
")",
"for",
"prefix",
"in",
"cached_funcs",... | 45f33be4e623d0e7a2b31a83eb68af48dfbb959b |
valid | get_field_for_proxy | Returns a field object instance for a given PrefProxy object.
:param PrefProxy pref_proxy:
:rtype: models.Field | siteprefs/utils.py | def get_field_for_proxy(pref_proxy):
"""Returns a field object instance for a given PrefProxy object.
:param PrefProxy pref_proxy:
:rtype: models.Field
"""
field = {
bool: models.BooleanField,
int: models.IntegerField,
float: models.FloatField,
datetime: models.Da... | def get_field_for_proxy(pref_proxy):
"""Returns a field object instance for a given PrefProxy object.
:param PrefProxy pref_proxy:
:rtype: models.Field
"""
field = {
bool: models.BooleanField,
int: models.IntegerField,
float: models.FloatField,
datetime: models.Da... | [
"Returns",
"a",
"field",
"object",
"instance",
"for",
"a",
"given",
"PrefProxy",
"object",
"."
] | idlesign/django-siteprefs | python | https://github.com/idlesign/django-siteprefs/blob/3d6bf5e64220fe921468a36fce68e15d7947cf92/siteprefs/utils.py#L227-L245 | [
"def",
"get_field_for_proxy",
"(",
"pref_proxy",
")",
":",
"field",
"=",
"{",
"bool",
":",
"models",
".",
"BooleanField",
",",
"int",
":",
"models",
".",
"IntegerField",
",",
"float",
":",
"models",
".",
"FloatField",
",",
"datetime",
":",
"models",
".",
... | 3d6bf5e64220fe921468a36fce68e15d7947cf92 |
valid | update_field_from_proxy | Updates field object with data from a PrefProxy object.
:param models.Field field_obj:
:param PrefProxy pref_proxy: | siteprefs/utils.py | def update_field_from_proxy(field_obj, pref_proxy):
"""Updates field object with data from a PrefProxy object.
:param models.Field field_obj:
:param PrefProxy pref_proxy:
"""
attr_names = ('verbose_name', 'help_text', 'default')
for attr_name in attr_names:
setattr(field_obj, attr_na... | def update_field_from_proxy(field_obj, pref_proxy):
"""Updates field object with data from a PrefProxy object.
:param models.Field field_obj:
:param PrefProxy pref_proxy:
"""
attr_names = ('verbose_name', 'help_text', 'default')
for attr_name in attr_names:
setattr(field_obj, attr_na... | [
"Updates",
"field",
"object",
"with",
"data",
"from",
"a",
"PrefProxy",
"object",
"."
] | idlesign/django-siteprefs | python | https://github.com/idlesign/django-siteprefs/blob/3d6bf5e64220fe921468a36fce68e15d7947cf92/siteprefs/utils.py#L248-L259 | [
"def",
"update_field_from_proxy",
"(",
"field_obj",
",",
"pref_proxy",
")",
":",
"attr_names",
"=",
"(",
"'verbose_name'",
",",
"'help_text'",
",",
"'default'",
")",
"for",
"attr_name",
"in",
"attr_names",
":",
"setattr",
"(",
"field_obj",
",",
"attr_name",
",",... | 3d6bf5e64220fe921468a36fce68e15d7947cf92 |
valid | get_pref_model_class | Returns preferences model class dynamically crated for a given app or None on conflict. | siteprefs/utils.py | def get_pref_model_class(app, prefs, get_prefs_func):
"""Returns preferences model class dynamically crated for a given app or None on conflict."""
module = '%s.%s' % (app, PREFS_MODULE_NAME)
model_dict = {
'_prefs_app': app,
'_get_prefs': staticmethod(get_prefs_func),
... | def get_pref_model_class(app, prefs, get_prefs_func):
"""Returns preferences model class dynamically crated for a given app or None on conflict."""
module = '%s.%s' % (app, PREFS_MODULE_NAME)
model_dict = {
'_prefs_app': app,
'_get_prefs': staticmethod(get_prefs_func),
... | [
"Returns",
"preferences",
"model",
"class",
"dynamically",
"crated",
"for",
"a",
"given",
"app",
"or",
"None",
"on",
"conflict",
"."
] | idlesign/django-siteprefs | python | https://github.com/idlesign/django-siteprefs/blob/3d6bf5e64220fe921468a36fce68e15d7947cf92/siteprefs/utils.py#L262-L303 | [
"def",
"get_pref_model_class",
"(",
"app",
",",
"prefs",
",",
"get_prefs_func",
")",
":",
"module",
"=",
"'%s.%s'",
"%",
"(",
"app",
",",
"PREFS_MODULE_NAME",
")",
"model_dict",
"=",
"{",
"'_prefs_app'",
":",
"app",
",",
"'_get_prefs'",
":",
"staticmethod",
... | 3d6bf5e64220fe921468a36fce68e15d7947cf92 |
valid | get_frame_locals | Returns locals dictionary from a given frame.
:param int stepback:
:rtype: dict | siteprefs/utils.py | def get_frame_locals(stepback=0):
"""Returns locals dictionary from a given frame.
:param int stepback:
:rtype: dict
"""
with Frame(stepback=stepback) as frame:
locals_dict = frame.f_locals
return locals_dict | def get_frame_locals(stepback=0):
"""Returns locals dictionary from a given frame.
:param int stepback:
:rtype: dict
"""
with Frame(stepback=stepback) as frame:
locals_dict = frame.f_locals
return locals_dict | [
"Returns",
"locals",
"dictionary",
"from",
"a",
"given",
"frame",
"."
] | idlesign/django-siteprefs | python | https://github.com/idlesign/django-siteprefs/blob/3d6bf5e64220fe921468a36fce68e15d7947cf92/siteprefs/utils.py#L353-L364 | [
"def",
"get_frame_locals",
"(",
"stepback",
"=",
"0",
")",
":",
"with",
"Frame",
"(",
"stepback",
"=",
"stepback",
")",
"as",
"frame",
":",
"locals_dict",
"=",
"frame",
".",
"f_locals",
"return",
"locals_dict"
] | 3d6bf5e64220fe921468a36fce68e15d7947cf92 |
valid | traverse_local_prefs | Generator to walk through variables considered as preferences
in locals dict of a given frame.
:param int stepback:
:rtype: tuple | siteprefs/utils.py | def traverse_local_prefs(stepback=0):
"""Generator to walk through variables considered as preferences
in locals dict of a given frame.
:param int stepback:
:rtype: tuple
"""
locals_dict = get_frame_locals(stepback+1)
for k in locals_dict:
if not k.startswith('_') and k.upper() ==... | def traverse_local_prefs(stepback=0):
"""Generator to walk through variables considered as preferences
in locals dict of a given frame.
:param int stepback:
:rtype: tuple
"""
locals_dict = get_frame_locals(stepback+1)
for k in locals_dict:
if not k.startswith('_') and k.upper() ==... | [
"Generator",
"to",
"walk",
"through",
"variables",
"considered",
"as",
"preferences",
"in",
"locals",
"dict",
"of",
"a",
"given",
"frame",
"."
] | idlesign/django-siteprefs | python | https://github.com/idlesign/django-siteprefs/blob/3d6bf5e64220fe921468a36fce68e15d7947cf92/siteprefs/utils.py#L367-L379 | [
"def",
"traverse_local_prefs",
"(",
"stepback",
"=",
"0",
")",
":",
"locals_dict",
"=",
"get_frame_locals",
"(",
"stepback",
"+",
"1",
")",
"for",
"k",
"in",
"locals_dict",
":",
"if",
"not",
"k",
".",
"startswith",
"(",
"'_'",
")",
"and",
"k",
".",
"up... | 3d6bf5e64220fe921468a36fce68e15d7947cf92 |
valid | import_prefs | Imports preferences modules from packages (apps) and project root. | siteprefs/utils.py | def import_prefs():
"""Imports preferences modules from packages (apps) and project root."""
# settings.py locals if autodiscover_siteprefs() is in urls.py
settings_locals = get_frame_locals(3)
if 'self' not in settings_locals: # If not SiteprefsConfig.ready()
# Try to import project-wide... | def import_prefs():
"""Imports preferences modules from packages (apps) and project root."""
# settings.py locals if autodiscover_siteprefs() is in urls.py
settings_locals = get_frame_locals(3)
if 'self' not in settings_locals: # If not SiteprefsConfig.ready()
# Try to import project-wide... | [
"Imports",
"preferences",
"modules",
"from",
"packages",
"(",
"apps",
")",
"and",
"project",
"root",
"."
] | idlesign/django-siteprefs | python | https://github.com/idlesign/django-siteprefs/blob/3d6bf5e64220fe921468a36fce68e15d7947cf92/siteprefs/utils.py#L392-L408 | [
"def",
"import_prefs",
"(",
")",
":",
"# settings.py locals if autodiscover_siteprefs() is in urls.py",
"settings_locals",
"=",
"get_frame_locals",
"(",
"3",
")",
"if",
"'self'",
"not",
"in",
"settings_locals",
":",
"# If not SiteprefsConfig.ready()",
"# Try to import project-w... | 3d6bf5e64220fe921468a36fce68e15d7947cf92 |
valid | print_file_info | Prints file details in the current directory | examples.py | def print_file_info():
"""Prints file details in the current directory"""
tpl = TableLogger(columns='file,created,modified,size')
for f in os.listdir('.'):
size = os.stat(f).st_size
date_created = datetime.fromtimestamp(os.path.getctime(f))
date_modified = datetime.fromtimestamp(os.p... | def print_file_info():
"""Prints file details in the current directory"""
tpl = TableLogger(columns='file,created,modified,size')
for f in os.listdir('.'):
size = os.stat(f).st_size
date_created = datetime.fromtimestamp(os.path.getctime(f))
date_modified = datetime.fromtimestamp(os.p... | [
"Prints",
"file",
"details",
"in",
"the",
"current",
"directory"
] | AleksTk/table-logger | python | https://github.com/AleksTk/table-logger/blob/d2326e053fb972ed7ae4950d0e8c6e7c9f4399b8/examples.py#L27-L34 | [
"def",
"print_file_info",
"(",
")",
":",
"tpl",
"=",
"TableLogger",
"(",
"columns",
"=",
"'file,created,modified,size'",
")",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"'.'",
")",
":",
"size",
"=",
"os",
".",
"stat",
"(",
"f",
")",
".",
"st_size",
... | d2326e053fb972ed7ae4950d0e8c6e7c9f4399b8 |
valid | DispatchGroup._bind_args | Attempt to bind the args to the type signature. First try to just bind
to the signature, then ensure that all arguments match the parameter
types. | dispatching.py | def _bind_args(sig, param_matchers, args, kwargs):
'''
Attempt to bind the args to the type signature. First try to just bind
to the signature, then ensure that all arguments match the parameter
types.
'''
#Bind to signature. May throw its own TypeError
bound = si... | def _bind_args(sig, param_matchers, args, kwargs):
'''
Attempt to bind the args to the type signature. First try to just bind
to the signature, then ensure that all arguments match the parameter
types.
'''
#Bind to signature. May throw its own TypeError
bound = si... | [
"Attempt",
"to",
"bind",
"the",
"args",
"to",
"the",
"type",
"signature",
".",
"First",
"try",
"to",
"just",
"bind",
"to",
"the",
"signature",
"then",
"ensure",
"that",
"all",
"arguments",
"match",
"the",
"parameter",
"types",
"."
] | Lucretiel/Dispatch | python | https://github.com/Lucretiel/Dispatch/blob/dffbce6bacb4370c4ecd11652e5ba8a6aaf2b5b4/dispatching.py#L34-L47 | [
"def",
"_bind_args",
"(",
"sig",
",",
"param_matchers",
",",
"args",
",",
"kwargs",
")",
":",
"#Bind to signature. May throw its own TypeError",
"bound",
"=",
"sig",
".",
"bind",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"not",
"all",
"(",
"par... | dffbce6bacb4370c4ecd11652e5ba8a6aaf2b5b4 |
valid | DispatchGroup._make_param_matcher | For a given annotation, return a function which, when called on a
function argument, returns true if that argument matches the annotation.
If the annotation is a type, it calls isinstance; if it's a callable,
it calls it on the object; otherwise, it performs a value comparison.
If the pa... | dispatching.py | def _make_param_matcher(annotation, kind=None):
'''
For a given annotation, return a function which, when called on a
function argument, returns true if that argument matches the annotation.
If the annotation is a type, it calls isinstance; if it's a callable,
it calls it on the ... | def _make_param_matcher(annotation, kind=None):
'''
For a given annotation, return a function which, when called on a
function argument, returns true if that argument matches the annotation.
If the annotation is a type, it calls isinstance; if it's a callable,
it calls it on the ... | [
"For",
"a",
"given",
"annotation",
"return",
"a",
"function",
"which",
"when",
"called",
"on",
"a",
"function",
"argument",
"returns",
"true",
"if",
"that",
"argument",
"matches",
"the",
"annotation",
".",
"If",
"the",
"annotation",
"is",
"a",
"type",
"it",
... | Lucretiel/Dispatch | python | https://github.com/Lucretiel/Dispatch/blob/dffbce6bacb4370c4ecd11652e5ba8a6aaf2b5b4/dispatching.py#L50-L69 | [
"def",
"_make_param_matcher",
"(",
"annotation",
",",
"kind",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"annotation",
",",
"type",
")",
"or",
"(",
"isinstance",
"(",
"annotation",
",",
"tuple",
")",
"and",
"all",
"(",
"isinstance",
"(",
"a",
",",
... | dffbce6bacb4370c4ecd11652e5ba8a6aaf2b5b4 |
valid | DispatchGroup._make_all_matchers | For every parameter, create a matcher if the parameter has an
annotation. | dispatching.py | def _make_all_matchers(cls, parameters):
'''
For every parameter, create a matcher if the parameter has an
annotation.
'''
for name, param in parameters:
annotation = param.annotation
if annotation is not Parameter.empty:
yield name, cls._m... | def _make_all_matchers(cls, parameters):
'''
For every parameter, create a matcher if the parameter has an
annotation.
'''
for name, param in parameters:
annotation = param.annotation
if annotation is not Parameter.empty:
yield name, cls._m... | [
"For",
"every",
"parameter",
"create",
"a",
"matcher",
"if",
"the",
"parameter",
"has",
"an",
"annotation",
"."
] | Lucretiel/Dispatch | python | https://github.com/Lucretiel/Dispatch/blob/dffbce6bacb4370c4ecd11652e5ba8a6aaf2b5b4/dispatching.py#L72-L80 | [
"def",
"_make_all_matchers",
"(",
"cls",
",",
"parameters",
")",
":",
"for",
"name",
",",
"param",
"in",
"parameters",
":",
"annotation",
"=",
"param",
".",
"annotation",
"if",
"annotation",
"is",
"not",
"Parameter",
".",
"empty",
":",
"yield",
"name",
","... | dffbce6bacb4370c4ecd11652e5ba8a6aaf2b5b4 |
valid | DispatchGroup._make_dispatch | Create a dispatch pair for func- a tuple of (bind_args, func), where
bind_args is a function that, when called with (args, kwargs), attempts
to bind those args to the type signature of func, or else raise a
TypeError | dispatching.py | def _make_dispatch(cls, func):
'''
Create a dispatch pair for func- a tuple of (bind_args, func), where
bind_args is a function that, when called with (args, kwargs), attempts
to bind those args to the type signature of func, or else raise a
TypeError
'''
sig = si... | def _make_dispatch(cls, func):
'''
Create a dispatch pair for func- a tuple of (bind_args, func), where
bind_args is a function that, when called with (args, kwargs), attempts
to bind those args to the type signature of func, or else raise a
TypeError
'''
sig = si... | [
"Create",
"a",
"dispatch",
"pair",
"for",
"func",
"-",
"a",
"tuple",
"of",
"(",
"bind_args",
"func",
")",
"where",
"bind_args",
"is",
"a",
"function",
"that",
"when",
"called",
"with",
"(",
"args",
"kwargs",
")",
"attempts",
"to",
"bind",
"those",
"args"... | Lucretiel/Dispatch | python | https://github.com/Lucretiel/Dispatch/blob/dffbce6bacb4370c4ecd11652e5ba8a6aaf2b5b4/dispatching.py#L83-L92 | [
"def",
"_make_dispatch",
"(",
"cls",
",",
"func",
")",
":",
"sig",
"=",
"signature",
"(",
"func",
")",
"matchers",
"=",
"tuple",
"(",
"cls",
".",
"_make_all_matchers",
"(",
"sig",
".",
"parameters",
".",
"items",
"(",
")",
")",
")",
"return",
"(",
"p... | dffbce6bacb4370c4ecd11652e5ba8a6aaf2b5b4 |
valid | DispatchGroup._make_wrapper | Makes a wrapper function that executes a dispatch call for func. The
wrapper has the dispatch and dispatch_first attributes, so that
additional overloads can be added to the group. | dispatching.py | def _make_wrapper(self, func):
'''
Makes a wrapper function that executes a dispatch call for func. The
wrapper has the dispatch and dispatch_first attributes, so that
additional overloads can be added to the group.
'''
#TODO: consider using a class to make attribute for... | def _make_wrapper(self, func):
'''
Makes a wrapper function that executes a dispatch call for func. The
wrapper has the dispatch and dispatch_first attributes, so that
additional overloads can be added to the group.
'''
#TODO: consider using a class to make attribute for... | [
"Makes",
"a",
"wrapper",
"function",
"that",
"executes",
"a",
"dispatch",
"call",
"for",
"func",
".",
"The",
"wrapper",
"has",
"the",
"dispatch",
"and",
"dispatch_first",
"attributes",
"so",
"that",
"additional",
"overloads",
"can",
"be",
"added",
"to",
"the",... | Lucretiel/Dispatch | python | https://github.com/Lucretiel/Dispatch/blob/dffbce6bacb4370c4ecd11652e5ba8a6aaf2b5b4/dispatching.py#L94-L111 | [
"def",
"_make_wrapper",
"(",
"self",
",",
"func",
")",
":",
"#TODO: consider using a class to make attribute forwarding easier.",
"#TODO: consider using simply another DispatchGroup, with self.callees",
"# assigned by reference to the original callees.",
"@",
"wraps",
"(",
"func",
")",... | dffbce6bacb4370c4ecd11652e5ba8a6aaf2b5b4 |
valid | DispatchGroup.dispatch | Adds the decorated function to this dispatch. | dispatching.py | def dispatch(self, func):
'''
Adds the decorated function to this dispatch.
'''
self.callees.append(self._make_dispatch(func))
return self._make_wrapper(func) | def dispatch(self, func):
'''
Adds the decorated function to this dispatch.
'''
self.callees.append(self._make_dispatch(func))
return self._make_wrapper(func) | [
"Adds",
"the",
"decorated",
"function",
"to",
"this",
"dispatch",
"."
] | Lucretiel/Dispatch | python | https://github.com/Lucretiel/Dispatch/blob/dffbce6bacb4370c4ecd11652e5ba8a6aaf2b5b4/dispatching.py#L113-L118 | [
"def",
"dispatch",
"(",
"self",
",",
"func",
")",
":",
"self",
".",
"callees",
".",
"append",
"(",
"self",
".",
"_make_dispatch",
"(",
"func",
")",
")",
"return",
"self",
".",
"_make_wrapper",
"(",
"func",
")"
] | dffbce6bacb4370c4ecd11652e5ba8a6aaf2b5b4 |
valid | DispatchGroup.dispatch_first | Adds the decorated function to this dispatch, at the FRONT of the order.
Useful for allowing third parties to add overloaded functionality
to be executed before default functionality. | dispatching.py | def dispatch_first(self, func):
'''
Adds the decorated function to this dispatch, at the FRONT of the order.
Useful for allowing third parties to add overloaded functionality
to be executed before default functionality.
'''
self.callees.appendleft(self._make_dispatch(func... | def dispatch_first(self, func):
'''
Adds the decorated function to this dispatch, at the FRONT of the order.
Useful for allowing third parties to add overloaded functionality
to be executed before default functionality.
'''
self.callees.appendleft(self._make_dispatch(func... | [
"Adds",
"the",
"decorated",
"function",
"to",
"this",
"dispatch",
"at",
"the",
"FRONT",
"of",
"the",
"order",
".",
"Useful",
"for",
"allowing",
"third",
"parties",
"to",
"add",
"overloaded",
"functionality",
"to",
"be",
"executed",
"before",
"default",
"functi... | Lucretiel/Dispatch | python | https://github.com/Lucretiel/Dispatch/blob/dffbce6bacb4370c4ecd11652e5ba8a6aaf2b5b4/dispatching.py#L120-L127 | [
"def",
"dispatch_first",
"(",
"self",
",",
"func",
")",
":",
"self",
".",
"callees",
".",
"appendleft",
"(",
"self",
".",
"_make_dispatch",
"(",
"func",
")",
")",
"return",
"self",
".",
"_make_wrapper",
"(",
"func",
")"
] | dffbce6bacb4370c4ecd11652e5ba8a6aaf2b5b4 |
valid | DispatchGroup.lookup_explicit | Lookup the function that will be called with a given set of arguments,
or raise DispatchError. Requires explicit tuple/dict grouping of
arguments (see DispatchGroup.lookup for a function-like interface). | dispatching.py | def lookup_explicit(self, args, kwargs):
'''
Lookup the function that will be called with a given set of arguments,
or raise DispatchError. Requires explicit tuple/dict grouping of
arguments (see DispatchGroup.lookup for a function-like interface).
'''
for bind_args, call... | def lookup_explicit(self, args, kwargs):
'''
Lookup the function that will be called with a given set of arguments,
or raise DispatchError. Requires explicit tuple/dict grouping of
arguments (see DispatchGroup.lookup for a function-like interface).
'''
for bind_args, call... | [
"Lookup",
"the",
"function",
"that",
"will",
"be",
"called",
"with",
"a",
"given",
"set",
"of",
"arguments",
"or",
"raise",
"DispatchError",
".",
"Requires",
"explicit",
"tuple",
"/",
"dict",
"grouping",
"of",
"arguments",
"(",
"see",
"DispatchGroup",
".",
"... | Lucretiel/Dispatch | python | https://github.com/Lucretiel/Dispatch/blob/dffbce6bacb4370c4ecd11652e5ba8a6aaf2b5b4/dispatching.py#L129-L148 | [
"def",
"lookup_explicit",
"(",
"self",
",",
"args",
",",
"kwargs",
")",
":",
"for",
"bind_args",
",",
"callee",
"in",
"self",
".",
"callees",
":",
"try",
":",
"#bind to the signature and types. Raises TypeError on failure",
"bind_args",
"(",
"args",
",",
"kwargs",... | dffbce6bacb4370c4ecd11652e5ba8a6aaf2b5b4 |
valid | DispatchGroup.execute | Dispatch a call. Call the first function whose type signature matches
the arguemts. | dispatching.py | def execute(self, args, kwargs):
'''
Dispatch a call. Call the first function whose type signature matches
the arguemts.
'''
return self.lookup_explicit(args, kwargs)(*args, **kwargs) | def execute(self, args, kwargs):
'''
Dispatch a call. Call the first function whose type signature matches
the arguemts.
'''
return self.lookup_explicit(args, kwargs)(*args, **kwargs) | [
"Dispatch",
"a",
"call",
".",
"Call",
"the",
"first",
"function",
"whose",
"type",
"signature",
"matches",
"the",
"arguemts",
"."
] | Lucretiel/Dispatch | python | https://github.com/Lucretiel/Dispatch/blob/dffbce6bacb4370c4ecd11652e5ba8a6aaf2b5b4/dispatching.py#L157-L162 | [
"def",
"execute",
"(",
"self",
",",
"args",
",",
"kwargs",
")",
":",
"return",
"self",
".",
"lookup_explicit",
"(",
"args",
",",
"kwargs",
")",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | dffbce6bacb4370c4ecd11652e5ba8a6aaf2b5b4 |
valid | TableLogger.setup_formatters | Setup formatters by observing the first row.
Args:
*args: row cells | table_logger/table_logger.py | def setup_formatters(self, *args):
"""Setup formatters by observing the first row.
Args:
*args: row cells
"""
formatters = []
col_offset = 0
# initialize formatters for row-id, timestamp and time-diff columns
if self.rownum:
format... | def setup_formatters(self, *args):
"""Setup formatters by observing the first row.
Args:
*args: row cells
"""
formatters = []
col_offset = 0
# initialize formatters for row-id, timestamp and time-diff columns
if self.rownum:
format... | [
"Setup",
"formatters",
"by",
"observing",
"the",
"first",
"row",
".",
"Args",
":",
"*",
"args",
":",
"row",
"cells"
] | AleksTk/table-logger | python | https://github.com/AleksTk/table-logger/blob/d2326e053fb972ed7ae4950d0e8c6e7c9f4399b8/table_logger/table_logger.py#L208-L254 | [
"def",
"setup_formatters",
"(",
"self",
",",
"*",
"args",
")",
":",
"formatters",
"=",
"[",
"]",
"col_offset",
"=",
"0",
"# initialize formatters for row-id, timestamp and time-diff columns",
"if",
"self",
".",
"rownum",
":",
"formatters",
".",
"append",
"(",
"fmt... | d2326e053fb972ed7ae4950d0e8c6e7c9f4399b8 |
valid | TableLogger.setup | Do preparations before printing the first row
Args:
*args: first row cells | table_logger/table_logger.py | def setup(self, *args):
"""Do preparations before printing the first row
Args:
*args: first row cells
"""
self.setup_formatters(*args)
if self.columns:
self.print_header()
elif self.border and not self.csv:
self.print_line(sel... | def setup(self, *args):
"""Do preparations before printing the first row
Args:
*args: first row cells
"""
self.setup_formatters(*args)
if self.columns:
self.print_header()
elif self.border and not self.csv:
self.print_line(sel... | [
"Do",
"preparations",
"before",
"printing",
"the",
"first",
"row",
"Args",
":",
"*",
"args",
":",
"first",
"row",
"cells"
] | AleksTk/table-logger | python | https://github.com/AleksTk/table-logger/blob/d2326e053fb972ed7ae4950d0e8c6e7c9f4399b8/table_logger/table_logger.py#L256-L266 | [
"def",
"setup",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"setup_formatters",
"(",
"*",
"args",
")",
"if",
"self",
".",
"columns",
":",
"self",
".",
"print_header",
"(",
")",
"elif",
"self",
".",
"border",
"and",
"not",
"self",
".",
"cs... | d2326e053fb972ed7ae4950d0e8c6e7c9f4399b8 |
valid | TableLogger.csv_format | Converts row values into a csv line
Args:
row: a list of row cells as unicode
Returns:
csv_line (unicode) | table_logger/table_logger.py | def csv_format(self, row):
"""Converts row values into a csv line
Args:
row: a list of row cells as unicode
Returns:
csv_line (unicode)
"""
if PY2:
buf = io.BytesIO()
csvwriter = csv.writer(buf)
csvwriter.writer... | def csv_format(self, row):
"""Converts row values into a csv line
Args:
row: a list of row cells as unicode
Returns:
csv_line (unicode)
"""
if PY2:
buf = io.BytesIO()
csvwriter = csv.writer(buf)
csvwriter.writer... | [
"Converts",
"row",
"values",
"into",
"a",
"csv",
"line",
"Args",
":",
"row",
":",
"a",
"list",
"of",
"row",
"cells",
"as",
"unicode",
"Returns",
":",
"csv_line",
"(",
"unicode",
")"
] | AleksTk/table-logger | python | https://github.com/AleksTk/table-logger/blob/d2326e053fb972ed7ae4950d0e8c6e7c9f4399b8/table_logger/table_logger.py#L306-L324 | [
"def",
"csv_format",
"(",
"self",
",",
"row",
")",
":",
"if",
"PY2",
":",
"buf",
"=",
"io",
".",
"BytesIO",
"(",
")",
"csvwriter",
"=",
"csv",
".",
"writer",
"(",
"buf",
")",
"csvwriter",
".",
"writerow",
"(",
"[",
"c",
".",
"strip",
"(",
")",
... | d2326e053fb972ed7ae4950d0e8c6e7c9f4399b8 |
valid | convertShpToExtend | reprojette en WGS84 et recupere l'extend | python/utils.py | def convertShpToExtend(pathToShp):
"""
reprojette en WGS84 et recupere l'extend
"""
driver = ogr.GetDriverByName('ESRI Shapefile')
dataset = driver.Open(pathToShp)
if dataset is not None:
# from Layer
layer = dataset.GetLayer()
spatialRef = layer.GetSpatialRef()
... | def convertShpToExtend(pathToShp):
"""
reprojette en WGS84 et recupere l'extend
"""
driver = ogr.GetDriverByName('ESRI Shapefile')
dataset = driver.Open(pathToShp)
if dataset is not None:
# from Layer
layer = dataset.GetLayer()
spatialRef = layer.GetSpatialRef()
... | [
"reprojette",
"en",
"WGS84",
"et",
"recupere",
"l",
"extend"
] | yoannMoreau/gfsDownload | python | https://github.com/yoannMoreau/gfsDownload/blob/56e91a5dffb536596a80d2d614ebe858d9ab5ab7/python/utils.py#L75-L110 | [
"def",
"convertShpToExtend",
"(",
"pathToShp",
")",
":",
"driver",
"=",
"ogr",
".",
"GetDriverByName",
"(",
"'ESRI Shapefile'",
")",
"dataset",
"=",
"driver",
".",
"Open",
"(",
"pathToShp",
")",
"if",
"dataset",
"is",
"not",
"None",
":",
"# from Layer",
"lay... | 56e91a5dffb536596a80d2d614ebe858d9ab5ab7 |
valid | create_request_gfs | Genere la structure de requete pour le téléchargement de données GFS
INPUTS:\n
-date : au format annee-mois-jour\n
-heure : au format heure:minute:seconde\n
-coord : une liste des coordonnees au format [N,W,S,E]\n
-dim_grille : taille de la grille en degree \n | python/utils.py | def create_request_gfs(dateStart,dateEnd,stepList,levelList,grid,extent,paramList,typeData):
"""
Genere la structure de requete pour le téléchargement de données GFS
INPUTS:\n
-date : au format annee-mois-jour\n
-heure : au format heure:minute:seconde\n
-coord : une ... | def create_request_gfs(dateStart,dateEnd,stepList,levelList,grid,extent,paramList,typeData):
"""
Genere la structure de requete pour le téléchargement de données GFS
INPUTS:\n
-date : au format annee-mois-jour\n
-heure : au format heure:minute:seconde\n
-coord : une ... | [
"Genere",
"la",
"structure",
"de",
"requete",
"pour",
"le",
"téléchargement",
"de",
"données",
"GFS",
"INPUTS",
":",
"\\",
"n",
"-",
"date",
":",
"au",
"format",
"annee",
"-",
"mois",
"-",
"jour",
"\\",
"n",
"-",
"heure",
":",
"au",
"format",
"heure",
... | yoannMoreau/gfsDownload | python | https://github.com/yoannMoreau/gfsDownload/blob/56e91a5dffb536596a80d2d614ebe858d9ab5ab7/python/utils.py#L179-L264 | [
"def",
"create_request_gfs",
"(",
"dateStart",
",",
"dateEnd",
",",
"stepList",
",",
"levelList",
",",
"grid",
",",
"extent",
",",
"paramList",
",",
"typeData",
")",
":",
"URLlist",
"=",
"[",
"]",
"#Control datetype",
"listForcastSurface",
"=",
"[",
"'GUST'",
... | 56e91a5dffb536596a80d2d614ebe858d9ab5ab7 |
valid | convertGribToTiff | Convert GRIB to Tif | python/utils.py | def convertGribToTiff(listeFile,listParam,listLevel,liststep,grid,startDate,endDate,outFolder):
""" Convert GRIB to Tif"""
dicoValues={}
for l in listeFile:
grbs = pygrib.open(l)
grbs.seek(0)
index=1
for j in range(len(listLevel),0,-1):
for i in range(le... | def convertGribToTiff(listeFile,listParam,listLevel,liststep,grid,startDate,endDate,outFolder):
""" Convert GRIB to Tif"""
dicoValues={}
for l in listeFile:
grbs = pygrib.open(l)
grbs.seek(0)
index=1
for j in range(len(listLevel),0,-1):
for i in range(le... | [
"Convert",
"GRIB",
"to",
"Tif"
] | yoannMoreau/gfsDownload | python | https://github.com/yoannMoreau/gfsDownload/blob/56e91a5dffb536596a80d2d614ebe858d9ab5ab7/python/utils.py#L331-L370 | [
"def",
"convertGribToTiff",
"(",
"listeFile",
",",
"listParam",
",",
"listLevel",
",",
"liststep",
",",
"grid",
",",
"startDate",
",",
"endDate",
",",
"outFolder",
")",
":",
"dicoValues",
"=",
"{",
"}",
"for",
"l",
"in",
"listeFile",
":",
"grbs",
"=",
"p... | 56e91a5dffb536596a80d2d614ebe858d9ab5ab7 |
valid | on_pref_update | Triggered on dynamic preferences model save.
Issues DB save and reread. | siteprefs/toolbox.py | def on_pref_update(*args, **kwargs):
"""Triggered on dynamic preferences model save.
Issues DB save and reread.
"""
Preference.update_prefs(*args, **kwargs)
Preference.read_prefs(get_prefs()) | def on_pref_update(*args, **kwargs):
"""Triggered on dynamic preferences model save.
Issues DB save and reread.
"""
Preference.update_prefs(*args, **kwargs)
Preference.read_prefs(get_prefs()) | [
"Triggered",
"on",
"dynamic",
"preferences",
"model",
"save",
".",
"Issues",
"DB",
"save",
"and",
"reread",
"."
] | idlesign/django-siteprefs | python | https://github.com/idlesign/django-siteprefs/blob/3d6bf5e64220fe921468a36fce68e15d7947cf92/siteprefs/toolbox.py#L21-L27 | [
"def",
"on_pref_update",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"Preference",
".",
"update_prefs",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"Preference",
".",
"read_prefs",
"(",
"get_prefs",
"(",
")",
")"
] | 3d6bf5e64220fe921468a36fce68e15d7947cf92 |
valid | get_app_prefs | Returns a dictionary with preferences for a certain app/module.
:param str|unicode app:
:rtype: dict | siteprefs/toolbox.py | def get_app_prefs(app=None):
"""Returns a dictionary with preferences for a certain app/module.
:param str|unicode app:
:rtype: dict
"""
if app is None:
with Frame(stepback=1) as frame:
app = frame.f_globals['__name__'].split('.')[0]
prefs = get_prefs()
if app not i... | def get_app_prefs(app=None):
"""Returns a dictionary with preferences for a certain app/module.
:param str|unicode app:
:rtype: dict
"""
if app is None:
with Frame(stepback=1) as frame:
app = frame.f_globals['__name__'].split('.')[0]
prefs = get_prefs()
if app not i... | [
"Returns",
"a",
"dictionary",
"with",
"preferences",
"for",
"a",
"certain",
"app",
"/",
"module",
"."
] | idlesign/django-siteprefs | python | https://github.com/idlesign/django-siteprefs/blob/3d6bf5e64220fe921468a36fce68e15d7947cf92/siteprefs/toolbox.py#L42-L60 | [
"def",
"get_app_prefs",
"(",
"app",
"=",
"None",
")",
":",
"if",
"app",
"is",
"None",
":",
"with",
"Frame",
"(",
"stepback",
"=",
"1",
")",
"as",
"frame",
":",
"app",
"=",
"frame",
".",
"f_globals",
"[",
"'__name__'",
"]",
".",
"split",
"(",
"'.'",... | 3d6bf5e64220fe921468a36fce68e15d7947cf92 |
valid | bind_proxy | Binds PrefProxy objects to module variables used by apps as preferences.
:param list|tuple values: Preference values.
:param str|unicode category: Category name the preference belongs to.
:param Field field: Django model field to represent this preference.
:param str|unicode verbose_name: Field verb... | siteprefs/toolbox.py | def bind_proxy(values, category=None, field=None, verbose_name=None, help_text='', static=True, readonly=False):
"""Binds PrefProxy objects to module variables used by apps as preferences.
:param list|tuple values: Preference values.
:param str|unicode category: Category name the preference belongs to.
... | def bind_proxy(values, category=None, field=None, verbose_name=None, help_text='', static=True, readonly=False):
"""Binds PrefProxy objects to module variables used by apps as preferences.
:param list|tuple values: Preference values.
:param str|unicode category: Category name the preference belongs to.
... | [
"Binds",
"PrefProxy",
"objects",
"to",
"module",
"variables",
"used",
"by",
"apps",
"as",
"preferences",
"."
] | idlesign/django-siteprefs | python | https://github.com/idlesign/django-siteprefs/blob/3d6bf5e64220fe921468a36fce68e15d7947cf92/siteprefs/toolbox.py#L71-L133 | [
"def",
"bind_proxy",
"(",
"values",
",",
"category",
"=",
"None",
",",
"field",
"=",
"None",
",",
"verbose_name",
"=",
"None",
",",
"help_text",
"=",
"''",
",",
"static",
"=",
"True",
",",
"readonly",
"=",
"False",
")",
":",
"addrs",
"=",
"OrderedDict"... | 3d6bf5e64220fe921468a36fce68e15d7947cf92 |
valid | register_admin_models | Registers dynamically created preferences models for Admin interface.
:param admin.AdminSite admin_site: AdminSite object. | siteprefs/toolbox.py | def register_admin_models(admin_site):
"""Registers dynamically created preferences models for Admin interface.
:param admin.AdminSite admin_site: AdminSite object.
"""
global __MODELS_REGISTRY
prefs = get_prefs()
for app_label, prefs_items in prefs.items():
model_class = get_pref_m... | def register_admin_models(admin_site):
"""Registers dynamically created preferences models for Admin interface.
:param admin.AdminSite admin_site: AdminSite object.
"""
global __MODELS_REGISTRY
prefs = get_prefs()
for app_label, prefs_items in prefs.items():
model_class = get_pref_m... | [
"Registers",
"dynamically",
"created",
"preferences",
"models",
"for",
"Admin",
"interface",
"."
] | idlesign/django-siteprefs | python | https://github.com/idlesign/django-siteprefs/blob/3d6bf5e64220fe921468a36fce68e15d7947cf92/siteprefs/toolbox.py#L136-L152 | [
"def",
"register_admin_models",
"(",
"admin_site",
")",
":",
"global",
"__MODELS_REGISTRY",
"prefs",
"=",
"get_prefs",
"(",
")",
"for",
"app_label",
",",
"prefs_items",
"in",
"prefs",
".",
"items",
"(",
")",
":",
"model_class",
"=",
"get_pref_model_class",
"(",
... | 3d6bf5e64220fe921468a36fce68e15d7947cf92 |
valid | autodiscover_siteprefs | Automatically discovers and registers all preferences available in all apps.
:param admin.AdminSite admin_site: Custom AdminSite object. | siteprefs/toolbox.py | def autodiscover_siteprefs(admin_site=None):
"""Automatically discovers and registers all preferences available in all apps.
:param admin.AdminSite admin_site: Custom AdminSite object.
"""
if admin_site is None:
admin_site = admin.site
# Do not discover anything if called from manage.py (... | def autodiscover_siteprefs(admin_site=None):
"""Automatically discovers and registers all preferences available in all apps.
:param admin.AdminSite admin_site: Custom AdminSite object.
"""
if admin_site is None:
admin_site = admin.site
# Do not discover anything if called from manage.py (... | [
"Automatically",
"discovers",
"and",
"registers",
"all",
"preferences",
"available",
"in",
"all",
"apps",
"."
] | idlesign/django-siteprefs | python | https://github.com/idlesign/django-siteprefs/blob/3d6bf5e64220fe921468a36fce68e15d7947cf92/siteprefs/toolbox.py#L155-L168 | [
"def",
"autodiscover_siteprefs",
"(",
"admin_site",
"=",
"None",
")",
":",
"if",
"admin_site",
"is",
"None",
":",
"admin_site",
"=",
"admin",
".",
"site",
"# Do not discover anything if called from manage.py (e.g. executing commands from cli).",
"if",
"'manage'",
"not",
"... | 3d6bf5e64220fe921468a36fce68e15d7947cf92 |
valid | patch_locals | Temporarily (see unpatch_locals()) replaces all module variables
considered preferences with PatchedLocal objects, so that every
variable has different hash returned by id(). | siteprefs/toolbox.py | def patch_locals(depth=2):
"""Temporarily (see unpatch_locals()) replaces all module variables
considered preferences with PatchedLocal objects, so that every
variable has different hash returned by id().
"""
for name, locals_dict in traverse_local_prefs(depth):
locals_dict[name] = PatchedL... | def patch_locals(depth=2):
"""Temporarily (see unpatch_locals()) replaces all module variables
considered preferences with PatchedLocal objects, so that every
variable has different hash returned by id().
"""
for name, locals_dict in traverse_local_prefs(depth):
locals_dict[name] = PatchedL... | [
"Temporarily",
"(",
"see",
"unpatch_locals",
"()",
")",
"replaces",
"all",
"module",
"variables",
"considered",
"preferences",
"with",
"PatchedLocal",
"objects",
"so",
"that",
"every",
"variable",
"has",
"different",
"hash",
"returned",
"by",
"id",
"()",
"."
] | idlesign/django-siteprefs | python | https://github.com/idlesign/django-siteprefs/blob/3d6bf5e64220fe921468a36fce68e15d7947cf92/siteprefs/toolbox.py#L171-L180 | [
"def",
"patch_locals",
"(",
"depth",
"=",
"2",
")",
":",
"for",
"name",
",",
"locals_dict",
"in",
"traverse_local_prefs",
"(",
"depth",
")",
":",
"locals_dict",
"[",
"name",
"]",
"=",
"PatchedLocal",
"(",
"name",
",",
"locals_dict",
"[",
"name",
"]",
")"... | 3d6bf5e64220fe921468a36fce68e15d7947cf92 |
valid | unpatch_locals | Restores the original values of module variables
considered preferences if they are still PatchedLocal
and not PrefProxy. | siteprefs/toolbox.py | def unpatch_locals(depth=3):
"""Restores the original values of module variables
considered preferences if they are still PatchedLocal
and not PrefProxy.
"""
for name, locals_dict in traverse_local_prefs(depth):
if isinstance(locals_dict[name], PatchedLocal):
locals_dict[name] =... | def unpatch_locals(depth=3):
"""Restores the original values of module variables
considered preferences if they are still PatchedLocal
and not PrefProxy.
"""
for name, locals_dict in traverse_local_prefs(depth):
if isinstance(locals_dict[name], PatchedLocal):
locals_dict[name] =... | [
"Restores",
"the",
"original",
"values",
"of",
"module",
"variables",
"considered",
"preferences",
"if",
"they",
"are",
"still",
"PatchedLocal",
"and",
"not",
"PrefProxy",
"."
] | idlesign/django-siteprefs | python | https://github.com/idlesign/django-siteprefs/blob/3d6bf5e64220fe921468a36fce68e15d7947cf92/siteprefs/toolbox.py#L183-L193 | [
"def",
"unpatch_locals",
"(",
"depth",
"=",
"3",
")",
":",
"for",
"name",
",",
"locals_dict",
"in",
"traverse_local_prefs",
"(",
"depth",
")",
":",
"if",
"isinstance",
"(",
"locals_dict",
"[",
"name",
"]",
",",
"PatchedLocal",
")",
":",
"locals_dict",
"[",... | 3d6bf5e64220fe921468a36fce68e15d7947cf92 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.