repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteActiveWindow | def qteActiveWindow(self):
"""
Return the currently active ``QtmacsWindow`` object.
If no Qtmacs window is currently active (for instance because
the user is working with another application at the moment)
then the method returns the first window in the window list.
The... | python | def qteActiveWindow(self):
"""
Return the currently active ``QtmacsWindow`` object.
If no Qtmacs window is currently active (for instance because
the user is working with another application at the moment)
then the method returns the first window in the window list.
The... | [
"def",
"qteActiveWindow",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"_qteWindowList",
")",
"==",
"0",
":",
"self",
".",
"qteLogger",
".",
"critical",
"(",
"'The window list is empty.'",
")",
"return",
"None",
"elif",
"len",
"(",
"self",
".",
... | Return the currently active ``QtmacsWindow`` object.
If no Qtmacs window is currently active (for instance because
the user is working with another application at the moment)
then the method returns the first window in the window list.
The method only returns **None** if the window lis... | [
"Return",
"the",
"currently",
"active",
"QtmacsWindow",
"object",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L1507-L1543 | train | Return the currently active Qtmacs window. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteNextWindow | def qteNextWindow(self):
"""
Return next window in cyclic order.
|Args|
* **None**
|Returns|
* **QtmacsWindow**: the next window in the Qtmacs internal
window list.
|Raises|
* **None**
"""
# Get the currently active window... | python | def qteNextWindow(self):
"""
Return next window in cyclic order.
|Args|
* **None**
|Returns|
* **QtmacsWindow**: the next window in the Qtmacs internal
window list.
|Raises|
* **None**
"""
# Get the currently active window... | [
"def",
"qteNextWindow",
"(",
"self",
")",
":",
"# Get the currently active window.",
"win",
"=",
"self",
".",
"qteActiveWindow",
"(",
")",
"if",
"win",
"in",
"self",
".",
"_qteWindowList",
":",
"# Find the index of the window in the window list and",
"# cyclically move to... | Return next window in cyclic order.
|Args|
* **None**
|Returns|
* **QtmacsWindow**: the next window in the Qtmacs internal
window list.
|Raises|
* **None** | [
"Return",
"next",
"window",
"in",
"cyclic",
"order",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L1545-L1575 | train | Return the next window in cyclic order. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteKillWindow | def qteKillWindow(self, windowObj: QtmacsWindow=None):
"""
Kill the specified window (applets inside the window are not
deleted).
.. note:: The method does nothing if ``windowObj`` is the only
window left.
|Args|
* *windowObj* (**QtmacsWindow**): window obje... | python | def qteKillWindow(self, windowObj: QtmacsWindow=None):
"""
Kill the specified window (applets inside the window are not
deleted).
.. note:: The method does nothing if ``windowObj`` is the only
window left.
|Args|
* *windowObj* (**QtmacsWindow**): window obje... | [
"def",
"qteKillWindow",
"(",
"self",
",",
"windowObj",
":",
"QtmacsWindow",
"=",
"None",
")",
":",
"# Use the currently active window if none was specified.",
"if",
"windowObj",
"is",
"None",
":",
"windowObj",
"=",
"self",
".",
"qteActiveWindow",
"(",
")",
"if",
"... | Kill the specified window (applets inside the window are not
deleted).
.. note:: The method does nothing if ``windowObj`` is the only
window left.
|Args|
* *windowObj* (**QtmacsWindow**): window object to delete.
|Returns|
* **None**
|Raises|
... | [
"Kill",
"the",
"specified",
"window",
"(",
"applets",
"inside",
"the",
"window",
"are",
"not",
"deleted",
")",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L1578-L1669 | train | Kill the specified window. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteNextApplet | def qteNextApplet(self, numSkip: int=1, ofsApp: (QtmacsApplet, str)=None,
skipInvisible: bool=True, skipVisible: bool=False,
skipMiniApplet: bool=True,
windowObj: QtmacsWindow=None):
"""
Return the next applet in cyclic order.
If... | python | def qteNextApplet(self, numSkip: int=1, ofsApp: (QtmacsApplet, str)=None,
skipInvisible: bool=True, skipVisible: bool=False,
skipMiniApplet: bool=True,
windowObj: QtmacsWindow=None):
"""
Return the next applet in cyclic order.
If... | [
"def",
"qteNextApplet",
"(",
"self",
",",
"numSkip",
":",
"int",
"=",
"1",
",",
"ofsApp",
":",
"(",
"QtmacsApplet",
",",
"str",
")",
"=",
"None",
",",
"skipInvisible",
":",
"bool",
"=",
"True",
",",
"skipVisible",
":",
"bool",
"=",
"False",
",",
"ski... | Return the next applet in cyclic order.
If ``ofsApp=None`` then start cycling at the currently active
applet. If ``ofsApp`` does not fit the selection criteria,
then the cycling starts at the next applet in cyclic order
that does.
The returned applet is ``numSkip`` items in cyc... | [
"Return",
"the",
"next",
"applet",
"in",
"cyclic",
"order",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L1672-L1809 | train | Return the next applet in the cyclic order. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteRunMacro | def qteRunMacro(self, macroName: str, widgetObj: QtGui.QWidget=None,
keysequence: QtmacsKeysequence=None):
"""
Queue a previously registered macro for execution once the
event loop is idle.
The reason for queuing macros in the first place, instead of
running ... | python | def qteRunMacro(self, macroName: str, widgetObj: QtGui.QWidget=None,
keysequence: QtmacsKeysequence=None):
"""
Queue a previously registered macro for execution once the
event loop is idle.
The reason for queuing macros in the first place, instead of
running ... | [
"def",
"qteRunMacro",
"(",
"self",
",",
"macroName",
":",
"str",
",",
"widgetObj",
":",
"QtGui",
".",
"QWidget",
"=",
"None",
",",
"keysequence",
":",
"QtmacsKeysequence",
"=",
"None",
")",
":",
"# Add the new macro to the queue and call qteUpdate to ensure",
"# tha... | Queue a previously registered macro for execution once the
event loop is idle.
The reason for queuing macros in the first place, instead of
running them straight away, is to ensure that the event loop
updates all the widgets in between any two macros. This will
avoid many spurio... | [
"Queue",
"a",
"previously",
"registered",
"macro",
"for",
"execution",
"once",
"the",
"event",
"loop",
"is",
"idle",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L1812-L1844 | train | Execute a macro in the event loop. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain._qteRunQueuedMacro | def _qteRunQueuedMacro(self, macroName: str,
widgetObj: QtGui.QWidget=None,
keysequence: QtmacsKeysequence=None):
"""
Execute the next macro in the macro queue.
This method is triggered by the ``timerEvent`` in conjunction
with the f... | python | def _qteRunQueuedMacro(self, macroName: str,
widgetObj: QtGui.QWidget=None,
keysequence: QtmacsKeysequence=None):
"""
Execute the next macro in the macro queue.
This method is triggered by the ``timerEvent`` in conjunction
with the f... | [
"def",
"_qteRunQueuedMacro",
"(",
"self",
",",
"macroName",
":",
"str",
",",
"widgetObj",
":",
"QtGui",
".",
"QWidget",
"=",
"None",
",",
"keysequence",
":",
"QtmacsKeysequence",
"=",
"None",
")",
":",
"# Fetch the applet holding the widget (this may be None).",
"ap... | Execute the next macro in the macro queue.
This method is triggered by the ``timerEvent`` in conjunction
with the focus manager to ensure the event loop updates the
GUI in between any two macros.
.. warning:: Never call this method directly.
|Args|
* ``macroName`` (**... | [
"Execute",
"the",
"next",
"macro",
"in",
"the",
"macro",
"queue",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L1847-L1912 | train | Execute the next macro in the macro queue. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteNewApplet | def qteNewApplet(self, appletName: str, appletID: str=None,
windowObj: QtmacsWindow=None):
"""
Create a new instance of ``appletName`` and assign it the
``appletID``.
This method creates a new instance of ``appletName``, as
registered by the ``qteRegisterApp... | python | def qteNewApplet(self, appletName: str, appletID: str=None,
windowObj: QtmacsWindow=None):
"""
Create a new instance of ``appletName`` and assign it the
``appletID``.
This method creates a new instance of ``appletName``, as
registered by the ``qteRegisterApp... | [
"def",
"qteNewApplet",
"(",
"self",
",",
"appletName",
":",
"str",
",",
"appletID",
":",
"str",
"=",
"None",
",",
"windowObj",
":",
"QtmacsWindow",
"=",
"None",
")",
":",
"# Use the currently active window if none was specified.",
"if",
"windowObj",
"is",
"None",
... | Create a new instance of ``appletName`` and assign it the
``appletID``.
This method creates a new instance of ``appletName``, as
registered by the ``qteRegisterApplet`` method. If an applet
with ``appletID`` already exists then the method does nothing
and returns **None**, other... | [
"Create",
"a",
"new",
"instance",
"of",
"appletName",
"and",
"assign",
"it",
"the",
"appletID",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L1915-L2022 | train | Create a new applet with the given name and ID. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteAddMiniApplet | def qteAddMiniApplet(self, appletObj: QtmacsApplet):
"""
Install ``appletObj`` as the mini applet in the window layout.
At any given point there can ever only be one mini applet in
the entire Qtmacs application, irrespective of how many
windows are open.
Note that this ... | python | def qteAddMiniApplet(self, appletObj: QtmacsApplet):
"""
Install ``appletObj`` as the mini applet in the window layout.
At any given point there can ever only be one mini applet in
the entire Qtmacs application, irrespective of how many
windows are open.
Note that this ... | [
"def",
"qteAddMiniApplet",
"(",
"self",
",",
"appletObj",
":",
"QtmacsApplet",
")",
":",
"# Do nothing if a custom mini applet has already been",
"# installed.",
"if",
"self",
".",
"_qteMiniApplet",
"is",
"not",
"None",
":",
"msg",
"=",
"'Cannot replace mini applet more t... | Install ``appletObj`` as the mini applet in the window layout.
At any given point there can ever only be one mini applet in
the entire Qtmacs application, irrespective of how many
windows are open.
Note that this method does nothing if a custom mini applet is
already active. Us... | [
"Install",
"appletObj",
"as",
"the",
"mini",
"applet",
"in",
"the",
"window",
"layout",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L2025-L2098 | train | Install the appletObj as the mini applet. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteKillMiniApplet | def qteKillMiniApplet(self):
"""
Remove the mini applet.
If a different applet is to be restored/focused then call
``qteMakeAppletActive`` for that applet *after* calling this
method.
|Args|
* **None**
|Returns|
* **None**
|Raises|
... | python | def qteKillMiniApplet(self):
"""
Remove the mini applet.
If a different applet is to be restored/focused then call
``qteMakeAppletActive`` for that applet *after* calling this
method.
|Args|
* **None**
|Returns|
* **None**
|Raises|
... | [
"def",
"qteKillMiniApplet",
"(",
"self",
")",
":",
"# Sanity check: is the handle valid?",
"if",
"self",
".",
"_qteMiniApplet",
"is",
"None",
":",
"return",
"# Sanity check: is it really a mini applet?",
"if",
"not",
"self",
".",
"qteIsMiniApplet",
"(",
"self",
".",
"... | Remove the mini applet.
If a different applet is to be restored/focused then call
``qteMakeAppletActive`` for that applet *after* calling this
method.
|Args|
* **None**
|Returns|
* **None**
|Raises|
* **None** | [
"Remove",
"the",
"mini",
"applet",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L2100-L2175 | train | Kill the mini applet. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain._qteFindAppletInSplitter | def _qteFindAppletInSplitter(self, appletObj: QtmacsApplet,
split: QtmacsSplitter):
"""
Return the splitter that holds ``appletObj``.
This method recursively searches for ``appletObj`` in the
nested splitter hierarchy of the window layout, starting at
... | python | def _qteFindAppletInSplitter(self, appletObj: QtmacsApplet,
split: QtmacsSplitter):
"""
Return the splitter that holds ``appletObj``.
This method recursively searches for ``appletObj`` in the
nested splitter hierarchy of the window layout, starting at
... | [
"def",
"_qteFindAppletInSplitter",
"(",
"self",
",",
"appletObj",
":",
"QtmacsApplet",
",",
"split",
":",
"QtmacsSplitter",
")",
":",
"def",
"splitterIter",
"(",
"split",
")",
":",
"\"\"\"\n Iterator over all QtmacsSplitters.\n \"\"\"",
"for",
"idx",... | Return the splitter that holds ``appletObj``.
This method recursively searches for ``appletObj`` in the
nested splitter hierarchy of the window layout, starting at
``split``. If successful, the method returns a reference to
the splitter, otherwise it returns **None**.
|Args|
... | [
"Return",
"the",
"splitter",
"that",
"holds",
"appletObj",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L2178-L2219 | train | This method searches for appletObj in the applet hierarchy starting at
and traversing all splitters until appletObj is found. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteSplitApplet | def qteSplitApplet(self, applet: (QtmacsApplet, str)=None,
splitHoriz: bool=True,
windowObj: QtmacsWindow=None):
"""
Reveal ``applet`` by splitting the space occupied by the
current applet.
If ``applet`` is already visible then the method do... | python | def qteSplitApplet(self, applet: (QtmacsApplet, str)=None,
splitHoriz: bool=True,
windowObj: QtmacsWindow=None):
"""
Reveal ``applet`` by splitting the space occupied by the
current applet.
If ``applet`` is already visible then the method do... | [
"def",
"qteSplitApplet",
"(",
"self",
",",
"applet",
":",
"(",
"QtmacsApplet",
",",
"str",
")",
"=",
"None",
",",
"splitHoriz",
":",
"bool",
"=",
"True",
",",
"windowObj",
":",
"QtmacsWindow",
"=",
"None",
")",
":",
"# If ``newAppObj`` was specified by its ID ... | Reveal ``applet`` by splitting the space occupied by the
current applet.
If ``applet`` is already visible then the method does
nothing. Furthermore, this method does not change the focus,
ie. the currently active applet will remain active.
If ``applet`` is **None** then the nex... | [
"Reveal",
"applet",
"by",
"splitting",
"the",
"space",
"occupied",
"by",
"the",
"current",
"applet",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L2222-L2363 | train | Split the applet into two pieces. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteReplaceAppletInLayout | def qteReplaceAppletInLayout(self, newApplet: (QtmacsApplet, str),
oldApplet: (QtmacsApplet, str)=None,
windowObj: QtmacsWindow=None):
"""
Replace ``oldApplet`` with ``newApplet`` in the window layout.
If ``oldApplet`` is **None*... | python | def qteReplaceAppletInLayout(self, newApplet: (QtmacsApplet, str),
oldApplet: (QtmacsApplet, str)=None,
windowObj: QtmacsWindow=None):
"""
Replace ``oldApplet`` with ``newApplet`` in the window layout.
If ``oldApplet`` is **None*... | [
"def",
"qteReplaceAppletInLayout",
"(",
"self",
",",
"newApplet",
":",
"(",
"QtmacsApplet",
",",
"str",
")",
",",
"oldApplet",
":",
"(",
"QtmacsApplet",
",",
"str",
")",
"=",
"None",
",",
"windowObj",
":",
"QtmacsWindow",
"=",
"None",
")",
":",
"# If ``old... | Replace ``oldApplet`` with ``newApplet`` in the window layout.
If ``oldApplet`` is **None** then the currently active applet
will be replaced. If ``windowObj`` is **None** then the
currently active window is used.
The ``oldApplet`` and ``newApplet`` parameters can either be
ins... | [
"Replace",
"oldApplet",
"with",
"newApplet",
"in",
"the",
"window",
"layout",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L2366-L2469 | train | Replace applet with newApplet in the window layout. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteRemoveAppletFromLayout | def qteRemoveAppletFromLayout(self, applet: (QtmacsApplet, str)):
"""
Remove ``applet`` from the window layout.
This method removes ``applet`` and implicitly deletes
obsolete (ie. half-full) splitters in the process. If
``applet`` is the only visible applet in the layout then it... | python | def qteRemoveAppletFromLayout(self, applet: (QtmacsApplet, str)):
"""
Remove ``applet`` from the window layout.
This method removes ``applet`` and implicitly deletes
obsolete (ie. half-full) splitters in the process. If
``applet`` is the only visible applet in the layout then it... | [
"def",
"qteRemoveAppletFromLayout",
"(",
"self",
",",
"applet",
":",
"(",
"QtmacsApplet",
",",
"str",
")",
")",
":",
"# If ``applet`` was specified by its ID (ie. a string) then",
"# fetch the associated ``QtmacsApplet`` instance. If",
"# ``applet`` is already an instance of ``Qtmacs... | Remove ``applet`` from the window layout.
This method removes ``applet`` and implicitly deletes
obsolete (ie. half-full) splitters in the process. If
``applet`` is the only visible applet in the layout then it
will be replaced with the first invisible applet. If no
invisible app... | [
"Remove",
"applet",
"from",
"the",
"window",
"layout",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L2472-L2596 | train | Remove applet from the window layout. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteKillApplet | def qteKillApplet(self, appletID: str):
"""
Destroy the applet with ID ``appletID``.
This method removes ``appletID`` from Qtmacs permanently - no
questions asked. It is the responsibility of the (macro)
programmer to use it responsibly.
If the applet was visible then t... | python | def qteKillApplet(self, appletID: str):
"""
Destroy the applet with ID ``appletID``.
This method removes ``appletID`` from Qtmacs permanently - no
questions asked. It is the responsibility of the (macro)
programmer to use it responsibly.
If the applet was visible then t... | [
"def",
"qteKillApplet",
"(",
"self",
",",
"appletID",
":",
"str",
")",
":",
"# Compile list of all applet IDs.",
"ID_list",
"=",
"[",
"_",
".",
"qteAppletID",
"(",
")",
"for",
"_",
"in",
"self",
".",
"_qteAppletList",
"]",
"if",
"appletID",
"not",
"in",
"I... | Destroy the applet with ID ``appletID``.
This method removes ``appletID`` from Qtmacs permanently - no
questions asked. It is the responsibility of the (macro)
programmer to use it responsibly.
If the applet was visible then the method also takes care of
replacing with the next... | [
"Destroy",
"the",
"applet",
"with",
"ID",
"appletID",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L2599-L2677 | train | Kill applet with the given applet ID. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteRunHook | def qteRunHook(self, hookName: str, msgObj: QtmacsMessage=None):
"""
Trigger the hook named ``hookName`` and pass on ``msgObj``.
This will call all slots associated with ``hookName`` but
without calling the event loop in between. Therefore, if
one slots changes the state of the ... | python | def qteRunHook(self, hookName: str, msgObj: QtmacsMessage=None):
"""
Trigger the hook named ``hookName`` and pass on ``msgObj``.
This will call all slots associated with ``hookName`` but
without calling the event loop in between. Therefore, if
one slots changes the state of the ... | [
"def",
"qteRunHook",
"(",
"self",
",",
"hookName",
":",
"str",
",",
"msgObj",
":",
"QtmacsMessage",
"=",
"None",
")",
":",
"# Shorthand.",
"reg",
"=",
"self",
".",
"_qteRegistryHooks",
"# Do nothing if there are not recipients for the hook.",
"if",
"hookName",
"not"... | Trigger the hook named ``hookName`` and pass on ``msgObj``.
This will call all slots associated with ``hookName`` but
without calling the event loop in between. Therefore, if
one slots changes the state of the GUI, every subsequent slot
may have difficulties determining the actual state... | [
"Trigger",
"the",
"hook",
"named",
"hookName",
"and",
"pass",
"on",
"msgObj",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L2680-L2741 | train | Execute a hook named hookName and pass on msgObj. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteConnectHook | def qteConnectHook(self, hookName: str,
slot: (types.FunctionType, types.MethodType)):
"""
Connect the method or function ``slot`` to ``hookName``.
|Args|
* ``hookName`` (**str**): name of the hook.
* ``slot`` (**function**, **method**): the routine to ex... | python | def qteConnectHook(self, hookName: str,
slot: (types.FunctionType, types.MethodType)):
"""
Connect the method or function ``slot`` to ``hookName``.
|Args|
* ``hookName`` (**str**): name of the hook.
* ``slot`` (**function**, **method**): the routine to ex... | [
"def",
"qteConnectHook",
"(",
"self",
",",
"hookName",
":",
"str",
",",
"slot",
":",
"(",
"types",
".",
"FunctionType",
",",
"types",
".",
"MethodType",
")",
")",
":",
"# Shorthand.",
"reg",
"=",
"self",
".",
"_qteRegistryHooks",
"if",
"hookName",
"in",
... | Connect the method or function ``slot`` to ``hookName``.
|Args|
* ``hookName`` (**str**): name of the hook.
* ``slot`` (**function**, **method**): the routine to execute
when the hook triggers.
|Returns|
* **None**
|Raises|
* **QtmacsArgumentError*... | [
"Connect",
"the",
"method",
"or",
"function",
"slot",
"to",
"hookName",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L2744-L2768 | train | Connect the method or function or slot to hookName. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteDisconnectHook | def qteDisconnectHook(self, hookName: str,
slot: (types.FunctionType, types.MethodType)):
"""
Disconnect ``slot`` from ``hookName``.
If ``hookName`` does not exist, or ``slot`` is not connected
to ``hookName`` then return **False**, otherwise disassociate
... | python | def qteDisconnectHook(self, hookName: str,
slot: (types.FunctionType, types.MethodType)):
"""
Disconnect ``slot`` from ``hookName``.
If ``hookName`` does not exist, or ``slot`` is not connected
to ``hookName`` then return **False**, otherwise disassociate
... | [
"def",
"qteDisconnectHook",
"(",
"self",
",",
"hookName",
":",
"str",
",",
"slot",
":",
"(",
"types",
".",
"FunctionType",
",",
"types",
".",
"MethodType",
")",
")",
":",
"# Shorthand.",
"reg",
"=",
"self",
".",
"_qteRegistryHooks",
"# Return immediately if no... | Disconnect ``slot`` from ``hookName``.
If ``hookName`` does not exist, or ``slot`` is not connected
to ``hookName`` then return **False**, otherwise disassociate
``slot`` with ``hookName`` and return **True**.
|Args|
* ``hookName`` (**str**): name of the hook.
* ``slot... | [
"Disconnect",
"slot",
"from",
"hookName",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L2771-L2816 | train | Disconnect a slot from a hook. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteImportModule | def qteImportModule(self, fileName: str):
"""
Import ``fileName`` at run-time.
If ``fileName`` has no path prefix then it must be in the
standard Python module path. Relative path names are possible.
|Args|
* ``fileName`` (**str**): file name (with full path) of module... | python | def qteImportModule(self, fileName: str):
"""
Import ``fileName`` at run-time.
If ``fileName`` has no path prefix then it must be in the
standard Python module path. Relative path names are possible.
|Args|
* ``fileName`` (**str**): file name (with full path) of module... | [
"def",
"qteImportModule",
"(",
"self",
",",
"fileName",
":",
"str",
")",
":",
"# Split the absolute file name into the path- and file name.",
"path",
",",
"name",
"=",
"os",
".",
"path",
".",
"split",
"(",
"fileName",
")",
"name",
",",
"ext",
"=",
"os",
".",
... | Import ``fileName`` at run-time.
If ``fileName`` has no path prefix then it must be in the
standard Python module path. Relative path names are possible.
|Args|
* ``fileName`` (**str**): file name (with full path) of module
to import.
|Returns|
* **module**... | [
"Import",
"fileName",
"at",
"run",
"-",
"time",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L2819-L2871 | train | Import the module named fileName at run - time. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteMacroNameMangling | def qteMacroNameMangling(self, macroCls):
"""
Convert the class name of a macro class to macro name.
The name mangling inserts a '-' character after every capital
letter and then lowers the entire string.
Example: if the class name of ``macroCls`` is 'ThisIsAMacro'
then... | python | def qteMacroNameMangling(self, macroCls):
"""
Convert the class name of a macro class to macro name.
The name mangling inserts a '-' character after every capital
letter and then lowers the entire string.
Example: if the class name of ``macroCls`` is 'ThisIsAMacro'
then... | [
"def",
"qteMacroNameMangling",
"(",
"self",
",",
"macroCls",
")",
":",
"# Replace camel bump as hyphenated lower case string.",
"macroName",
"=",
"re",
".",
"sub",
"(",
"r\"([A-Z])\"",
",",
"r'-\\1'",
",",
"macroCls",
".",
"__name__",
")",
"# If the first character of t... | Convert the class name of a macro class to macro name.
The name mangling inserts a '-' character after every capital
letter and then lowers the entire string.
Example: if the class name of ``macroCls`` is 'ThisIsAMacro'
then this method will return 'this-is-a-macro', ie. every
... | [
"Convert",
"the",
"class",
"name",
"of",
"a",
"macro",
"class",
"to",
"macro",
"name",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L2873-L2911 | train | Return the name mangling for the given macro class. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteRegisterMacro | def qteRegisterMacro(self, macroCls, replaceMacro: bool=False,
macroName: str=None):
"""
Register a macro.
If ``macroName`` is **None** then its named is deduced from
its class name (see ``qteMacroNameMangling`` for details).
Multiple macros with the sa... | python | def qteRegisterMacro(self, macroCls, replaceMacro: bool=False,
macroName: str=None):
"""
Register a macro.
If ``macroName`` is **None** then its named is deduced from
its class name (see ``qteMacroNameMangling`` for details).
Multiple macros with the sa... | [
"def",
"qteRegisterMacro",
"(",
"self",
",",
"macroCls",
",",
"replaceMacro",
":",
"bool",
"=",
"False",
",",
"macroName",
":",
"str",
"=",
"None",
")",
":",
"# Check type of input arguments.",
"if",
"not",
"issubclass",
"(",
"macroCls",
",",
"QtmacsMacro",
")... | Register a macro.
If ``macroName`` is **None** then its named is deduced from
its class name (see ``qteMacroNameMangling`` for details).
Multiple macros with the same name can co-exist as long as
their applet- and widget signatures, as reported by the
``qteAppletSignature`` and... | [
"Register",
"a",
"macro",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L2914-L3044 | train | Register a macro in the system. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteIsMacroRegistered | def qteIsMacroRegistered(self, macroName: str,
widgetObj: QtGui.QWidget=None):
"""
Return **True** if a macro with name ``macroName`` exists.
If ``widgetObj`` is **None** then only the macro name is
matched. Otherwise, only macros that are compatible with
... | python | def qteIsMacroRegistered(self, macroName: str,
widgetObj: QtGui.QWidget=None):
"""
Return **True** if a macro with name ``macroName`` exists.
If ``widgetObj`` is **None** then only the macro name is
matched. Otherwise, only macros that are compatible with
... | [
"def",
"qteIsMacroRegistered",
"(",
"self",
",",
"macroName",
":",
"str",
",",
"widgetObj",
":",
"QtGui",
".",
"QWidget",
"=",
"None",
")",
":",
"if",
"widgetObj",
"is",
"None",
":",
"# Ignore the applet- and widget signature and simply check",
"# if a macro with the ... | Return **True** if a macro with name ``macroName`` exists.
If ``widgetObj`` is **None** then only the macro name is
matched. Otherwise, only macros that are compatible with
``widgetObj`` are returned.
|Args|
* ``macroName`` (**str**): name of macro.
* ``widgetObj`` (*... | [
"Return",
"**",
"True",
"**",
"if",
"a",
"macro",
"with",
"name",
"macroName",
"exists",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L3047-L3086 | train | Return True if a macro with the given name exists. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteGetMacroObject | def qteGetMacroObject(self, macroName: str, widgetObj: QtGui.QWidget):
"""
Return macro that is name- and signature compatible with
``macroName`` and ``widgetObj``.
The method considers all macros with name ``macroName`` and
returns the one that matches 'best'. To determine this... | python | def qteGetMacroObject(self, macroName: str, widgetObj: QtGui.QWidget):
"""
Return macro that is name- and signature compatible with
``macroName`` and ``widgetObj``.
The method considers all macros with name ``macroName`` and
returns the one that matches 'best'. To determine this... | [
"def",
"qteGetMacroObject",
"(",
"self",
",",
"macroName",
":",
"str",
",",
"widgetObj",
":",
"QtGui",
".",
"QWidget",
")",
":",
"# Determine the applet- and widget signature. This is trivial",
"# if the widget was registered with Qtmacs because its",
"# '_qteAdmin' attribute wil... | Return macro that is name- and signature compatible with
``macroName`` and ``widgetObj``.
The method considers all macros with name ``macroName`` and
returns the one that matches 'best'. To determine this best
match, the applet-and widget signatures of the macro are
compared to ... | [
"Return",
"macro",
"that",
"is",
"name",
"-",
"and",
"signature",
"compatible",
"with",
"macroName",
"and",
"widgetObj",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L3089-L3213 | train | Return the object that matches the given macroName and widgetObj. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteGetAllMacroNames | def qteGetAllMacroNames(self, widgetObj: QtGui.QWidget=None):
"""
Return all macro names known to Qtmacs as a list.
If ``widgetObj`` is **None** then the names of all registered
macros are returned as a tuple. Otherwise, only those macro
compatible with ``widgetObj`` are returne... | python | def qteGetAllMacroNames(self, widgetObj: QtGui.QWidget=None):
"""
Return all macro names known to Qtmacs as a list.
If ``widgetObj`` is **None** then the names of all registered
macros are returned as a tuple. Otherwise, only those macro
compatible with ``widgetObj`` are returne... | [
"def",
"qteGetAllMacroNames",
"(",
"self",
",",
"widgetObj",
":",
"QtGui",
".",
"QWidget",
"=",
"None",
")",
":",
"# The keys of qteRegistryMacros are (macroObj, app_sig,",
"# wid_sig) tuples. Get them, extract the macro names, and",
"# remove all duplicates.",
"macro_list",
"=",... | Return all macro names known to Qtmacs as a list.
If ``widgetObj`` is **None** then the names of all registered
macros are returned as a tuple. Otherwise, only those macro
compatible with ``widgetObj`` are returned. See
``qteGetMacroObject`` for the definition of a compatible
ma... | [
"Return",
"all",
"macro",
"names",
"known",
"to",
"Qtmacs",
"as",
"a",
"list",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L3216-L3262 | train | Return all the macro names known to Qtmacs as a list. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteBindKeyGlobal | def qteBindKeyGlobal(self, keysequence, macroName: str):
"""
Associate ``macroName`` with ``keysequence`` in all current
applets.
This method will bind ``macroName`` to ``keysequence`` in the
global key map and **all** local key maps. This also applies
for all applets (a... | python | def qteBindKeyGlobal(self, keysequence, macroName: str):
"""
Associate ``macroName`` with ``keysequence`` in all current
applets.
This method will bind ``macroName`` to ``keysequence`` in the
global key map and **all** local key maps. This also applies
for all applets (a... | [
"def",
"qteBindKeyGlobal",
"(",
"self",
",",
"keysequence",
",",
"macroName",
":",
"str",
")",
":",
"# Convert the key sequence into a QtmacsKeysequence object, or",
"# raise an QtmacsOtherError if the conversion is impossible.",
"keysequence",
"=",
"QtmacsKeysequence",
"(",
"key... | Associate ``macroName`` with ``keysequence`` in all current
applets.
This method will bind ``macroName`` to ``keysequence`` in the
global key map and **all** local key maps. This also applies
for all applets (and their constituent widgets) yet to be
instantiated because they wil... | [
"Associate",
"macroName",
"with",
"keysequence",
"in",
"all",
"current",
"applets",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L3265-L3327 | train | Bind a keysequence to a global keymap. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteBindKeyApplet | def qteBindKeyApplet(self, keysequence, macroName: str,
appletObj: QtmacsApplet):
"""
Bind ``macroName`` to all widgets in ``appletObj``.
This method does not affect the key bindings of other applets,
or other instances of the same applet.
The ``keysequ... | python | def qteBindKeyApplet(self, keysequence, macroName: str,
appletObj: QtmacsApplet):
"""
Bind ``macroName`` to all widgets in ``appletObj``.
This method does not affect the key bindings of other applets,
or other instances of the same applet.
The ``keysequ... | [
"def",
"qteBindKeyApplet",
"(",
"self",
",",
"keysequence",
",",
"macroName",
":",
"str",
",",
"appletObj",
":",
"QtmacsApplet",
")",
":",
"# Convert the key sequence into a QtmacsKeysequence object, or",
"# raise a QtmacsKeysequenceError if the conversion is",
"# impossible.",
... | Bind ``macroName`` to all widgets in ``appletObj``.
This method does not affect the key bindings of other applets,
or other instances of the same applet.
The ``keysequence`` can be specified either as a string (eg
'<ctrl>+x <ctrl>+f'), or a list of tuples containing the
constan... | [
"Bind",
"macroName",
"to",
"all",
"widgets",
"in",
"appletObj",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L3330-L3385 | train | Bind a keysequence to all widgets in appletObj. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteBindKeyWidget | def qteBindKeyWidget(self, keysequence, macroName: str,
widgetObj: QtGui.QWidget):
"""
Bind ``macroName`` to ``widgetObj`` and associate it with
``keysequence``.
This method does not affect the key bindings of other applets
and/or widgets and can be used... | python | def qteBindKeyWidget(self, keysequence, macroName: str,
widgetObj: QtGui.QWidget):
"""
Bind ``macroName`` to ``widgetObj`` and associate it with
``keysequence``.
This method does not affect the key bindings of other applets
and/or widgets and can be used... | [
"def",
"qteBindKeyWidget",
"(",
"self",
",",
"keysequence",
",",
"macroName",
":",
"str",
",",
"widgetObj",
":",
"QtGui",
".",
"QWidget",
")",
":",
"# Convert the key sequence into a QtmacsKeysequence object, or",
"# raise an QtmacsKeysequenceError if the conversion is",
"# i... | Bind ``macroName`` to ``widgetObj`` and associate it with
``keysequence``.
This method does not affect the key bindings of other applets
and/or widgets and can be used to individualise the key
bindings inside every applet instance and every widget inside
that instance. Even mult... | [
"Bind",
"macroName",
"to",
"widgetObj",
"and",
"associate",
"it",
"with",
"keysequence",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L3388-L3456 | train | Bind a keysequence to widgetObj and associate it with macroName. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteUnbindKeyApplet | def qteUnbindKeyApplet(self, applet: (QtmacsApplet, str), keysequence):
"""
Remove ``keysequence`` bindings from all widgets inside ``applet``.
This method does not affect the key bindings of other applets,
or different instances of the same applet.
The ``keysequence`` can be s... | python | def qteUnbindKeyApplet(self, applet: (QtmacsApplet, str), keysequence):
"""
Remove ``keysequence`` bindings from all widgets inside ``applet``.
This method does not affect the key bindings of other applets,
or different instances of the same applet.
The ``keysequence`` can be s... | [
"def",
"qteUnbindKeyApplet",
"(",
"self",
",",
"applet",
":",
"(",
"QtmacsApplet",
",",
"str",
")",
",",
"keysequence",
")",
":",
"# If ``applet`` was specified by its ID (ie. a string) then",
"# fetch the associated ``QtmacsApplet`` instance. If",
"# ``applet`` is already an ins... | Remove ``keysequence`` bindings from all widgets inside ``applet``.
This method does not affect the key bindings of other applets,
or different instances of the same applet.
The ``keysequence`` can be specified either as a string (eg
'<ctrl>+x <ctrl>+f'), or a list of tuples containing... | [
"Remove",
"keysequence",
"bindings",
"from",
"all",
"widgets",
"inside",
"applet",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L3459-L3519 | train | Remove keybindings from all widgets inside applet. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteUnbindKeyFromWidgetObject | def qteUnbindKeyFromWidgetObject(self, keysequence,
widgetObj: QtGui.QWidget):
"""
Disassociate the macro triggered by ``keysequence`` from
``widgetObj``.
The ``keysequence`` can be specified either as a string (eg
'<ctrl>+x <ctrl>+f'), or a ... | python | def qteUnbindKeyFromWidgetObject(self, keysequence,
widgetObj: QtGui.QWidget):
"""
Disassociate the macro triggered by ``keysequence`` from
``widgetObj``.
The ``keysequence`` can be specified either as a string (eg
'<ctrl>+x <ctrl>+f'), or a ... | [
"def",
"qteUnbindKeyFromWidgetObject",
"(",
"self",
",",
"keysequence",
",",
"widgetObj",
":",
"QtGui",
".",
"QWidget",
")",
":",
"# Convert the key sequence into a QtmacsKeysequence object, or",
"# raise an QtmacsKeysequenceError if the conversion is",
"# impossible.",
"keysequenc... | Disassociate the macro triggered by ``keysequence`` from
``widgetObj``.
The ``keysequence`` can be specified either as a string (eg
'<ctrl>+x <ctrl>+f'), or a list of tuples containing the
constants from the ``QtCore.Qt`` name space
(eg. [(ControlModifier, Key_X), (ControlModifi... | [
"Disassociate",
"the",
"macro",
"triggered",
"by",
"keysequence",
"from",
"widgetObj",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L3522-L3569 | train | Remove the macro triggered by keysequence from the given widgetObj. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteUnbindAllFromApplet | def qteUnbindAllFromApplet(self, applet: (QtmacsApplet, str)):
"""
Restore the global key-map for all widgets inside ``applet``.
This method effectively resets the key map of all widgets to
the state they would be in if the widgets were newly
instantiated right now.
The... | python | def qteUnbindAllFromApplet(self, applet: (QtmacsApplet, str)):
"""
Restore the global key-map for all widgets inside ``applet``.
This method effectively resets the key map of all widgets to
the state they would be in if the widgets were newly
instantiated right now.
The... | [
"def",
"qteUnbindAllFromApplet",
"(",
"self",
",",
"applet",
":",
"(",
"QtmacsApplet",
",",
"str",
")",
")",
":",
"# If ``applet`` was specified by its ID (ie. a string) then",
"# fetch the associated ``QtmacsApplet`` instance. If",
"# ``applet`` is already an instance of ``QtmacsApp... | Restore the global key-map for all widgets inside ``applet``.
This method effectively resets the key map of all widgets to
the state they would be in if the widgets were newly
instantiated right now.
The ``applet`` parameter can either be an instance of
``QtmacsApplet`` or a st... | [
"Restore",
"the",
"global",
"key",
"-",
"map",
"for",
"all",
"widgets",
"inside",
"applet",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L3572-L3619 | train | Unbind all widgets from applet to applet s internal key - map. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteUnbindAllFromWidgetObject | def qteUnbindAllFromWidgetObject(self, widgetObj: QtGui.QWidget):
"""
Reset the local key-map of ``widgetObj`` to the current global
key-map.
|Args|
* ``widgetObj`` (**QWidget**): determines which widgets
signature to use.
|Returns|
* **None**
... | python | def qteUnbindAllFromWidgetObject(self, widgetObj: QtGui.QWidget):
"""
Reset the local key-map of ``widgetObj`` to the current global
key-map.
|Args|
* ``widgetObj`` (**QWidget**): determines which widgets
signature to use.
|Returns|
* **None**
... | [
"def",
"qteUnbindAllFromWidgetObject",
"(",
"self",
",",
"widgetObj",
":",
"QtGui",
".",
"QWidget",
")",
":",
"# Check type of input arguments.",
"if",
"not",
"hasattr",
"(",
"widgetObj",
",",
"'_qteAdmin'",
")",
":",
"msg",
"=",
"'<widgetObj> was probably not added w... | Reset the local key-map of ``widgetObj`` to the current global
key-map.
|Args|
* ``widgetObj`` (**QWidget**): determines which widgets
signature to use.
|Returns|
* **None**
|Raises|
* **QtmacsArgumentError** if at least one argument has an invalid... | [
"Reset",
"the",
"local",
"key",
"-",
"map",
"of",
"widgetObj",
"to",
"the",
"current",
"global",
"key",
"-",
"map",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L3622-L3649 | train | Unbind all keys from the given widgetObj. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteRegisterApplet | def qteRegisterApplet(self, cls, replaceApplet: bool=False):
"""
Register ``cls`` as an applet.
The name of the applet is the class name of ``cls``
itself. For instance, if the applet was defined and registered
as
class NewApplet17(QtmacsApplet):
...... | python | def qteRegisterApplet(self, cls, replaceApplet: bool=False):
"""
Register ``cls`` as an applet.
The name of the applet is the class name of ``cls``
itself. For instance, if the applet was defined and registered
as
class NewApplet17(QtmacsApplet):
...... | [
"def",
"qteRegisterApplet",
"(",
"self",
",",
"cls",
",",
"replaceApplet",
":",
"bool",
"=",
"False",
")",
":",
"# Check type of input arguments.",
"if",
"not",
"issubclass",
"(",
"cls",
",",
"QtmacsApplet",
")",
":",
"args",
"=",
"(",
"'cls'",
",",
"'class ... | Register ``cls`` as an applet.
The name of the applet is the class name of ``cls``
itself. For instance, if the applet was defined and registered
as
class NewApplet17(QtmacsApplet):
...
app_name = qteRegisterApplet(NewApplet17)
then the applet ... | [
"Register",
"cls",
"as",
"an",
"applet",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L3688-L3758 | train | Register a applet class as an applet. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteGetAppletHandle | def qteGetAppletHandle(self, appletID: str):
"""
Return a handle to ``appletID``.
If no applet with ID ``appletID`` exists then **None** is
returned.
|Args|
* ``appletID`` (**str**): ID of applet.
|Returns|
* **QtmacsApplet**: handle to applet with ID... | python | def qteGetAppletHandle(self, appletID: str):
"""
Return a handle to ``appletID``.
If no applet with ID ``appletID`` exists then **None** is
returned.
|Args|
* ``appletID`` (**str**): ID of applet.
|Returns|
* **QtmacsApplet**: handle to applet with ID... | [
"def",
"qteGetAppletHandle",
"(",
"self",
",",
"appletID",
":",
"str",
")",
":",
"# Compile list of applet Ids.",
"id_list",
"=",
"[",
"_",
".",
"qteAppletID",
"(",
")",
"for",
"_",
"in",
"self",
".",
"_qteAppletList",
"]",
"# If one of the applets has ``appletID`... | Return a handle to ``appletID``.
If no applet with ID ``appletID`` exists then **None** is
returned.
|Args|
* ``appletID`` (**str**): ID of applet.
|Returns|
* **QtmacsApplet**: handle to applet with ID ``appletID``.
|Raises|
* **QtmacsArgumentError... | [
"Return",
"a",
"handle",
"to",
"appletID",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L3797-L3825 | train | Return a handle to applet with ID appletID. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteMakeAppletActive | def qteMakeAppletActive(self, applet: (QtmacsApplet, str)):
"""
Make ``applet`` visible and give it the focus.
If ``applet`` is not yet visible it will replace the
currently active applet, otherwise only the focus will shift.
The ``applet`` parameter can either be an instance o... | python | def qteMakeAppletActive(self, applet: (QtmacsApplet, str)):
"""
Make ``applet`` visible and give it the focus.
If ``applet`` is not yet visible it will replace the
currently active applet, otherwise only the focus will shift.
The ``applet`` parameter can either be an instance o... | [
"def",
"qteMakeAppletActive",
"(",
"self",
",",
"applet",
":",
"(",
"QtmacsApplet",
",",
"str",
")",
")",
":",
"# If ``applet`` was specified by its ID (ie. a string) then",
"# fetch the associated ``QtmacsApplet`` instance. If",
"# ``applet`` is already an instance of ``QtmacsApplet... | Make ``applet`` visible and give it the focus.
If ``applet`` is not yet visible it will replace the
currently active applet, otherwise only the focus will shift.
The ``applet`` parameter can either be an instance of
``QtmacsApplet`` or a string denoting an applet ID. In the
lat... | [
"Make",
"applet",
"visible",
"and",
"give",
"it",
"the",
"focus",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L3828-L3885 | train | Make applet active and give it the focus. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteCloseQtmacs | def qteCloseQtmacs(self):
"""
Close Qtmacs.
First kill all applets, then shut down Qtmacs.
|Args|
* **None**
|Returns|
* **None**
|Raises|
* **None**
"""
# Announce the shutdown.
msgObj = QtmacsMessage()
msgOb... | python | def qteCloseQtmacs(self):
"""
Close Qtmacs.
First kill all applets, then shut down Qtmacs.
|Args|
* **None**
|Returns|
* **None**
|Raises|
* **None**
"""
# Announce the shutdown.
msgObj = QtmacsMessage()
msgOb... | [
"def",
"qteCloseQtmacs",
"(",
"self",
")",
":",
"# Announce the shutdown.",
"msgObj",
"=",
"QtmacsMessage",
"(",
")",
"msgObj",
".",
"setSignalName",
"(",
"'qtesigCloseQtmacs'",
")",
"self",
".",
"qtesigCloseQtmacs",
".",
"emit",
"(",
"msgObj",
")",
"# Kill all ap... | Close Qtmacs.
First kill all applets, then shut down Qtmacs.
|Args|
* **None**
|Returns|
* **None**
|Raises|
* **None** | [
"Close",
"Qtmacs",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L3887-L3921 | train | Close all Qtmacs and all windows. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteDefVar | def qteDefVar(self, varName: str, value, module=None, doc: str=None):
"""
Define and document ``varName`` in an arbitrary name space.
If ``module`` is **None** then ``qte_global`` will be used.
.. warning: If the ``varName`` was already defined in
``module`` then its value a... | python | def qteDefVar(self, varName: str, value, module=None, doc: str=None):
"""
Define and document ``varName`` in an arbitrary name space.
If ``module`` is **None** then ``qte_global`` will be used.
.. warning: If the ``varName`` was already defined in
``module`` then its value a... | [
"def",
"qteDefVar",
"(",
"self",
",",
"varName",
":",
"str",
",",
"value",
",",
"module",
"=",
"None",
",",
"doc",
":",
"str",
"=",
"None",
")",
":",
"# Use the global name space per default.",
"if",
"module",
"is",
"None",
":",
"module",
"=",
"qte_global"... | Define and document ``varName`` in an arbitrary name space.
If ``module`` is **None** then ``qte_global`` will be used.
.. warning: If the ``varName`` was already defined in
``module`` then its value and documentation are overwritten
without warning.
|Args|
* ``... | [
"Define",
"and",
"document",
"varName",
"in",
"an",
"arbitrary",
"name",
"space",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L3943-L3982 | train | Define and document a variable in an arbitrary name space. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteGetVariableDoc | def qteGetVariableDoc(self, varName: str, module=None):
"""
Retrieve documentation for ``varName`` defined in ``module``.
If ``module`` is **None** then ``qte_global`` will be used.
|Args|
* ``varName`` (**str**): variable name.
* ``module`` (**Python module**): the mo... | python | def qteGetVariableDoc(self, varName: str, module=None):
"""
Retrieve documentation for ``varName`` defined in ``module``.
If ``module`` is **None** then ``qte_global`` will be used.
|Args|
* ``varName`` (**str**): variable name.
* ``module`` (**Python module**): the mo... | [
"def",
"qteGetVariableDoc",
"(",
"self",
",",
"varName",
":",
"str",
",",
"module",
"=",
"None",
")",
":",
"# Use the global name space per default.",
"if",
"module",
"is",
"None",
":",
"module",
"=",
"qte_global",
"# No documentation for the variable can exists if the ... | Retrieve documentation for ``varName`` defined in ``module``.
If ``module`` is **None** then ``qte_global`` will be used.
|Args|
* ``varName`` (**str**): variable name.
* ``module`` (**Python module**): the module in which the
variable should be defined.
|Returns|
... | [
"Retrieve",
"documentation",
"for",
"varName",
"defined",
"in",
"module",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L3985-L4019 | train | Return the documentation string for varName defined in module. |
olitheolix/qtmacs | qtmacs/qtmacsmain.py | QtmacsMain.qteEmulateKeypresses | def qteEmulateKeypresses(self, keysequence):
"""
Emulate the Qt key presses that define ``keysequence``.
The method will put the keys into a queue and process them one
by one once the event loop is idle, ie. the event loop
executes all signals and macros associated with the emul... | python | def qteEmulateKeypresses(self, keysequence):
"""
Emulate the Qt key presses that define ``keysequence``.
The method will put the keys into a queue and process them one
by one once the event loop is idle, ie. the event loop
executes all signals and macros associated with the emul... | [
"def",
"qteEmulateKeypresses",
"(",
"self",
",",
"keysequence",
")",
":",
"# Convert the key sequence into a QtmacsKeysequence object, or",
"# raise an QtmacsOtherError if the conversion is impossible.",
"keysequence",
"=",
"QtmacsKeysequence",
"(",
"keysequence",
")",
"key_list",
... | Emulate the Qt key presses that define ``keysequence``.
The method will put the keys into a queue and process them one
by one once the event loop is idle, ie. the event loop
executes all signals and macros associated with the emulated
key press first before the next one is emulated.
... | [
"Emulate",
"the",
"Qt",
"key",
"presses",
"that",
"define",
"keysequence",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L4027-L4059 | train | Emulate the key presses that define keysequence. |
a1ezzz/wasp-general | wasp_general/datetime.py | utc_datetime | def utc_datetime(dt=None, local_value=True):
""" Convert local datetime and/or datetime without timezone information to UTC datetime with timezone
information.
:param dt: local datetime to convert. If is None, then system datetime value is used
:param local_value: whether dt is a datetime in system timezone or UTC... | python | def utc_datetime(dt=None, local_value=True):
""" Convert local datetime and/or datetime without timezone information to UTC datetime with timezone
information.
:param dt: local datetime to convert. If is None, then system datetime value is used
:param local_value: whether dt is a datetime in system timezone or UTC... | [
"def",
"utc_datetime",
"(",
"dt",
"=",
"None",
",",
"local_value",
"=",
"True",
")",
":",
"# TODO: rename local_value to local_tz or in_local_tz",
"if",
"dt",
"is",
"None",
":",
"return",
"datetime",
".",
"now",
"(",
"tz",
"=",
"timezone",
".",
"utc",
")",
"... | Convert local datetime and/or datetime without timezone information to UTC datetime with timezone
information.
:param dt: local datetime to convert. If is None, then system datetime value is used
:param local_value: whether dt is a datetime in system timezone or UTC datetime without timezone information
:return: d... | [
"Convert",
"local",
"datetime",
"and",
"/",
"or",
"datetime",
"without",
"timezone",
"information",
"to",
"UTC",
"datetime",
"with",
"timezone",
"information",
"."
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/datetime.py#L42-L61 | train | Convert local datetime and datetime without timezone information to UTC datetime with timezone information. |
a1ezzz/wasp-general | wasp_general/datetime.py | local_datetime | def local_datetime(dt=None, utc_value=True):
""" Convert UTC datetime and/or datetime without timezone information to local datetime with timezone
information
:param dt: datetime in UTC to convert. If is None, then system datetime value is used
:param utc_value: whether dt is a datetime in UTC or in system timezon... | python | def local_datetime(dt=None, utc_value=True):
""" Convert UTC datetime and/or datetime without timezone information to local datetime with timezone
information
:param dt: datetime in UTC to convert. If is None, then system datetime value is used
:param utc_value: whether dt is a datetime in UTC or in system timezon... | [
"def",
"local_datetime",
"(",
"dt",
"=",
"None",
",",
"utc_value",
"=",
"True",
")",
":",
"# TODO: rename utc_value to utc_tz or in_utc_tz",
"if",
"dt",
"is",
"None",
":",
"return",
"datetime",
".",
"now",
"(",
"tz",
"=",
"local_tz",
"(",
")",
")",
"result",... | Convert UTC datetime and/or datetime without timezone information to local datetime with timezone
information
:param dt: datetime in UTC to convert. If is None, then system datetime value is used
:param utc_value: whether dt is a datetime in UTC or in system timezone without timezone information
:return: datetime ... | [
"Convert",
"UTC",
"datetime",
"and",
"/",
"or",
"datetime",
"without",
"timezone",
"information",
"to",
"local",
"datetime",
"with",
"timezone",
"information"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/datetime.py#L65-L84 | train | Convert UTC datetime and or datetime without timezone information to local datetime with timezone information. |
projectshift/shift-schema | shiftschema/schema.py | Schema.has_property | def has_property(self, property_name):
"""
Check if schema has property
:param property_name: str, name to check
:return: bool
"""
if property_name in self.properties:
return True
elif property_name in self.entities:
return True
eli... | python | def has_property(self, property_name):
"""
Check if schema has property
:param property_name: str, name to check
:return: bool
"""
if property_name in self.properties:
return True
elif property_name in self.entities:
return True
eli... | [
"def",
"has_property",
"(",
"self",
",",
"property_name",
")",
":",
"if",
"property_name",
"in",
"self",
".",
"properties",
":",
"return",
"True",
"elif",
"property_name",
"in",
"self",
".",
"entities",
":",
"return",
"True",
"elif",
"property_name",
"in",
"... | Check if schema has property
:param property_name: str, name to check
:return: bool | [
"Check",
"if",
"schema",
"has",
"property",
":",
"param",
"property_name",
":",
"str",
"name",
"to",
"check",
":",
"return",
":",
"bool"
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/schema.py#L41-L54 | train | Check if schema has property with given name |
projectshift/shift-schema | shiftschema/schema.py | Schema.add_state_validator | def add_state_validator(self, validator):
"""
Add entity state validator
:param validator: a validator, implementing AbstractValidator
:return: None
"""
if not isinstance(validator, AbstractValidator):
err = '{} is not a subclass of {}'
raise Inval... | python | def add_state_validator(self, validator):
"""
Add entity state validator
:param validator: a validator, implementing AbstractValidator
:return: None
"""
if not isinstance(validator, AbstractValidator):
err = '{} is not a subclass of {}'
raise Inval... | [
"def",
"add_state_validator",
"(",
"self",
",",
"validator",
")",
":",
"if",
"not",
"isinstance",
"(",
"validator",
",",
"AbstractValidator",
")",
":",
"err",
"=",
"'{} is not a subclass of {}'",
"raise",
"InvalidValidator",
"(",
"err",
".",
"format",
"(",
"vali... | Add entity state validator
:param validator: a validator, implementing AbstractValidator
:return: None | [
"Add",
"entity",
"state",
"validator",
":",
"param",
"validator",
":",
"a",
"validator",
"implementing",
"AbstractValidator",
":",
"return",
":",
"None"
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/schema.py#L71-L82 | train | Add a state validator to the list of state validators. |
projectshift/shift-schema | shiftschema/schema.py | Schema.add_property | def add_property(self, property_name, use_context=True):
"""
Add simple property to schema
:param property_name: str, property name
:param use_context: bool, whether custom context should be used
:return: shiftschema.property.SimpleProperty
"""
if self.has_propert... | python | def add_property(self, property_name, use_context=True):
"""
Add simple property to schema
:param property_name: str, property name
:param use_context: bool, whether custom context should be used
:return: shiftschema.property.SimpleProperty
"""
if self.has_propert... | [
"def",
"add_property",
"(",
"self",
",",
"property_name",
",",
"use_context",
"=",
"True",
")",
":",
"if",
"self",
".",
"has_property",
"(",
"property_name",
")",
":",
"err",
"=",
"'Property \"{}\" already exists'",
"raise",
"PropertyExists",
"(",
"err",
".",
... | Add simple property to schema
:param property_name: str, property name
:param use_context: bool, whether custom context should be used
:return: shiftschema.property.SimpleProperty | [
"Add",
"simple",
"property",
"to",
"schema",
":",
"param",
"property_name",
":",
"str",
"property",
"name",
":",
"param",
"use_context",
":",
"bool",
"whether",
"custom",
"context",
"should",
"be",
"used",
":",
"return",
":",
"shiftschema",
".",
"property",
... | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/schema.py#L84-L97 | train | Add a simple property to the schema. |
projectshift/shift-schema | shiftschema/schema.py | Schema.add_entity | def add_entity(self, property_name, use_context=True):
"""
Add entity property to schema
:param property_name: str, property name
:param use_context: bool, whether custom context should be used
:return: shiftschema.property.EntityProperty
"""
if self.has_property(... | python | def add_entity(self, property_name, use_context=True):
"""
Add entity property to schema
:param property_name: str, property name
:param use_context: bool, whether custom context should be used
:return: shiftschema.property.EntityProperty
"""
if self.has_property(... | [
"def",
"add_entity",
"(",
"self",
",",
"property_name",
",",
"use_context",
"=",
"True",
")",
":",
"if",
"self",
".",
"has_property",
"(",
"property_name",
")",
":",
"err",
"=",
"'Property \"{}\" already exists'",
"raise",
"PropertyExists",
"(",
"err",
".",
"f... | Add entity property to schema
:param property_name: str, property name
:param use_context: bool, whether custom context should be used
:return: shiftschema.property.EntityProperty | [
"Add",
"entity",
"property",
"to",
"schema",
":",
"param",
"property_name",
":",
"str",
"property",
"name",
":",
"param",
"use_context",
":",
"bool",
"whether",
"custom",
"context",
"should",
"be",
"used",
":",
"return",
":",
"shiftschema",
".",
"property",
... | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/schema.py#L99-L111 | train | Add entity property to schema
|
projectshift/shift-schema | shiftschema/schema.py | Schema.add_collection | def add_collection(self, property_name, use_context=True):
"""
Add collection property to schema
:param property_name: str, property name
:param property_name: str, property name
:return: shiftschema.property.CollectionProperty
"""
if self.has_property(property_na... | python | def add_collection(self, property_name, use_context=True):
"""
Add collection property to schema
:param property_name: str, property name
:param property_name: str, property name
:return: shiftschema.property.CollectionProperty
"""
if self.has_property(property_na... | [
"def",
"add_collection",
"(",
"self",
",",
"property_name",
",",
"use_context",
"=",
"True",
")",
":",
"if",
"self",
".",
"has_property",
"(",
"property_name",
")",
":",
"err",
"=",
"'Property \"{}\" already exists'",
"raise",
"PropertyExists",
"(",
"err",
".",
... | Add collection property to schema
:param property_name: str, property name
:param property_name: str, property name
:return: shiftschema.property.CollectionProperty | [
"Add",
"collection",
"property",
"to",
"schema",
":",
"param",
"property_name",
":",
"str",
"property",
"name",
":",
"param",
"property_name",
":",
"str",
"property",
"name",
":",
"return",
":",
"shiftschema",
".",
"property",
".",
"CollectionProperty"
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/schema.py#L113-L126 | train | Add a collection property to schema
|
projectshift/shift-schema | shiftschema/schema.py | Schema.get | def get(self, model, property_name):
"""
Get property from model. Use getter if possible.
:param model: model or dict
:param property_name: str, name on the model
:return: mixed
"""
if type(model) is dict:
if property_name not in model:
... | python | def get(self, model, property_name):
"""
Get property from model. Use getter if possible.
:param model: model or dict
:param property_name: str, name on the model
:return: mixed
"""
if type(model) is dict:
if property_name not in model:
... | [
"def",
"get",
"(",
"self",
",",
"model",
",",
"property_name",
")",
":",
"if",
"type",
"(",
"model",
")",
"is",
"dict",
":",
"if",
"property_name",
"not",
"in",
"model",
":",
"return",
"None",
"else",
":",
"return",
"model",
"[",
"property_name",
"]",
... | Get property from model. Use getter if possible.
:param model: model or dict
:param property_name: str, name on the model
:return: mixed | [
"Get",
"property",
"from",
"model",
".",
"Use",
"getter",
"if",
"possible",
".",
":",
"param",
"model",
":",
"model",
"or",
"dict",
":",
"param",
"property_name",
":",
"str",
"name",
"on",
"the",
"model",
":",
"return",
":",
"mixed"
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/schema.py#L128-L147 | train | Get property from model. Use getter if possible. |
projectshift/shift-schema | shiftschema/schema.py | Schema.set | def set(self, model, property_name, value):
"""
Set model property to value. Use setter if possible.
:param model: model object or dict
:param property_name: str, name on the model
:param value: mixed, a value to set
:return: None
"""
if type(model) is dic... | python | def set(self, model, property_name, value):
"""
Set model property to value. Use setter if possible.
:param model: model object or dict
:param property_name: str, name on the model
:param value: mixed, a value to set
:return: None
"""
if type(model) is dic... | [
"def",
"set",
"(",
"self",
",",
"model",
",",
"property_name",
",",
"value",
")",
":",
"if",
"type",
"(",
"model",
")",
"is",
"dict",
":",
"model",
"[",
"property_name",
"]",
"=",
"value",
"elif",
"hasattr",
"(",
"model",
",",
"'set_'",
"+",
"propert... | Set model property to value. Use setter if possible.
:param model: model object or dict
:param property_name: str, name on the model
:param value: mixed, a value to set
:return: None | [
"Set",
"model",
"property",
"to",
"value",
".",
"Use",
"setter",
"if",
"possible",
".",
":",
"param",
"model",
":",
"model",
"object",
"or",
"dict",
":",
"param",
"property_name",
":",
"str",
"name",
"on",
"the",
"model",
":",
"param",
"value",
":",
"m... | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/schema.py#L149-L166 | train | Set the value of the specified property in the specified model. Use setter if possible. |
projectshift/shift-schema | shiftschema/schema.py | Schema.process | def process(self, model=None, context=None):
"""
Perform validation and filtering at the same time, return a
validation result object.
:param model: object or dict
:param context: object, dict or None
:return: shiftschema.result.Result
"""
self.filter(mod... | python | def process(self, model=None, context=None):
"""
Perform validation and filtering at the same time, return a
validation result object.
:param model: object or dict
:param context: object, dict or None
:return: shiftschema.result.Result
"""
self.filter(mod... | [
"def",
"process",
"(",
"self",
",",
"model",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"self",
".",
"filter",
"(",
"model",
",",
"context",
")",
"return",
"self",
".",
"validate",
"(",
"model",
",",
"context",
")"
] | Perform validation and filtering at the same time, return a
validation result object.
:param model: object or dict
:param context: object, dict or None
:return: shiftschema.result.Result | [
"Perform",
"validation",
"and",
"filtering",
"at",
"the",
"same",
"time",
"return",
"a",
"validation",
"result",
"object",
"."
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/schema.py#L168-L178 | train | Perform validation and filtering at the same time return a
validation result object. |
projectshift/shift-schema | shiftschema/schema.py | Schema.filter | def filter(self, model=None, context=None):
"""
Perform filtering on the model. Will change model in place.
:param model: object or dict
:param context: object, dict or None
:return: None
"""
if model is None:
return
# properties
self.... | python | def filter(self, model=None, context=None):
"""
Perform filtering on the model. Will change model in place.
:param model: object or dict
:param context: object, dict or None
:return: None
"""
if model is None:
return
# properties
self.... | [
"def",
"filter",
"(",
"self",
",",
"model",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"if",
"model",
"is",
"None",
":",
"return",
"# properties",
"self",
".",
"filter_properties",
"(",
"model",
",",
"context",
"=",
"context",
")",
"# entities",... | Perform filtering on the model. Will change model in place.
:param model: object or dict
:param context: object, dict or None
:return: None | [
"Perform",
"filtering",
"on",
"the",
"model",
".",
"Will",
"change",
"model",
"in",
"place",
".",
":",
"param",
"model",
":",
"object",
"or",
"dict",
":",
"param",
"context",
":",
"object",
"dict",
"or",
"None",
":",
"return",
":",
"None"
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/schema.py#L180-L197 | train | Perform filtering on the model. Will change model in place. |
projectshift/shift-schema | shiftschema/schema.py | Schema.filter_properties | def filter_properties(self, model, context=None):
"""
Filter simple properties
Runs filters on simple properties changing them in place.
:param model: object or dict
:param context: object, dict or None
:return: None
"""
if model is None:
retu... | python | def filter_properties(self, model, context=None):
"""
Filter simple properties
Runs filters on simple properties changing them in place.
:param model: object or dict
:param context: object, dict or None
:return: None
"""
if model is None:
retu... | [
"def",
"filter_properties",
"(",
"self",
",",
"model",
",",
"context",
"=",
"None",
")",
":",
"if",
"model",
"is",
"None",
":",
"return",
"for",
"property_name",
"in",
"self",
".",
"properties",
":",
"prop",
"=",
"self",
".",
"properties",
"[",
"property... | Filter simple properties
Runs filters on simple properties changing them in place.
:param model: object or dict
:param context: object, dict or None
:return: None | [
"Filter",
"simple",
"properties",
"Runs",
"filters",
"on",
"simple",
"properties",
"changing",
"them",
"in",
"place",
".",
":",
"param",
"model",
":",
"object",
"or",
"dict",
":",
"param",
"context",
":",
"object",
"dict",
"or",
"None",
":",
"return",
":",... | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/schema.py#L199-L222 | train | Filters simple properties based on their value. |
projectshift/shift-schema | shiftschema/schema.py | Schema.filter_entities | def filter_entities(self, model, context=None):
"""
Filter entities
Runs filters on entity properties changing them in place.
:param model: object or dict
:param context: object, dict or None
:return: None
"""
if model is None:
return
... | python | def filter_entities(self, model, context=None):
"""
Filter entities
Runs filters on entity properties changing them in place.
:param model: object or dict
:param context: object, dict or None
:return: None
"""
if model is None:
return
... | [
"def",
"filter_entities",
"(",
"self",
",",
"model",
",",
"context",
"=",
"None",
")",
":",
"if",
"model",
"is",
"None",
":",
"return",
"for",
"property_name",
"in",
"self",
".",
"entities",
":",
"prop",
"=",
"self",
".",
"entities",
"[",
"property_name"... | Filter entities
Runs filters on entity properties changing them in place.
:param model: object or dict
:param context: object, dict or None
:return: None | [
"Filter",
"entities",
"Runs",
"filters",
"on",
"entity",
"properties",
"changing",
"them",
"in",
"place",
".",
":",
"param",
"model",
":",
"object",
"or",
"dict",
":",
"param",
"context",
":",
"object",
"dict",
"or",
"None",
":",
"return",
":",
"None"
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/schema.py#L224-L250 | train | Filters the entity properties of the given model. |
projectshift/shift-schema | shiftschema/schema.py | Schema.filter_collections | def filter_collections(self, model, context=None):
"""
Filter collections
Runs filters on collection properties changing them in place.
:param model: object or dict
:param context: object, dict or None
:return: None
"""
if model is None:
retur... | python | def filter_collections(self, model, context=None):
"""
Filter collections
Runs filters on collection properties changing them in place.
:param model: object or dict
:param context: object, dict or None
:return: None
"""
if model is None:
retur... | [
"def",
"filter_collections",
"(",
"self",
",",
"model",
",",
"context",
"=",
"None",
")",
":",
"if",
"model",
"is",
"None",
":",
"return",
"for",
"property_name",
"in",
"self",
".",
"collections",
":",
"prop",
"=",
"self",
".",
"collections",
"[",
"prope... | Filter collections
Runs filters on collection properties changing them in place.
:param model: object or dict
:param context: object, dict or None
:return: None | [
"Filter",
"collections",
"Runs",
"filters",
"on",
"collection",
"properties",
"changing",
"them",
"in",
"place",
".",
":",
"param",
"model",
":",
"object",
"or",
"dict",
":",
"param",
"context",
":",
"object",
"dict",
"or",
"None",
":",
"return",
":",
"Non... | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/schema.py#L252-L276 | train | Filters collections with schema |
projectshift/shift-schema | shiftschema/schema.py | Schema.validate | def validate(self, model=None, context=None):
"""
Validate model and return validation result object
:param model: object or dict
:param context: object, dict or None
:return: shiftschema.result.Result
"""
# inject with settings
result = Result(translato... | python | def validate(self, model=None, context=None):
"""
Validate model and return validation result object
:param model: object or dict
:param context: object, dict or None
:return: shiftschema.result.Result
"""
# inject with settings
result = Result(translato... | [
"def",
"validate",
"(",
"self",
",",
"model",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"# inject with settings",
"result",
"=",
"Result",
"(",
"translator",
"=",
"self",
".",
"translator",
",",
"locale",
"=",
"self",
".",
"locale",
")",
"# val... | Validate model and return validation result object
:param model: object or dict
:param context: object, dict or None
:return: shiftschema.result.Result | [
"Validate",
"model",
"and",
"return",
"validation",
"result",
"object",
":",
"param",
"model",
":",
"object",
"or",
"dict",
":",
"param",
"context",
":",
"object",
"dict",
"or",
"None",
":",
"return",
":",
"shiftschema",
".",
"result",
".",
"Result"
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/schema.py#L278-L306 | train | Validate model and return validation result object
|
projectshift/shift-schema | shiftschema/schema.py | Schema.validate_state | def validate_state(self, model, context=None):
"""
Validate model state
Run state validators and return and result object.
:param model: object or dict
:param context: object, dict or None
:return: shiftschema.result.Result
"""
result = Result()
f... | python | def validate_state(self, model, context=None):
"""
Validate model state
Run state validators and return and result object.
:param model: object or dict
:param context: object, dict or None
:return: shiftschema.result.Result
"""
result = Result()
f... | [
"def",
"validate_state",
"(",
"self",
",",
"model",
",",
"context",
"=",
"None",
")",
":",
"result",
"=",
"Result",
"(",
")",
"for",
"state_validator",
"in",
"self",
".",
"state",
":",
"error",
"=",
"state_validator",
".",
"run",
"(",
"value",
"=",
"mo... | Validate model state
Run state validators and return and result object.
:param model: object or dict
:param context: object, dict or None
:return: shiftschema.result.Result | [
"Validate",
"model",
"state",
"Run",
"state",
"validators",
"and",
"return",
"and",
"result",
"object",
".",
":",
"param",
"model",
":",
"object",
"or",
"dict",
":",
"param",
"context",
":",
"object",
"dict",
"or",
"None",
":",
"return",
":",
"shiftschema"... | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/schema.py#L308-L326 | train | Validate model state and return and result object. |
projectshift/shift-schema | shiftschema/schema.py | Schema.validate_properties | def validate_properties(self, model, context=None):
"""
Validate simple properties
Performs validation on simple properties to return a result object.
:param model: object or dict
:param context: object, dict or None
:return: shiftschema.result.Result
"""
... | python | def validate_properties(self, model, context=None):
"""
Validate simple properties
Performs validation on simple properties to return a result object.
:param model: object or dict
:param context: object, dict or None
:return: shiftschema.result.Result
"""
... | [
"def",
"validate_properties",
"(",
"self",
",",
"model",
",",
"context",
"=",
"None",
")",
":",
"result",
"=",
"Result",
"(",
")",
"for",
"property_name",
"in",
"self",
".",
"properties",
":",
"prop",
"=",
"self",
".",
"properties",
"[",
"property_name",
... | Validate simple properties
Performs validation on simple properties to return a result object.
:param model: object or dict
:param context: object, dict or None
:return: shiftschema.result.Result | [
"Validate",
"simple",
"properties",
"Performs",
"validation",
"on",
"simple",
"properties",
"to",
"return",
"a",
"result",
"object",
".",
":",
"param",
"model",
":",
"object",
"or",
"dict",
":",
"param",
"context",
":",
"object",
"dict",
"or",
"None",
":",
... | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/schema.py#L328-L352 | train | Validate simple properties and return a result object. |
projectshift/shift-schema | shiftschema/schema.py | Schema.validate_entities | def validate_entities(self, model, context=None):
"""
Validate entity properties
Performs validation on entity properties to return a result object.
:param model: object or dict
:param context: object, dict or None
:return: shiftschema.result.Result
"""
r... | python | def validate_entities(self, model, context=None):
"""
Validate entity properties
Performs validation on entity properties to return a result object.
:param model: object or dict
:param context: object, dict or None
:return: shiftschema.result.Result
"""
r... | [
"def",
"validate_entities",
"(",
"self",
",",
"model",
",",
"context",
"=",
"None",
")",
":",
"result",
"=",
"Result",
"(",
")",
"for",
"property_name",
"in",
"self",
".",
"entities",
":",
"prop",
"=",
"self",
".",
"entities",
"[",
"property_name",
"]",
... | Validate entity properties
Performs validation on entity properties to return a result object.
:param model: object or dict
:param context: object, dict or None
:return: shiftschema.result.Result | [
"Validate",
"entity",
"properties",
"Performs",
"validation",
"on",
"entity",
"properties",
"to",
"return",
"a",
"result",
"object",
".",
":",
"param",
"model",
":",
"object",
"or",
"dict",
":",
"param",
"context",
":",
"object",
"dict",
"or",
"None",
":",
... | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/schema.py#L354-L391 | train | Validate entity properties and return a result object. |
projectshift/shift-schema | shiftschema/schema.py | Schema.validate_collections | def validate_collections(self, model, context=None):
"""
Validate collection properties
Performs validation on collection properties to return a result object.
:param model: object or dict
:param context: object, dict or None
:return: shiftschema.result.Result
""... | python | def validate_collections(self, model, context=None):
"""
Validate collection properties
Performs validation on collection properties to return a result object.
:param model: object or dict
:param context: object, dict or None
:return: shiftschema.result.Result
""... | [
"def",
"validate_collections",
"(",
"self",
",",
"model",
",",
"context",
"=",
"None",
")",
":",
"result",
"=",
"Result",
"(",
")",
"for",
"property_name",
"in",
"self",
".",
"collections",
":",
"prop",
"=",
"self",
".",
"collections",
"[",
"property_name"... | Validate collection properties
Performs validation on collection properties to return a result object.
:param model: object or dict
:param context: object, dict or None
:return: shiftschema.result.Result | [
"Validate",
"collection",
"properties",
"Performs",
"validation",
"on",
"collection",
"properties",
"to",
"return",
"a",
"result",
"object",
".",
":",
"param",
"model",
":",
"object",
"or",
"dict",
":",
"param",
"context",
":",
"object",
"dict",
"or",
"None",
... | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/schema.py#L393-L427 | train | Validate collection properties and return a result object. |
Midnighter/dependency-info | src/depinfo/info.py | get_sys_info | def get_sys_info():
"""Return system information as a dict."""
blob = dict()
blob["OS"] = platform.system()
blob["OS-release"] = platform.release()
blob["Python"] = platform.python_version()
return blob | python | def get_sys_info():
"""Return system information as a dict."""
blob = dict()
blob["OS"] = platform.system()
blob["OS-release"] = platform.release()
blob["Python"] = platform.python_version()
return blob | [
"def",
"get_sys_info",
"(",
")",
":",
"blob",
"=",
"dict",
"(",
")",
"blob",
"[",
"\"OS\"",
"]",
"=",
"platform",
".",
"system",
"(",
")",
"blob",
"[",
"\"OS-release\"",
"]",
"=",
"platform",
".",
"release",
"(",
")",
"blob",
"[",
"\"Python\"",
"]",
... | Return system information as a dict. | [
"Return",
"system",
"information",
"as",
"a",
"dict",
"."
] | 15bcada0a1d6c047cbe10b844d5bd909ea8cc752 | https://github.com/Midnighter/dependency-info/blob/15bcada0a1d6c047cbe10b844d5bd909ea8cc752/src/depinfo/info.py#L38-L44 | train | Return system information as a dict. |
Midnighter/dependency-info | src/depinfo/info.py | get_pkg_info | def get_pkg_info(
package_name, additional=("pip", "flit", "pbr", "setuptools", "wheel")
):
"""Return build and package dependencies as a dict."""
dist_index = build_dist_index(pkg_resources.working_set)
root = dist_index[package_name]
tree = construct_tree(dist_index)
dependencies = {pkg.name: ... | python | def get_pkg_info(
package_name, additional=("pip", "flit", "pbr", "setuptools", "wheel")
):
"""Return build and package dependencies as a dict."""
dist_index = build_dist_index(pkg_resources.working_set)
root = dist_index[package_name]
tree = construct_tree(dist_index)
dependencies = {pkg.name: ... | [
"def",
"get_pkg_info",
"(",
"package_name",
",",
"additional",
"=",
"(",
"\"pip\"",
",",
"\"flit\"",
",",
"\"pbr\"",
",",
"\"setuptools\"",
",",
"\"wheel\"",
")",
")",
":",
"dist_index",
"=",
"build_dist_index",
"(",
"pkg_resources",
".",
"working_set",
")",
"... | Return build and package dependencies as a dict. | [
"Return",
"build",
"and",
"package",
"dependencies",
"as",
"a",
"dict",
"."
] | 15bcada0a1d6c047cbe10b844d5bd909ea8cc752 | https://github.com/Midnighter/dependency-info/blob/15bcada0a1d6c047cbe10b844d5bd909ea8cc752/src/depinfo/info.py#L47-L65 | train | Return build and package dependencies as a dict. |
Midnighter/dependency-info | src/depinfo/info.py | print_info | def print_info(info):
"""Print an information dict to stdout in order."""
format_str = "{:<%d} {:>%d}" % (
max(map(len, info)),
max(map(len, info.values())),
)
for name in sorted(info):
print(format_str.format(name, info[name])) | python | def print_info(info):
"""Print an information dict to stdout in order."""
format_str = "{:<%d} {:>%d}" % (
max(map(len, info)),
max(map(len, info.values())),
)
for name in sorted(info):
print(format_str.format(name, info[name])) | [
"def",
"print_info",
"(",
"info",
")",
":",
"format_str",
"=",
"\"{:<%d} {:>%d}\"",
"%",
"(",
"max",
"(",
"map",
"(",
"len",
",",
"info",
")",
")",
",",
"max",
"(",
"map",
"(",
"len",
",",
"info",
".",
"values",
"(",
")",
")",
")",
",",
")",
"f... | Print an information dict to stdout in order. | [
"Print",
"an",
"information",
"dict",
"to",
"stdout",
"in",
"order",
"."
] | 15bcada0a1d6c047cbe10b844d5bd909ea8cc752 | https://github.com/Midnighter/dependency-info/blob/15bcada0a1d6c047cbe10b844d5bd909ea8cc752/src/depinfo/info.py#L68-L75 | train | Print an information dict to stdout in order. |
Midnighter/dependency-info | src/depinfo/info.py | print_dependencies | def print_dependencies(package_name):
"""Print the formatted information to standard out."""
info = get_sys_info()
print("\nSystem Information")
print("==================")
print_info(info)
info = get_pkg_info(package_name)
print("\nPackage Versions")
print("================")
print... | python | def print_dependencies(package_name):
"""Print the formatted information to standard out."""
info = get_sys_info()
print("\nSystem Information")
print("==================")
print_info(info)
info = get_pkg_info(package_name)
print("\nPackage Versions")
print("================")
print... | [
"def",
"print_dependencies",
"(",
"package_name",
")",
":",
"info",
"=",
"get_sys_info",
"(",
")",
"print",
"(",
"\"\\nSystem Information\"",
")",
"print",
"(",
"\"==================\"",
")",
"print_info",
"(",
"info",
")",
"info",
"=",
"get_pkg_info",
"(",
"pac... | Print the formatted information to standard out. | [
"Print",
"the",
"formatted",
"information",
"to",
"standard",
"out",
"."
] | 15bcada0a1d6c047cbe10b844d5bd909ea8cc752 | https://github.com/Midnighter/dependency-info/blob/15bcada0a1d6c047cbe10b844d5bd909ea8cc752/src/depinfo/info.py#L78-L88 | train | Print the formatted information to standard out. |
OpenGov/og-python-utils | ogutils/web/operators.py | repeat_read_url_request | def repeat_read_url_request(url, headers=None, data=None, retries=2, logger=None):
'''
Allows for repeated http requests up to retries additional times
'''
if logger:
logger.debug("Retrieving url content: {}".format(url))
req = urllib2.Request(url, data, headers=headers or {})
ret... | python | def repeat_read_url_request(url, headers=None, data=None, retries=2, logger=None):
'''
Allows for repeated http requests up to retries additional times
'''
if logger:
logger.debug("Retrieving url content: {}".format(url))
req = urllib2.Request(url, data, headers=headers or {})
ret... | [
"def",
"repeat_read_url_request",
"(",
"url",
",",
"headers",
"=",
"None",
",",
"data",
"=",
"None",
",",
"retries",
"=",
"2",
",",
"logger",
"=",
"None",
")",
":",
"if",
"logger",
":",
"logger",
".",
"debug",
"(",
"\"Retrieving url content: {}\"",
".",
... | Allows for repeated http requests up to retries additional times | [
"Allows",
"for",
"repeated",
"http",
"requests",
"up",
"to",
"retries",
"additional",
"times"
] | 00f44927383dd1bd6348f47302c4453d56963479 | https://github.com/OpenGov/og-python-utils/blob/00f44927383dd1bd6348f47302c4453d56963479/ogutils/web/operators.py#L6-L13 | train | Allows for repeated http requests up to retries additional times |
OpenGov/og-python-utils | ogutils/web/operators.py | repeat_read_json_url_request | def repeat_read_json_url_request(url, headers=None, data=None, retries=2, logger=None):
'''
Allows for repeated http requests up to retries additional times with convienence
wrapper on jsonization of response
'''
if logger:
logger.debug("Retrieving url json content: {}".format(url))
... | python | def repeat_read_json_url_request(url, headers=None, data=None, retries=2, logger=None):
'''
Allows for repeated http requests up to retries additional times with convienence
wrapper on jsonization of response
'''
if logger:
logger.debug("Retrieving url json content: {}".format(url))
... | [
"def",
"repeat_read_json_url_request",
"(",
"url",
",",
"headers",
"=",
"None",
",",
"data",
"=",
"None",
",",
"retries",
"=",
"2",
",",
"logger",
"=",
"None",
")",
":",
"if",
"logger",
":",
"logger",
".",
"debug",
"(",
"\"Retrieving url json content: {}\"",... | Allows for repeated http requests up to retries additional times with convienence
wrapper on jsonization of response | [
"Allows",
"for",
"repeated",
"http",
"requests",
"up",
"to",
"retries",
"additional",
"times",
"with",
"convienence",
"wrapper",
"on",
"jsonization",
"of",
"response"
] | 00f44927383dd1bd6348f47302c4453d56963479 | https://github.com/OpenGov/og-python-utils/blob/00f44927383dd1bd6348f47302c4453d56963479/ogutils/web/operators.py#L15-L23 | train | This function is used to repeat a json request on a list of objects. |
atl/py-smartdc | smartdc/machine.py | priv | def priv(x):
"""
Quick and dirty method to find an IP on a private network given a correctly
formatted IPv4 quad.
"""
if x.startswith(u'172.'):
return 16 <= int(x.split(u'.')[1]) < 32
return x.startswith((u'192.168.', u'10.', u'172.')) | python | def priv(x):
"""
Quick and dirty method to find an IP on a private network given a correctly
formatted IPv4 quad.
"""
if x.startswith(u'172.'):
return 16 <= int(x.split(u'.')[1]) < 32
return x.startswith((u'192.168.', u'10.', u'172.')) | [
"def",
"priv",
"(",
"x",
")",
":",
"if",
"x",
".",
"startswith",
"(",
"u'172.'",
")",
":",
"return",
"16",
"<=",
"int",
"(",
"x",
".",
"split",
"(",
"u'.'",
")",
"[",
"1",
"]",
")",
"<",
"32",
"return",
"x",
".",
"startswith",
"(",
"(",
"u'19... | Quick and dirty method to find an IP on a private network given a correctly
formatted IPv4 quad. | [
"Quick",
"and",
"dirty",
"method",
"to",
"find",
"an",
"IP",
"on",
"a",
"private",
"network",
"given",
"a",
"correctly",
"formatted",
"IPv4",
"quad",
"."
] | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L7-L14 | train | Quick and dirty method to find an IP on a private network given a correctly - formatted IPv4 quad. |
atl/py-smartdc | smartdc/machine.py | Machine._save | def _save(self, data):
"""
Take the data from a dict and commit them to appropriate attributes.
"""
self.name = data.get('name')
self.type = data.get('type')
self.state = data.get('state')
self.dataset = data.get('dataset')
self.memory = data.get('memory')... | python | def _save(self, data):
"""
Take the data from a dict and commit them to appropriate attributes.
"""
self.name = data.get('name')
self.type = data.get('type')
self.state = data.get('state')
self.dataset = data.get('dataset')
self.memory = data.get('memory')... | [
"def",
"_save",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"name",
"=",
"data",
".",
"get",
"(",
"'name'",
")",
"self",
".",
"type",
"=",
"data",
".",
"get",
"(",
"'type'",
")",
"self",
".",
"state",
"=",
"data",
".",
"get",
"(",
"'state'... | Take the data from a dict and commit them to appropriate attributes. | [
"Take",
"the",
"data",
"from",
"a",
"dict",
"and",
"commit",
"them",
"to",
"appropriate",
"attributes",
"."
] | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L135-L152 | train | Save the data to the object. |
atl/py-smartdc | smartdc/machine.py | Machine.refresh | def refresh(self, credentials=False):
"""
::
GET /:login/machines/:id
:param credentials: whether to return machine passwords
:type credentials: :py:class:`bool`
Fetch the existing state and values for the
:py:class:`smartdc.machine... | python | def refresh(self, credentials=False):
"""
::
GET /:login/machines/:id
:param credentials: whether to return machine passwords
:type credentials: :py:class:`bool`
Fetch the existing state and values for the
:py:class:`smartdc.machine... | [
"def",
"refresh",
"(",
"self",
",",
"credentials",
"=",
"False",
")",
":",
"data",
"=",
"self",
".",
"datacenter",
".",
"raw_machine_data",
"(",
"self",
".",
"id",
",",
"credentials",
"=",
"credentials",
")",
"self",
".",
"_save",
"(",
"data",
")"
] | ::
GET /:login/machines/:id
:param credentials: whether to return machine passwords
:type credentials: :py:class:`bool`
Fetch the existing state and values for the
:py:class:`smartdc.machine.Machine` from the datacenter and commit the
valu... | [
"::",
"GET",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
":",
"param",
"credentials",
":",
"whether",
"to",
"return",
"machine",
"passwords",
":",
"type",
"credentials",
":",
":",
"py",
":",
"class",
":",
"bool",
"Fetch",
"the",
"existing",
"st... | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L211-L226 | train | Refresh the state of the object. |
atl/py-smartdc | smartdc/machine.py | Machine.credentials | def credentials(self):
"""
::
GET /:login/machines/:id?credentials=True
:Returns: known login-password pairs for the machine
:rtype: :py:class:`dict`
Provisionally re-fetch the machine information with the credentials
flag enabled.
... | python | def credentials(self):
"""
::
GET /:login/machines/:id?credentials=True
:Returns: known login-password pairs for the machine
:rtype: :py:class:`dict`
Provisionally re-fetch the machine information with the credentials
flag enabled.
... | [
"def",
"credentials",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_credentials",
":",
"self",
".",
"refresh",
"(",
"credentials",
"=",
"True",
")",
"return",
"self",
".",
"_credentials"
] | ::
GET /:login/machines/:id?credentials=True
:Returns: known login-password pairs for the machine
:rtype: :py:class:`dict`
Provisionally re-fetch the machine information with the credentials
flag enabled. | [
"::",
"GET",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id?credentials",
"=",
"True",
":",
"Returns",
":",
"known",
"login",
"-",
"password",
"pairs",
"for",
"the",
"machine",
":",
"rtype",
":",
":",
"py",
":",
"class",
":",
"dict",
"Provisionally"... | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L228-L242 | train | Returns the known login - password pairs for the machine. |
atl/py-smartdc | smartdc/machine.py | Machine.stop | def stop(self):
"""
::
POST /:login/machines/:id?action=stop
Initiate shutdown of the remote machine.
"""
action = {'action': 'stop'}
j, r = self.datacenter.request('POST', self.path, params=action)
r.raise_for_status() | python | def stop(self):
"""
::
POST /:login/machines/:id?action=stop
Initiate shutdown of the remote machine.
"""
action = {'action': 'stop'}
j, r = self.datacenter.request('POST', self.path, params=action)
r.raise_for_status() | [
"def",
"stop",
"(",
"self",
")",
":",
"action",
"=",
"{",
"'action'",
":",
"'stop'",
"}",
"j",
",",
"r",
"=",
"self",
".",
"datacenter",
".",
"request",
"(",
"'POST'",
",",
"self",
".",
"path",
",",
"params",
"=",
"action",
")",
"r",
".",
"raise_... | ::
POST /:login/machines/:id?action=stop
Initiate shutdown of the remote machine. | [
"::",
"POST",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id?action",
"=",
"stop",
"Initiate",
"shutdown",
"of",
"the",
"remote",
"machine",
"."
] | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L259-L269 | train | Stop the remote machine. |
atl/py-smartdc | smartdc/machine.py | Machine.resize | def resize(self, package):
"""
::
POST /:login/machines/:id?action=resize
Initiate resizing of the remote machine to a new package.
"""
if isinstance(package, dict):
package = package['name']
action = {'action': 'resize',
... | python | def resize(self, package):
"""
::
POST /:login/machines/:id?action=resize
Initiate resizing of the remote machine to a new package.
"""
if isinstance(package, dict):
package = package['name']
action = {'action': 'resize',
... | [
"def",
"resize",
"(",
"self",
",",
"package",
")",
":",
"if",
"isinstance",
"(",
"package",
",",
"dict",
")",
":",
"package",
"=",
"package",
"[",
"'name'",
"]",
"action",
"=",
"{",
"'action'",
":",
"'resize'",
",",
"'package'",
":",
"package",
"}",
... | ::
POST /:login/machines/:id?action=resize
Initiate resizing of the remote machine to a new package. | [
"::",
"POST",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id?action",
"=",
"resize",
"Initiate",
"resizing",
"of",
"the",
"remote",
"machine",
"to",
"a",
"new",
"package",
"."
] | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L295-L308 | train | This method resizes the remote machine to a new package. |
atl/py-smartdc | smartdc/machine.py | Machine.delete | def delete(self):
"""
::
DELETE /:login/machines/:id
Initiate deletion of a stopped remote machine.
"""
j, r = self.datacenter.request('DELETE', self.path)
r.raise_for_status() | python | def delete(self):
"""
::
DELETE /:login/machines/:id
Initiate deletion of a stopped remote machine.
"""
j, r = self.datacenter.request('DELETE', self.path)
r.raise_for_status() | [
"def",
"delete",
"(",
"self",
")",
":",
"j",
",",
"r",
"=",
"self",
".",
"datacenter",
".",
"request",
"(",
"'DELETE'",
",",
"self",
".",
"path",
")",
"r",
".",
"raise_for_status",
"(",
")"
] | ::
DELETE /:login/machines/:id
Initiate deletion of a stopped remote machine. | [
"::",
"DELETE",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
"Initiate",
"deletion",
"of",
"a",
"stopped",
"remote",
"machine",
"."
] | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L310-L319 | train | Delete a stopped remote machine. |
atl/py-smartdc | smartdc/machine.py | Machine.poll_until | def poll_until(self, state, interval=2):
"""
::
GET /:login/machines/:id
:param state: target state
:type state: :py:class:`basestring`
:param interval: pause in seconds between polls
:type interval: :py:class:`int`
... | python | def poll_until(self, state, interval=2):
"""
::
GET /:login/machines/:id
:param state: target state
:type state: :py:class:`basestring`
:param interval: pause in seconds between polls
:type interval: :py:class:`int`
... | [
"def",
"poll_until",
"(",
"self",
",",
"state",
",",
"interval",
"=",
"2",
")",
":",
"while",
"self",
".",
"status",
"(",
")",
"!=",
"state",
":",
"time",
".",
"sleep",
"(",
"interval",
")"
] | ::
GET /:login/machines/:id
:param state: target state
:type state: :py:class:`basestring`
:param interval: pause in seconds between polls
:type interval: :py:class:`int`
Convenience method that continuously polls the current state ... | [
"::",
"GET",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
":",
"param",
"state",
":",
"target",
"state",
":",
"type",
"state",
":",
":",
"py",
":",
"class",
":",
"basestring",
":",
"param",
"interval",
":",
"pause",
"in",
"seconds",
"between",... | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L321-L342 | train | This method is used to poll the current state of the object remotely until the named state is reached. |
atl/py-smartdc | smartdc/machine.py | Machine.poll_while | def poll_while(self, state, interval=2):
"""
::
GET /:login/machines/:id
:param state: (assumed) current state
:type state: :py:class:`basestring`
:param interval: pause in seconds between polls
:type interval: :py:class:`int`
... | python | def poll_while(self, state, interval=2):
"""
::
GET /:login/machines/:id
:param state: (assumed) current state
:type state: :py:class:`basestring`
:param interval: pause in seconds between polls
:type interval: :py:class:`int`
... | [
"def",
"poll_while",
"(",
"self",
",",
"state",
",",
"interval",
"=",
"2",
")",
":",
"while",
"self",
".",
"status",
"(",
")",
"==",
"state",
":",
"time",
".",
"sleep",
"(",
"interval",
")"
] | ::
GET /:login/machines/:id
:param state: (assumed) current state
:type state: :py:class:`basestring`
:param interval: pause in seconds between polls
:type interval: :py:class:`int`
Convenience method that continuously polls the cur... | [
"::",
"GET",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
":",
"param",
"state",
":",
"(",
"assumed",
")",
"current",
"state",
":",
"type",
"state",
":",
":",
"py",
":",
"class",
":",
"basestring",
":",
"param",
"interval",
":",
"pause",
"in... | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L344-L365 | train | This method is used to poll the current state of the object remotely until the state changes. |
atl/py-smartdc | smartdc/machine.py | Machine.get_metadata | def get_metadata(self):
"""
::
GET /:login/machines/:id/metadata
:Returns: machine metadata
:rtype: :py:class:`dict`
Fetch and return the metadata dict for the machine. The method
refreshes the locally cached copy of the metadata ke... | python | def get_metadata(self):
"""
::
GET /:login/machines/:id/metadata
:Returns: machine metadata
:rtype: :py:class:`dict`
Fetch and return the metadata dict for the machine. The method
refreshes the locally cached copy of the metadata ke... | [
"def",
"get_metadata",
"(",
"self",
")",
":",
"j",
",",
"_",
"=",
"self",
".",
"datacenter",
".",
"request",
"(",
"'GET'",
",",
"self",
".",
"path",
"+",
"'/metadata'",
")",
"self",
".",
"metadata",
"=",
"j",
"return",
"j"
] | ::
GET /:login/machines/:id/metadata
:Returns: machine metadata
:rtype: :py:class:`dict`
Fetch and return the metadata dict for the machine. The method
refreshes the locally cached copy of the metadata kept in the
:py:attr:`metadata` attri... | [
"::",
"GET",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
"/",
"metadata",
":",
"Returns",
":",
"machine",
"metadata",
":",
"rtype",
":",
":",
"py",
":",
"class",
":",
"dict",
"Fetch",
"and",
"return",
"the",
"metadata",
"dict",
"for",
"the",
... | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L367-L382 | train | Gets the metadata for the specified machine. |
atl/py-smartdc | smartdc/machine.py | Machine.update_metadata | def update_metadata(self, **kwargs):
"""
::
POST /:login/machines/:id/metadata
:Returns: current metadata
:rtype: :py:class:`dict`
Send an metadata dict update for the machine (following dict.update()
semantics) using the keys and v... | python | def update_metadata(self, **kwargs):
"""
::
POST /:login/machines/:id/metadata
:Returns: current metadata
:rtype: :py:class:`dict`
Send an metadata dict update for the machine (following dict.update()
semantics) using the keys and v... | [
"def",
"update_metadata",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"j",
",",
"_",
"=",
"self",
".",
"datacenter",
".",
"request",
"(",
"'POST'",
",",
"self",
".",
"path",
"+",
"'/metadata'",
",",
"data",
"=",
"kwargs",
")",
"self",
".",
"met... | ::
POST /:login/machines/:id/metadata
:Returns: current metadata
:rtype: :py:class:`dict`
Send an metadata dict update for the machine (following dict.update()
semantics) using the keys and values passed in the keyword arguments.
The metho... | [
"::",
"POST",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
"/",
"metadata",
":",
"Returns",
":",
"current",
"metadata",
":",
"rtype",
":",
":",
"py",
":",
"class",
":",
"dict",
"Send",
"an",
"metadata",
"dict",
"update",
"for",
"the",
"machine... | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L384-L401 | train | Update the metadata dictionary for the current machine. |
atl/py-smartdc | smartdc/machine.py | Machine.delete_metadata_at_key | def delete_metadata_at_key(self, key):
"""
::
DELETE /:login/machines/:id/metadata/:key
:param key: identifier for matadata entry
:type key: :py:class:`basestring`
:Returns: current metadata
:rtype: :py:class:`dict`
... | python | def delete_metadata_at_key(self, key):
"""
::
DELETE /:login/machines/:id/metadata/:key
:param key: identifier for matadata entry
:type key: :py:class:`basestring`
:Returns: current metadata
:rtype: :py:class:`dict`
... | [
"def",
"delete_metadata_at_key",
"(",
"self",
",",
"key",
")",
":",
"j",
",",
"r",
"=",
"self",
".",
"datacenter",
".",
"request",
"(",
"'DELETE'",
",",
"self",
".",
"path",
"+",
"'/metadata/'",
"+",
"key",
")",
"r",
".",
"raise_for_status",
"(",
")",
... | ::
DELETE /:login/machines/:id/metadata/:key
:param key: identifier for matadata entry
:type key: :py:class:`basestring`
:Returns: current metadata
:rtype: :py:class:`dict`
Deletes the machine metadata contained at 'key'. Also expli... | [
"::",
"DELETE",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
"/",
"metadata",
"/",
":",
"key",
":",
"param",
"key",
":",
"identifier",
"for",
"matadata",
"entry",
":",
"type",
"key",
":",
":",
"py",
":",
"class",
":",
"basestring",
":",
"Ret... | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L403-L422 | train | Delete the metadata at the given key. |
atl/py-smartdc | smartdc/machine.py | Machine.set_boot_script | def set_boot_script(self, filename):
"""
::
POST /:login/machines/:id/metadata
:param filename: file path to the script to be uploaded and executed
at boot on the machine
:type filename: :py:class:`basestring`
Replace the existin... | python | def set_boot_script(self, filename):
"""
::
POST /:login/machines/:id/metadata
:param filename: file path to the script to be uploaded and executed
at boot on the machine
:type filename: :py:class:`basestring`
Replace the existin... | [
"def",
"set_boot_script",
"(",
"self",
",",
"filename",
")",
":",
"data",
"=",
"{",
"}",
"with",
"open",
"(",
"filename",
")",
"as",
"f",
":",
"data",
"[",
"'user-script'",
"]",
"=",
"f",
".",
"read",
"(",
")",
"j",
",",
"r",
"=",
"self",
".",
... | ::
POST /:login/machines/:id/metadata
:param filename: file path to the script to be uploaded and executed
at boot on the machine
:type filename: :py:class:`basestring`
Replace the existing boot script for the machine with the data in the
... | [
"::",
"POST",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
"/",
"metadata",
":",
"param",
"filename",
":",
"file",
"path",
"to",
"the",
"script",
"to",
"be",
"uploaded",
"and",
"executed",
"at",
"boot",
"on",
"the",
"machine",
":",
"type",
"fi... | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L424-L447 | train | Set the boot script for the machine. |
atl/py-smartdc | smartdc/machine.py | Machine.delete_boot_script | def delete_boot_script(self):
"""
::
DELETE /:login/machines/:id/metadata/user-script
Deletes any existing boot script on the machine.
"""
j, r = self.datacenter.request('DELETE', self.path +
'/metadata/user-script')
r.raise_... | python | def delete_boot_script(self):
"""
::
DELETE /:login/machines/:id/metadata/user-script
Deletes any existing boot script on the machine.
"""
j, r = self.datacenter.request('DELETE', self.path +
'/metadata/user-script')
r.raise_... | [
"def",
"delete_boot_script",
"(",
"self",
")",
":",
"j",
",",
"r",
"=",
"self",
".",
"datacenter",
".",
"request",
"(",
"'DELETE'",
",",
"self",
".",
"path",
"+",
"'/metadata/user-script'",
")",
"r",
".",
"raise_for_status",
"(",
")",
"self",
".",
"boot_... | ::
DELETE /:login/machines/:id/metadata/user-script
Deletes any existing boot script on the machine. | [
"::",
"DELETE",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
"/",
"metadata",
"/",
"user",
"-",
"script",
"Deletes",
"any",
"existing",
"boot",
"script",
"on",
"the",
"machine",
"."
] | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L449-L460 | train | Delete the boot script on the machine. |
atl/py-smartdc | smartdc/machine.py | Machine.delete_all_metadata | def delete_all_metadata(self):
"""
::
DELETE /:login/machines/:id/metadata
:Returns: current metadata
:rtype: empty :py:class:`dict`
Deletes all the metadata stored for this machine. Also explicitly
requests and returns the machine ... | python | def delete_all_metadata(self):
"""
::
DELETE /:login/machines/:id/metadata
:Returns: current metadata
:rtype: empty :py:class:`dict`
Deletes all the metadata stored for this machine. Also explicitly
requests and returns the machine ... | [
"def",
"delete_all_metadata",
"(",
"self",
")",
":",
"j",
",",
"r",
"=",
"self",
".",
"datacenter",
".",
"request",
"(",
"'DELETE'",
",",
"self",
".",
"path",
"+",
"'/metadata'",
")",
"r",
".",
"raise_for_status",
"(",
")",
"return",
"self",
".",
"get_... | ::
DELETE /:login/machines/:id/metadata
:Returns: current metadata
:rtype: empty :py:class:`dict`
Deletes all the metadata stored for this machine. Also explicitly
requests and returns the machine metadata so that the local copy stays
sync... | [
"::",
"DELETE",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
"/",
"metadata",
":",
"Returns",
":",
"current",
"metadata",
":",
"rtype",
":",
"empty",
":",
"py",
":",
"class",
":",
"dict",
"Deletes",
"all",
"the",
"metadata",
"stored",
"for",
"... | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L462-L477 | train | A method to delete all the metadata stored for this machine. |
atl/py-smartdc | smartdc/machine.py | Machine.get_tags | def get_tags(self):
"""
::
GET /:login/machines/:id/tags
:Returns: complete set of tags for this machine
:rtype: :py:class:`dict`
A local copy is not kept because these are essentially search keys.
"""
j, _ = self.datacenter... | python | def get_tags(self):
"""
::
GET /:login/machines/:id/tags
:Returns: complete set of tags for this machine
:rtype: :py:class:`dict`
A local copy is not kept because these are essentially search keys.
"""
j, _ = self.datacenter... | [
"def",
"get_tags",
"(",
"self",
")",
":",
"j",
",",
"_",
"=",
"self",
".",
"datacenter",
".",
"request",
"(",
"'GET'",
",",
"self",
".",
"path",
"+",
"'/tags'",
")",
"return",
"j"
] | ::
GET /:login/machines/:id/tags
:Returns: complete set of tags for this machine
:rtype: :py:class:`dict`
A local copy is not kept because these are essentially search keys. | [
"::",
"GET",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
"/",
"tags",
":",
"Returns",
":",
"complete",
"set",
"of",
"tags",
"for",
"this",
"machine",
":",
"rtype",
":",
":",
"py",
":",
"class",
":",
"dict",
"A",
"local",
"copy",
"is",
"no... | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L479-L491 | train | Returns a complete set of tags for this machine. |
atl/py-smartdc | smartdc/machine.py | Machine.add_tags | def add_tags(self, **kwargs):
"""
::
POST /:login/machines/:id/tags
Appends the tags (expressed as arbitrary keyword arguments) to those
already set for the machine.
"""
j, _ = self.datacenter.request('POST', self.path + '/tags',
... | python | def add_tags(self, **kwargs):
"""
::
POST /:login/machines/:id/tags
Appends the tags (expressed as arbitrary keyword arguments) to those
already set for the machine.
"""
j, _ = self.datacenter.request('POST', self.path + '/tags',
... | [
"def",
"add_tags",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"j",
",",
"_",
"=",
"self",
".",
"datacenter",
".",
"request",
"(",
"'POST'",
",",
"self",
".",
"path",
"+",
"'/tags'",
",",
"data",
"=",
"kwargs",
")",
"return",
"j"
] | ::
POST /:login/machines/:id/tags
Appends the tags (expressed as arbitrary keyword arguments) to those
already set for the machine. | [
"::",
"POST",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
"/",
"tags",
"Appends",
"the",
"tags",
"(",
"expressed",
"as",
"arbitrary",
"keyword",
"arguments",
")",
"to",
"those",
"already",
"set",
"for",
"the",
"machine",
"."
] | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L493-L504 | train | Adds tags to the set of those products for this machine. |
atl/py-smartdc | smartdc/machine.py | Machine.get_tag | def get_tag(self, tag):
"""
::
GET /:login/machines/:id/tags/:tag
:Returns: the value for a single tag
:rtype: :py:class:`basestring`
"""
headers = {'Accept': 'text/plain'}
j, _ = self.datacenter.request('GET', self.path + '/tags/' + ... | python | def get_tag(self, tag):
"""
::
GET /:login/machines/:id/tags/:tag
:Returns: the value for a single tag
:rtype: :py:class:`basestring`
"""
headers = {'Accept': 'text/plain'}
j, _ = self.datacenter.request('GET', self.path + '/tags/' + ... | [
"def",
"get_tag",
"(",
"self",
",",
"tag",
")",
":",
"headers",
"=",
"{",
"'Accept'",
":",
"'text/plain'",
"}",
"j",
",",
"_",
"=",
"self",
".",
"datacenter",
".",
"request",
"(",
"'GET'",
",",
"self",
".",
"path",
"+",
"'/tags/'",
"+",
"tag",
")",... | ::
GET /:login/machines/:id/tags/:tag
:Returns: the value for a single tag
:rtype: :py:class:`basestring` | [
"::",
"GET",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
"/",
"tags",
"/",
":",
"tag",
":",
"Returns",
":",
"the",
"value",
"for",
"a",
"single",
"tag",
":",
"rtype",
":",
":",
"py",
":",
"class",
":",
"basestring"
] | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L506-L517 | train | Gets the value for a single tag |
atl/py-smartdc | smartdc/machine.py | Machine.delete_tag | def delete_tag(self, tag):
"""
::
DELETE /:login/machines/:id/tags/:tag
Delete a tag and its corresponding value on the machine.
"""
j, r = self.datacenter.request('DELETE', self.path + '/tags/' + tag)
r.raise_for_status() | python | def delete_tag(self, tag):
"""
::
DELETE /:login/machines/:id/tags/:tag
Delete a tag and its corresponding value on the machine.
"""
j, r = self.datacenter.request('DELETE', self.path + '/tags/' + tag)
r.raise_for_status() | [
"def",
"delete_tag",
"(",
"self",
",",
"tag",
")",
":",
"j",
",",
"r",
"=",
"self",
".",
"datacenter",
".",
"request",
"(",
"'DELETE'",
",",
"self",
".",
"path",
"+",
"'/tags/'",
"+",
"tag",
")",
"r",
".",
"raise_for_status",
"(",
")"
] | ::
DELETE /:login/machines/:id/tags/:tag
Delete a tag and its corresponding value on the machine. | [
"::",
"DELETE",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
"/",
"tags",
"/",
":",
"tag",
"Delete",
"a",
"tag",
"and",
"its",
"corresponding",
"value",
"on",
"the",
"machine",
"."
] | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L519-L528 | train | Delete a tag and its corresponding value on the machine. |
atl/py-smartdc | smartdc/machine.py | Machine.delete_all_tags | def delete_all_tags(self):
"""
::
DELETE /:login/machines/:id/tags
Delete all tags and their corresponding values on the machine.
"""
j, r = self.datacenter.request('DELETE', self.path + '/tags')
r.raise_for_status() | python | def delete_all_tags(self):
"""
::
DELETE /:login/machines/:id/tags
Delete all tags and their corresponding values on the machine.
"""
j, r = self.datacenter.request('DELETE', self.path + '/tags')
r.raise_for_status() | [
"def",
"delete_all_tags",
"(",
"self",
")",
":",
"j",
",",
"r",
"=",
"self",
".",
"datacenter",
".",
"request",
"(",
"'DELETE'",
",",
"self",
".",
"path",
"+",
"'/tags'",
")",
"r",
".",
"raise_for_status",
"(",
")"
] | ::
DELETE /:login/machines/:id/tags
Delete all tags and their corresponding values on the machine. | [
"::",
"DELETE",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
"/",
"tags",
"Delete",
"all",
"tags",
"and",
"their",
"corresponding",
"values",
"on",
"the",
"machine",
"."
] | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L530-L539 | train | Delete all tags on the machine. |
atl/py-smartdc | smartdc/machine.py | Machine.raw_snapshot_data | def raw_snapshot_data(self, name):
"""
::
GET /:login/machines/:id/snapshots/:name
:param name: identifier for snapshot
:type name: :py:class:`basestring`
:rtype: :py:class:`dict`
Used internally to get a raw dict of a singl... | python | def raw_snapshot_data(self, name):
"""
::
GET /:login/machines/:id/snapshots/:name
:param name: identifier for snapshot
:type name: :py:class:`basestring`
:rtype: :py:class:`dict`
Used internally to get a raw dict of a singl... | [
"def",
"raw_snapshot_data",
"(",
"self",
",",
"name",
")",
":",
"j",
",",
"_",
"=",
"self",
".",
"datacenter",
".",
"request",
"(",
"'GET'",
",",
"self",
".",
"path",
"+",
"'/snapshots/'",
"+",
"str",
"(",
"name",
")",
")",
"return",
"j"
] | ::
GET /:login/machines/:id/snapshots/:name
:param name: identifier for snapshot
:type name: :py:class:`basestring`
:rtype: :py:class:`dict`
Used internally to get a raw dict of a single machine snapshot. | [
"::",
"GET",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
"/",
"snapshots",
"/",
":",
"name",
":",
"param",
"name",
":",
"identifier",
"for",
"snapshot",
":",
"type",
"name",
":",
":",
"py",
":",
"class",
":",
"basestring",
":",
"rtype",
":"... | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L541-L556 | train | Get the raw data for a single snapshot. |
atl/py-smartdc | smartdc/machine.py | Machine.snapshots | def snapshots(self):
"""
::
GET /:login/machines/:id/snapshots
:rtype: :py:class:`list` of :py:class:`smartdc.machine.Snapshot`
Lists all snapshots for the Machine.
"""
j, _ = self.datacenter.request('GET', self.path + '/snapshots')
... | python | def snapshots(self):
"""
::
GET /:login/machines/:id/snapshots
:rtype: :py:class:`list` of :py:class:`smartdc.machine.Snapshot`
Lists all snapshots for the Machine.
"""
j, _ = self.datacenter.request('GET', self.path + '/snapshots')
... | [
"def",
"snapshots",
"(",
"self",
")",
":",
"j",
",",
"_",
"=",
"self",
".",
"datacenter",
".",
"request",
"(",
"'GET'",
",",
"self",
".",
"path",
"+",
"'/snapshots'",
")",
"return",
"[",
"Snapshot",
"(",
"machine",
"=",
"self",
",",
"data",
"=",
"s... | ::
GET /:login/machines/:id/snapshots
:rtype: :py:class:`list` of :py:class:`smartdc.machine.Snapshot`
Lists all snapshots for the Machine. | [
"::",
"GET",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
"/",
"snapshots",
":",
"rtype",
":",
":",
"py",
":",
"class",
":",
"list",
"of",
":",
"py",
":",
"class",
":",
"smartdc",
".",
"machine",
".",
"Snapshot",
"Lists",
"all",
"snapshots",... | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L558-L569 | train | Gets all snapshots for the Machine. |
atl/py-smartdc | smartdc/machine.py | Machine.create_snapshot | def create_snapshot(self, name):
"""
::
POST /:login/machines/:id/snapshots
:param name: identifier for snapshot
:type name: :py:class:`basestring`
:rtype: :py:class:`smartdc.machine.Snapshot`
Create a snapshot for this mach... | python | def create_snapshot(self, name):
"""
::
POST /:login/machines/:id/snapshots
:param name: identifier for snapshot
:type name: :py:class:`basestring`
:rtype: :py:class:`smartdc.machine.Snapshot`
Create a snapshot for this mach... | [
"def",
"create_snapshot",
"(",
"self",
",",
"name",
")",
":",
"params",
"=",
"{",
"'name'",
":",
"name",
"}",
"j",
",",
"_",
"=",
"self",
".",
"datacenter",
".",
"request",
"(",
"'POST'",
",",
"self",
".",
"path",
"+",
"'/snapshots'",
",",
"data",
... | ::
POST /:login/machines/:id/snapshots
:param name: identifier for snapshot
:type name: :py:class:`basestring`
:rtype: :py:class:`smartdc.machine.Snapshot`
Create a snapshot for this machine's current state with the given
`name`. | [
"::",
"POST",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
"/",
"snapshots",
":",
"param",
"name",
":",
"identifier",
"for",
"snapshot",
":",
"type",
"name",
":",
":",
"py",
":",
"class",
":",
"basestring",
":",
"rtype",
":",
":",
"py",
":",... | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L571-L588 | train | Creates a snapshot for this machine s current state with the given name. |
atl/py-smartdc | smartdc/machine.py | Machine.start_from_snapshot | def start_from_snapshot(self, name):
"""
::
POST /:login/machines/:id/snapshots/:name
:param name: identifier for snapshot
:type name: :py:class:`basestring`
Start the machine from the snapshot with the given 'name'.
"""
_, r... | python | def start_from_snapshot(self, name):
"""
::
POST /:login/machines/:id/snapshots/:name
:param name: identifier for snapshot
:type name: :py:class:`basestring`
Start the machine from the snapshot with the given 'name'.
"""
_, r... | [
"def",
"start_from_snapshot",
"(",
"self",
",",
"name",
")",
":",
"_",
",",
"r",
"=",
"self",
".",
"datacenter",
".",
"request",
"(",
"'POST'",
",",
"self",
".",
"path",
"+",
"'/snapshots/'",
"+",
"str",
"(",
"name",
")",
")",
"r",
".",
"raise_for_st... | ::
POST /:login/machines/:id/snapshots/:name
:param name: identifier for snapshot
:type name: :py:class:`basestring`
Start the machine from the snapshot with the given 'name'. | [
"::",
"POST",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
"/",
"snapshots",
"/",
":",
"name",
":",
"param",
"name",
":",
"identifier",
"for",
"snapshot",
":",
"type",
"name",
":",
":",
"py",
":",
"class",
":",
"basestring",
"Start",
"the",
... | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L590-L604 | train | Start a new machine from a snapshot. |
atl/py-smartdc | smartdc/machine.py | Snapshot._save | def _save(self, data):
"""
Take the data from a dict and commit them to appropriate attributes.
"""
self.state = data.get('state')
self.created = dt_time(data.get('created'))
self.updated = dt_time(data.get('updated')) | python | def _save(self, data):
"""
Take the data from a dict and commit them to appropriate attributes.
"""
self.state = data.get('state')
self.created = dt_time(data.get('created'))
self.updated = dt_time(data.get('updated')) | [
"def",
"_save",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"state",
"=",
"data",
".",
"get",
"(",
"'state'",
")",
"self",
".",
"created",
"=",
"dt_time",
"(",
"data",
".",
"get",
"(",
"'created'",
")",
")",
"self",
".",
"updated",
"=",
"dt_... | Take the data from a dict and commit them to appropriate attributes. | [
"Take",
"the",
"data",
"from",
"a",
"dict",
"and",
"commit",
"them",
"to",
"appropriate",
"attributes",
"."
] | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L681-L687 | train | Save the data from a dict and commit them to appropriate attributes. |
atl/py-smartdc | smartdc/machine.py | Snapshot.refresh | def refresh(self):
"""
::
GET /:login/machines/:id/snapshots/:name
Fetch the existing state and values for the snapshot
and commit the values locally.
"""
data = self.machine.raw_snapshot_data(self.name)
self._save(data) | python | def refresh(self):
"""
::
GET /:login/machines/:id/snapshots/:name
Fetch the existing state and values for the snapshot
and commit the values locally.
"""
data = self.machine.raw_snapshot_data(self.name)
self._save(data) | [
"def",
"refresh",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"machine",
".",
"raw_snapshot_data",
"(",
"self",
".",
"name",
")",
"self",
".",
"_save",
"(",
"data",
")"
] | ::
GET /:login/machines/:id/snapshots/:name
Fetch the existing state and values for the snapshot
and commit the values locally. | [
"::",
"GET",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
"/",
"snapshots",
"/",
":",
"name",
"Fetch",
"the",
"existing",
"state",
"and",
"values",
"for",
"the",
"snapshot",
"and",
"commit",
"the",
"values",
"locally",
"."
] | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L697-L707 | train | Refreshes the state of the object. |
atl/py-smartdc | smartdc/machine.py | Snapshot.delete | def delete(self):
"""
::
DELETE /:login/machines/:id/snapshots/:name
Deletes the snapshot from the machine.
"""
_, r = self.machine.datacenter.request('DELETE', self.path)
r.raise_for_status() | python | def delete(self):
"""
::
DELETE /:login/machines/:id/snapshots/:name
Deletes the snapshot from the machine.
"""
_, r = self.machine.datacenter.request('DELETE', self.path)
r.raise_for_status() | [
"def",
"delete",
"(",
"self",
")",
":",
"_",
",",
"r",
"=",
"self",
".",
"machine",
".",
"datacenter",
".",
"request",
"(",
"'DELETE'",
",",
"self",
".",
"path",
")",
"r",
".",
"raise_for_status",
"(",
")"
] | ::
DELETE /:login/machines/:id/snapshots/:name
Deletes the snapshot from the machine. | [
"::",
"DELETE",
"/",
":",
"login",
"/",
"machines",
"/",
":",
"id",
"/",
"snapshots",
"/",
":",
"name",
"Deletes",
"the",
"snapshot",
"from",
"the",
"machine",
"."
] | cc5cd5910e19004cc46e376ce035affe28fc798e | https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L724-L733 | train | Deletes the snapshot from the machine. |
olitheolix/qtmacs | doc/source/code_snippets/tut_4_2.py | Worker.work | def work(self):
"""
Use a blocking <sleep> call to periodically trigger a signal.
"""
import time
for val in range(200):
time.sleep(0.1)
self.sigUpdate.emit(val + 1) | python | def work(self):
"""
Use a blocking <sleep> call to periodically trigger a signal.
"""
import time
for val in range(200):
time.sleep(0.1)
self.sigUpdate.emit(val + 1) | [
"def",
"work",
"(",
"self",
")",
":",
"import",
"time",
"for",
"val",
"in",
"range",
"(",
"200",
")",
":",
"time",
".",
"sleep",
"(",
"0.1",
")",
"self",
".",
"sigUpdate",
".",
"emit",
"(",
"val",
"+",
"1",
")"
] | Use a blocking <sleep> call to periodically trigger a signal. | [
"Use",
"a",
"blocking",
"<sleep",
">",
"call",
"to",
"periodically",
"trigger",
"a",
"signal",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/doc/source/code_snippets/tut_4_2.py#L27-L34 | train | This function is called by the daemon to periodically trigger a signal. |
a1ezzz/wasp-general | wasp_general/network/transport.py | WNetworkNativeTransport.target_socket | def target_socket(self, config):
""" :meth:`.WNetworkNativeTransportProto.server_socket` method implementation
"""
address = config[self.__target_socket_config.section][self.__target_socket_config.address_option]
port = config.getint(self.__target_socket_config.section, self.__target_socket_config.port_option)
... | python | def target_socket(self, config):
""" :meth:`.WNetworkNativeTransportProto.server_socket` method implementation
"""
address = config[self.__target_socket_config.section][self.__target_socket_config.address_option]
port = config.getint(self.__target_socket_config.section, self.__target_socket_config.port_option)
... | [
"def",
"target_socket",
"(",
"self",
",",
"config",
")",
":",
"address",
"=",
"config",
"[",
"self",
".",
"__target_socket_config",
".",
"section",
"]",
"[",
"self",
".",
"__target_socket_config",
".",
"address_option",
"]",
"port",
"=",
"config",
".",
"geti... | :meth:`.WNetworkNativeTransportProto.server_socket` method implementation | [
":",
"meth",
":",
".",
"WNetworkNativeTransportProto",
".",
"server_socket",
"method",
"implementation"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/transport.py#L146-L155 | train | meth :. WNetworkNativeTransportProto. server_socket method implementation
|
a1ezzz/wasp-general | wasp_general/network/transport.py | WNetworkNativeTransport.bind_socket | def bind_socket(self, config):
""" :meth:`.WNetworkNativeTransportProto.bind_socket` method implementation
"""
address = config[self.__bind_socket_config.section][self.__bind_socket_config.address_option]
port = config.getint(self.__bind_socket_config.section, self.__bind_socket_config.port_option)
return WIP... | python | def bind_socket(self, config):
""" :meth:`.WNetworkNativeTransportProto.bind_socket` method implementation
"""
address = config[self.__bind_socket_config.section][self.__bind_socket_config.address_option]
port = config.getint(self.__bind_socket_config.section, self.__bind_socket_config.port_option)
return WIP... | [
"def",
"bind_socket",
"(",
"self",
",",
"config",
")",
":",
"address",
"=",
"config",
"[",
"self",
".",
"__bind_socket_config",
".",
"section",
"]",
"[",
"self",
".",
"__bind_socket_config",
".",
"address_option",
"]",
"port",
"=",
"config",
".",
"getint",
... | :meth:`.WNetworkNativeTransportProto.bind_socket` method implementation | [
":",
"meth",
":",
".",
"WNetworkNativeTransportProto",
".",
"bind_socket",
"method",
"implementation"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/transport.py#L158-L163 | train | method implementation for WNetworkNativeTransportProto. bind_socket |
a1ezzz/wasp-general | wasp_general/network/transport.py | WNetworkNativeTransport.server_socket | def server_socket(self, config):
""" :meth:`.WNetworkNativeTransportProto.server_socket` method implementation
"""
if self.__server_socket is None:
self.__server_socket = self.create_server_socket(config)
self.__server_socket.bind(self.bind_socket(config).pair())
return self.__server_socket | python | def server_socket(self, config):
""" :meth:`.WNetworkNativeTransportProto.server_socket` method implementation
"""
if self.__server_socket is None:
self.__server_socket = self.create_server_socket(config)
self.__server_socket.bind(self.bind_socket(config).pair())
return self.__server_socket | [
"def",
"server_socket",
"(",
"self",
",",
"config",
")",
":",
"if",
"self",
".",
"__server_socket",
"is",
"None",
":",
"self",
".",
"__server_socket",
"=",
"self",
".",
"create_server_socket",
"(",
"config",
")",
"self",
".",
"__server_socket",
".",
"bind",
... | :meth:`.WNetworkNativeTransportProto.server_socket` method implementation | [
":",
"meth",
":",
".",
"WNetworkNativeTransportProto",
".",
"server_socket",
"method",
"implementation"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/transport.py#L192-L198 | train | :meth :. WNetworkNativeTransportProto. server_socket method implementation
|
a1ezzz/wasp-general | wasp_general/network/transport.py | WNetworkNativeTransport.close_server_socket | def close_server_socket(self, config, close_fd=True):
""" :meth:`.WNetworkNativeTransportProto.close_server_socket` method implementation
"""
if close_fd is True:
self.__server_socket.close()
self.__server_socket = None | python | def close_server_socket(self, config, close_fd=True):
""" :meth:`.WNetworkNativeTransportProto.close_server_socket` method implementation
"""
if close_fd is True:
self.__server_socket.close()
self.__server_socket = None | [
"def",
"close_server_socket",
"(",
"self",
",",
"config",
",",
"close_fd",
"=",
"True",
")",
":",
"if",
"close_fd",
"is",
"True",
":",
"self",
".",
"__server_socket",
".",
"close",
"(",
")",
"self",
".",
"__server_socket",
"=",
"None"
] | :meth:`.WNetworkNativeTransportProto.close_server_socket` method implementation | [
":",
"meth",
":",
".",
"WNetworkNativeTransportProto",
".",
"close_server_socket",
"method",
"implementation"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/transport.py#L201-L206 | train | method implementation of. WNetworkNativeTransportProto. close_server_socket |
a1ezzz/wasp-general | wasp_general/network/transport.py | WNetworkNativeTransport.client_socket | def client_socket(self, config):
""" :meth:`.WNetworkNativeTransportProto.client_socket` method implementation
"""
if self.__client_socket is None:
self.__client_socket = self.create_client_socket(config)
return self.__client_socket | python | def client_socket(self, config):
""" :meth:`.WNetworkNativeTransportProto.client_socket` method implementation
"""
if self.__client_socket is None:
self.__client_socket = self.create_client_socket(config)
return self.__client_socket | [
"def",
"client_socket",
"(",
"self",
",",
"config",
")",
":",
"if",
"self",
".",
"__client_socket",
"is",
"None",
":",
"self",
".",
"__client_socket",
"=",
"self",
".",
"create_client_socket",
"(",
"config",
")",
"return",
"self",
".",
"__client_socket"
] | :meth:`.WNetworkNativeTransportProto.client_socket` method implementation | [
":",
"meth",
":",
".",
"WNetworkNativeTransportProto",
".",
"client_socket",
"method",
"implementation"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/transport.py#L209-L214 | train | method implementation
. client_socket |
a1ezzz/wasp-general | wasp_general/network/transport.py | WNetworkNativeTransport.close_client_socket | def close_client_socket(self, config, close_fd=True):
""" :meth:`.WNetworkNativeTransportProto.close_client_socket` method implementation
"""
if close_fd is True:
self.__client_socket.close()
self.__client_socket = None | python | def close_client_socket(self, config, close_fd=True):
""" :meth:`.WNetworkNativeTransportProto.close_client_socket` method implementation
"""
if close_fd is True:
self.__client_socket.close()
self.__client_socket = None | [
"def",
"close_client_socket",
"(",
"self",
",",
"config",
",",
"close_fd",
"=",
"True",
")",
":",
"if",
"close_fd",
"is",
"True",
":",
"self",
".",
"__client_socket",
".",
"close",
"(",
")",
"self",
".",
"__client_socket",
"=",
"None"
] | :meth:`.WNetworkNativeTransportProto.close_client_socket` method implementation | [
":",
"meth",
":",
".",
"WNetworkNativeTransportProto",
".",
"close_client_socket",
"method",
"implementation"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/transport.py#L217-L222 | train | method implementation for closing client socket |
a1ezzz/wasp-general | wasp_general/network/transport.py | WBroadcastNetworkTransport.target_socket | def target_socket(self, config):
""" This method overrides :meth:`.WNetworkNativeTransport.target_socket` method. Do the same thing as
basic method do, but also checks that the result address is IPv4 address.
:param config: beacon configuration
:return: WIPV4SocketInfo
"""
target = WNetworkNativeTransport.... | python | def target_socket(self, config):
""" This method overrides :meth:`.WNetworkNativeTransport.target_socket` method. Do the same thing as
basic method do, but also checks that the result address is IPv4 address.
:param config: beacon configuration
:return: WIPV4SocketInfo
"""
target = WNetworkNativeTransport.... | [
"def",
"target_socket",
"(",
"self",
",",
"config",
")",
":",
"target",
"=",
"WNetworkNativeTransport",
".",
"target_socket",
"(",
"self",
",",
"config",
")",
"if",
"isinstance",
"(",
"target",
".",
"address",
"(",
")",
",",
"WIPV4Address",
")",
"is",
"Fal... | This method overrides :meth:`.WNetworkNativeTransport.target_socket` method. Do the same thing as
basic method do, but also checks that the result address is IPv4 address.
:param config: beacon configuration
:return: WIPV4SocketInfo | [
"This",
"method",
"overrides",
":",
"meth",
":",
".",
"WNetworkNativeTransport",
".",
"target_socket",
"method",
".",
"Do",
"the",
"same",
"thing",
"as",
"basic",
"method",
"do",
"but",
"also",
"checks",
"that",
"the",
"result",
"address",
"is",
"IPv4",
"add... | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/transport.py#L261-L271 | train | This method overrides the method to check that the result address is IPv4 address. |
a1ezzz/wasp-general | wasp_general/network/transport.py | WBroadcastNetworkTransport.create_client_socket | def create_client_socket(self, config):
""" Create client broadcast socket
:param config: client configuration
:return: socket.socket
"""
client_socket = WUDPNetworkNativeTransport.create_client_socket(self, config)
client_socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
return client_socket | python | def create_client_socket(self, config):
""" Create client broadcast socket
:param config: client configuration
:return: socket.socket
"""
client_socket = WUDPNetworkNativeTransport.create_client_socket(self, config)
client_socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
return client_socket | [
"def",
"create_client_socket",
"(",
"self",
",",
"config",
")",
":",
"client_socket",
"=",
"WUDPNetworkNativeTransport",
".",
"create_client_socket",
"(",
"self",
",",
"config",
")",
"client_socket",
".",
"setsockopt",
"(",
"socket",
".",
"SOL_SOCKET",
",",
"socke... | Create client broadcast socket
:param config: client configuration
:return: socket.socket | [
"Create",
"client",
"broadcast",
"socket"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/transport.py#L274-L282 | train | Create client broadcast socket
= 0 |
a1ezzz/wasp-general | wasp_general/network/transport.py | WMulticastNetworkTransport.target_socket | def target_socket(self, config):
""" This method overrides :meth:`.WNetworkNativeTransport.target_socket` method. Do the same thing as
basic method do, but also checks that the result address is IPv4 multicast address.
:param config: beacon configuration
:return: WIPV4SocketInfo
"""
target = WUDPNetworkNat... | python | def target_socket(self, config):
""" This method overrides :meth:`.WNetworkNativeTransport.target_socket` method. Do the same thing as
basic method do, but also checks that the result address is IPv4 multicast address.
:param config: beacon configuration
:return: WIPV4SocketInfo
"""
target = WUDPNetworkNat... | [
"def",
"target_socket",
"(",
"self",
",",
"config",
")",
":",
"target",
"=",
"WUDPNetworkNativeTransport",
".",
"target_socket",
"(",
"self",
",",
"config",
")",
"if",
"WNetworkIPV4",
".",
"is_multicast",
"(",
"target",
".",
"address",
"(",
")",
")",
"is",
... | This method overrides :meth:`.WNetworkNativeTransport.target_socket` method. Do the same thing as
basic method do, but also checks that the result address is IPv4 multicast address.
:param config: beacon configuration
:return: WIPV4SocketInfo | [
"This",
"method",
"overrides",
":",
"meth",
":",
".",
"WNetworkNativeTransport",
".",
"target_socket",
"method",
".",
"Do",
"the",
"same",
"thing",
"as",
"basic",
"method",
"do",
"but",
"also",
"checks",
"that",
"the",
"result",
"address",
"is",
"IPv4",
"mul... | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/transport.py#L297-L307 | train | This method overrides WNetworkNativeTransport. target_socket method. |
a1ezzz/wasp-general | wasp_general/network/transport.py | WMulticastNetworkTransport.create_server_socket | def create_server_socket(self, config):
""" Create server multicast socket. Socket will be joined to the multicast-group (same as it is
specified in client configuration, same as client does)
:param config: server configuration
:return: socket.socket
"""
server_socket = WUDPNetworkNativeTransport.create_se... | python | def create_server_socket(self, config):
""" Create server multicast socket. Socket will be joined to the multicast-group (same as it is
specified in client configuration, same as client does)
:param config: server configuration
:return: socket.socket
"""
server_socket = WUDPNetworkNativeTransport.create_se... | [
"def",
"create_server_socket",
"(",
"self",
",",
"config",
")",
":",
"server_socket",
"=",
"WUDPNetworkNativeTransport",
".",
"create_server_socket",
"(",
"self",
",",
"config",
")",
"group",
"=",
"socket",
".",
"inet_aton",
"(",
"str",
"(",
"self",
".",
"targ... | Create server multicast socket. Socket will be joined to the multicast-group (same as it is
specified in client configuration, same as client does)
:param config: server configuration
:return: socket.socket | [
"Create",
"server",
"multicast",
"socket",
".",
"Socket",
"will",
"be",
"joined",
"to",
"the",
"multicast",
"-",
"group",
"(",
"same",
"as",
"it",
"is",
"specified",
"in",
"client",
"configuration",
"same",
"as",
"client",
"does",
")"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/transport.py#L310-L322 | train | Create server multicast socket. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.