repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
titusjan/argos | argos/repo/rtiplugins/ncdf.py | NcdfGroupRti._fetchAllChildren | def _fetchAllChildren(self):
""" Fetches all sub groups and variables that this group contains.
"""
assert self._ncGroup is not None, "dataset undefined (file not opened?)"
assert self.canFetchChildren(), "canFetchChildren must be True"
childItems = []
# Add dimensions
... | python | def _fetchAllChildren(self):
""" Fetches all sub groups and variables that this group contains.
"""
assert self._ncGroup is not None, "dataset undefined (file not opened?)"
assert self.canFetchChildren(), "canFetchChildren must be True"
childItems = []
# Add dimensions
... | [
"def",
"_fetchAllChildren",
"(",
"self",
")",
":",
"assert",
"self",
".",
"_ncGroup",
"is",
"not",
"None",
",",
"\"dataset undefined (file not opened?)\"",
"assert",
"self",
".",
"canFetchChildren",
"(",
")",
",",
"\"canFetchChildren must be True\"",
"childItems",
"="... | Fetches all sub groups and variables that this group contains. | [
"Fetches",
"all",
"sub",
"groups",
"and",
"variables",
"that",
"this",
"group",
"contains",
"."
] | train | https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/repo/rtiplugins/ncdf.py#L393-L413 |
titusjan/argos | argos/repo/rtiplugins/ncdf.py | NcdfFileRti._openResources | def _openResources(self):
""" Opens the root Dataset.
"""
logger.info("Opening: {}".format(self._fileName))
self._ncGroup = Dataset(self._fileName) | python | def _openResources(self):
""" Opens the root Dataset.
"""
logger.info("Opening: {}".format(self._fileName))
self._ncGroup = Dataset(self._fileName) | [
"def",
"_openResources",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"Opening: {}\"",
".",
"format",
"(",
"self",
".",
"_fileName",
")",
")",
"self",
".",
"_ncGroup",
"=",
"Dataset",
"(",
"self",
".",
"_fileName",
")"
] | Opens the root Dataset. | [
"Opens",
"the",
"root",
"Dataset",
"."
] | train | https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/repo/rtiplugins/ncdf.py#L431-L435 |
titusjan/argos | argos/repo/rtiplugins/ncdf.py | NcdfFileRti._closeResources | def _closeResources(self):
""" Closes the root Dataset.
"""
logger.info("Closing: {}".format(self._fileName))
self._ncGroup.close()
self._ncGroup = None | python | def _closeResources(self):
""" Closes the root Dataset.
"""
logger.info("Closing: {}".format(self._fileName))
self._ncGroup.close()
self._ncGroup = None | [
"def",
"_closeResources",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"Closing: {}\"",
".",
"format",
"(",
"self",
".",
"_fileName",
")",
")",
"self",
".",
"_ncGroup",
".",
"close",
"(",
")",
"self",
".",
"_ncGroup",
"=",
"None"
] | Closes the root Dataset. | [
"Closes",
"the",
"root",
"Dataset",
"."
] | train | https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/repo/rtiplugins/ncdf.py#L437-L442 |
titusjan/argos | argos/repo/rtiplugins/scipyio.py | WavFileRti._openResources | def _openResources(self):
""" Uses numpy.loadtxt to open the underlying file.
"""
try:
rate, data = scipy.io.wavfile.read(self._fileName, mmap=True)
except Exception as ex:
logger.warning(ex)
logger.warning("Unable to read wav with memmory mapping. Try... | python | def _openResources(self):
""" Uses numpy.loadtxt to open the underlying file.
"""
try:
rate, data = scipy.io.wavfile.read(self._fileName, mmap=True)
except Exception as ex:
logger.warning(ex)
logger.warning("Unable to read wav with memmory mapping. Try... | [
"def",
"_openResources",
"(",
"self",
")",
":",
"try",
":",
"rate",
",",
"data",
"=",
"scipy",
".",
"io",
".",
"wavfile",
".",
"read",
"(",
"self",
".",
"_fileName",
",",
"mmap",
"=",
"True",
")",
"except",
"Exception",
"as",
"ex",
":",
"logger",
"... | Uses numpy.loadtxt to open the underlying file. | [
"Uses",
"numpy",
".",
"loadtxt",
"to",
"open",
"the",
"underlying",
"file",
"."
] | train | https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/repo/rtiplugins/scipyio.py#L134-L145 |
titusjan/argos | argos/repo/rtiplugins/scipyio.py | WavFileRti._fetchAllChildren | def _fetchAllChildren(self):
""" Adds an ArrayRti per column as children so that they can be inspected easily
"""
childItems = []
if self._array.ndim == 2:
_nRows, nCols = self._array.shape if self._array is not None else (0, 0)
for col in range(nCols):
... | python | def _fetchAllChildren(self):
""" Adds an ArrayRti per column as children so that they can be inspected easily
"""
childItems = []
if self._array.ndim == 2:
_nRows, nCols = self._array.shape if self._array is not None else (0, 0)
for col in range(nCols):
... | [
"def",
"_fetchAllChildren",
"(",
"self",
")",
":",
"childItems",
"=",
"[",
"]",
"if",
"self",
".",
"_array",
".",
"ndim",
"==",
"2",
":",
"_nRows",
",",
"nCols",
"=",
"self",
".",
"_array",
".",
"shape",
"if",
"self",
".",
"_array",
"is",
"not",
"N... | Adds an ArrayRti per column as children so that they can be inspected easily | [
"Adds",
"an",
"ArrayRti",
"per",
"column",
"as",
"children",
"so",
"that",
"they",
"can",
"be",
"inspected",
"easily"
] | train | https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/repo/rtiplugins/scipyio.py#L155-L166 |
titusjan/argos | argos/inspector/qtplugins/text.py | TextInspector._drawContents | def _drawContents(self, reason=None, initiator=None):
""" Converts the (zero-dimensional) sliced array to string and puts it in the text editor.
The reason and initiator parameters are ignored.
See AbstractInspector.updateContents for their description.
"""
logger.debug(... | python | def _drawContents(self, reason=None, initiator=None):
""" Converts the (zero-dimensional) sliced array to string and puts it in the text editor.
The reason and initiator parameters are ignored.
See AbstractInspector.updateContents for their description.
"""
logger.debug(... | [
"def",
"_drawContents",
"(",
"self",
",",
"reason",
"=",
"None",
",",
"initiator",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"\"TextInspector._drawContents: {}\"",
".",
"format",
"(",
"self",
")",
")",
"self",
".",
"_clearContents",
"(",
")",
"sl... | Converts the (zero-dimensional) sliced array to string and puts it in the text editor.
The reason and initiator parameters are ignored.
See AbstractInspector.updateContents for their description. | [
"Converts",
"the",
"(",
"zero",
"-",
"dimensional",
")",
"sliced",
"array",
"to",
"string",
"and",
"puts",
"it",
"in",
"the",
"text",
"editor",
"."
] | train | https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/inspector/qtplugins/text.py#L102-L132 |
titusjan/argos | argos/inspector/pgplugins/pgplotitem.py | middleMouseClickEvent | def middleMouseClickEvent(argosPgPlotItem, axisNumber, mouseClickEvent):
""" Emits sigAxisReset when the middle mouse button is clicked on an axis of the the plot item.
"""
if mouseClickEvent.button() == QtCore.Qt.MiddleButton:
mouseClickEvent.accept()
argosPgPlotItem.emitResetAxisSignal(axi... | python | def middleMouseClickEvent(argosPgPlotItem, axisNumber, mouseClickEvent):
""" Emits sigAxisReset when the middle mouse button is clicked on an axis of the the plot item.
"""
if mouseClickEvent.button() == QtCore.Qt.MiddleButton:
mouseClickEvent.accept()
argosPgPlotItem.emitResetAxisSignal(axi... | [
"def",
"middleMouseClickEvent",
"(",
"argosPgPlotItem",
",",
"axisNumber",
",",
"mouseClickEvent",
")",
":",
"if",
"mouseClickEvent",
".",
"button",
"(",
")",
"==",
"QtCore",
".",
"Qt",
".",
"MiddleButton",
":",
"mouseClickEvent",
".",
"accept",
"(",
")",
"arg... | Emits sigAxisReset when the middle mouse button is clicked on an axis of the the plot item. | [
"Emits",
"sigAxisReset",
"when",
"the",
"middle",
"mouse",
"button",
"is",
"clicked",
"on",
"an",
"axis",
"of",
"the",
"the",
"plot",
"item",
"."
] | train | https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/inspector/pgplugins/pgplotitem.py#L49-L54 |
titusjan/argos | argos/inspector/pgplugins/pgplotitem.py | ArgosPgPlotItem.close | def close(self):
""" Is called before destruction. Can be used to clean-up resources
Could be called 'finalize' but PlotItem already has a close so we reuse that.
"""
logger.debug("Finalizing: {}".format(self))
super(ArgosPgPlotItem, self).close() | python | def close(self):
""" Is called before destruction. Can be used to clean-up resources
Could be called 'finalize' but PlotItem already has a close so we reuse that.
"""
logger.debug("Finalizing: {}".format(self))
super(ArgosPgPlotItem, self).close() | [
"def",
"close",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Finalizing: {}\"",
".",
"format",
"(",
"self",
")",
")",
"super",
"(",
"ArgosPgPlotItem",
",",
"self",
")",
".",
"close",
"(",
")"
] | Is called before destruction. Can be used to clean-up resources
Could be called 'finalize' but PlotItem already has a close so we reuse that. | [
"Is",
"called",
"before",
"destruction",
".",
"Can",
"be",
"used",
"to",
"clean",
"-",
"up",
"resources",
"Could",
"be",
"called",
"finalize",
"but",
"PlotItem",
"already",
"has",
"a",
"close",
"so",
"we",
"reuse",
"that",
"."
] | train | https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/inspector/pgplugins/pgplotitem.py#L120-L125 |
titusjan/argos | argos/inspector/pgplugins/pgplotitem.py | ArgosPgPlotItem.contextMenuEvent | def contextMenuEvent(self, event):
""" Shows the context menu at the cursor position
We need to take the event-based approach because ArgosPgPlotItem does derives from
QGraphicsWidget, and not from QWidget, and therefore doesn't have the
customContextMenuRequested signal.
... | python | def contextMenuEvent(self, event):
""" Shows the context menu at the cursor position
We need to take the event-based approach because ArgosPgPlotItem does derives from
QGraphicsWidget, and not from QWidget, and therefore doesn't have the
customContextMenuRequested signal.
... | [
"def",
"contextMenuEvent",
"(",
"self",
",",
"event",
")",
":",
"contextMenu",
"=",
"QtWidgets",
".",
"QMenu",
"(",
")",
"for",
"action",
"in",
"self",
".",
"actions",
"(",
")",
":",
"contextMenu",
".",
"addAction",
"(",
"action",
")",
"contextMenu",
"."... | Shows the context menu at the cursor position
We need to take the event-based approach because ArgosPgPlotItem does derives from
QGraphicsWidget, and not from QWidget, and therefore doesn't have the
customContextMenuRequested signal. | [
"Shows",
"the",
"context",
"menu",
"at",
"the",
"cursor",
"position"
] | train | https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/inspector/pgplugins/pgplotitem.py#L128-L138 |
titusjan/argos | argos/inspector/pgplugins/pgplotitem.py | ArgosPgPlotItem.emitResetAxisSignal | def emitResetAxisSignal(self, axisNumber):
""" Emits the sigResetAxis with the axisNumber as parameter
axisNumber should be 0 for X, 1 for Y, and 2 for both axes.
"""
assert axisNumber in (VALID_AXES_NUMBERS), \
"Axis Nr should be one of {}, got {}".format(VALID_AXES_NUMB... | python | def emitResetAxisSignal(self, axisNumber):
""" Emits the sigResetAxis with the axisNumber as parameter
axisNumber should be 0 for X, 1 for Y, and 2 for both axes.
"""
assert axisNumber in (VALID_AXES_NUMBERS), \
"Axis Nr should be one of {}, got {}".format(VALID_AXES_NUMB... | [
"def",
"emitResetAxisSignal",
"(",
"self",
",",
"axisNumber",
")",
":",
"assert",
"axisNumber",
"in",
"(",
"VALID_AXES_NUMBERS",
")",
",",
"\"Axis Nr should be one of {}, got {}\"",
".",
"format",
"(",
"VALID_AXES_NUMBERS",
",",
"axisNumber",
")",
"# Hide 'auto-scale (A... | Emits the sigResetAxis with the axisNumber as parameter
axisNumber should be 0 for X, 1 for Y, and 2 for both axes. | [
"Emits",
"the",
"sigResetAxis",
"with",
"the",
"axisNumber",
"as",
"parameter",
"axisNumber",
"should",
"be",
"0",
"for",
"X",
"1",
"for",
"Y",
"and",
"2",
"for",
"both",
"axes",
"."
] | train | https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/inspector/pgplugins/pgplotitem.py#L148-L168 |
tarmstrong/nbdiff | nbdiff/merge.py | merge | def merge(local, base, remote, check_modified=False):
"""Generate unmerged series of changes (including conflicts).
By diffing the two diffs, we find *changes* that are
on the local branch, the remote branch, or both.
We arbitrarily choose the "local" branch to be the "before"
and the "remote" bran... | python | def merge(local, base, remote, check_modified=False):
"""Generate unmerged series of changes (including conflicts).
By diffing the two diffs, we find *changes* that are
on the local branch, the remote branch, or both.
We arbitrarily choose the "local" branch to be the "before"
and the "remote" bran... | [
"def",
"merge",
"(",
"local",
",",
"base",
",",
"remote",
",",
"check_modified",
"=",
"False",
")",
":",
"base_local",
"=",
"diff",
".",
"diff",
"(",
"base",
",",
"local",
",",
"check_modified",
"=",
"check_modified",
")",
"base_remote",
"=",
"diff",
"."... | Generate unmerged series of changes (including conflicts).
By diffing the two diffs, we find *changes* that are
on the local branch, the remote branch, or both.
We arbitrarily choose the "local" branch to be the "before"
and the "remote" branch to be the "after" in the diff algorithm.
Therefore:
... | [
"Generate",
"unmerged",
"series",
"of",
"changes",
"(",
"including",
"conflicts",
")",
"."
] | train | https://github.com/tarmstrong/nbdiff/blob/3fdfb89f94fc0f4821bc04999ddf53b34d882ab9/nbdiff/merge.py#L11-L43 |
tarmstrong/nbdiff | nbdiff/merge.py | notebook_merge | def notebook_merge(local, base, remote, check_modified=False):
"""Unify three notebooks into a single notebook with merge metadata.
The result of this function is a valid notebook that can be loaded
by the IPython Notebook front-end. This function adds additional
cell metadata that the front-end Javasc... | python | def notebook_merge(local, base, remote, check_modified=False):
"""Unify three notebooks into a single notebook with merge metadata.
The result of this function is a valid notebook that can be loaded
by the IPython Notebook front-end. This function adds additional
cell metadata that the front-end Javasc... | [
"def",
"notebook_merge",
"(",
"local",
",",
"base",
",",
"remote",
",",
"check_modified",
"=",
"False",
")",
":",
"local_cells",
"=",
"get_cells",
"(",
"local",
")",
"base_cells",
"=",
"get_cells",
"(",
"base",
")",
"remote_cells",
"=",
"get_cells",
"(",
"... | Unify three notebooks into a single notebook with merge metadata.
The result of this function is a valid notebook that can be loaded
by the IPython Notebook front-end. This function adds additional
cell metadata that the front-end Javascript uses to render the merge.
Parameters
----------
loca... | [
"Unify",
"three",
"notebooks",
"into",
"a",
"single",
"notebook",
"with",
"merge",
"metadata",
"."
] | train | https://github.com/tarmstrong/nbdiff/blob/3fdfb89f94fc0f4821bc04999ddf53b34d882ab9/nbdiff/merge.py#L46-L177 |
tarmstrong/nbdiff | nbdiff/notebook_parser.py | NotebookParser.parse | def parse(self, json_data):
"""Parse a notebook .ipynb file.
Parameters
----------
json_data : file
A file handle for an .ipynb file.
Returns
-------
nb : An IPython Notebook data structure.
"""
data = current.read(json_data, 'ipynb')... | python | def parse(self, json_data):
"""Parse a notebook .ipynb file.
Parameters
----------
json_data : file
A file handle for an .ipynb file.
Returns
-------
nb : An IPython Notebook data structure.
"""
data = current.read(json_data, 'ipynb')... | [
"def",
"parse",
"(",
"self",
",",
"json_data",
")",
":",
"data",
"=",
"current",
".",
"read",
"(",
"json_data",
",",
"'ipynb'",
")",
"json_data",
".",
"close",
"(",
")",
"return",
"data"
] | Parse a notebook .ipynb file.
Parameters
----------
json_data : file
A file handle for an .ipynb file.
Returns
-------
nb : An IPython Notebook data structure. | [
"Parse",
"a",
"notebook",
".",
"ipynb",
"file",
"."
] | train | https://github.com/tarmstrong/nbdiff/blob/3fdfb89f94fc0f4821bc04999ddf53b34d882ab9/nbdiff/notebook_parser.py#L6-L20 |
tarmstrong/nbdiff | nbdiff/notebook_diff.py | notebook_diff | def notebook_diff(nb1, nb2, check_modified=True):
"""Unify two notebooks into a single notebook with diff metadata.
The result of this function is a valid notebook that can be loaded
by the IPython Notebook front-end. This function adds additional
cell metadata that the front-end Javascript uses to ren... | python | def notebook_diff(nb1, nb2, check_modified=True):
"""Unify two notebooks into a single notebook with diff metadata.
The result of this function is a valid notebook that can be loaded
by the IPython Notebook front-end. This function adds additional
cell metadata that the front-end Javascript uses to ren... | [
"def",
"notebook_diff",
"(",
"nb1",
",",
"nb2",
",",
"check_modified",
"=",
"True",
")",
":",
"nb1_cells",
"=",
"nb1",
"[",
"'worksheets'",
"]",
"[",
"0",
"]",
"[",
"'cells'",
"]",
"nb2_cells",
"=",
"nb2",
"[",
"'worksheets'",
"]",
"[",
"0",
"]",
"["... | Unify two notebooks into a single notebook with diff metadata.
The result of this function is a valid notebook that can be loaded
by the IPython Notebook front-end. This function adds additional
cell metadata that the front-end Javascript uses to render the diffs.
Parameters
----------
nb1 : d... | [
"Unify",
"two",
"notebooks",
"into",
"a",
"single",
"notebook",
"with",
"diff",
"metadata",
"."
] | train | https://github.com/tarmstrong/nbdiff/blob/3fdfb89f94fc0f4821bc04999ddf53b34d882ab9/nbdiff/notebook_diff.py#L5-L41 |
tarmstrong/nbdiff | nbdiff/notebook_diff.py | diff_result_to_cell | def diff_result_to_cell(item):
'''diff.diff returns a dictionary with all the information we need,
but we want to extract the cell and change its metadata.'''
state = item['state']
if state == 'modified':
new_cell = item['modifiedvalue'].data
old_cell = item['originalvalue'].data
... | python | def diff_result_to_cell(item):
'''diff.diff returns a dictionary with all the information we need,
but we want to extract the cell and change its metadata.'''
state = item['state']
if state == 'modified':
new_cell = item['modifiedvalue'].data
old_cell = item['originalvalue'].data
... | [
"def",
"diff_result_to_cell",
"(",
"item",
")",
":",
"state",
"=",
"item",
"[",
"'state'",
"]",
"if",
"state",
"==",
"'modified'",
":",
"new_cell",
"=",
"item",
"[",
"'modifiedvalue'",
"]",
".",
"data",
"old_cell",
"=",
"item",
"[",
"'originalvalue'",
"]",... | diff.diff returns a dictionary with all the information we need,
but we want to extract the cell and change its metadata. | [
"diff",
".",
"diff",
"returns",
"a",
"dictionary",
"with",
"all",
"the",
"information",
"we",
"need",
"but",
"we",
"want",
"to",
"extract",
"the",
"cell",
"and",
"change",
"its",
"metadata",
"."
] | train | https://github.com/tarmstrong/nbdiff/blob/3fdfb89f94fc0f4821bc04999ddf53b34d882ab9/nbdiff/notebook_diff.py#L61-L74 |
tarmstrong/nbdiff | nbdiff/notebook_diff.py | cells_diff | def cells_diff(before_cells, after_cells, check_modified=False):
'''Diff two arrays of cells.'''
before_comps = [
CellComparator(cell, check_modified=check_modified)
for cell in before_cells
]
after_comps = [
CellComparator(cell, check_modified=check_modified)
for cell in... | python | def cells_diff(before_cells, after_cells, check_modified=False):
'''Diff two arrays of cells.'''
before_comps = [
CellComparator(cell, check_modified=check_modified)
for cell in before_cells
]
after_comps = [
CellComparator(cell, check_modified=check_modified)
for cell in... | [
"def",
"cells_diff",
"(",
"before_cells",
",",
"after_cells",
",",
"check_modified",
"=",
"False",
")",
":",
"before_comps",
"=",
"[",
"CellComparator",
"(",
"cell",
",",
"check_modified",
"=",
"check_modified",
")",
"for",
"cell",
"in",
"before_cells",
"]",
"... | Diff two arrays of cells. | [
"Diff",
"two",
"arrays",
"of",
"cells",
"."
] | train | https://github.com/tarmstrong/nbdiff/blob/3fdfb89f94fc0f4821bc04999ddf53b34d882ab9/nbdiff/notebook_diff.py#L77-L92 |
tarmstrong/nbdiff | nbdiff/notebook_diff.py | words_diff | def words_diff(before_words, after_words):
'''Diff the words in two strings.
This is intended for use in diffing prose and other forms of text
where line breaks have little semantic value.
Parameters
----------
before_words : str
A string to be used as the baseline version.
after_w... | python | def words_diff(before_words, after_words):
'''Diff the words in two strings.
This is intended for use in diffing prose and other forms of text
where line breaks have little semantic value.
Parameters
----------
before_words : str
A string to be used as the baseline version.
after_w... | [
"def",
"words_diff",
"(",
"before_words",
",",
"after_words",
")",
":",
"before_comps",
"=",
"before_words",
".",
"split",
"(",
")",
"after_comps",
"=",
"after_words",
".",
"split",
"(",
")",
"diff_result",
"=",
"diff",
"(",
"before_comps",
",",
"after_comps",... | Diff the words in two strings.
This is intended for use in diffing prose and other forms of text
where line breaks have little semantic value.
Parameters
----------
before_words : str
A string to be used as the baseline version.
after_words : str
A string to be compared against... | [
"Diff",
"the",
"words",
"in",
"two",
"strings",
"."
] | train | https://github.com/tarmstrong/nbdiff/blob/3fdfb89f94fc0f4821bc04999ddf53b34d882ab9/nbdiff/notebook_diff.py#L95-L119 |
tarmstrong/nbdiff | nbdiff/notebook_diff.py | lines_diff | def lines_diff(before_lines, after_lines, check_modified=False):
'''Diff the lines in two strings.
Parameters
----------
before_lines : iterable
Iterable containing lines used as the baseline version.
after_lines : iterable
Iterable containing lines to be compared against the baseli... | python | def lines_diff(before_lines, after_lines, check_modified=False):
'''Diff the lines in two strings.
Parameters
----------
before_lines : iterable
Iterable containing lines used as the baseline version.
after_lines : iterable
Iterable containing lines to be compared against the baseli... | [
"def",
"lines_diff",
"(",
"before_lines",
",",
"after_lines",
",",
"check_modified",
"=",
"False",
")",
":",
"before_comps",
"=",
"[",
"LineComparator",
"(",
"line",
",",
"check_modified",
"=",
"check_modified",
")",
"for",
"line",
"in",
"before_lines",
"]",
"... | Diff the lines in two strings.
Parameters
----------
before_lines : iterable
Iterable containing lines used as the baseline version.
after_lines : iterable
Iterable containing lines to be compared against the baseline.
Returns
-------
diff_result : A list of dictionaries co... | [
"Diff",
"the",
"lines",
"in",
"two",
"strings",
"."
] | train | https://github.com/tarmstrong/nbdiff/blob/3fdfb89f94fc0f4821bc04999ddf53b34d882ab9/nbdiff/notebook_diff.py#L122-L149 |
tarmstrong/nbdiff | nbdiff/diff.py | diff | def diff(before, after, check_modified=False):
"""Diff two sequences of comparable objects.
The result of this function is a list of dictionaries containing
values in ``before`` or ``after`` with a ``state`` of either
'unchanged', 'added', 'deleted', or 'modified'.
>>> import pprint
>>> result... | python | def diff(before, after, check_modified=False):
"""Diff two sequences of comparable objects.
The result of this function is a list of dictionaries containing
values in ``before`` or ``after`` with a ``state`` of either
'unchanged', 'added', 'deleted', or 'modified'.
>>> import pprint
>>> result... | [
"def",
"diff",
"(",
"before",
",",
"after",
",",
"check_modified",
"=",
"False",
")",
":",
"# The grid will be empty if `before` or `after` are",
"# empty; this will violate the assumptions made in the rest",
"# of this function.",
"# If this is the case, we know what the result of the... | Diff two sequences of comparable objects.
The result of this function is a list of dictionaries containing
values in ``before`` or ``after`` with a ``state`` of either
'unchanged', 'added', 'deleted', or 'modified'.
>>> import pprint
>>> result = diff(['a', 'b', 'c'], ['b', 'c', 'd'])
>>> ppri... | [
"Diff",
"two",
"sequences",
"of",
"comparable",
"objects",
"."
] | train | https://github.com/tarmstrong/nbdiff/blob/3fdfb89f94fc0f4821bc04999ddf53b34d882ab9/nbdiff/diff.py#L7-L96 |
tarmstrong/nbdiff | nbdiff/comparable.py | LineComparator.equal | def equal(self, line1, line2):
'''
return true if exactly equal or if equal but modified,
otherwise return false
return type: BooleanPlus
'''
eqLine = line1 == line2
if eqLine:
return BooleanPlus(True, False)
else:
unchanged_count ... | python | def equal(self, line1, line2):
'''
return true if exactly equal or if equal but modified,
otherwise return false
return type: BooleanPlus
'''
eqLine = line1 == line2
if eqLine:
return BooleanPlus(True, False)
else:
unchanged_count ... | [
"def",
"equal",
"(",
"self",
",",
"line1",
",",
"line2",
")",
":",
"eqLine",
"=",
"line1",
"==",
"line2",
"if",
"eqLine",
":",
"return",
"BooleanPlus",
"(",
"True",
",",
"False",
")",
"else",
":",
"unchanged_count",
"=",
"self",
".",
"count_similar_words... | return true if exactly equal or if equal but modified,
otherwise return false
return type: BooleanPlus | [
"return",
"true",
"if",
"exactly",
"equal",
"or",
"if",
"equal",
"but",
"modified",
"otherwise",
"return",
"false",
"return",
"type",
":",
"BooleanPlus"
] | train | https://github.com/tarmstrong/nbdiff/blob/3fdfb89f94fc0f4821bc04999ddf53b34d882ab9/nbdiff/comparable.py#L34-L52 |
tarmstrong/nbdiff | nbdiff/comparable.py | CellComparator.compare_cells | def compare_cells(self, cell1, cell2):
'''
return true if exactly equal or if equal but modified,
otherwise return false
return type: BooleanPlus
'''
eqlanguage = cell1["language"] == cell2["language"]
eqinput = cell1["input"] == cell2["input"]
eqoutputs =... | python | def compare_cells(self, cell1, cell2):
'''
return true if exactly equal or if equal but modified,
otherwise return false
return type: BooleanPlus
'''
eqlanguage = cell1["language"] == cell2["language"]
eqinput = cell1["input"] == cell2["input"]
eqoutputs =... | [
"def",
"compare_cells",
"(",
"self",
",",
"cell1",
",",
"cell2",
")",
":",
"eqlanguage",
"=",
"cell1",
"[",
"\"language\"",
"]",
"==",
"cell2",
"[",
"\"language\"",
"]",
"eqinput",
"=",
"cell1",
"[",
"\"input\"",
"]",
"==",
"cell2",
"[",
"\"input\"",
"]"... | return true if exactly equal or if equal but modified,
otherwise return false
return type: BooleanPlus | [
"return",
"true",
"if",
"exactly",
"equal",
"or",
"if",
"equal",
"but",
"modified",
"otherwise",
"return",
"false",
"return",
"type",
":",
"BooleanPlus"
] | train | https://github.com/tarmstrong/nbdiff/blob/3fdfb89f94fc0f4821bc04999ddf53b34d882ab9/nbdiff/comparable.py#L122-L142 |
asphalt-framework/asphalt | asphalt/core/runner.py | run_application | def run_application(component: Union[Component, Dict[str, Any]], *, event_loop_policy: str = None,
max_threads: int = None, logging: Union[Dict[str, Any], int, None] = INFO,
start_timeout: Union[int, float, None] = 10):
"""
Configure logging and start the given root compo... | python | def run_application(component: Union[Component, Dict[str, Any]], *, event_loop_policy: str = None,
max_threads: int = None, logging: Union[Dict[str, Any], int, None] = INFO,
start_timeout: Union[int, float, None] = 10):
"""
Configure logging and start the given root compo... | [
"def",
"run_application",
"(",
"component",
":",
"Union",
"[",
"Component",
",",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
",",
"*",
",",
"event_loop_policy",
":",
"str",
"=",
"None",
",",
"max_threads",
":",
"int",
"=",
"None",
",",
"logging",
":",
... | Configure logging and start the given root component in the default asyncio event loop.
Assuming the root component was started successfully, the event loop will continue running
until the process is terminated.
Initializes the logging system first based on the value of ``logging``:
* If the value i... | [
"Configure",
"logging",
"and",
"start",
"the",
"given",
"root",
"component",
"in",
"the",
"default",
"asyncio",
"event",
"loop",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/runner.py#L27-L145 |
asphalt-framework/asphalt | asphalt/core/concurrent.py | executor | def executor(func_or_executor: Union[Executor, str, Callable[..., T_Retval]]) -> \
Union[WrappedCallable, Callable[..., WrappedCallable]]:
"""
Decorate a function to run in an executor.
If no executor (or ``None``) is given, the current event loop's default executor is used.
Otherwise, the argu... | python | def executor(func_or_executor: Union[Executor, str, Callable[..., T_Retval]]) -> \
Union[WrappedCallable, Callable[..., WrappedCallable]]:
"""
Decorate a function to run in an executor.
If no executor (or ``None``) is given, the current event loop's default executor is used.
Otherwise, the argu... | [
"def",
"executor",
"(",
"func_or_executor",
":",
"Union",
"[",
"Executor",
",",
"str",
",",
"Callable",
"[",
"...",
",",
"T_Retval",
"]",
"]",
")",
"->",
"Union",
"[",
"WrappedCallable",
",",
"Callable",
"[",
"...",
",",
"WrappedCallable",
"]",
"]",
":",... | Decorate a function to run in an executor.
If no executor (or ``None``) is given, the current event loop's default executor is used.
Otherwise, the argument must be a PEP 3148 compliant thread pool executor or the name of an
:class:`~concurrent.futures.Executor` instance.
If a decorated callable is ca... | [
"Decorate",
"a",
"function",
"to",
"run",
"in",
"an",
"executor",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/concurrent.py#L17-L86 |
asphalt-framework/asphalt | asphalt/core/utils.py | qualified_name | def qualified_name(obj) -> str:
"""
Return the qualified name (e.g. package.module.Type) for the given object.
If ``obj`` is not a class, the returned name will match its type instead.
"""
if not isclass(obj):
obj = type(obj)
if obj.__module__ == 'builtins':
return obj.__name_... | python | def qualified_name(obj) -> str:
"""
Return the qualified name (e.g. package.module.Type) for the given object.
If ``obj`` is not a class, the returned name will match its type instead.
"""
if not isclass(obj):
obj = type(obj)
if obj.__module__ == 'builtins':
return obj.__name_... | [
"def",
"qualified_name",
"(",
"obj",
")",
"->",
"str",
":",
"if",
"not",
"isclass",
"(",
"obj",
")",
":",
"obj",
"=",
"type",
"(",
"obj",
")",
"if",
"obj",
".",
"__module__",
"==",
"'builtins'",
":",
"return",
"obj",
".",
"__name__",
"else",
":",
"... | Return the qualified name (e.g. package.module.Type) for the given object.
If ``obj`` is not a class, the returned name will match its type instead. | [
"Return",
"the",
"qualified",
"name",
"(",
"e",
".",
"g",
".",
"package",
".",
"module",
".",
"Type",
")",
"for",
"the",
"given",
"object",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/utils.py#L46-L59 |
asphalt-framework/asphalt | asphalt/core/utils.py | callable_name | def callable_name(func: Callable) -> str:
"""Return the qualified name (e.g. package.module.func) for the given callable."""
if func.__module__ == 'builtins':
return func.__name__
else:
return '{}.{}'.format(func.__module__, func.__qualname__) | python | def callable_name(func: Callable) -> str:
"""Return the qualified name (e.g. package.module.func) for the given callable."""
if func.__module__ == 'builtins':
return func.__name__
else:
return '{}.{}'.format(func.__module__, func.__qualname__) | [
"def",
"callable_name",
"(",
"func",
":",
"Callable",
")",
"->",
"str",
":",
"if",
"func",
".",
"__module__",
"==",
"'builtins'",
":",
"return",
"func",
".",
"__name__",
"else",
":",
"return",
"'{}.{}'",
".",
"format",
"(",
"func",
".",
"__module__",
","... | Return the qualified name (e.g. package.module.func) for the given callable. | [
"Return",
"the",
"qualified",
"name",
"(",
"e",
".",
"g",
".",
"package",
".",
"module",
".",
"func",
")",
"for",
"the",
"given",
"callable",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/utils.py#L62-L67 |
asphalt-framework/asphalt | asphalt/core/utils.py | merge_config | def merge_config(original: Optional[Dict[str, Any]],
overrides: Optional[Dict[str, Any]]) -> Dict[str, Any]:
"""
Return a copy of the ``original`` configuration dictionary, with overrides from ``overrides``
applied.
This similar to what :meth:`dict.update` does, but when a dictionary i... | python | def merge_config(original: Optional[Dict[str, Any]],
overrides: Optional[Dict[str, Any]]) -> Dict[str, Any]:
"""
Return a copy of the ``original`` configuration dictionary, with overrides from ``overrides``
applied.
This similar to what :meth:`dict.update` does, but when a dictionary i... | [
"def",
"merge_config",
"(",
"original",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
",",
"overrides",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"assert... | Return a copy of the ``original`` configuration dictionary, with overrides from ``overrides``
applied.
This similar to what :meth:`dict.update` does, but when a dictionary is about to be
replaced with another dictionary, it instead merges the contents.
If a key in ``overrides`` is a dotted path (ie. `... | [
"Return",
"a",
"copy",
"of",
"the",
"original",
"configuration",
"dictionary",
"with",
"overrides",
"from",
"overrides",
"applied",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/utils.py#L70-L101 |
asphalt-framework/asphalt | asphalt/core/utils.py | PluginContainer.resolve | def resolve(self, obj):
"""
Resolve a reference to an entry point or a variable in a module.
If ``obj`` is a ``module:varname`` reference to an object, :func:`resolve_reference` is
used to resolve it. If it is a string of any other kind, the named entry point is loaded
from this... | python | def resolve(self, obj):
"""
Resolve a reference to an entry point or a variable in a module.
If ``obj`` is a ``module:varname`` reference to an object, :func:`resolve_reference` is
used to resolve it. If it is a string of any other kind, the named entry point is loaded
from this... | [
"def",
"resolve",
"(",
"self",
",",
"obj",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"str",
")",
":",
"return",
"obj",
"if",
"':'",
"in",
"obj",
":",
"return",
"resolve_reference",
"(",
"obj",
")",
"value",
"=",
"self",
".",
"_entrypoints... | Resolve a reference to an entry point or a variable in a module.
If ``obj`` is a ``module:varname`` reference to an object, :func:`resolve_reference` is
used to resolve it. If it is a string of any other kind, the named entry point is loaded
from this container's namespace. Otherwise, ``obj`` i... | [
"Resolve",
"a",
"reference",
"to",
"an",
"entry",
"point",
"or",
"a",
"variable",
"in",
"a",
"module",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/utils.py#L120-L145 |
asphalt-framework/asphalt | asphalt/core/utils.py | PluginContainer.create_object | def create_object(self, type: Union[type, str], **constructor_kwargs):
"""
Instantiate a plugin.
The entry points in this namespace must point to subclasses of the ``base_class`` parameter
passed to this container.
:param type: an entry point identifier, a ``module:varname`` re... | python | def create_object(self, type: Union[type, str], **constructor_kwargs):
"""
Instantiate a plugin.
The entry points in this namespace must point to subclasses of the ``base_class`` parameter
passed to this container.
:param type: an entry point identifier, a ``module:varname`` re... | [
"def",
"create_object",
"(",
"self",
",",
"type",
":",
"Union",
"[",
"type",
",",
"str",
"]",
",",
"*",
"*",
"constructor_kwargs",
")",
":",
"assert",
"check_argument_types",
"(",
")",
"assert",
"self",
".",
"base_class",
",",
"'base class has not been defined... | Instantiate a plugin.
The entry points in this namespace must point to subclasses of the ``base_class`` parameter
passed to this container.
:param type: an entry point identifier, a ``module:varname`` reference to a class, or an
actual class object
:param constructor_kwargs... | [
"Instantiate",
"a",
"plugin",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/utils.py#L147-L167 |
asphalt-framework/asphalt | asphalt/core/utils.py | PluginContainer.all | def all(self) -> List[Any]:
"""
Load all entry points (if not already loaded) in this namespace and return the resulting
objects as a list.
"""
values = []
for name, value in self._entrypoints.items():
if isinstance(value, EntryPoint):
value =... | python | def all(self) -> List[Any]:
"""
Load all entry points (if not already loaded) in this namespace and return the resulting
objects as a list.
"""
values = []
for name, value in self._entrypoints.items():
if isinstance(value, EntryPoint):
value =... | [
"def",
"all",
"(",
"self",
")",
"->",
"List",
"[",
"Any",
"]",
":",
"values",
"=",
"[",
"]",
"for",
"name",
",",
"value",
"in",
"self",
".",
"_entrypoints",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"EntryPoint",
")",
":... | Load all entry points (if not already loaded) in this namespace and return the resulting
objects as a list. | [
"Load",
"all",
"entry",
"points",
"(",
"if",
"not",
"already",
"loaded",
")",
"in",
"this",
"namespace",
"and",
"return",
"the",
"resulting",
"objects",
"as",
"a",
"list",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/utils.py#L174-L187 |
asphalt-framework/asphalt | asphalt/core/component.py | ContainerComponent.add_component | def add_component(self, alias: str, type: Union[str, type] = None, **config):
"""
Add a child component.
This will instantiate a component class, as specified by the ``type`` argument.
If the second argument is omitted, the value of ``alias`` is used as its value.
The locally ... | python | def add_component(self, alias: str, type: Union[str, type] = None, **config):
"""
Add a child component.
This will instantiate a component class, as specified by the ``type`` argument.
If the second argument is omitted, the value of ``alias`` is used as its value.
The locally ... | [
"def",
"add_component",
"(",
"self",
",",
"alias",
":",
"str",
",",
"type",
":",
"Union",
"[",
"str",
",",
"type",
"]",
"=",
"None",
",",
"*",
"*",
"config",
")",
":",
"assert",
"check_argument_types",
"(",
")",
"if",
"not",
"isinstance",
"(",
"alias... | Add a child component.
This will instantiate a component class, as specified by the ``type`` argument.
If the second argument is omitted, the value of ``alias`` is used as its value.
The locally given configuration can be overridden by component configuration parameters
supplied to th... | [
"Add",
"a",
"child",
"component",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/component.py#L63-L99 |
asphalt-framework/asphalt | asphalt/core/component.py | ContainerComponent.start | async def start(self, ctx: Context):
"""
Create child components that have been configured but not yet created and then calls their
:meth:`~Component.start` methods in separate tasks and waits until they have completed.
"""
for alias in self.component_configs:
if ali... | python | async def start(self, ctx: Context):
"""
Create child components that have been configured but not yet created and then calls their
:meth:`~Component.start` methods in separate tasks and waits until they have completed.
"""
for alias in self.component_configs:
if ali... | [
"async",
"def",
"start",
"(",
"self",
",",
"ctx",
":",
"Context",
")",
":",
"for",
"alias",
"in",
"self",
".",
"component_configs",
":",
"if",
"alias",
"not",
"in",
"self",
".",
"child_components",
":",
"self",
".",
"add_component",
"(",
"alias",
")",
... | Create child components that have been configured but not yet created and then calls their
:meth:`~Component.start` methods in separate tasks and waits until they have completed. | [
"Create",
"child",
"components",
"that",
"have",
"been",
"configured",
"but",
"not",
"yet",
"created",
"and",
"then",
"calls",
"their",
":",
"meth",
":",
"~Component",
".",
"start",
"methods",
"in",
"separate",
"tasks",
"and",
"waits",
"until",
"they",
"have... | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/component.py#L101-L113 |
asphalt-framework/asphalt | asphalt/core/context.py | executor | def executor(arg: Union[Executor, str, Callable] = None):
"""
Decorate a function so that it runs in an :class:`~concurrent.futures.Executor`.
If a resource name is given, the first argument must be a :class:`~.Context`.
Usage::
@executor
def should_run_in_executor():
...
... | python | def executor(arg: Union[Executor, str, Callable] = None):
"""
Decorate a function so that it runs in an :class:`~concurrent.futures.Executor`.
If a resource name is given, the first argument must be a :class:`~.Context`.
Usage::
@executor
def should_run_in_executor():
...
... | [
"def",
"executor",
"(",
"arg",
":",
"Union",
"[",
"Executor",
",",
"str",
",",
"Callable",
"]",
"=",
"None",
")",
":",
"def",
"outer_wrapper",
"(",
"func",
":",
"Callable",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"inner_wrapper",
"(",
"*",
... | Decorate a function so that it runs in an :class:`~concurrent.futures.Executor`.
If a resource name is given, the first argument must be a :class:`~.Context`.
Usage::
@executor
def should_run_in_executor():
...
With a resource name::
@executor('resourcename')
... | [
"Decorate",
"a",
"function",
"so",
"that",
"it",
"runs",
"in",
"an",
":",
"class",
":",
"~concurrent",
".",
"futures",
".",
"Executor",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/context.py#L539-L580 |
asphalt-framework/asphalt | asphalt/core/context.py | context_teardown | def context_teardown(func: Callable):
"""
Wrap an async generator function to execute the rest of the function at context teardown.
This function returns an async function, which, when called, starts the wrapped async
generator. The wrapped async function is run until the first ``yield`` statement
... | python | def context_teardown(func: Callable):
"""
Wrap an async generator function to execute the rest of the function at context teardown.
This function returns an async function, which, when called, starts the wrapped async
generator. The wrapped async function is run until the first ``yield`` statement
... | [
"def",
"context_teardown",
"(",
"func",
":",
"Callable",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"async",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"async",
"def",
"teardown_callback",
"(",
"exception",
":",... | Wrap an async generator function to execute the rest of the function at context teardown.
This function returns an async function, which, when called, starts the wrapped async
generator. The wrapped async function is run until the first ``yield`` statement
(``await async_generator.yield_()`` on Python 3.5)... | [
"Wrap",
"an",
"async",
"generator",
"function",
"to",
"execute",
"the",
"rest",
"of",
"the",
"function",
"at",
"context",
"teardown",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/context.py#L583-L638 |
asphalt-framework/asphalt | asphalt/core/context.py | Context.context_chain | def context_chain(self) -> List['Context']:
"""Return a list of contexts starting from this one, its parent and so on."""
contexts = []
ctx = self # type: Optional[Context]
while ctx is not None:
contexts.append(ctx)
ctx = ctx.parent
return contexts | python | def context_chain(self) -> List['Context']:
"""Return a list of contexts starting from this one, its parent and so on."""
contexts = []
ctx = self # type: Optional[Context]
while ctx is not None:
contexts.append(ctx)
ctx = ctx.parent
return contexts | [
"def",
"context_chain",
"(",
"self",
")",
"->",
"List",
"[",
"'Context'",
"]",
":",
"contexts",
"=",
"[",
"]",
"ctx",
"=",
"self",
"# type: Optional[Context]",
"while",
"ctx",
"is",
"not",
"None",
":",
"contexts",
".",
"append",
"(",
"ctx",
")",
"ctx",
... | Return a list of contexts starting from this one, its parent and so on. | [
"Return",
"a",
"list",
"of",
"contexts",
"starting",
"from",
"this",
"one",
"its",
"parent",
"and",
"so",
"on",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/context.py#L176-L184 |
asphalt-framework/asphalt | asphalt/core/context.py | Context.add_teardown_callback | def add_teardown_callback(self, callback: Callable, pass_exception: bool = False) -> None:
"""
Add a callback to be called when this context closes.
This is intended for cleanup of resources, and the list of callbacks is processed in the
reverse order in which they were added, so the la... | python | def add_teardown_callback(self, callback: Callable, pass_exception: bool = False) -> None:
"""
Add a callback to be called when this context closes.
This is intended for cleanup of resources, and the list of callbacks is processed in the
reverse order in which they were added, so the la... | [
"def",
"add_teardown_callback",
"(",
"self",
",",
"callback",
":",
"Callable",
",",
"pass_exception",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"assert",
"check_argument_types",
"(",
")",
"self",
".",
"_check_closed",
"(",
")",
"self",
".",
"_teardo... | Add a callback to be called when this context closes.
This is intended for cleanup of resources, and the list of callbacks is processed in the
reverse order in which they were added, so the last added callback will be called first.
The callback may return an awaitable. If it does, the awaitabl... | [
"Add",
"a",
"callback",
"to",
"be",
"called",
"when",
"this",
"context",
"closes",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/context.py#L205-L223 |
asphalt-framework/asphalt | asphalt/core/context.py | Context.close | async def close(self, exception: BaseException = None) -> None:
"""
Close this context and call any necessary resource teardown callbacks.
If a teardown callback returns an awaitable, the return value is awaited on before calling
any further teardown callbacks.
All callbacks wi... | python | async def close(self, exception: BaseException = None) -> None:
"""
Close this context and call any necessary resource teardown callbacks.
If a teardown callback returns an awaitable, the return value is awaited on before calling
any further teardown callbacks.
All callbacks wi... | [
"async",
"def",
"close",
"(",
"self",
",",
"exception",
":",
"BaseException",
"=",
"None",
")",
"->",
"None",
":",
"self",
".",
"_check_closed",
"(",
")",
"self",
".",
"_closed",
"=",
"True",
"exceptions",
"=",
"[",
"]",
"for",
"callback",
",",
"pass_e... | Close this context and call any necessary resource teardown callbacks.
If a teardown callback returns an awaitable, the return value is awaited on before calling
any further teardown callbacks.
All callbacks will be processed, even if some of them raise exceptions. If at least one
call... | [
"Close",
"this",
"context",
"and",
"call",
"any",
"necessary",
"resource",
"teardown",
"callbacks",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/context.py#L225-L256 |
asphalt-framework/asphalt | asphalt/core/context.py | Context.add_resource | def add_resource(self, value, name: str = 'default', context_attr: str = None,
types: Union[type, Sequence[type]] = ()) -> None:
"""
Add a resource to this context.
This will cause a ``resource_added`` event to be dispatched.
:param value: the actual resource value... | python | def add_resource(self, value, name: str = 'default', context_attr: str = None,
types: Union[type, Sequence[type]] = ()) -> None:
"""
Add a resource to this context.
This will cause a ``resource_added`` event to be dispatched.
:param value: the actual resource value... | [
"def",
"add_resource",
"(",
"self",
",",
"value",
",",
"name",
":",
"str",
"=",
"'default'",
",",
"context_attr",
":",
"str",
"=",
"None",
",",
"types",
":",
"Union",
"[",
"type",
",",
"Sequence",
"[",
"type",
"]",
"]",
"=",
"(",
")",
")",
"->",
... | Add a resource to this context.
This will cause a ``resource_added`` event to be dispatched.
:param value: the actual resource value
:param name: name of this resource (unique among all its registered types within a single
context)
:param context_attr: name of the context a... | [
"Add",
"a",
"resource",
"to",
"this",
"context",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/context.py#L272-L317 |
asphalt-framework/asphalt | asphalt/core/context.py | Context.add_resource_factory | def add_resource_factory(self, factory_callback: factory_callback_type,
types: Union[type, Sequence[Type]], name: str = 'default',
context_attr: str = None) -> None:
"""
Add a resource factory to this context.
This will cause a ``resourc... | python | def add_resource_factory(self, factory_callback: factory_callback_type,
types: Union[type, Sequence[Type]], name: str = 'default',
context_attr: str = None) -> None:
"""
Add a resource factory to this context.
This will cause a ``resourc... | [
"def",
"add_resource_factory",
"(",
"self",
",",
"factory_callback",
":",
"factory_callback_type",
",",
"types",
":",
"Union",
"[",
"type",
",",
"Sequence",
"[",
"Type",
"]",
"]",
",",
"name",
":",
"str",
"=",
"'default'",
",",
"context_attr",
":",
"str",
... | Add a resource factory to this context.
This will cause a ``resource_added`` event to be dispatched.
A resource factory is a callable that generates a "contextual" resource when it is
requested by either using any of the methods :meth:`get_resource`, :meth:`require_resource`
or :meth:`... | [
"Add",
"a",
"resource",
"factory",
"to",
"this",
"context",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/context.py#L319-L380 |
asphalt-framework/asphalt | asphalt/core/context.py | Context.get_resource | def get_resource(self, type: Type[T_Resource], name: str = 'default') -> Optional[T_Resource]:
"""
Look up a resource in the chain of contexts.
:param type: type of the requested resource
:param name: name of the requested resource
:return: the requested resource, or ``None`` if... | python | def get_resource(self, type: Type[T_Resource], name: str = 'default') -> Optional[T_Resource]:
"""
Look up a resource in the chain of contexts.
:param type: type of the requested resource
:param name: name of the requested resource
:return: the requested resource, or ``None`` if... | [
"def",
"get_resource",
"(",
"self",
",",
"type",
":",
"Type",
"[",
"T_Resource",
"]",
",",
"name",
":",
"str",
"=",
"'default'",
")",
"->",
"Optional",
"[",
"T_Resource",
"]",
":",
"assert",
"check_argument_types",
"(",
")",
"self",
".",
"_check_closed",
... | Look up a resource in the chain of contexts.
:param type: type of the requested resource
:param name: name of the requested resource
:return: the requested resource, or ``None`` if none was available | [
"Look",
"up",
"a",
"resource",
"in",
"the",
"chain",
"of",
"contexts",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/context.py#L382-L408 |
asphalt-framework/asphalt | asphalt/core/context.py | Context.get_resources | def get_resources(self, type: Type[T_Resource]) -> Set[T_Resource]:
"""
Retrieve all the resources of the given type in this context and its parents.
Any matching resource factories are also triggered if necessary.
:param type: type of the resources to get
:return: a set of all... | python | def get_resources(self, type: Type[T_Resource]) -> Set[T_Resource]:
"""
Retrieve all the resources of the given type in this context and its parents.
Any matching resource factories are also triggered if necessary.
:param type: type of the resources to get
:return: a set of all... | [
"def",
"get_resources",
"(",
"self",
",",
"type",
":",
"Type",
"[",
"T_Resource",
"]",
")",
"->",
"Set",
"[",
"T_Resource",
"]",
":",
"assert",
"check_argument_types",
"(",
")",
"# Collect all the matching resources from this context",
"resources",
"=",
"{",
"cont... | Retrieve all the resources of the given type in this context and its parents.
Any matching resource factories are also triggered if necessary.
:param type: type of the resources to get
:return: a set of all found resources of the given type | [
"Retrieve",
"all",
"the",
"resources",
"of",
"the",
"given",
"type",
"in",
"this",
"context",
"and",
"its",
"parents",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/context.py#L410-L442 |
asphalt-framework/asphalt | asphalt/core/context.py | Context.require_resource | def require_resource(self, type: Type[T_Resource], name: str = 'default') -> T_Resource:
"""
Look up a resource in the chain of contexts and raise an exception if it is not found.
This is like :meth:`get_resource` except that instead of returning ``None`` when a resource
is not found, i... | python | def require_resource(self, type: Type[T_Resource], name: str = 'default') -> T_Resource:
"""
Look up a resource in the chain of contexts and raise an exception if it is not found.
This is like :meth:`get_resource` except that instead of returning ``None`` when a resource
is not found, i... | [
"def",
"require_resource",
"(",
"self",
",",
"type",
":",
"Type",
"[",
"T_Resource",
"]",
",",
"name",
":",
"str",
"=",
"'default'",
")",
"->",
"T_Resource",
":",
"resource",
"=",
"self",
".",
"get_resource",
"(",
"type",
",",
"name",
")",
"if",
"resou... | Look up a resource in the chain of contexts and raise an exception if it is not found.
This is like :meth:`get_resource` except that instead of returning ``None`` when a resource
is not found, it will raise :exc:`~asphalt.core.context.ResourceNotFound`.
:param type: type of the requested resou... | [
"Look",
"up",
"a",
"resource",
"in",
"the",
"chain",
"of",
"contexts",
"and",
"raise",
"an",
"exception",
"if",
"it",
"is",
"not",
"found",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/context.py#L444-L462 |
asphalt-framework/asphalt | asphalt/core/context.py | Context.request_resource | async def request_resource(self, type: Type[T_Resource], name: str = 'default') -> T_Resource:
"""
Look up a resource in the chain of contexts.
This is like :meth:`get_resource` except that if the resource is not already available, it
will wait for one to become available.
:par... | python | async def request_resource(self, type: Type[T_Resource], name: str = 'default') -> T_Resource:
"""
Look up a resource in the chain of contexts.
This is like :meth:`get_resource` except that if the resource is not already available, it
will wait for one to become available.
:par... | [
"async",
"def",
"request_resource",
"(",
"self",
",",
"type",
":",
"Type",
"[",
"T_Resource",
"]",
",",
"name",
":",
"str",
"=",
"'default'",
")",
"->",
"T_Resource",
":",
"# First try to locate an existing resource in this context and its parents",
"value",
"=",
"s... | Look up a resource in the chain of contexts.
This is like :meth:`get_resource` except that if the resource is not already available, it
will wait for one to become available.
:param type: type of the requested resource
:param name: name of the requested resource
:return: the re... | [
"Look",
"up",
"a",
"resource",
"in",
"the",
"chain",
"of",
"contexts",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/context.py#L464-L485 |
asphalt-framework/asphalt | asphalt/core/context.py | Context.call_async | def call_async(self, func: Callable, *args, **kwargs):
"""
Call the given callable in the event loop thread.
This method lets you call asynchronous code from a worker thread.
Do not use it from within the event loop thread.
If the callable returns an awaitable, it is resolved b... | python | def call_async(self, func: Callable, *args, **kwargs):
"""
Call the given callable in the event loop thread.
This method lets you call asynchronous code from a worker thread.
Do not use it from within the event loop thread.
If the callable returns an awaitable, it is resolved b... | [
"def",
"call_async",
"(",
"self",
",",
"func",
":",
"Callable",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"asyncio_extras",
".",
"call_async",
"(",
"self",
".",
"loop",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")... | Call the given callable in the event loop thread.
This method lets you call asynchronous code from a worker thread.
Do not use it from within the event loop thread.
If the callable returns an awaitable, it is resolved before returning to the caller.
:param func: a regular function or ... | [
"Call",
"the",
"given",
"callable",
"in",
"the",
"event",
"loop",
"thread",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/context.py#L487-L502 |
asphalt-framework/asphalt | asphalt/core/context.py | Context.call_in_executor | def call_in_executor(self, func: Callable, *args, executor: Union[Executor, str] = None,
**kwargs) -> Awaitable:
"""
Call the given callable in an executor.
:param func: the callable to call
:param args: positional arguments to call the callable with
:pa... | python | def call_in_executor(self, func: Callable, *args, executor: Union[Executor, str] = None,
**kwargs) -> Awaitable:
"""
Call the given callable in an executor.
:param func: the callable to call
:param args: positional arguments to call the callable with
:pa... | [
"def",
"call_in_executor",
"(",
"self",
",",
"func",
":",
"Callable",
",",
"*",
"args",
",",
"executor",
":",
"Union",
"[",
"Executor",
",",
"str",
"]",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"->",
"Awaitable",
":",
"assert",
"check_argument_types",
... | Call the given callable in an executor.
:param func: the callable to call
:param args: positional arguments to call the callable with
:param executor: either an :class:`~concurrent.futures.Executor` instance, the resource
name of one or ``None`` to use the event loop's default execu... | [
"Call",
"the",
"given",
"callable",
"in",
"an",
"executor",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/context.py#L504-L521 |
asphalt-framework/asphalt | asphalt/core/context.py | Context.threadpool | def threadpool(self, executor: Union[Executor, str] = None):
"""
Return an asynchronous context manager that runs the block in a (thread pool) executor.
:param executor: either an :class:`~concurrent.futures.Executor` instance, the resource
name of one or ``None`` to use the event l... | python | def threadpool(self, executor: Union[Executor, str] = None):
"""
Return an asynchronous context manager that runs the block in a (thread pool) executor.
:param executor: either an :class:`~concurrent.futures.Executor` instance, the resource
name of one or ``None`` to use the event l... | [
"def",
"threadpool",
"(",
"self",
",",
"executor",
":",
"Union",
"[",
"Executor",
",",
"str",
"]",
"=",
"None",
")",
":",
"assert",
"check_argument_types",
"(",
")",
"if",
"isinstance",
"(",
"executor",
",",
"str",
")",
":",
"executor",
"=",
"self",
".... | Return an asynchronous context manager that runs the block in a (thread pool) executor.
:param executor: either an :class:`~concurrent.futures.Executor` instance, the resource
name of one or ``None`` to use the event loop's default executor
:return: an asynchronous context manager | [
"Return",
"an",
"asynchronous",
"context",
"manager",
"that",
"runs",
"the",
"block",
"in",
"a",
"(",
"thread",
"pool",
")",
"executor",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/context.py#L523-L536 |
asphalt-framework/asphalt | asphalt/core/event.py | stream_events | def stream_events(signals: Sequence[Signal], filter: Callable[[T_Event], bool] = None, *,
max_queue_size: int = 0) -> AsyncIterator[T_Event]:
"""
Return an async generator that yields events from the given signals.
Only events that pass the filter callable (if one has been given) are retu... | python | def stream_events(signals: Sequence[Signal], filter: Callable[[T_Event], bool] = None, *,
max_queue_size: int = 0) -> AsyncIterator[T_Event]:
"""
Return an async generator that yields events from the given signals.
Only events that pass the filter callable (if one has been given) are retu... | [
"def",
"stream_events",
"(",
"signals",
":",
"Sequence",
"[",
"Signal",
"]",
",",
"filter",
":",
"Callable",
"[",
"[",
"T_Event",
"]",
",",
"bool",
"]",
"=",
"None",
",",
"*",
",",
"max_queue_size",
":",
"int",
"=",
"0",
")",
"->",
"AsyncIterator",
"... | Return an async generator that yields events from the given signals.
Only events that pass the filter callable (if one has been given) are returned.
If no filter function was given, all events are yielded from the generator.
:param signals: the signals to get events from
:param filter: a callable that... | [
"Return",
"an",
"async",
"generator",
"that",
"yields",
"events",
"from",
"the",
"given",
"signals",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/event.py#L228-L267 |
asphalt-framework/asphalt | asphalt/core/event.py | wait_event | async def wait_event(signals: Sequence['Signal[T_Event]'],
filter: Callable[[T_Event], bool] = None) -> T_Event:
"""
Wait until any of the given signals dispatches an event that satisfies the filter (if any).
If no filter has been given, the first event dispatched from the signal is re... | python | async def wait_event(signals: Sequence['Signal[T_Event]'],
filter: Callable[[T_Event], bool] = None) -> T_Event:
"""
Wait until any of the given signals dispatches an event that satisfies the filter (if any).
If no filter has been given, the first event dispatched from the signal is re... | [
"async",
"def",
"wait_event",
"(",
"signals",
":",
"Sequence",
"[",
"'Signal[T_Event]'",
"]",
",",
"filter",
":",
"Callable",
"[",
"[",
"T_Event",
"]",
",",
"bool",
"]",
"=",
"None",
")",
"->",
"T_Event",
":",
"if",
"sys",
".",
"version_info",
">=",
"(... | Wait until any of the given signals dispatches an event that satisfies the filter (if any).
If no filter has been given, the first event dispatched from the signal is returned.
:param signals: the signals to get events from
:param filter: a callable that takes an event object as an argument and returns ``... | [
"Wait",
"until",
"any",
"of",
"the",
"given",
"signals",
"dispatches",
"an",
"event",
"that",
"satisfies",
"the",
"filter",
"(",
"if",
"any",
")",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/event.py#L270-L287 |
asphalt-framework/asphalt | asphalt/core/event.py | Signal.connect | def connect(self, callback: Callable[[T_Event], Any]) -> Callable[[T_Event], Any]:
"""
Connect a callback to this signal.
Each callable can only be connected once. Duplicate registrations are ignored.
If you need to pass extra arguments to the callback, you can use :func:`functools.par... | python | def connect(self, callback: Callable[[T_Event], Any]) -> Callable[[T_Event], Any]:
"""
Connect a callback to this signal.
Each callable can only be connected once. Duplicate registrations are ignored.
If you need to pass extra arguments to the callback, you can use :func:`functools.par... | [
"def",
"connect",
"(",
"self",
",",
"callback",
":",
"Callable",
"[",
"[",
"T_Event",
"]",
",",
"Any",
"]",
")",
"->",
"Callable",
"[",
"[",
"T_Event",
"]",
",",
"Any",
"]",
":",
"assert",
"check_argument_types",
"(",
")",
"if",
"self",
".",
"listene... | Connect a callback to this signal.
Each callable can only be connected once. Duplicate registrations are ignored.
If you need to pass extra arguments to the callback, you can use :func:`functools.partial`
to wrap the callable.
:param callback: a callable that will receive an event obj... | [
"Connect",
"a",
"callback",
"to",
"this",
"signal",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/event.py#L106-L125 |
asphalt-framework/asphalt | asphalt/core/event.py | Signal.disconnect | def disconnect(self, callback: Callable) -> None:
"""
Disconnects the given callback.
The callback will no longer receive events from this signal.
No action is taken if the callback is not on the list of listener callbacks.
:param callback: the callable to remove
"""
... | python | def disconnect(self, callback: Callable) -> None:
"""
Disconnects the given callback.
The callback will no longer receive events from this signal.
No action is taken if the callback is not on the list of listener callbacks.
:param callback: the callable to remove
"""
... | [
"def",
"disconnect",
"(",
"self",
",",
"callback",
":",
"Callable",
")",
"->",
"None",
":",
"assert",
"check_argument_types",
"(",
")",
"try",
":",
"if",
"self",
".",
"listeners",
"is",
"not",
"None",
":",
"self",
".",
"listeners",
".",
"remove",
"(",
... | Disconnects the given callback.
The callback will no longer receive events from this signal.
No action is taken if the callback is not on the list of listener callbacks.
:param callback: the callable to remove | [
"Disconnects",
"the",
"given",
"callback",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/event.py#L127-L143 |
asphalt-framework/asphalt | asphalt/core/event.py | Signal.dispatch_raw | def dispatch_raw(self, event: Event) -> Awaitable[bool]:
"""
Dispatch the given event object to all listeners.
Creates a new task in which all listener callbacks are called with the given event as
the only argument. Coroutine callbacks are converted to their own respective tasks and
... | python | def dispatch_raw(self, event: Event) -> Awaitable[bool]:
"""
Dispatch the given event object to all listeners.
Creates a new task in which all listener callbacks are called with the given event as
the only argument. Coroutine callbacks are converted to their own respective tasks and
... | [
"def",
"dispatch_raw",
"(",
"self",
",",
"event",
":",
"Event",
")",
"->",
"Awaitable",
"[",
"bool",
"]",
":",
"async",
"def",
"do_dispatch",
"(",
")",
"->",
"None",
":",
"awaitables",
"=",
"[",
"]",
"all_successful",
"=",
"True",
"for",
"callback",
"i... | Dispatch the given event object to all listeners.
Creates a new task in which all listener callbacks are called with the given event as
the only argument. Coroutine callbacks are converted to their own respective tasks and
waited for concurrently.
Before the dispatching is done, a snap... | [
"Dispatch",
"the",
"given",
"event",
"object",
"to",
"all",
"listeners",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/event.py#L145-L200 |
asphalt-framework/asphalt | asphalt/core/event.py | Signal.dispatch | def dispatch(self, *args, **kwargs) -> Awaitable[bool]:
"""
Create and dispatch an event.
This method constructs an event object and then passes it to :meth:`dispatch_event` for
the actual dispatching.
:param args: positional arguments to the constructor of the associated event... | python | def dispatch(self, *args, **kwargs) -> Awaitable[bool]:
"""
Create and dispatch an event.
This method constructs an event object and then passes it to :meth:`dispatch_event` for
the actual dispatching.
:param args: positional arguments to the constructor of the associated event... | [
"def",
"dispatch",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"Awaitable",
"[",
"bool",
"]",
":",
"event",
"=",
"self",
".",
"event_class",
"(",
"self",
".",
"source",
"(",
")",
",",
"cast",
"(",
"str",
",",
"self",
".",
... | Create and dispatch an event.
This method constructs an event object and then passes it to :meth:`dispatch_event` for
the actual dispatching.
:param args: positional arguments to the constructor of the associated event class
:param kwargs: keyword arguments to the constructor of the as... | [
"Create",
"and",
"dispatch",
"an",
"event",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/event.py#L202-L217 |
asphalt-framework/asphalt | asphalt/core/event.py | Signal.wait_event | def wait_event(self, filter: Callable[[T_Event], bool] = None) -> Awaitable[T_Event]:
"""Shortcut for calling :func:`wait_event` with this signal in the first argument."""
return wait_event([self], filter) | python | def wait_event(self, filter: Callable[[T_Event], bool] = None) -> Awaitable[T_Event]:
"""Shortcut for calling :func:`wait_event` with this signal in the first argument."""
return wait_event([self], filter) | [
"def",
"wait_event",
"(",
"self",
",",
"filter",
":",
"Callable",
"[",
"[",
"T_Event",
"]",
",",
"bool",
"]",
"=",
"None",
")",
"->",
"Awaitable",
"[",
"T_Event",
"]",
":",
"return",
"wait_event",
"(",
"[",
"self",
"]",
",",
"filter",
")"
] | Shortcut for calling :func:`wait_event` with this signal in the first argument. | [
"Shortcut",
"for",
"calling",
":",
"func",
":",
"wait_event",
"with",
"this",
"signal",
"in",
"the",
"first",
"argument",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/event.py#L219-L221 |
asphalt-framework/asphalt | asphalt/core/event.py | Signal.stream_events | def stream_events(self, filter: Callable[[Event], bool] = None, *, max_queue_size: int = 0):
"""Shortcut for calling :func:`stream_events` with this signal in the first argument."""
return stream_events([self], filter, max_queue_size=max_queue_size) | python | def stream_events(self, filter: Callable[[Event], bool] = None, *, max_queue_size: int = 0):
"""Shortcut for calling :func:`stream_events` with this signal in the first argument."""
return stream_events([self], filter, max_queue_size=max_queue_size) | [
"def",
"stream_events",
"(",
"self",
",",
"filter",
":",
"Callable",
"[",
"[",
"Event",
"]",
",",
"bool",
"]",
"=",
"None",
",",
"*",
",",
"max_queue_size",
":",
"int",
"=",
"0",
")",
":",
"return",
"stream_events",
"(",
"[",
"self",
"]",
",",
"fil... | Shortcut for calling :func:`stream_events` with this signal in the first argument. | [
"Shortcut",
"for",
"calling",
":",
"func",
":",
"stream_events",
"with",
"this",
"signal",
"in",
"the",
"first",
"argument",
"."
] | train | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/event.py#L223-L225 |
samfoo/vt102 | vt102/__init__.py | stream._escape_sequence | def _escape_sequence(self, char):
"""
Handle characters seen when in an escape sequence. Most non-vt52
commands start with a left-bracket after the escape and then a
stream of parameters and a command.
"""
num = ord(char)
if char == "[":
self.state =... | python | def _escape_sequence(self, char):
"""
Handle characters seen when in an escape sequence. Most non-vt52
commands start with a left-bracket after the escape and then a
stream of parameters and a command.
"""
num = ord(char)
if char == "[":
self.state =... | [
"def",
"_escape_sequence",
"(",
"self",
",",
"char",
")",
":",
"num",
"=",
"ord",
"(",
"char",
")",
"if",
"char",
"==",
"\"[\"",
":",
"self",
".",
"state",
"=",
"\"escape-lb\"",
"elif",
"char",
"==",
"\"(\"",
":",
"self",
".",
"state",
"=",
"\"charse... | Handle characters seen when in an escape sequence. Most non-vt52
commands start with a left-bracket after the escape and then a
stream of parameters and a command. | [
"Handle",
"characters",
"seen",
"when",
"in",
"an",
"escape",
"sequence",
".",
"Most",
"non",
"-",
"vt52",
"commands",
"start",
"with",
"a",
"left",
"-",
"bracket",
"after",
"the",
"escape",
"and",
"then",
"a",
"stream",
"of",
"parameters",
"and",
"a",
"... | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L189-L207 |
samfoo/vt102 | vt102/__init__.py | stream._end_escape_sequence | def _end_escape_sequence(self, char):
"""
Handle the end of an escape sequence. The final character in an escape
sequence is the command to execute, which corresponds to the event that
is dispatched here.
"""
num = ord(char)
if num in self.sequence:
s... | python | def _end_escape_sequence(self, char):
"""
Handle the end of an escape sequence. The final character in an escape
sequence is the command to execute, which corresponds to the event that
is dispatched here.
"""
num = ord(char)
if num in self.sequence:
s... | [
"def",
"_end_escape_sequence",
"(",
"self",
",",
"char",
")",
":",
"num",
"=",
"ord",
"(",
"char",
")",
"if",
"num",
"in",
"self",
".",
"sequence",
":",
"self",
".",
"dispatch",
"(",
"self",
".",
"sequence",
"[",
"num",
"]",
",",
"*",
"self",
".",
... | Handle the end of an escape sequence. The final character in an escape
sequence is the command to execute, which corresponds to the event that
is dispatched here. | [
"Handle",
"the",
"end",
"of",
"an",
"escape",
"sequence",
".",
"The",
"final",
"character",
"in",
"an",
"escape",
"sequence",
"is",
"the",
"command",
"to",
"execute",
"which",
"corresponds",
"to",
"the",
"event",
"that",
"is",
"dispatched",
"here",
"."
] | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L209-L221 |
samfoo/vt102 | vt102/__init__.py | stream._escape_parameters | def _escape_parameters(self, char):
"""
Parse parameters in an escape sequence. Parameters are a list of
numbers in ascii (e.g. '12', '4', '42', etc) separated by a semicolon
(e.g. "12;4;42").
See the [vt102 user guide](http://vt100.net/docs/vt102-ug/) for more
d... | python | def _escape_parameters(self, char):
"""
Parse parameters in an escape sequence. Parameters are a list of
numbers in ascii (e.g. '12', '4', '42', etc) separated by a semicolon
(e.g. "12;4;42").
See the [vt102 user guide](http://vt100.net/docs/vt102-ug/) for more
d... | [
"def",
"_escape_parameters",
"(",
"self",
",",
"char",
")",
":",
"if",
"char",
"==",
"\";\"",
":",
"self",
".",
"params",
".",
"append",
"(",
"int",
"(",
"self",
".",
"current_param",
")",
")",
"self",
".",
"current_param",
"=",
"\"\"",
"elif",
"char",... | Parse parameters in an escape sequence. Parameters are a list of
numbers in ascii (e.g. '12', '4', '42', etc) separated by a semicolon
(e.g. "12;4;42").
See the [vt102 user guide](http://vt100.net/docs/vt102-ug/) for more
details on the formatting of escape parameters. | [
"Parse",
"parameters",
"in",
"an",
"escape",
"sequence",
".",
"Parameters",
"are",
"a",
"list",
"of",
"numbers",
"in",
"ascii",
"(",
"e",
".",
"g",
".",
"12",
"4",
"42",
"etc",
")",
"separated",
"by",
"a",
"semicolon",
"(",
"e",
".",
"g",
".",
"12"... | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L223-L246 |
samfoo/vt102 | vt102/__init__.py | stream._stream | def _stream(self, char):
"""
Process a character when in the
default 'stream' state.
"""
num = ord(char)
if num in self.basic:
self.dispatch(self.basic[num])
elif num == ctrl.ESC:
self.state = "escape"
elif num == 0x00:
... | python | def _stream(self, char):
"""
Process a character when in the
default 'stream' state.
"""
num = ord(char)
if num in self.basic:
self.dispatch(self.basic[num])
elif num == ctrl.ESC:
self.state = "escape"
elif num == 0x00:
... | [
"def",
"_stream",
"(",
"self",
",",
"char",
")",
":",
"num",
"=",
"ord",
"(",
"char",
")",
"if",
"num",
"in",
"self",
".",
"basic",
":",
"self",
".",
"dispatch",
"(",
"self",
".",
"basic",
"[",
"num",
"]",
")",
"elif",
"num",
"==",
"ctrl",
".",... | Process a character when in the
default 'stream' state. | [
"Process",
"a",
"character",
"when",
"in",
"the",
"default",
"stream",
"state",
"."
] | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L263-L278 |
samfoo/vt102 | vt102/__init__.py | stream.consume | def consume(self, char):
"""
Consume a single character and advance the state as necessary.
"""
if self.state == "stream":
self._stream(char)
elif self.state == "escape":
self._escape_sequence(char)
elif self.state == "escape-lb":
self... | python | def consume(self, char):
"""
Consume a single character and advance the state as necessary.
"""
if self.state == "stream":
self._stream(char)
elif self.state == "escape":
self._escape_sequence(char)
elif self.state == "escape-lb":
self... | [
"def",
"consume",
"(",
"self",
",",
"char",
")",
":",
"if",
"self",
".",
"state",
"==",
"\"stream\"",
":",
"self",
".",
"_stream",
"(",
"char",
")",
"elif",
"self",
".",
"state",
"==",
"\"escape\"",
":",
"self",
".",
"_escape_sequence",
"(",
"char",
... | Consume a single character and advance the state as necessary. | [
"Consume",
"a",
"single",
"character",
"and",
"advance",
"the",
"state",
"as",
"necessary",
"."
] | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L280-L296 |
samfoo/vt102 | vt102/__init__.py | stream.process | def process(self, chars):
"""
Consume a string of and advance the state as necessary.
"""
while len(chars) > 0:
self.consume(chars[0])
chars = chars[1:] | python | def process(self, chars):
"""
Consume a string of and advance the state as necessary.
"""
while len(chars) > 0:
self.consume(chars[0])
chars = chars[1:] | [
"def",
"process",
"(",
"self",
",",
"chars",
")",
":",
"while",
"len",
"(",
"chars",
")",
">",
"0",
":",
"self",
".",
"consume",
"(",
"chars",
"[",
"0",
"]",
")",
"chars",
"=",
"chars",
"[",
"1",
":",
"]"
] | Consume a string of and advance the state as necessary. | [
"Consume",
"a",
"string",
"of",
"and",
"advance",
"the",
"state",
"as",
"necessary",
"."
] | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L298-L305 |
samfoo/vt102 | vt102/__init__.py | stream.add_event_listener | def add_event_listener(self, event, function):
"""
Add an event listen for a particular event. Depending on the event
there may or may not be parameters passed to function. Most escape
streams also allow for an empty set of parameters (with a default
value). Providing these defa... | python | def add_event_listener(self, event, function):
"""
Add an event listen for a particular event. Depending on the event
there may or may not be parameters passed to function. Most escape
streams also allow for an empty set of parameters (with a default
value). Providing these defa... | [
"def",
"add_event_listener",
"(",
"self",
",",
"event",
",",
"function",
")",
":",
"if",
"event",
"not",
"in",
"self",
".",
"listeners",
":",
"self",
".",
"listeners",
"[",
"event",
"]",
"=",
"[",
"]",
"self",
".",
"listeners",
"[",
"event",
"]",
"."... | Add an event listen for a particular event. Depending on the event
there may or may not be parameters passed to function. Most escape
streams also allow for an empty set of parameters (with a default
value). Providing these default values and accepting variable arguments
is the responsi... | [
"Add",
"an",
"event",
"listen",
"for",
"a",
"particular",
"event",
".",
"Depending",
"on",
"the",
"event",
"there",
"may",
"or",
"may",
"not",
"be",
"parameters",
"passed",
"to",
"function",
".",
"Most",
"escape",
"streams",
"also",
"allow",
"for",
"an",
... | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L307-L325 |
samfoo/vt102 | vt102/__init__.py | stream.dispatch | def dispatch(self, event, *args):
"""
Dispatch an event where `args` is a tuple of the arguments to send to
any callbacks. If any callback throws an exception, the subsequent
callbacks will be aborted.
"""
for callback in self.listeners.get(event, []):
if l... | python | def dispatch(self, event, *args):
"""
Dispatch an event where `args` is a tuple of the arguments to send to
any callbacks. If any callback throws an exception, the subsequent
callbacks will be aborted.
"""
for callback in self.listeners.get(event, []):
if l... | [
"def",
"dispatch",
"(",
"self",
",",
"event",
",",
"*",
"args",
")",
":",
"for",
"callback",
"in",
"self",
".",
"listeners",
".",
"get",
"(",
"event",
",",
"[",
"]",
")",
":",
"if",
"len",
"(",
"args",
")",
">",
"0",
":",
"callback",
"(",
"*",
... | Dispatch an event where `args` is a tuple of the arguments to send to
any callbacks. If any callback throws an exception, the subsequent
callbacks will be aborted. | [
"Dispatch",
"an",
"event",
"where",
"args",
"is",
"a",
"tuple",
"of",
"the",
"arguments",
"to",
"send",
"to",
"any",
"callbacks",
".",
"If",
"any",
"callback",
"throws",
"an",
"exception",
"the",
"subsequent",
"callbacks",
"will",
"be",
"aborted",
"."
] | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L327-L338 |
samfoo/vt102 | vt102/__init__.py | screen.attach | def attach(self, events):
"""
Attach this screen to a events that processes commands and dispatches
events. Sets up the appropriate event handlers so that the screen will
update itself automatically as the events processes data.
"""
if events is not None:
ev... | python | def attach(self, events):
"""
Attach this screen to a events that processes commands and dispatches
events. Sets up the appropriate event handlers so that the screen will
update itself automatically as the events processes data.
"""
if events is not None:
ev... | [
"def",
"attach",
"(",
"self",
",",
"events",
")",
":",
"if",
"events",
"is",
"not",
"None",
":",
"events",
".",
"add_event_listener",
"(",
"\"print\"",
",",
"self",
".",
"_print",
")",
"events",
".",
"add_event_listener",
"(",
"\"backspace\"",
",",
"self",... | Attach this screen to a events that processes commands and dispatches
events. Sets up the appropriate event handlers so that the screen will
update itself automatically as the events processes data. | [
"Attach",
"this",
"screen",
"to",
"a",
"events",
"that",
"processes",
"commands",
"and",
"dispatches",
"events",
".",
"Sets",
"up",
"the",
"appropriate",
"event",
"handlers",
"so",
"that",
"the",
"screen",
"will",
"update",
"itself",
"automatically",
"as",
"th... | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L397-L434 |
samfoo/vt102 | vt102/__init__.py | screen.resize | def resize(self, shape):
"""
Resize the screen. If the requested screen size has more rows than the
existing screen, rows will be added at the bottom. If the requested
size has less rows than the existing screen rows will be clipped at the
top of the screen.
Similarly if... | python | def resize(self, shape):
"""
Resize the screen. If the requested screen size has more rows than the
existing screen, rows will be added at the bottom. If the requested
size has less rows than the existing screen rows will be clipped at the
top of the screen.
Similarly if... | [
"def",
"resize",
"(",
"self",
",",
"shape",
")",
":",
"rows",
",",
"cols",
"=",
"shape",
"# Honestly though, you can't trust anyone these days...",
"assert",
"(",
"rows",
">",
"0",
"and",
"cols",
">",
"0",
")",
"# First resize the rows",
"if",
"self",
".",
"si... | Resize the screen. If the requested screen size has more rows than the
existing screen, rows will be added at the bottom. If the requested
size has less rows than the existing screen rows will be clipped at the
top of the screen.
Similarly if the existing screen has less columns than th... | [
"Resize",
"the",
"screen",
".",
"If",
"the",
"requested",
"screen",
"size",
"has",
"more",
"rows",
"than",
"the",
"existing",
"screen",
"rows",
"will",
"be",
"added",
"at",
"the",
"bottom",
".",
"If",
"the",
"requested",
"size",
"has",
"less",
"rows",
"t... | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L442-L488 |
samfoo/vt102 | vt102/__init__.py | screen._print | def _print(self, char):
"""
Print a character at the current cursor position and advance the
cursor.
"""
# Don't make bugs where we try to print a screen.
assert len(char) == 1
try:
try:
# Python 3
char = self.decoder... | python | def _print(self, char):
"""
Print a character at the current cursor position and advance the
cursor.
"""
# Don't make bugs where we try to print a screen.
assert len(char) == 1
try:
try:
# Python 3
char = self.decoder... | [
"def",
"_print",
"(",
"self",
",",
"char",
")",
":",
"# Don't make bugs where we try to print a screen. ",
"assert",
"len",
"(",
"char",
")",
"==",
"1",
"try",
":",
"try",
":",
"# Python 3",
"char",
"=",
"self",
".",
"decoder",
"(",
"bytes",
"(",
"char",
"... | Print a character at the current cursor position and advance the
cursor. | [
"Print",
"a",
"character",
"at",
"the",
"current",
"cursor",
"position",
"and",
"advance",
"the",
"cursor",
"."
] | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L513-L550 |
samfoo/vt102 | vt102/__init__.py | screen._index | def _index(self):
"""
Move the cursor down one row in the same column. If the cursor is at
the last row, create a new row at the bottom.
"""
if self.y + 1 >= self.size[0]:
# If the cursor is currently on the last row, then spawn another
# and scroll down... | python | def _index(self):
"""
Move the cursor down one row in the same column. If the cursor is at
the last row, create a new row at the bottom.
"""
if self.y + 1 >= self.size[0]:
# If the cursor is currently on the last row, then spawn another
# and scroll down... | [
"def",
"_index",
"(",
"self",
")",
":",
"if",
"self",
".",
"y",
"+",
"1",
">=",
"self",
".",
"size",
"[",
"0",
"]",
":",
"# If the cursor is currently on the last row, then spawn another",
"# and scroll down (removing the top row).",
"self",
".",
"display",
"=",
"... | Move the cursor down one row in the same column. If the cursor is at
the last row, create a new row at the bottom. | [
"Move",
"the",
"cursor",
"down",
"one",
"row",
"in",
"the",
"same",
"column",
".",
"If",
"the",
"cursor",
"is",
"at",
"the",
"last",
"row",
"create",
"a",
"new",
"row",
"at",
"the",
"bottom",
"."
] | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L559-L572 |
samfoo/vt102 | vt102/__init__.py | screen._reverse_index | def _reverse_index(self):
"""
Move the cursor up one row in the same column. If the cursor is at the
first row, create a new row at the top.
"""
if self.y == 0:
# If the cursor is currently at the first row, then scroll the
# screen up.
self.di... | python | def _reverse_index(self):
"""
Move the cursor up one row in the same column. If the cursor is at the
first row, create a new row at the top.
"""
if self.y == 0:
# If the cursor is currently at the first row, then scroll the
# screen up.
self.di... | [
"def",
"_reverse_index",
"(",
"self",
")",
":",
"if",
"self",
".",
"y",
"==",
"0",
":",
"# If the cursor is currently at the first row, then scroll the",
"# screen up.",
"self",
".",
"display",
"=",
"[",
"u\" \"",
"*",
"self",
".",
"size",
"[",
"1",
"]",
"]",
... | Move the cursor up one row in the same column. If the cursor is at the
first row, create a new row at the top. | [
"Move",
"the",
"cursor",
"up",
"one",
"row",
"in",
"the",
"same",
"column",
".",
"If",
"the",
"cursor",
"is",
"at",
"the",
"first",
"row",
"create",
"a",
"new",
"row",
"at",
"the",
"top",
"."
] | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L574-L586 |
samfoo/vt102 | vt102/__init__.py | screen._next_tab_stop | def _next_tab_stop(self):
"""
Return the x value of the next available tabstop or the x value of the
margin if there are no more tabstops.
"""
for stop in sorted(self.tabstops):
if self.x < stop:
return stop
return self.size[1] - 1 | python | def _next_tab_stop(self):
"""
Return the x value of the next available tabstop or the x value of the
margin if there are no more tabstops.
"""
for stop in sorted(self.tabstops):
if self.x < stop:
return stop
return self.size[1] - 1 | [
"def",
"_next_tab_stop",
"(",
"self",
")",
":",
"for",
"stop",
"in",
"sorted",
"(",
"self",
".",
"tabstops",
")",
":",
"if",
"self",
".",
"x",
"<",
"stop",
":",
"return",
"stop",
"return",
"self",
".",
"size",
"[",
"1",
"]",
"-",
"1"
] | Return the x value of the next available tabstop or the x value of the
margin if there are no more tabstops. | [
"Return",
"the",
"x",
"value",
"of",
"the",
"next",
"available",
"tabstop",
"or",
"the",
"x",
"value",
"of",
"the",
"margin",
"if",
"there",
"are",
"no",
"more",
"tabstops",
"."
] | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L604-L613 |
samfoo/vt102 | vt102/__init__.py | screen._restore_cursor | def _restore_cursor(self):
"""
Set the current cursor position to whatever cursor is on top of the
stack.
"""
if len(self.cursor_save_stack):
self.x, self.y = self.cursor_save_stack.pop() | python | def _restore_cursor(self):
"""
Set the current cursor position to whatever cursor is on top of the
stack.
"""
if len(self.cursor_save_stack):
self.x, self.y = self.cursor_save_stack.pop() | [
"def",
"_restore_cursor",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"cursor_save_stack",
")",
":",
"self",
".",
"x",
",",
"self",
".",
"y",
"=",
"self",
".",
"cursor_save_stack",
".",
"pop",
"(",
")"
] | Set the current cursor position to whatever cursor is on top of the
stack. | [
"Set",
"the",
"current",
"cursor",
"position",
"to",
"whatever",
"cursor",
"is",
"on",
"top",
"of",
"the",
"stack",
"."
] | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L637-L644 |
samfoo/vt102 | vt102/__init__.py | screen._insert_line | def _insert_line(self, count=1):
"""
Inserts lines at line with cursor. Lines displayed below cursor move
down. Lines moved past the bottom margin are lost.
"""
trimmed = self.display[:self.y+1] + \
[u" " * self.size[1]] * count + \
self.disp... | python | def _insert_line(self, count=1):
"""
Inserts lines at line with cursor. Lines displayed below cursor move
down. Lines moved past the bottom margin are lost.
"""
trimmed = self.display[:self.y+1] + \
[u" " * self.size[1]] * count + \
self.disp... | [
"def",
"_insert_line",
"(",
"self",
",",
"count",
"=",
"1",
")",
":",
"trimmed",
"=",
"self",
".",
"display",
"[",
":",
"self",
".",
"y",
"+",
"1",
"]",
"+",
"[",
"u\" \"",
"*",
"self",
".",
"size",
"[",
"1",
"]",
"]",
"*",
"count",
"+",
"sel... | Inserts lines at line with cursor. Lines displayed below cursor move
down. Lines moved past the bottom margin are lost. | [
"Inserts",
"lines",
"at",
"line",
"with",
"cursor",
".",
"Lines",
"displayed",
"below",
"cursor",
"move",
"down",
".",
"Lines",
"moved",
"past",
"the",
"bottom",
"margin",
"are",
"lost",
"."
] | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L646-L654 |
samfoo/vt102 | vt102/__init__.py | screen._delete_line | def _delete_line(self, count=1):
"""
Deletes count lines, starting at line with cursor. As lines are
deleted, lines displayed below cursor move up. Lines added to bottom of
screen have spaces with same character attributes as last line moved
up.
"""
self.display... | python | def _delete_line(self, count=1):
"""
Deletes count lines, starting at line with cursor. As lines are
deleted, lines displayed below cursor move up. Lines added to bottom of
screen have spaces with same character attributes as last line moved
up.
"""
self.display... | [
"def",
"_delete_line",
"(",
"self",
",",
"count",
"=",
"1",
")",
":",
"self",
".",
"display",
"=",
"self",
".",
"display",
"[",
":",
"self",
".",
"y",
"]",
"+",
"self",
".",
"display",
"[",
"self",
".",
"y",
"+",
"1",
":",
"]",
"self",
".",
"... | Deletes count lines, starting at line with cursor. As lines are
deleted, lines displayed below cursor move up. Lines added to bottom of
screen have spaces with same character attributes as last line moved
up. | [
"Deletes",
"count",
"lines",
"starting",
"at",
"line",
"with",
"cursor",
".",
"As",
"lines",
"are",
"deleted",
"lines",
"displayed",
"below",
"cursor",
"move",
"up",
".",
"Lines",
"added",
"to",
"bottom",
"of",
"screen",
"have",
"spaces",
"with",
"same",
"... | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L656-L670 |
samfoo/vt102 | vt102/__init__.py | screen._delete_character | def _delete_character(self, count=1):
"""
Deletes count characters, starting with the character at cursor
position. When a character is deleted, all characters to the right
of cursor move left.
"""
# First resize the text display
row = self.display[self.y]
... | python | def _delete_character(self, count=1):
"""
Deletes count characters, starting with the character at cursor
position. When a character is deleted, all characters to the right
of cursor move left.
"""
# First resize the text display
row = self.display[self.y]
... | [
"def",
"_delete_character",
"(",
"self",
",",
"count",
"=",
"1",
")",
":",
"# First resize the text display",
"row",
"=",
"self",
".",
"display",
"[",
"self",
".",
"y",
"]",
"count",
"=",
"min",
"(",
"count",
",",
"self",
".",
"size",
"[",
"1",
"]",
... | Deletes count characters, starting with the character at cursor
position. When a character is deleted, all characters to the right
of cursor move left. | [
"Deletes",
"count",
"characters",
"starting",
"with",
"the",
"character",
"at",
"cursor",
"position",
".",
"When",
"a",
"character",
"is",
"deleted",
"all",
"characters",
"to",
"the",
"right",
"of",
"cursor",
"move",
"left",
"."
] | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L672-L688 |
samfoo/vt102 | vt102/__init__.py | screen._erase_in_line | def _erase_in_line(self, type_of=0):
"""
Erases the row in a specific way, depending on the type_of.
"""
row = self.display[self.y]
attrs = self.attributes[self.y]
if type_of == 0:
# Erase from the cursor to the end of line, including the cursor
r... | python | def _erase_in_line(self, type_of=0):
"""
Erases the row in a specific way, depending on the type_of.
"""
row = self.display[self.y]
attrs = self.attributes[self.y]
if type_of == 0:
# Erase from the cursor to the end of line, including the cursor
r... | [
"def",
"_erase_in_line",
"(",
"self",
",",
"type_of",
"=",
"0",
")",
":",
"row",
"=",
"self",
".",
"display",
"[",
"self",
".",
"y",
"]",
"attrs",
"=",
"self",
".",
"attributes",
"[",
"self",
".",
"y",
"]",
"if",
"type_of",
"==",
"0",
":",
"# Era... | Erases the row in a specific way, depending on the type_of. | [
"Erases",
"the",
"row",
"in",
"a",
"specific",
"way",
"depending",
"on",
"the",
"type_of",
"."
] | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L690-L711 |
samfoo/vt102 | vt102/__init__.py | screen._cursor_down | def _cursor_down(self, count=1):
"""
Moves cursor down count lines in same column. Cursor stops at bottom
margin.
"""
self.y = min(self.size[0] - 1, self.y + count) | python | def _cursor_down(self, count=1):
"""
Moves cursor down count lines in same column. Cursor stops at bottom
margin.
"""
self.y = min(self.size[0] - 1, self.y + count) | [
"def",
"_cursor_down",
"(",
"self",
",",
"count",
"=",
"1",
")",
":",
"self",
".",
"y",
"=",
"min",
"(",
"self",
".",
"size",
"[",
"0",
"]",
"-",
"1",
",",
"self",
".",
"y",
"+",
"count",
")"
] | Moves cursor down count lines in same column. Cursor stops at bottom
margin. | [
"Moves",
"cursor",
"down",
"count",
"lines",
"in",
"same",
"column",
".",
"Cursor",
"stops",
"at",
"bottom",
"margin",
"."
] | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L765-L770 |
samfoo/vt102 | vt102/__init__.py | screen._cursor_forward | def _cursor_forward(self, count=1):
"""
Moves cursor right count columns. Cursor stops at right margin.
"""
self.x = min(self.size[1] - 1, self.x + count) | python | def _cursor_forward(self, count=1):
"""
Moves cursor right count columns. Cursor stops at right margin.
"""
self.x = min(self.size[1] - 1, self.x + count) | [
"def",
"_cursor_forward",
"(",
"self",
",",
"count",
"=",
"1",
")",
":",
"self",
".",
"x",
"=",
"min",
"(",
"self",
".",
"size",
"[",
"1",
"]",
"-",
"1",
",",
"self",
".",
"x",
"+",
"count",
")"
] | Moves cursor right count columns. Cursor stops at right margin. | [
"Moves",
"cursor",
"right",
"count",
"columns",
".",
"Cursor",
"stops",
"at",
"right",
"margin",
"."
] | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L778-L782 |
samfoo/vt102 | vt102/__init__.py | screen._cursor_position | def _cursor_position(self, row=0, column=0):
"""
Set the cursor to a specific row and column.
Obnoxiously row/column is 1 based, instead of zero based, so we need
to compensate. I know I've created bugs in here somehow.
Confoundingly, inputs of 0 are still acceptable, and shou... | python | def _cursor_position(self, row=0, column=0):
"""
Set the cursor to a specific row and column.
Obnoxiously row/column is 1 based, instead of zero based, so we need
to compensate. I know I've created bugs in here somehow.
Confoundingly, inputs of 0 are still acceptable, and shou... | [
"def",
"_cursor_position",
"(",
"self",
",",
"row",
"=",
"0",
",",
"column",
"=",
"0",
")",
":",
"if",
"row",
"==",
"0",
":",
"row",
"=",
"1",
"if",
"column",
"==",
"0",
":",
"column",
"=",
"1",
"self",
".",
"y",
"=",
"min",
"(",
"row",
"-",
... | Set the cursor to a specific row and column.
Obnoxiously row/column is 1 based, instead of zero based, so we need
to compensate. I know I've created bugs in here somehow.
Confoundingly, inputs of 0 are still acceptable, and should move to
the beginning of the row/column as if they wer... | [
"Set",
"the",
"cursor",
"to",
"a",
"specific",
"row",
"and",
"column",
"."
] | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L784-L800 |
samfoo/vt102 | vt102/__init__.py | screen._text_attr | def _text_attr(self, attr):
"""
Given a text attribute, set the current cursor appropriately.
"""
attr = text[attr]
if attr == "reset":
self.cursor_attributes = self.default_attributes
elif attr == "underline-off":
self.cursor_attributes = self._re... | python | def _text_attr(self, attr):
"""
Given a text attribute, set the current cursor appropriately.
"""
attr = text[attr]
if attr == "reset":
self.cursor_attributes = self.default_attributes
elif attr == "underline-off":
self.cursor_attributes = self._re... | [
"def",
"_text_attr",
"(",
"self",
",",
"attr",
")",
":",
"attr",
"=",
"text",
"[",
"attr",
"]",
"if",
"attr",
"==",
"\"reset\"",
":",
"self",
".",
"cursor_attributes",
"=",
"self",
".",
"default_attributes",
"elif",
"attr",
"==",
"\"underline-off\"",
":",
... | Given a text attribute, set the current cursor appropriately. | [
"Given",
"a",
"text",
"attribute",
"set",
"the",
"current",
"cursor",
"appropriately",
"."
] | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L820-L834 |
samfoo/vt102 | vt102/__init__.py | screen._color_attr | def _color_attr(self, ground, attr):
"""
Given a color attribute, set the current cursor appropriately.
"""
attr = colors[ground][attr]
attrs = self.cursor_attributes
if ground == "foreground":
self.cursor_attributes = (attrs[0], attr, attrs[2])
elif ... | python | def _color_attr(self, ground, attr):
"""
Given a color attribute, set the current cursor appropriately.
"""
attr = colors[ground][attr]
attrs = self.cursor_attributes
if ground == "foreground":
self.cursor_attributes = (attrs[0], attr, attrs[2])
elif ... | [
"def",
"_color_attr",
"(",
"self",
",",
"ground",
",",
"attr",
")",
":",
"attr",
"=",
"colors",
"[",
"ground",
"]",
"[",
"attr",
"]",
"attrs",
"=",
"self",
".",
"cursor_attributes",
"if",
"ground",
"==",
"\"foreground\"",
":",
"self",
".",
"cursor_attrib... | Given a color attribute, set the current cursor appropriately. | [
"Given",
"a",
"color",
"attribute",
"set",
"the",
"current",
"cursor",
"appropriately",
"."
] | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L836-L845 |
samfoo/vt102 | vt102/__init__.py | screen._set_attr | def _set_attr(self, attr):
"""
Given some text attribute, set the current cursor attributes
appropriately.
"""
if attr in text:
self._text_attr(attr)
elif attr in colors["foreground"]:
self._color_attr("foreground", attr)
elif attr in colo... | python | def _set_attr(self, attr):
"""
Given some text attribute, set the current cursor attributes
appropriately.
"""
if attr in text:
self._text_attr(attr)
elif attr in colors["foreground"]:
self._color_attr("foreground", attr)
elif attr in colo... | [
"def",
"_set_attr",
"(",
"self",
",",
"attr",
")",
":",
"if",
"attr",
"in",
"text",
":",
"self",
".",
"_text_attr",
"(",
"attr",
")",
"elif",
"attr",
"in",
"colors",
"[",
"\"foreground\"",
"]",
":",
"self",
".",
"_color_attr",
"(",
"\"foreground\"",
",... | Given some text attribute, set the current cursor attributes
appropriately. | [
"Given",
"some",
"text",
"attribute",
"set",
"the",
"current",
"cursor",
"attributes",
"appropriately",
"."
] | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L847-L857 |
samfoo/vt102 | vt102/__init__.py | screen._select_graphic_rendition | def _select_graphic_rendition(self, *attrs):
"""
Set the current text attribute.
"""
if len(attrs) == 0:
# No arguments means that we're really trying to do a reset.
attrs = [0]
for attr in attrs:
self._set_attr(attr) | python | def _select_graphic_rendition(self, *attrs):
"""
Set the current text attribute.
"""
if len(attrs) == 0:
# No arguments means that we're really trying to do a reset.
attrs = [0]
for attr in attrs:
self._set_attr(attr) | [
"def",
"_select_graphic_rendition",
"(",
"self",
",",
"*",
"attrs",
")",
":",
"if",
"len",
"(",
"attrs",
")",
"==",
"0",
":",
"# No arguments means that we're really trying to do a reset.",
"attrs",
"=",
"[",
"0",
"]",
"for",
"attr",
"in",
"attrs",
":",
"self"... | Set the current text attribute. | [
"Set",
"the",
"current",
"text",
"attribute",
"."
] | train | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L859-L869 |
gmr/flatdict | flatdict.py | FlatDict.as_dict | def as_dict(self):
"""Return the :class:`~flatdict.FlatDict` as a :class:`dict`
:rtype: dict
"""
out = dict({})
for key in self.keys():
if self._has_delimiter(key):
pk, ck = key.split(self._delimiter, 1)
if self._has_delimiter(ck):
... | python | def as_dict(self):
"""Return the :class:`~flatdict.FlatDict` as a :class:`dict`
:rtype: dict
"""
out = dict({})
for key in self.keys():
if self._has_delimiter(key):
pk, ck = key.split(self._delimiter, 1)
if self._has_delimiter(ck):
... | [
"def",
"as_dict",
"(",
"self",
")",
":",
"out",
"=",
"dict",
"(",
"{",
"}",
")",
"for",
"key",
"in",
"self",
".",
"keys",
"(",
")",
":",
"if",
"self",
".",
"_has_delimiter",
"(",
"key",
")",
":",
"pk",
",",
"ck",
"=",
"key",
".",
"split",
"("... | Return the :class:`~flatdict.FlatDict` as a :class:`dict`
:rtype: dict | [
"Return",
"the",
":",
"class",
":",
"~flatdict",
".",
"FlatDict",
"as",
"a",
":",
"class",
":",
"dict"
] | train | https://github.com/gmr/flatdict/blob/40bfa64972b2dc148643116db786aa106e7d7d56/flatdict.py#L168-L188 |
gmr/flatdict | flatdict.py | FlatDict.keys | def keys(self):
"""Return a copy of the flat dictionary's list of keys.
See the note for :meth:`flatdict.FlatDict.items`.
:rtype: list
"""
keys = []
for key, value in self._values.items():
if isinstance(value, (FlatDict, dict)):
nested = [sel... | python | def keys(self):
"""Return a copy of the flat dictionary's list of keys.
See the note for :meth:`flatdict.FlatDict.items`.
:rtype: list
"""
keys = []
for key, value in self._values.items():
if isinstance(value, (FlatDict, dict)):
nested = [sel... | [
"def",
"keys",
"(",
"self",
")",
":",
"keys",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"self",
".",
"_values",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"FlatDict",
",",
"dict",
")",
")",
":",
"nested",
"=... | Return a copy of the flat dictionary's list of keys.
See the note for :meth:`flatdict.FlatDict.items`.
:rtype: list | [
"Return",
"a",
"copy",
"of",
"the",
"flat",
"dictionary",
"s",
"list",
"of",
"keys",
".",
"See",
"the",
"note",
"for",
":",
"meth",
":",
"flatdict",
".",
"FlatDict",
".",
"items",
"."
] | train | https://github.com/gmr/flatdict/blob/40bfa64972b2dc148643116db786aa106e7d7d56/flatdict.py#L276-L290 |
gmr/flatdict | flatdict.py | FlatDict.pop | def pop(self, key, default=NO_DEFAULT):
"""If key is in the flat dictionary, remove it and return its value,
else return default. If default is not given and key is not in the
dictionary, :exc:`KeyError` is raised.
:param mixed key: The key name
:param mixed default: The default... | python | def pop(self, key, default=NO_DEFAULT):
"""If key is in the flat dictionary, remove it and return its value,
else return default. If default is not given and key is not in the
dictionary, :exc:`KeyError` is raised.
:param mixed key: The key name
:param mixed default: The default... | [
"def",
"pop",
"(",
"self",
",",
"key",
",",
"default",
"=",
"NO_DEFAULT",
")",
":",
"if",
"key",
"not",
"in",
"self",
"and",
"default",
"!=",
"NO_DEFAULT",
":",
"return",
"default",
"value",
"=",
"self",
"[",
"key",
"]",
"self",
".",
"__delitem__",
"... | If key is in the flat dictionary, remove it and return its value,
else return default. If default is not given and key is not in the
dictionary, :exc:`KeyError` is raised.
:param mixed key: The key name
:param mixed default: The default value
:rtype: mixed | [
"If",
"key",
"is",
"in",
"the",
"flat",
"dictionary",
"remove",
"it",
"and",
"return",
"its",
"value",
"else",
"return",
"default",
".",
"If",
"default",
"is",
"not",
"given",
"and",
"key",
"is",
"not",
"in",
"the",
"dictionary",
":",
"exc",
":",
"KeyE... | train | https://github.com/gmr/flatdict/blob/40bfa64972b2dc148643116db786aa106e7d7d56/flatdict.py#L292-L306 |
gmr/flatdict | flatdict.py | FlatDict.setdefault | def setdefault(self, key, default):
"""If key is in the flat dictionary, return its value. If not,
insert key with a value of default and return default.
default defaults to ``None``.
:param mixed key: The key name
:param mixed default: The default value
:rtype: mixed
... | python | def setdefault(self, key, default):
"""If key is in the flat dictionary, return its value. If not,
insert key with a value of default and return default.
default defaults to ``None``.
:param mixed key: The key name
:param mixed default: The default value
:rtype: mixed
... | [
"def",
"setdefault",
"(",
"self",
",",
"key",
",",
"default",
")",
":",
"if",
"key",
"not",
"in",
"self",
"or",
"not",
"self",
".",
"__getitem__",
"(",
"key",
")",
":",
"self",
".",
"__setitem__",
"(",
"key",
",",
"default",
")",
"return",
"self",
... | If key is in the flat dictionary, return its value. If not,
insert key with a value of default and return default.
default defaults to ``None``.
:param mixed key: The key name
:param mixed default: The default value
:rtype: mixed | [
"If",
"key",
"is",
"in",
"the",
"flat",
"dictionary",
"return",
"its",
"value",
".",
"If",
"not",
"insert",
"key",
"with",
"a",
"value",
"of",
"default",
"and",
"return",
"default",
".",
"default",
"defaults",
"to",
"None",
"."
] | train | https://github.com/gmr/flatdict/blob/40bfa64972b2dc148643116db786aa106e7d7d56/flatdict.py#L308-L320 |
gmr/flatdict | flatdict.py | FlatDict.set_delimiter | def set_delimiter(self, delimiter):
"""Override the default or passed in delimiter with a new value. If
the requested delimiter already exists in a key, a :exc:`ValueError`
will be raised.
:param str delimiter: The delimiter to use
:raises: ValueError
"""
for ke... | python | def set_delimiter(self, delimiter):
"""Override the default or passed in delimiter with a new value. If
the requested delimiter already exists in a key, a :exc:`ValueError`
will be raised.
:param str delimiter: The delimiter to use
:raises: ValueError
"""
for ke... | [
"def",
"set_delimiter",
"(",
"self",
",",
"delimiter",
")",
":",
"for",
"key",
"in",
"self",
".",
"keys",
"(",
")",
":",
"if",
"delimiter",
"in",
"key",
":",
"raise",
"ValueError",
"(",
"'Key {!r} collides with delimiter {!r}'",
",",
"key",
",",
"delimiter",... | Override the default or passed in delimiter with a new value. If
the requested delimiter already exists in a key, a :exc:`ValueError`
will be raised.
:param str delimiter: The delimiter to use
:raises: ValueError | [
"Override",
"the",
"default",
"or",
"passed",
"in",
"delimiter",
"with",
"a",
"new",
"value",
".",
"If",
"the",
"requested",
"delimiter",
"already",
"exists",
"in",
"a",
"key",
"a",
":",
"exc",
":",
"ValueError",
"will",
"be",
"raised",
"."
] | train | https://github.com/gmr/flatdict/blob/40bfa64972b2dc148643116db786aa106e7d7d56/flatdict.py#L322-L338 |
gmr/flatdict | flatdict.py | FlatterDict.as_dict | def as_dict(self):
"""Return the :class:`~flatdict.FlatterDict` as a nested
:class:`dict`.
:rtype: dict
"""
out = dict({})
for key in self.keys():
if self._has_delimiter(key):
pk, ck = key.split(self._delimiter, 1)
if self._ha... | python | def as_dict(self):
"""Return the :class:`~flatdict.FlatterDict` as a nested
:class:`dict`.
:rtype: dict
"""
out = dict({})
for key in self.keys():
if self._has_delimiter(key):
pk, ck = key.split(self._delimiter, 1)
if self._ha... | [
"def",
"as_dict",
"(",
"self",
")",
":",
"out",
"=",
"dict",
"(",
"{",
"}",
")",
"for",
"key",
"in",
"self",
".",
"keys",
"(",
")",
":",
"if",
"self",
".",
"_has_delimiter",
"(",
"key",
")",
":",
"pk",
",",
"ck",
"=",
"key",
".",
"split",
"("... | Return the :class:`~flatdict.FlatterDict` as a nested
:class:`dict`.
:rtype: dict | [
"Return",
"the",
":",
"class",
":",
"~flatdict",
".",
"FlatterDict",
"as",
"a",
"nested",
":",
"class",
":",
"dict",
"."
] | train | https://github.com/gmr/flatdict/blob/40bfa64972b2dc148643116db786aa106e7d7d56/flatdict.py#L420-L448 |
gmr/flatdict | flatdict.py | FlatterDict._child_as_list | def _child_as_list(self, pk, ck):
"""Returns a list of values from the child FlatterDict instance
with string based integer keys.
:param str pk: The parent key
:param str ck: The child key
:rtype: list
"""
return [self._values[pk][ck][k]
for k in... | python | def _child_as_list(self, pk, ck):
"""Returns a list of values from the child FlatterDict instance
with string based integer keys.
:param str pk: The parent key
:param str ck: The child key
:rtype: list
"""
return [self._values[pk][ck][k]
for k in... | [
"def",
"_child_as_list",
"(",
"self",
",",
"pk",
",",
"ck",
")",
":",
"return",
"[",
"self",
".",
"_values",
"[",
"pk",
"]",
"[",
"ck",
"]",
"[",
"k",
"]",
"for",
"k",
"in",
"sorted",
"(",
"self",
".",
"_values",
"[",
"pk",
"]",
"[",
"ck",
"]... | Returns a list of values from the child FlatterDict instance
with string based integer keys.
:param str pk: The parent key
:param str ck: The child key
:rtype: list | [
"Returns",
"a",
"list",
"of",
"values",
"from",
"the",
"child",
"FlatterDict",
"instance",
"with",
"string",
"based",
"integer",
"keys",
"."
] | train | https://github.com/gmr/flatdict/blob/40bfa64972b2dc148643116db786aa106e7d7d56/flatdict.py#L450-L461 |
eugene-eeo/graphlite | graphlite/query.py | V.gen_query | def gen_query(self):
"""
Generate an SQL query for the edge object.
"""
return (
SQL.forwards_relation(self.src, self.rel) if self.dst is None else
SQL.inverse_relation(self.dst, self.rel)
) | python | def gen_query(self):
"""
Generate an SQL query for the edge object.
"""
return (
SQL.forwards_relation(self.src, self.rel) if self.dst is None else
SQL.inverse_relation(self.dst, self.rel)
) | [
"def",
"gen_query",
"(",
"self",
")",
":",
"return",
"(",
"SQL",
".",
"forwards_relation",
"(",
"self",
".",
"src",
",",
"self",
".",
"rel",
")",
"if",
"self",
".",
"dst",
"is",
"None",
"else",
"SQL",
".",
"inverse_relation",
"(",
"self",
".",
"dst",... | Generate an SQL query for the edge object. | [
"Generate",
"an",
"SQL",
"query",
"for",
"the",
"edge",
"object",
"."
] | train | https://github.com/eugene-eeo/graphlite/blob/8d17e9549ee8610570dcde1b427431a2584395b7/graphlite/query.py#L43-L50 |
eugene-eeo/graphlite | graphlite/query.py | Query.derived | def derived(self, statement, params=(), replace=False):
"""
Returns a new query object set up correctly with
the *statement* and *params* appended to the end
of the new instance's internal query and params,
along with the current instance's connection.
:param statement: ... | python | def derived(self, statement, params=(), replace=False):
"""
Returns a new query object set up correctly with
the *statement* and *params* appended to the end
of the new instance's internal query and params,
along with the current instance's connection.
:param statement: ... | [
"def",
"derived",
"(",
"self",
",",
"statement",
",",
"params",
"=",
"(",
")",
",",
"replace",
"=",
"False",
")",
":",
"return",
"Query",
"(",
"db",
"=",
"self",
".",
"db",
",",
"sql",
"=",
"(",
"statement",
",",
")",
"if",
"replace",
"else",
"se... | Returns a new query object set up correctly with
the *statement* and *params* appended to the end
of the new instance's internal query and params,
along with the current instance's connection.
:param statement: The SQL query string to append.
:param params: The parameters to app... | [
"Returns",
"a",
"new",
"query",
"object",
"set",
"up",
"correctly",
"with",
"the",
"*",
"statement",
"*",
"and",
"*",
"params",
"*",
"appended",
"to",
"the",
"end",
"of",
"the",
"new",
"instance",
"s",
"internal",
"query",
"and",
"params",
"along",
"with... | train | https://github.com/eugene-eeo/graphlite/blob/8d17e9549ee8610570dcde1b427431a2584395b7/graphlite/query.py#L87-L103 |
eugene-eeo/graphlite | graphlite/query.py | Query.traverse | def traverse(self, edge):
"""
Traverse the graph, and selecting the destination
nodes for a particular relation that the selected
nodes are a source of, i.e. select the friends of
my friends. You can traverse indefinitely.
:param edge: The edge query. If the edge's
... | python | def traverse(self, edge):
"""
Traverse the graph, and selecting the destination
nodes for a particular relation that the selected
nodes are a source of, i.e. select the friends of
my friends. You can traverse indefinitely.
:param edge: The edge query. If the edge's
... | [
"def",
"traverse",
"(",
"self",
",",
"edge",
")",
":",
"query",
"=",
"self",
".",
"statement",
"rel",
",",
"dst",
"=",
"edge",
".",
"rel",
",",
"edge",
".",
"dst",
"statement",
",",
"params",
"=",
"(",
"SQL",
".",
"compound_fwd_query",
"(",
"query",
... | Traverse the graph, and selecting the destination
nodes for a particular relation that the selected
nodes are a source of, i.e. select the friends of
my friends. You can traverse indefinitely.
:param edge: The edge query. If the edge's
destination node is specified then the ... | [
"Traverse",
"the",
"graph",
"and",
"selecting",
"the",
"destination",
"nodes",
"for",
"a",
"particular",
"relation",
"that",
"the",
"selected",
"nodes",
"are",
"a",
"source",
"of",
"i",
".",
"e",
".",
"select",
"the",
"friends",
"of",
"my",
"friends",
".",... | train | https://github.com/eugene-eeo/graphlite/blob/8d17e9549ee8610570dcde1b427431a2584395b7/graphlite/query.py#L117-L134 |
eugene-eeo/graphlite | graphlite/graph.py | Graph.setup_sql | def setup_sql(self, graphs):
"""
Sets up the SQL tables for the graph object,
and creates indexes as well.
:param graphs: The graphs to create.
"""
with closing(self.db.cursor()) as cursor:
for table in graphs:
cursor.execute(SQL.CREATE_TABLE ... | python | def setup_sql(self, graphs):
"""
Sets up the SQL tables for the graph object,
and creates indexes as well.
:param graphs: The graphs to create.
"""
with closing(self.db.cursor()) as cursor:
for table in graphs:
cursor.execute(SQL.CREATE_TABLE ... | [
"def",
"setup_sql",
"(",
"self",
",",
"graphs",
")",
":",
"with",
"closing",
"(",
"self",
".",
"db",
".",
"cursor",
"(",
")",
")",
"as",
"cursor",
":",
"for",
"table",
"in",
"graphs",
":",
"cursor",
".",
"execute",
"(",
"SQL",
".",
"CREATE_TABLE",
... | Sets up the SQL tables for the graph object,
and creates indexes as well.
:param graphs: The graphs to create. | [
"Sets",
"up",
"the",
"SQL",
"tables",
"for",
"the",
"graph",
"object",
"and",
"creates",
"indexes",
"as",
"well",
"."
] | train | https://github.com/eugene-eeo/graphlite/blob/8d17e9549ee8610570dcde1b427431a2584395b7/graphlite/graph.py#L21-L33 |
eugene-eeo/graphlite | graphlite/sql.py | remove | def remove(src, rel, dst):
"""
Returns an SQL statement that removes edges from
the SQL backing store. Either `src` or `dst` may
be specified, even both.
:param src: The source node.
:param rel: The relation.
:param dst: The destination node.
"""
smt = 'DELETE FROM %s' % rel
que... | python | def remove(src, rel, dst):
"""
Returns an SQL statement that removes edges from
the SQL backing store. Either `src` or `dst` may
be specified, even both.
:param src: The source node.
:param rel: The relation.
:param dst: The destination node.
"""
smt = 'DELETE FROM %s' % rel
que... | [
"def",
"remove",
"(",
"src",
",",
"rel",
",",
"dst",
")",
":",
"smt",
"=",
"'DELETE FROM %s'",
"%",
"rel",
"queries",
"=",
"[",
"]",
"params",
"=",
"[",
"]",
"if",
"src",
"is",
"not",
"None",
":",
"queries",
".",
"append",
"(",
"'src = ?'",
")",
... | Returns an SQL statement that removes edges from
the SQL backing store. Either `src` or `dst` may
be specified, even both.
:param src: The source node.
:param rel: The relation.
:param dst: The destination node. | [
"Returns",
"an",
"SQL",
"statement",
"that",
"removes",
"edges",
"from",
"the",
"SQL",
"backing",
"store",
".",
"Either",
"src",
"or",
"dst",
"may",
"be",
"specified",
"even",
"both",
"."
] | train | https://github.com/eugene-eeo/graphlite/blob/8d17e9549ee8610570dcde1b427431a2584395b7/graphlite/sql.py#L28-L53 |
eugene-eeo/graphlite | graphlite/sql.py | limit | def limit(lower, upper):
"""
Returns a SQlite-compliant LIMIT statement that
takes the *lower* and *upper* bounds into account.
:param lower: The lower bound.
:param upper: The upper bound.
"""
offset = lower or 0
lim = (upper - offset) if upper else -1
smt = 'LIMIT %d OFFSET %d' % ... | python | def limit(lower, upper):
"""
Returns a SQlite-compliant LIMIT statement that
takes the *lower* and *upper* bounds into account.
:param lower: The lower bound.
:param upper: The upper bound.
"""
offset = lower or 0
lim = (upper - offset) if upper else -1
smt = 'LIMIT %d OFFSET %d' % ... | [
"def",
"limit",
"(",
"lower",
",",
"upper",
")",
":",
"offset",
"=",
"lower",
"or",
"0",
"lim",
"=",
"(",
"upper",
"-",
"offset",
")",
"if",
"upper",
"else",
"-",
"1",
"smt",
"=",
"'LIMIT %d OFFSET %d'",
"%",
"(",
"lim",
",",
"offset",
")",
"return... | Returns a SQlite-compliant LIMIT statement that
takes the *lower* and *upper* bounds into account.
:param lower: The lower bound.
:param upper: The upper bound. | [
"Returns",
"a",
"SQlite",
"-",
"compliant",
"LIMIT",
"statement",
"that",
"takes",
"the",
"*",
"lower",
"*",
"and",
"*",
"upper",
"*",
"bounds",
"into",
"account",
"."
] | train | https://github.com/eugene-eeo/graphlite/blob/8d17e9549ee8610570dcde1b427431a2584395b7/graphlite/sql.py#L120-L131 |
eugene-eeo/graphlite | graphlite/transaction.py | Transaction.perform_ops | def perform_ops(self):
"""
Performs the stored operations on the database
connection.
"""
with self.db:
with closing(self.db.cursor()) as cursor:
cursor.execute('BEGIN TRANSACTION')
self._perform_ops(cursor) | python | def perform_ops(self):
"""
Performs the stored operations on the database
connection.
"""
with self.db:
with closing(self.db.cursor()) as cursor:
cursor.execute('BEGIN TRANSACTION')
self._perform_ops(cursor) | [
"def",
"perform_ops",
"(",
"self",
")",
":",
"with",
"self",
".",
"db",
":",
"with",
"closing",
"(",
"self",
".",
"db",
".",
"cursor",
"(",
")",
")",
"as",
"cursor",
":",
"cursor",
".",
"execute",
"(",
"'BEGIN TRANSACTION'",
")",
"self",
".",
"_perfo... | Performs the stored operations on the database
connection. | [
"Performs",
"the",
"stored",
"operations",
"on",
"the",
"database",
"connection",
"."
] | train | https://github.com/eugene-eeo/graphlite/blob/8d17e9549ee8610570dcde1b427431a2584395b7/graphlite/transaction.py#L85-L93 |
wtolson/gnsq | gnsq/httpclient.py | HTTPClient.from_url | def from_url(cls, url, **kwargs):
"""Create a client from a url."""
url = urllib3.util.parse_url(url)
if url.host:
kwargs.setdefault('host', url.host)
if url.port:
kwargs.setdefault('port', url.port)
if url.scheme == 'https':
kwargs.setdefaul... | python | def from_url(cls, url, **kwargs):
"""Create a client from a url."""
url = urllib3.util.parse_url(url)
if url.host:
kwargs.setdefault('host', url.host)
if url.port:
kwargs.setdefault('port', url.port)
if url.scheme == 'https':
kwargs.setdefaul... | [
"def",
"from_url",
"(",
"cls",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"urllib3",
".",
"util",
".",
"parse_url",
"(",
"url",
")",
"if",
"url",
".",
"host",
":",
"kwargs",
".",
"setdefault",
"(",
"'host'",
",",
"url",
".",
"host... | Create a client from a url. | [
"Create",
"a",
"client",
"from",
"a",
"url",
"."
] | train | https://github.com/wtolson/gnsq/blob/0fd02578b2c9c5fa30626d78579db2a46c10edac/gnsq/httpclient.py#L28-L40 |
wtolson/gnsq | gnsq/nsqd.py | NsqdTCPClient.connect | def connect(self):
"""Initialize connection to the nsqd."""
if self.state == DISCONNECTED:
raise errors.NSQException('connection already closed')
if self.is_connected:
return
stream = Stream(self.address, self.port, self.timeout)
stream.connect()
... | python | def connect(self):
"""Initialize connection to the nsqd."""
if self.state == DISCONNECTED:
raise errors.NSQException('connection already closed')
if self.is_connected:
return
stream = Stream(self.address, self.port, self.timeout)
stream.connect()
... | [
"def",
"connect",
"(",
"self",
")",
":",
"if",
"self",
".",
"state",
"==",
"DISCONNECTED",
":",
"raise",
"errors",
".",
"NSQException",
"(",
"'connection already closed'",
")",
"if",
"self",
".",
"is_connected",
":",
"return",
"stream",
"=",
"Stream",
"(",
... | Initialize connection to the nsqd. | [
"Initialize",
"connection",
"to",
"the",
"nsqd",
"."
] | train | https://github.com/wtolson/gnsq/blob/0fd02578b2c9c5fa30626d78579db2a46c10edac/gnsq/nsqd.py#L205-L218 |
wtolson/gnsq | gnsq/nsqd.py | NsqdTCPClient.close_stream | def close_stream(self):
"""Close the underlying socket."""
if not self.is_connected:
return
self.stream.close()
self.state = DISCONNECTED
self.on_close.send(self) | python | def close_stream(self):
"""Close the underlying socket."""
if not self.is_connected:
return
self.stream.close()
self.state = DISCONNECTED
self.on_close.send(self) | [
"def",
"close_stream",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_connected",
":",
"return",
"self",
".",
"stream",
".",
"close",
"(",
")",
"self",
".",
"state",
"=",
"DISCONNECTED",
"self",
".",
"on_close",
".",
"send",
"(",
"self",
")"
] | Close the underlying socket. | [
"Close",
"the",
"underlying",
"socket",
"."
] | train | https://github.com/wtolson/gnsq/blob/0fd02578b2c9c5fa30626d78579db2a46c10edac/gnsq/nsqd.py#L220-L227 |
wtolson/gnsq | gnsq/nsqd.py | NsqdTCPClient.read_response | def read_response(self):
"""Read an individual response from nsqd.
:returns: tuple of the frame type and the processed data.
"""
response = self._read_response()
frame, data = nsq.unpack_response(response)
self.last_response = time.time()
if frame not in self._f... | python | def read_response(self):
"""Read an individual response from nsqd.
:returns: tuple of the frame type and the processed data.
"""
response = self._read_response()
frame, data = nsq.unpack_response(response)
self.last_response = time.time()
if frame not in self._f... | [
"def",
"read_response",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"_read_response",
"(",
")",
"frame",
",",
"data",
"=",
"nsq",
".",
"unpack_response",
"(",
"response",
")",
"self",
".",
"last_response",
"=",
"time",
".",
"time",
"(",
")",
"... | Read an individual response from nsqd.
:returns: tuple of the frame type and the processed data. | [
"Read",
"an",
"individual",
"response",
"from",
"nsqd",
"."
] | train | https://github.com/wtolson/gnsq/blob/0fd02578b2c9c5fa30626d78579db2a46c10edac/gnsq/nsqd.py#L244-L259 |
wtolson/gnsq | gnsq/nsqd.py | NsqdTCPClient.identify | def identify(self):
"""Update client metadata on the server and negotiate features.
:returns: nsqd response data if there was feature negotiation,
otherwise ``None``
"""
self.send(nsq.identify({
# nsqd 0.2.28+
'client_id': self.client_id,
... | python | def identify(self):
"""Update client metadata on the server and negotiate features.
:returns: nsqd response data if there was feature negotiation,
otherwise ``None``
"""
self.send(nsq.identify({
# nsqd 0.2.28+
'client_id': self.client_id,
... | [
"def",
"identify",
"(",
"self",
")",
":",
"self",
".",
"send",
"(",
"nsq",
".",
"identify",
"(",
"{",
"# nsqd 0.2.28+",
"'client_id'",
":",
"self",
".",
"client_id",
",",
"'hostname'",
":",
"self",
".",
"hostname",
",",
"# nsqd 0.2.19+",
"'feature_negotiatio... | Update client metadata on the server and negotiate features.
:returns: nsqd response data if there was feature negotiation,
otherwise ``None`` | [
"Update",
"client",
"metadata",
"on",
"the",
"server",
"and",
"negotiate",
"features",
"."
] | train | https://github.com/wtolson/gnsq/blob/0fd02578b2c9c5fa30626d78579db2a46c10edac/gnsq/nsqd.py#L329-L393 |
wtolson/gnsq | gnsq/nsqd.py | NsqdTCPClient.auth | def auth(self):
"""Send authorization secret to nsqd."""
self.send(nsq.auth(self.auth_secret))
frame, data = self.read_response()
if frame == nsq.FRAME_TYPE_ERROR:
raise data
try:
response = json.loads(data.decode('utf-8'))
except ValueError:
... | python | def auth(self):
"""Send authorization secret to nsqd."""
self.send(nsq.auth(self.auth_secret))
frame, data = self.read_response()
if frame == nsq.FRAME_TYPE_ERROR:
raise data
try:
response = json.loads(data.decode('utf-8'))
except ValueError:
... | [
"def",
"auth",
"(",
"self",
")",
":",
"self",
".",
"send",
"(",
"nsq",
".",
"auth",
"(",
"self",
".",
"auth_secret",
")",
")",
"frame",
",",
"data",
"=",
"self",
".",
"read_response",
"(",
")",
"if",
"frame",
"==",
"nsq",
".",
"FRAME_TYPE_ERROR",
"... | Send authorization secret to nsqd. | [
"Send",
"authorization",
"secret",
"to",
"nsqd",
"."
] | train | https://github.com/wtolson/gnsq/blob/0fd02578b2c9c5fa30626d78579db2a46c10edac/gnsq/nsqd.py#L395-L412 |
wtolson/gnsq | gnsq/nsqd.py | NsqdTCPClient.subscribe | def subscribe(self, topic, channel):
"""Subscribe to a nsq `topic` and `channel`."""
self.send(nsq.subscribe(topic, channel)) | python | def subscribe(self, topic, channel):
"""Subscribe to a nsq `topic` and `channel`."""
self.send(nsq.subscribe(topic, channel)) | [
"def",
"subscribe",
"(",
"self",
",",
"topic",
",",
"channel",
")",
":",
"self",
".",
"send",
"(",
"nsq",
".",
"subscribe",
"(",
"topic",
",",
"channel",
")",
")"
] | Subscribe to a nsq `topic` and `channel`. | [
"Subscribe",
"to",
"a",
"nsq",
"topic",
"and",
"channel",
"."
] | train | https://github.com/wtolson/gnsq/blob/0fd02578b2c9c5fa30626d78579db2a46c10edac/gnsq/nsqd.py#L414-L416 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.