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
KE-works/pykechain
pykechain/models/service.py
Service.execute
def execute(self, interactive=False): """ Execute the service. For interactive (notebook) service execution, set interactive to True, defaults to False. .. versionadded:: 1.13 :param interactive: (optional) True if the notebook service should execute in interactive mode. ...
python
def execute(self, interactive=False): """ Execute the service. For interactive (notebook) service execution, set interactive to True, defaults to False. .. versionadded:: 1.13 :param interactive: (optional) True if the notebook service should execute in interactive mode. ...
[ "def", "execute", "(", "self", ",", "interactive", "=", "False", ")", ":", "url", "=", "self", ".", "_client", ".", "_build_url", "(", "'service_execute'", ",", "service_id", "=", "self", ".", "id", ")", "response", "=", "self", ".", "_client", ".", "_...
Execute the service. For interactive (notebook) service execution, set interactive to True, defaults to False. .. versionadded:: 1.13 :param interactive: (optional) True if the notebook service should execute in interactive mode. :type interactive: bool or None :return: Servic...
[ "Execute", "the", "service", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/service.py#L51-L71
train
Execute the service.
KE-works/pykechain
pykechain/models/service.py
Service.edit
def edit(self, name=None, description=None, version=None, **kwargs): """ Edit Service details. .. versionadded:: 1.13 :param name: (optional) name of the service to change. :type name: basestring or None :param description: (optional) description of the service. ...
python
def edit(self, name=None, description=None, version=None, **kwargs): """ Edit Service details. .. versionadded:: 1.13 :param name: (optional) name of the service to change. :type name: basestring or None :param description: (optional) description of the service. ...
[ "def", "edit", "(", "self", ",", "name", "=", "None", ",", "description", "=", "None", ",", "version", "=", "None", ",", "*", "*", "kwargs", ")", ":", "update_dict", "=", "{", "'id'", ":", "self", ".", "id", "}", "if", "name", ":", "if", "not", ...
Edit Service details. .. versionadded:: 1.13 :param name: (optional) name of the service to change. :type name: basestring or None :param description: (optional) description of the service. :type description: basestring or None :param version: (optional) version number ...
[ "Edit", "Service", "details", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/service.py#L73-L115
train
Edit the details of a service.
KE-works/pykechain
pykechain/models/service.py
Service.delete
def delete(self): # type: () -> None """Delete this service. :raises APIError: if delete was not succesfull. """ response = self._client._request('DELETE', self._client._build_url('service', service_id=self.id)) if response.status_code != requests.codes.no_content: # p...
python
def delete(self): # type: () -> None """Delete this service. :raises APIError: if delete was not succesfull. """ response = self._client._request('DELETE', self._client._build_url('service', service_id=self.id)) if response.status_code != requests.codes.no_content: # p...
[ "def", "delete", "(", "self", ")", ":", "# type: () -> None", "response", "=", "self", ".", "_client", ".", "_request", "(", "'DELETE'", ",", "self", ".", "_client", ".", "_build_url", "(", "'service'", ",", "service_id", "=", "self", ".", "id", ")", ")"...
Delete this service. :raises APIError: if delete was not succesfull.
[ "Delete", "this", "service", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/service.py#L117-L126
train
Delete this service.
KE-works/pykechain
pykechain/models/service.py
Service.upload
def upload(self, pkg_path): """ Upload a python script (or kecpkg) to the service. .. versionadded:: 1.13 :param pkg_path: path to the python script or kecpkg to upload. :type pkg_path: basestring :raises APIError: if the python package could not be uploaded. :r...
python
def upload(self, pkg_path): """ Upload a python script (or kecpkg) to the service. .. versionadded:: 1.13 :param pkg_path: path to the python script or kecpkg to upload. :type pkg_path: basestring :raises APIError: if the python package could not be uploaded. :r...
[ "def", "upload", "(", "self", ",", "pkg_path", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "pkg_path", ")", ":", "self", ".", "_upload", "(", "pkg_path", "=", "pkg_path", ")", "else", ":", "raise", "OSError", "(", "\"Could not locate python pa...
Upload a python script (or kecpkg) to the service. .. versionadded:: 1.13 :param pkg_path: path to the python script or kecpkg to upload. :type pkg_path: basestring :raises APIError: if the python package could not be uploaded. :raises OSError: if the python package could not b...
[ "Upload", "a", "python", "script", "(", "or", "kecpkg", ")", "to", "the", "service", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/service.py#L128-L142
train
Uploads a python script or kecpkg to the service.
KE-works/pykechain
pykechain/models/service.py
Service.save_as
def save_as(self, target_dir=None): """ Save the kecpkg service script to an (optional) target dir. Retains the filename of the service as known in KE-chain. .. versionadded:: 1.13 :param target_dir: (optional) target dir. If not provided will save to current working directory...
python
def save_as(self, target_dir=None): """ Save the kecpkg service script to an (optional) target dir. Retains the filename of the service as known in KE-chain. .. versionadded:: 1.13 :param target_dir: (optional) target dir. If not provided will save to current working directory...
[ "def", "save_as", "(", "self", ",", "target_dir", "=", "None", ")", ":", "full_path", "=", "os", ".", "path", ".", "join", "(", "target_dir", "or", "os", ".", "getcwd", "(", ")", ",", "self", ".", "filename", ")", "url", "=", "self", ".", "_client"...
Save the kecpkg service script to an (optional) target dir. Retains the filename of the service as known in KE-chain. .. versionadded:: 1.13 :param target_dir: (optional) target dir. If not provided will save to current working directory. :type target_dir: basestring or None :...
[ "Save", "the", "kecpkg", "service", "script", "to", "an", "(", "optional", ")", "target", "dir", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/service.py#L153-L175
train
Save the service script as known in KE - chain.
KE-works/pykechain
pykechain/models/service.py
Service.get_executions
def get_executions(self, **kwargs): """ Retrieve the executions related to the current service. .. versionadded:: 1.13 :param kwargs: (optional) additional search keyword arguments to limit the search even further. :type kwargs: dict :return: list of ServiceExecutions a...
python
def get_executions(self, **kwargs): """ Retrieve the executions related to the current service. .. versionadded:: 1.13 :param kwargs: (optional) additional search keyword arguments to limit the search even further. :type kwargs: dict :return: list of ServiceExecutions a...
[ "def", "get_executions", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_client", ".", "service_executions", "(", "service", "=", "self", ".", "id", ",", "scope", "=", "self", ".", "scope_id", ",", "*", "*", "kwargs", ")" ]
Retrieve the executions related to the current service. .. versionadded:: 1.13 :param kwargs: (optional) additional search keyword arguments to limit the search even further. :type kwargs: dict :return: list of ServiceExecutions associated to the current service.
[ "Retrieve", "the", "executions", "related", "to", "the", "current", "service", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/service.py#L177-L187
train
Retrieve the executions related to the current service.
KE-works/pykechain
pykechain/models/service.py
ServiceExecution.service
def service(self): """Retrieve the `Service` object to which this execution is associated.""" if not self._service: self._service = self._client.service(id=self.service_id) return self._service
python
def service(self): """Retrieve the `Service` object to which this execution is associated.""" if not self._service: self._service = self._client.service(id=self.service_id) return self._service
[ "def", "service", "(", "self", ")", ":", "if", "not", "self", ".", "_service", ":", "self", ".", "_service", "=", "self", ".", "_client", ".", "service", "(", "id", "=", "self", ".", "service_id", ")", "return", "self", ".", "_service" ]
Retrieve the `Service` object to which this execution is associated.
[ "Retrieve", "the", "Service", "object", "to", "which", "this", "execution", "is", "associated", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/service.py#L232-L236
train
Retrieve the Service object to which this execution is associated.
KE-works/pykechain
pykechain/models/service.py
ServiceExecution.terminate
def terminate(self): """ Terminate the Service execution. .. versionadded:: 1.13 :return: None if the termination request was successful :raises APIError: When the service execution could not be terminated. """ url = self._client._build_url('service_execution_te...
python
def terminate(self): """ Terminate the Service execution. .. versionadded:: 1.13 :return: None if the termination request was successful :raises APIError: When the service execution could not be terminated. """ url = self._client._build_url('service_execution_te...
[ "def", "terminate", "(", "self", ")", ":", "url", "=", "self", ".", "_client", ".", "_build_url", "(", "'service_execution_terminate'", ",", "service_execution_id", "=", "self", ".", "id", ")", "response", "=", "self", ".", "_client", ".", "_request", "(", ...
Terminate the Service execution. .. versionadded:: 1.13 :return: None if the termination request was successful :raises APIError: When the service execution could not be terminated.
[ "Terminate", "the", "Service", "execution", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/service.py#L241-L254
train
Terminate the service execution.
KE-works/pykechain
pykechain/models/service.py
ServiceExecution.get_log
def get_log(self, target_dir=None, log_filename='log.txt'): """ Retrieve the log of the service execution. .. versionadded:: 1.13 :param target_dir: (optional) directory path name where the store the log.txt to. :type target_dir: basestring or None :param log_filename: ...
python
def get_log(self, target_dir=None, log_filename='log.txt'): """ Retrieve the log of the service execution. .. versionadded:: 1.13 :param target_dir: (optional) directory path name where the store the log.txt to. :type target_dir: basestring or None :param log_filename: ...
[ "def", "get_log", "(", "self", ",", "target_dir", "=", "None", ",", "log_filename", "=", "'log.txt'", ")", ":", "full_path", "=", "os", ".", "path", ".", "join", "(", "target_dir", "or", "os", ".", "getcwd", "(", ")", ",", "log_filename", ")", "url", ...
Retrieve the log of the service execution. .. versionadded:: 1.13 :param target_dir: (optional) directory path name where the store the log.txt to. :type target_dir: basestring or None :param log_filename: (optional) log filename to write the log to, defaults to `log.txt`. :typ...
[ "Retrieve", "the", "log", "of", "the", "service", "execution", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/service.py#L256-L278
train
Retrieve the log of the service execution.
KE-works/pykechain
pykechain/models/service.py
ServiceExecution.get_notebook_url
def get_notebook_url(self): """ Get the url of the notebook, if the notebook is executed in interactive mode. .. versionadded:: 1.13 :return: full url to the interactive running notebook as `basestring` :raises APIError: when the url cannot be retrieved. """ url...
python
def get_notebook_url(self): """ Get the url of the notebook, if the notebook is executed in interactive mode. .. versionadded:: 1.13 :return: full url to the interactive running notebook as `basestring` :raises APIError: when the url cannot be retrieved. """ url...
[ "def", "get_notebook_url", "(", "self", ")", ":", "url", "=", "self", ".", "_client", ".", "_build_url", "(", "'service_execution_notebook_url'", ",", "service_execution_id", "=", "self", ".", "id", ")", "response", "=", "self", ".", "_client", ".", "_request"...
Get the url of the notebook, if the notebook is executed in interactive mode. .. versionadded:: 1.13 :return: full url to the interactive running notebook as `basestring` :raises APIError: when the url cannot be retrieved.
[ "Get", "the", "url", "of", "the", "notebook", "if", "the", "notebook", "is", "executed", "in", "interactive", "mode", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/service.py#L280-L297
train
Get the full url of the notebook in interactive mode.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/build/lib/biosignalsnotebooks/visualise.py
_plot_future
def _plot_future(time, data, legend=None, title=None, y_axis_label=None, hor_lines=None, hor_lines_leg=None, vert_lines=None, vert_lines_leg=None, apply_opensignals_style=True, show_plot=True, warn_print=False, **kwargs): """ Plotting function intended for an easy representation ...
python
def _plot_future(time, data, legend=None, title=None, y_axis_label=None, hor_lines=None, hor_lines_leg=None, vert_lines=None, vert_lines_leg=None, apply_opensignals_style=True, show_plot=True, warn_print=False, **kwargs): """ Plotting function intended for an easy representation ...
[ "def", "_plot_future", "(", "time", ",", "data", ",", "legend", "=", "None", ",", "title", "=", "None", ",", "y_axis_label", "=", "None", ",", "hor_lines", "=", "None", ",", "hor_lines_leg", "=", "None", ",", "vert_lines", "=", "None", ",", "vert_lines_l...
Plotting function intended for an easy representation of OpenSignals acquired data. ---------- Parameters ---------- time : list or list of lists List that contains the time axis samples or a list of lists, when it is intended to present data in a gridplot format. When the input is a li...
[ "Plotting", "function", "intended", "for", "an", "easy", "representation", "of", "OpenSignals", "acquired", "data", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/visualise.py#L52-L272
train
Function that returns a list of lists that can be used to plot the future data.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/build/lib/biosignalsnotebooks/visualise.py
plot
def plot(*args, legend=None, title=None, x_axis_label="Time (s)", y_axis_label=None, grid_plot=False, grid_lines=None, grid_columns=None, hor_lines=None, hor_lines_leg=None, vert_lines=None, vert_lines_leg=None, apply_opensignals_style=True, show_plot=True, warn_print=False, get_fig_list=Fals...
python
def plot(*args, legend=None, title=None, x_axis_label="Time (s)", y_axis_label=None, grid_plot=False, grid_lines=None, grid_columns=None, hor_lines=None, hor_lines_leg=None, vert_lines=None, vert_lines_leg=None, apply_opensignals_style=True, show_plot=True, warn_print=False, get_fig_list=Fals...
[ "def", "plot", "(", "*", "args", ",", "legend", "=", "None", ",", "title", "=", "None", ",", "x_axis_label", "=", "\"Time (s)\"", ",", "y_axis_label", "=", "None", ",", "grid_plot", "=", "False", ",", "grid_lines", "=", "None", ",", "grid_columns", "=", ...
----- Brief ----- Plotting function intended for an easy representation of OpenSignals acquired data. ----------- Description ----------- This function allows to plot data acquired with resource to OpenSignals, available at https://bitalino.com/en/software, in an easy way using the Boke...
[ "-----", "Brief", "-----", "Plotting", "function", "intended", "for", "an", "easy", "representation", "of", "OpenSignals", "acquired", "data", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/visualise.py#L275-L660
train
A basic function that can be used to plot data acquired with OpenSignals.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/build/lib/biosignalsnotebooks/visualise.py
opensignals_style
def opensignals_style(figure_list, grid_plot=None, toolbar="right"): """ ----- Brief ----- Function used to automatically apply the OpenSignals graphical style to Bokeh plots. ----------- Description ----------- OpenSignals has its own graphical style and Bokeh plots function in an ...
python
def opensignals_style(figure_list, grid_plot=None, toolbar="right"): """ ----- Brief ----- Function used to automatically apply the OpenSignals graphical style to Bokeh plots. ----------- Description ----------- OpenSignals has its own graphical style and Bokeh plots function in an ...
[ "def", "opensignals_style", "(", "figure_list", ",", "grid_plot", "=", "None", ",", "toolbar", "=", "\"right\"", ")", ":", "for", "fig", "in", "figure_list", ":", "fig", ".", "background_fill_color", "=", "(", "242", ",", "242", ",", "242", ")", "fig", "...
----- Brief ----- Function used to automatically apply the OpenSignals graphical style to Bokeh plots. ----------- Description ----------- OpenSignals has its own graphical style and Bokeh plots function in an object oriented way. This function allows to apply the Opensignals graphical...
[ "-----", "Brief", "-----", "Function", "used", "to", "automatically", "apply", "the", "OpenSignals", "graphical", "style", "to", "Bokeh", "plots", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/visualise.py#L663-L735
train
This function applies the Opensignals graphical style to a set of figures and grid plots.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/build/lib/biosignalsnotebooks/visualise.py
opensignals_kwargs
def opensignals_kwargs(obj): """ ----- Brief ----- Function used to automatically apply the OpenSignals graphical style to the toolbar of Bokeh grid plots. ----------- Description ----------- Bokeh grid plots have numerous options in order to personalise the visual aspect and functi...
python
def opensignals_kwargs(obj): """ ----- Brief ----- Function used to automatically apply the OpenSignals graphical style to the toolbar of Bokeh grid plots. ----------- Description ----------- Bokeh grid plots have numerous options in order to personalise the visual aspect and functi...
[ "def", "opensignals_kwargs", "(", "obj", ")", ":", "out", "=", "None", "if", "obj", "==", "\"figure\"", ":", "out", "=", "{", "}", "elif", "obj", "==", "\"gridplot\"", ":", "out", "=", "{", "\"toolbar_options\"", ":", "{", "\"logo\"", ":", "None", "}",...
----- Brief ----- Function used to automatically apply the OpenSignals graphical style to the toolbar of Bokeh grid plots. ----------- Description ----------- Bokeh grid plots have numerous options in order to personalise the visual aspect and functionalities of plots. OpenSignals uses ...
[ "-----", "Brief", "-----", "Function", "used", "to", "automatically", "apply", "the", "OpenSignals", "graphical", "style", "to", "the", "toolbar", "of", "Bokeh", "grid", "plots", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/visualise.py#L762-L799
train
Returns a dictionary with keyword arguments for OpenSignals graphical style.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/build/lib/biosignalsnotebooks/visualise.py
_check_validity_of_inputs
def _check_validity_of_inputs(data, input_arg, input_name, grid_plot, dimension): """ Function that verifies when an input ('input_arg') of function 'plot' has a valid structure. ---------- Parameters ---------- data : list or list of lists Structure with the data that will be plotted. ...
python
def _check_validity_of_inputs(data, input_arg, input_name, grid_plot, dimension): """ Function that verifies when an input ('input_arg') of function 'plot' has a valid structure. ---------- Parameters ---------- data : list or list of lists Structure with the data that will be plotted. ...
[ "def", "_check_validity_of_inputs", "(", "data", ",", "input_arg", ",", "input_name", ",", "grid_plot", ",", "dimension", ")", ":", "if", "input_arg", "is", "not", "None", ":", "if", "grid_plot", "is", "True", ":", "if", "isinstance", "(", "input_arg", ",", ...
Function that verifies when an input ('input_arg') of function 'plot' has a valid structure. ---------- Parameters ---------- data : list or list of lists Structure with the data that will be plotted. input_arg : list or list of lists The input data to be verified. input_name ...
[ "Function", "that", "verifies", "when", "an", "input", "(", "input_arg", ")", "of", "function", "plot", "has", "a", "valid", "structure", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/visualise.py#L807-L852
train
Function that verifies that an input of function plot has a valid structure.
pdxjohnny/SimpleHTTPSServer
SimpleHTTPSServer/SimpleWebSocketServer.py
WebSocket.sendFragmentStart
def sendFragmentStart(self, data): """ Send the start of a data fragment stream to a websocket client. Subsequent data should be sent using sendFragment(). A fragment stream is completed when sendFragmentEnd() is called. If data is a unicode object then the frame is ...
python
def sendFragmentStart(self, data): """ Send the start of a data fragment stream to a websocket client. Subsequent data should be sent using sendFragment(). A fragment stream is completed when sendFragmentEnd() is called. If data is a unicode object then the frame is ...
[ "def", "sendFragmentStart", "(", "self", ",", "data", ")", ":", "opcode", "=", "BINARY", "if", "isinstance", "(", "data", ",", "unicode", ")", ":", "opcode", "=", "TEXT", "self", ".", "_sendMessage", "(", "True", ",", "opcode", ",", "data", ")" ]
Send the start of a data fragment stream to a websocket client. Subsequent data should be sent using sendFragment(). A fragment stream is completed when sendFragmentEnd() is called. If data is a unicode object then the frame is sent as Text. If the data is a bytearray objec...
[ "Send", "the", "start", "of", "a", "data", "fragment", "stream", "to", "a", "websocket", "client", ".", "Subsequent", "data", "should", "be", "sent", "using", "sendFragment", "()", ".", "A", "fragment", "stream", "is", "completed", "when", "sendFragmentEnd", ...
5ba0490e1c15541287f89abedfdcd2ff70ad1e88
https://github.com/pdxjohnny/SimpleHTTPSServer/blob/5ba0490e1c15541287f89abedfdcd2ff70ad1e88/SimpleHTTPSServer/SimpleWebSocketServer.py#L311-L323
train
Send the start of a data fragment stream.
pdxjohnny/SimpleHTTPSServer
SimpleHTTPSServer/SimpleWebSocketServer.py
WebSocket.sendMessage
def sendMessage(self, data): """ Send websocket data frame to the client. If data is a unicode object then the frame is sent as Text. If the data is a bytearray object then the frame is sent as Binary. """ opcode = BINARY if isinstance(data, unicode): ...
python
def sendMessage(self, data): """ Send websocket data frame to the client. If data is a unicode object then the frame is sent as Text. If the data is a bytearray object then the frame is sent as Binary. """ opcode = BINARY if isinstance(data, unicode): ...
[ "def", "sendMessage", "(", "self", ",", "data", ")", ":", "opcode", "=", "BINARY", "if", "isinstance", "(", "data", ",", "unicode", ")", ":", "opcode", "=", "TEXT", "self", ".", "_sendMessage", "(", "False", ",", "opcode", ",", "data", ")" ]
Send websocket data frame to the client. If data is a unicode object then the frame is sent as Text. If the data is a bytearray object then the frame is sent as Binary.
[ "Send", "websocket", "data", "frame", "to", "the", "client", ".", "If", "data", "is", "a", "unicode", "object", "then", "the", "frame", "is", "sent", "as", "Text", ".", "If", "the", "data", "is", "a", "bytearray", "object", "then", "the", "frame", "is"...
5ba0490e1c15541287f89abedfdcd2ff70ad1e88
https://github.com/pdxjohnny/SimpleHTTPSServer/blob/5ba0490e1c15541287f89abedfdcd2ff70ad1e88/SimpleHTTPSServer/SimpleWebSocketServer.py#L343-L353
train
Send a message to the client.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/biosignalsnotebooks/synchronisation.py
synchronise_signals
def synchronise_signals(in_signal_1, in_signal_2): """ ----- Brief ----- This function synchronises the input signals using the full cross correlation function between the signals. ----------- Description ----------- Signals acquired with two devices may be dephased. It is possible ...
python
def synchronise_signals(in_signal_1, in_signal_2): """ ----- Brief ----- This function synchronises the input signals using the full cross correlation function between the signals. ----------- Description ----------- Signals acquired with two devices may be dephased. It is possible ...
[ "def", "synchronise_signals", "(", "in_signal_1", ",", "in_signal_2", ")", ":", "mean_1", ",", "std_1", ",", "mean_2", ",", "std_2", "=", "[", "np", ".", "mean", "(", "in_signal_1", ")", ",", "np", ".", "std", "(", "in_signal_1", ")", ",", "np", ".", ...
----- Brief ----- This function synchronises the input signals using the full cross correlation function between the signals. ----------- Description ----------- Signals acquired with two devices may be dephased. It is possible to synchronise the two signals by multiple methods. Here, i...
[ "-----", "Brief", "-----", "This", "function", "synchronises", "the", "input", "signals", "using", "the", "full", "cross", "correlation", "function", "between", "the", "signals", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/biosignalsnotebooks/synchronisation.py#L52-L125
train
This function synchronises two signals and returns the dephasing between them.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/biosignalsnotebooks/synchronisation.py
generate_sync_txt_file
def generate_sync_txt_file(in_path, channels=("CH1", "CH1"), new_path='sync_file.txt'): """ ----- Brief ----- This function allows to generate a text file with synchronised signals from the input file(s). ----------- Description ----------- OpenSignals files follow a specific struct...
python
def generate_sync_txt_file(in_path, channels=("CH1", "CH1"), new_path='sync_file.txt'): """ ----- Brief ----- This function allows to generate a text file with synchronised signals from the input file(s). ----------- Description ----------- OpenSignals files follow a specific struct...
[ "def", "generate_sync_txt_file", "(", "in_path", ",", "channels", "=", "(", "\"CH1\"", ",", "\"CH1\"", ")", ",", "new_path", "=", "'sync_file.txt'", ")", ":", "if", "type", "(", "in_path", ")", "is", "str", ":", "_create_txt_from_str", "(", "in_path", ",", ...
----- Brief ----- This function allows to generate a text file with synchronised signals from the input file(s). ----------- Description ----------- OpenSignals files follow a specific structure that allows to analyse all files in the same way. Furthermore, it allows those files to be o...
[ "-----", "Brief", "-----", "This", "function", "allows", "to", "generate", "a", "text", "file", "with", "synchronised", "signals", "from", "the", "input", "file", "(", "s", ")", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/biosignalsnotebooks/synchronisation.py#L128-L160
train
This function generates a sync. txt file from the input file.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/biosignalsnotebooks/synchronisation.py
generate_sync_h5_file
def generate_sync_h5_file(in_paths, channels=('channel_1', 'channel_1'), new_path='sync_file.h5'): """ ----- Brief ----- This function allows to generate a h5 file with synchronised signals from the input file(s). ----------- Description ----------- OpenSignals files follow a specif...
python
def generate_sync_h5_file(in_paths, channels=('channel_1', 'channel_1'), new_path='sync_file.h5'): """ ----- Brief ----- This function allows to generate a h5 file with synchronised signals from the input file(s). ----------- Description ----------- OpenSignals files follow a specif...
[ "def", "generate_sync_h5_file", "(", "in_paths", ",", "channels", "=", "(", "'channel_1'", ",", "'channel_1'", ")", ",", "new_path", "=", "'sync_file.h5'", ")", ":", "if", "type", "(", "in_paths", ")", "==", "list", "or", "type", "(", "in_paths", ")", "=="...
----- Brief ----- This function allows to generate a h5 file with synchronised signals from the input file(s). ----------- Description ----------- OpenSignals files follow a specific structure that allows to analyse all files in the same way. Furthermore, it allows those files to be ope...
[ "-----", "Brief", "-----", "This", "function", "allows", "to", "generate", "a", "h5", "file", "with", "synchronised", "signals", "from", "the", "input", "file", "(", "s", ")", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/biosignalsnotebooks/synchronisation.py#L163-L269
train
This function generates a new H5 file with synchronised signals from the input files.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/biosignalsnotebooks/synchronisation.py
create_synchronised_files
def create_synchronised_files(in_path=(('file1.txt', 'file2.txt'), ('file1.h5', 'file2.h5')), channels=(1, 1), file_name='sync_file'): """ ----- Brief ----- This function creates .txt and .h5 files with synchronised signals. ----------- Description ----------- ...
python
def create_synchronised_files(in_path=(('file1.txt', 'file2.txt'), ('file1.h5', 'file2.h5')), channels=(1, 1), file_name='sync_file'): """ ----- Brief ----- This function creates .txt and .h5 files with synchronised signals. ----------- Description ----------- ...
[ "def", "create_synchronised_files", "(", "in_path", "=", "(", "(", "'file1.txt'", ",", "'file2.txt'", ")", ",", "(", "'file1.h5'", ",", "'file2.h5'", ")", ")", ",", "channels", "=", "(", "1", ",", "1", ")", ",", "file_name", "=", "'sync_file'", ")", ":",...
----- Brief ----- This function creates .txt and .h5 files with synchronised signals. ----------- Description ----------- OpenSignals software generates 3 types of files structured in specific ways. The formats are .txt, .h5 and .edf. Those files follow specific structures in order to n...
[ "-----", "Brief", "-----", "This", "function", "creates", ".", "txt", "and", ".", "h5", "files", "with", "synchronised", "signals", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/biosignalsnotebooks/synchronisation.py#L272-L307
train
This function creates the. txt and. h5 files with synchronised signals.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/biosignalsnotebooks/synchronisation.py
_shape_array
def _shape_array(array1, array2): """ Function that equalises the input arrays by zero-padding the shortest one. ---------- Parameters ---------- array1: list or numpy.array Array array2: list or numpy.array Array Return ------ arrays: numpy.array Array ...
python
def _shape_array(array1, array2): """ Function that equalises the input arrays by zero-padding the shortest one. ---------- Parameters ---------- array1: list or numpy.array Array array2: list or numpy.array Array Return ------ arrays: numpy.array Array ...
[ "def", "_shape_array", "(", "array1", ",", "array2", ")", ":", "if", "len", "(", "array1", ")", ">", "len", "(", "array2", ")", ":", "new_array", "=", "array2", "old_array", "=", "array1", "else", ":", "new_array", "=", "array1", "old_array", "=", "arr...
Function that equalises the input arrays by zero-padding the shortest one. ---------- Parameters ---------- array1: list or numpy.array Array array2: list or numpy.array Array Return ------ arrays: numpy.array Array containing the equal-length arrays.
[ "Function", "that", "equalises", "the", "input", "arrays", "by", "zero", "-", "padding", "the", "shortest", "one", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/biosignalsnotebooks/synchronisation.py#L315-L348
train
Function that equalises the input arrays by zero - padding the shortest one.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/biosignalsnotebooks/synchronisation.py
_create_h5_file_old
def _create_h5_file_old(in_paths, new_path): """ Function to create a new .h5 file that contains the copy of the contents of the input file(s). in_paths : str or list If the input is a string, it is assumed that the two signals are in the same file, else, if the input is a list, it is assum...
python
def _create_h5_file_old(in_paths, new_path): """ Function to create a new .h5 file that contains the copy of the contents of the input file(s). in_paths : str or list If the input is a string, it is assumed that the two signals are in the same file, else, if the input is a list, it is assum...
[ "def", "_create_h5_file_old", "(", "in_paths", ",", "new_path", ")", ":", "if", "type", "(", "in_paths", ")", "==", "str", ":", "in_paths", "=", "[", "in_paths", "]", "new_file", "=", "File", "(", "new_path", ",", "'w'", ")", "for", "in_path", "in", "i...
Function to create a new .h5 file that contains the copy of the contents of the input file(s). in_paths : str or list If the input is a string, it is assumed that the two signals are in the same file, else, if the input is a list, it is assumed that the two signals are in different file (the list s...
[ "Function", "to", "create", "a", "new", ".", "h5", "file", "that", "contains", "the", "copy", "of", "the", "contents", "of", "the", "input", "file", "(", "s", ")", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/biosignalsnotebooks/synchronisation.py#L351-L415
train
Function to create a new. h5 file that contains the copy of the contents of the input files.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/biosignalsnotebooks/synchronisation.py
_create_h5_file
def _create_h5_file(in_paths, new_path): """ Function to create a new .h5 file that contains the copy of the contents of the input file(s). in_paths : str or list If the input is a string, it is assumed that the two signals are in the same file, else, if the input is a list, it is assumed t...
python
def _create_h5_file(in_paths, new_path): """ Function to create a new .h5 file that contains the copy of the contents of the input file(s). in_paths : str or list If the input is a string, it is assumed that the two signals are in the same file, else, if the input is a list, it is assumed t...
[ "def", "_create_h5_file", "(", "in_paths", ",", "new_path", ")", ":", "if", "type", "(", "in_paths", ")", "==", "str", ":", "in_paths", "=", "[", "in_paths", "]", "new_file", "=", "File", "(", "new_path", ",", "'w'", ")", "for", "i", ",", "in_path", ...
Function to create a new .h5 file that contains the copy of the contents of the input file(s). in_paths : str or list If the input is a string, it is assumed that the two signals are in the same file, else, if the input is a list, it is assumed that the two signals are in different file (the list s...
[ "Function", "to", "create", "a", "new", ".", "h5", "file", "that", "contains", "the", "copy", "of", "the", "contents", "of", "the", "input", "file", "(", "s", ")", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/biosignalsnotebooks/synchronisation.py#L418-L441
train
Function to create a new. h5 file containing the copy of the contents of the input files.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/biosignalsnotebooks/synchronisation.py
_create_txt_from_str
def _create_txt_from_str(in_path, channels, new_path): """ This function allows to generate a text file with synchronised signals from the input file. ---------- Parameters ---------- in_path : str Path to the file containing the two signals that will be synchronised. channels : lis...
python
def _create_txt_from_str(in_path, channels, new_path): """ This function allows to generate a text file with synchronised signals from the input file. ---------- Parameters ---------- in_path : str Path to the file containing the two signals that will be synchronised. channels : lis...
[ "def", "_create_txt_from_str", "(", "in_path", ",", "channels", ",", "new_path", ")", ":", "header", "=", "[", "\"# OpenSignals Text File Format\"", "]", "files", "=", "[", "bsnb", ".", "load", "(", "in_path", ")", "]", "with", "open", "(", "in_path", ",", ...
This function allows to generate a text file with synchronised signals from the input file. ---------- Parameters ---------- in_path : str Path to the file containing the two signals that will be synchronised. channels : list List with the strings identifying the channels of each si...
[ "This", "function", "allows", "to", "generate", "a", "text", "file", "with", "synchronised", "signals", "from", "the", "input", "file", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/biosignalsnotebooks/synchronisation.py#L444-L493
train
This function allows to create a text file with synchronised signals from the input file.
googleapis/protoc-java-resource-names-plugin
plugin/utils/path_template.py
PathTemplate.render
def render(self, bindings): """Renders a string from a path template using the provided bindings. Args: bindings (dict): A dictionary of var names to binding strings. Returns: str: The rendered instantiation of this path template. Raises: Validation...
python
def render(self, bindings): """Renders a string from a path template using the provided bindings. Args: bindings (dict): A dictionary of var names to binding strings. Returns: str: The rendered instantiation of this path template. Raises: Validation...
[ "def", "render", "(", "self", ",", "bindings", ")", ":", "out", "=", "[", "]", "binding", "=", "False", "for", "segment", "in", "self", ".", "segments", ":", "if", "segment", ".", "kind", "==", "_BINDING", ":", "if", "segment", ".", "literal", "not",...
Renders a string from a path template using the provided bindings. Args: bindings (dict): A dictionary of var names to binding strings. Returns: str: The rendered instantiation of this path template. Raises: ValidationError: If a key isn't provided or if a ...
[ "Renders", "a", "string", "from", "a", "path", "template", "using", "the", "provided", "bindings", "." ]
3fb2ec9b778f62646c05a7b960c893464c7791c0
https://github.com/googleapis/protoc-java-resource-names-plugin/blob/3fb2ec9b778f62646c05a7b960c893464c7791c0/plugin/utils/path_template.py#L82-L113
train
Renders a string from a path template using the provided bindings.
googleapis/protoc-java-resource-names-plugin
plugin/utils/path_template.py
PathTemplate.match
def match(self, path): """Matches a fully qualified path template string. Args: path (str): A fully qualified path template string. Returns: dict: Var names to matched binding values. Raises: ValidationException: If path can't be matched to the temp...
python
def match(self, path): """Matches a fully qualified path template string. Args: path (str): A fully qualified path template string. Returns: dict: Var names to matched binding values. Raises: ValidationException: If path can't be matched to the temp...
[ "def", "match", "(", "self", ",", "path", ")", ":", "this", "=", "self", ".", "segments", "that", "=", "path", ".", "split", "(", "'/'", ")", "current_var", "=", "None", "bindings", "=", "{", "}", "segment_count", "=", "self", ".", "segment_count", "...
Matches a fully qualified path template string. Args: path (str): A fully qualified path template string. Returns: dict: Var names to matched binding values. Raises: ValidationException: If path can't be matched to the template.
[ "Matches", "a", "fully", "qualified", "path", "template", "string", "." ]
3fb2ec9b778f62646c05a7b960c893464c7791c0
https://github.com/googleapis/protoc-java-resource-names-plugin/blob/3fb2ec9b778f62646c05a7b960c893464c7791c0/plugin/utils/path_template.py#L115-L157
train
Matches a fully qualified path template string.
googleapis/protoc-java-resource-names-plugin
plugin/utils/path_template.py
_Parser.parse
def parse(self, data): """Returns a list of path template segments parsed from data. Args: data: A path template string. Returns: A list of _Segment. """ self.binding_var_count = 0 self.segment_count = 0 segments = self.parser.parse(data)...
python
def parse(self, data): """Returns a list of path template segments parsed from data. Args: data: A path template string. Returns: A list of _Segment. """ self.binding_var_count = 0 self.segment_count = 0 segments = self.parser.parse(data)...
[ "def", "parse", "(", "self", ",", "data", ")", ":", "self", ".", "binding_var_count", "=", "0", "self", ".", "segment_count", "=", "0", "segments", "=", "self", ".", "parser", ".", "parse", "(", "data", ")", "# Validation step: checks that there are no nested ...
Returns a list of path template segments parsed from data. Args: data: A path template string. Returns: A list of _Segment.
[ "Returns", "a", "list", "of", "path", "template", "segments", "parsed", "from", "data", "." ]
3fb2ec9b778f62646c05a7b960c893464c7791c0
https://github.com/googleapis/protoc-java-resource-names-plugin/blob/3fb2ec9b778f62646c05a7b960c893464c7791c0/plugin/utils/path_template.py#L190-L211
train
Parses a path template string and returns a list of _Segment objects.
googleapis/protoc-java-resource-names-plugin
plugin/utils/path_template.py
_Parser.p_bound_segments
def p_bound_segments(self, p): """bound_segments : bound_segment FORWARD_SLASH bound_segments | bound_segment""" p[0] = p[1] if len(p) > 2: p[0].extend(p[3])
python
def p_bound_segments(self, p): """bound_segments : bound_segment FORWARD_SLASH bound_segments | bound_segment""" p[0] = p[1] if len(p) > 2: p[0].extend(p[3])
[ "def", "p_bound_segments", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "p", "[", "1", "]", "if", "len", "(", "p", ")", ">", "2", ":", "p", "[", "0", "]", ".", "extend", "(", "p", "[", "3", "]", ")" ]
bound_segments : bound_segment FORWARD_SLASH bound_segments | bound_segment
[ "bound_segments", ":", "bound_segment", "FORWARD_SLASH", "bound_segments", "|", "bound_segment" ]
3fb2ec9b778f62646c05a7b960c893464c7791c0
https://github.com/googleapis/protoc-java-resource-names-plugin/blob/3fb2ec9b778f62646c05a7b960c893464c7791c0/plugin/utils/path_template.py#L219-L224
train
bound_segments for the base class
googleapis/protoc-java-resource-names-plugin
plugin/utils/path_template.py
_Parser.p_unbound_segments
def p_unbound_segments(self, p): """unbound_segments : unbound_terminal FORWARD_SLASH unbound_segments | unbound_terminal""" p[0] = p[1] if len(p) > 2: p[0].extend(p[3])
python
def p_unbound_segments(self, p): """unbound_segments : unbound_terminal FORWARD_SLASH unbound_segments | unbound_terminal""" p[0] = p[1] if len(p) > 2: p[0].extend(p[3])
[ "def", "p_unbound_segments", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "p", "[", "1", "]", "if", "len", "(", "p", ")", ">", "2", ":", "p", "[", "0", "]", ".", "extend", "(", "p", "[", "3", "]", ")" ]
unbound_segments : unbound_terminal FORWARD_SLASH unbound_segments | unbound_terminal
[ "unbound_segments", ":", "unbound_terminal", "FORWARD_SLASH", "unbound_segments", "|", "unbound_terminal" ]
3fb2ec9b778f62646c05a7b960c893464c7791c0
https://github.com/googleapis/protoc-java-resource-names-plugin/blob/3fb2ec9b778f62646c05a7b960c893464c7791c0/plugin/utils/path_template.py#L226-L231
train
Unbound segments.
googleapis/protoc-java-resource-names-plugin
plugin/utils/path_template.py
_Parser.p_bound_terminal
def p_bound_terminal(self, p): """bound_terminal : unbound_terminal""" if p[1][0].literal in ['*', '**']: p[0] = [_Segment(_BINDING, '$%d' % self.binding_var_count), p[1][0], _Segment(_END_BINDING, '')] self.binding_var_count += 1 e...
python
def p_bound_terminal(self, p): """bound_terminal : unbound_terminal""" if p[1][0].literal in ['*', '**']: p[0] = [_Segment(_BINDING, '$%d' % self.binding_var_count), p[1][0], _Segment(_END_BINDING, '')] self.binding_var_count += 1 e...
[ "def", "p_bound_terminal", "(", "self", ",", "p", ")", ":", "if", "p", "[", "1", "]", "[", "0", "]", ".", "literal", "in", "[", "'*'", ",", "'**'", "]", ":", "p", "[", "0", "]", "=", "[", "_Segment", "(", "_BINDING", ",", "'$%d'", "%", "self"...
bound_terminal : unbound_terminal
[ "bound_terminal", ":", "unbound_terminal" ]
3fb2ec9b778f62646c05a7b960c893464c7791c0
https://github.com/googleapis/protoc-java-resource-names-plugin/blob/3fb2ec9b778f62646c05a7b960c893464c7791c0/plugin/utils/path_template.py#L245-L253
train
bound_terminal is a unbound terminal
googleapis/protoc-java-resource-names-plugin
plugin/utils/path_template.py
_Parser.p_variable
def p_variable(self, p): """variable : LEFT_BRACE LITERAL EQUALS unbound_segments RIGHT_BRACE | LEFT_BRACE LITERAL RIGHT_BRACE""" p[0] = [_Segment(_BINDING, p[2])] if len(p) > 4: p[0].extend(p[4]) else: p[0].append(_Segment(_TERMINAL, '*')) ...
python
def p_variable(self, p): """variable : LEFT_BRACE LITERAL EQUALS unbound_segments RIGHT_BRACE | LEFT_BRACE LITERAL RIGHT_BRACE""" p[0] = [_Segment(_BINDING, p[2])] if len(p) > 4: p[0].extend(p[4]) else: p[0].append(_Segment(_TERMINAL, '*')) ...
[ "def", "p_variable", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "[", "_Segment", "(", "_BINDING", ",", "p", "[", "2", "]", ")", "]", "if", "len", "(", "p", ")", ">", "4", ":", "p", "[", "0", "]", ".", "extend", "(", "p", ...
variable : LEFT_BRACE LITERAL EQUALS unbound_segments RIGHT_BRACE | LEFT_BRACE LITERAL RIGHT_BRACE
[ "variable", ":", "LEFT_BRACE", "LITERAL", "EQUALS", "unbound_segments", "RIGHT_BRACE", "|", "LEFT_BRACE", "LITERAL", "RIGHT_BRACE" ]
3fb2ec9b778f62646c05a7b960c893464c7791c0
https://github.com/googleapis/protoc-java-resource-names-plugin/blob/3fb2ec9b778f62646c05a7b960c893464c7791c0/plugin/utils/path_template.py#L255-L264
train
variable : variable LEFT_BRACE LITERAL EQUALS unbound_segments RIGHT_BRACE
thomasdelaet/python-velbus
velbus/messages/module_type_request.py
ModuleTypeRequestMessage.populate
def populate(self, priority, address, rtr, data): """ :return: None """ self.needs_low_priority(priority) self.needs_rtr(rtr) self.needs_no_data(data) self.set_attributes(priority, address, rtr)
python
def populate(self, priority, address, rtr, data): """ :return: None """ self.needs_low_priority(priority) self.needs_rtr(rtr) self.needs_no_data(data) self.set_attributes(priority, address, rtr)
[ "def", "populate", "(", "self", ",", "priority", ",", "address", ",", "rtr", ",", "data", ")", ":", "self", ".", "needs_low_priority", "(", "priority", ")", "self", ".", "needs_rtr", "(", "rtr", ")", "self", ".", "needs_no_data", "(", "data", ")", "sel...
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/module_type_request.py#L13-L20
train
Populates the object with the data.
mozilla/FoxPuppet
foxpuppet/windows/browser/notifications/base.py
BaseNotification.create
def create(window, root): """Create a notification object. Args: window (:py:class:`BrowserWindow`): Window object this region appears in. root (:py:class:`~selenium.webdriver.remote.webelement.WebElement`): WebDriver element objec...
python
def create(window, root): """Create a notification object. Args: window (:py:class:`BrowserWindow`): Window object this region appears in. root (:py:class:`~selenium.webdriver.remote.webelement.WebElement`): WebDriver element objec...
[ "def", "create", "(", "window", ",", "root", ")", ":", "notifications", "=", "{", "}", "_id", "=", "root", ".", "get_property", "(", "\"id\"", ")", "from", "foxpuppet", ".", "windows", ".", "browser", ".", "notifications", "import", "addons", "notification...
Create a notification object. Args: window (:py:class:`BrowserWindow`): Window object this region appears in. root (:py:class:`~selenium.webdriver.remote.webelement.WebElement`): WebDriver element object that serves as the root for the ...
[ "Create", "a", "notification", "object", "." ]
6575eb4c72fd024c986b254e198c8b4e6f68cddd
https://github.com/mozilla/FoxPuppet/blob/6575eb4c72fd024c986b254e198c8b4e6f68cddd/foxpuppet/windows/browser/notifications/base.py#L19-L39
train
Create a new notification object.
mozilla/FoxPuppet
foxpuppet/windows/browser/notifications/base.py
BaseNotification.label
def label(self): """Provide access to the notification label. Returns: str: The notification label """ with self.selenium.context(self.selenium.CONTEXT_CHROME): return self.root.get_attribute("label")
python
def label(self): """Provide access to the notification label. Returns: str: The notification label """ with self.selenium.context(self.selenium.CONTEXT_CHROME): return self.root.get_attribute("label")
[ "def", "label", "(", "self", ")", ":", "with", "self", ".", "selenium", ".", "context", "(", "self", ".", "selenium", ".", "CONTEXT_CHROME", ")", ":", "return", "self", ".", "root", ".", "get_attribute", "(", "\"label\"", ")" ]
Provide access to the notification label. Returns: str: The notification label
[ "Provide", "access", "to", "the", "notification", "label", "." ]
6575eb4c72fd024c986b254e198c8b4e6f68cddd
https://github.com/mozilla/FoxPuppet/blob/6575eb4c72fd024c986b254e198c8b4e6f68cddd/foxpuppet/windows/browser/notifications/base.py#L42-L50
train
Provide access to the notification label.
mozilla/FoxPuppet
foxpuppet/windows/browser/notifications/base.py
BaseNotification.origin
def origin(self): """Provide access to the notification origin. Returns: str: The notification origin. """ with self.selenium.context(self.selenium.CONTEXT_CHROME): return self.root.get_attribute("origin")
python
def origin(self): """Provide access to the notification origin. Returns: str: The notification origin. """ with self.selenium.context(self.selenium.CONTEXT_CHROME): return self.root.get_attribute("origin")
[ "def", "origin", "(", "self", ")", ":", "with", "self", ".", "selenium", ".", "context", "(", "self", ".", "selenium", ".", "CONTEXT_CHROME", ")", ":", "return", "self", ".", "root", ".", "get_attribute", "(", "\"origin\"", ")" ]
Provide access to the notification origin. Returns: str: The notification origin.
[ "Provide", "access", "to", "the", "notification", "origin", "." ]
6575eb4c72fd024c986b254e198c8b4e6f68cddd
https://github.com/mozilla/FoxPuppet/blob/6575eb4c72fd024c986b254e198c8b4e6f68cddd/foxpuppet/windows/browser/notifications/base.py#L53-L61
train
Provide access to the notification origin.
mozilla/FoxPuppet
foxpuppet/windows/browser/notifications/base.py
BaseNotification.find_primary_button
def find_primary_button(self): """Retrieve the primary button.""" if self.window.firefox_version >= 67: return self.root.find_element( By.CLASS_NAME, "popup-notification-primary-button") return self.root.find_anonymous_element_by_attribute( "anonid", "butt...
python
def find_primary_button(self): """Retrieve the primary button.""" if self.window.firefox_version >= 67: return self.root.find_element( By.CLASS_NAME, "popup-notification-primary-button") return self.root.find_anonymous_element_by_attribute( "anonid", "butt...
[ "def", "find_primary_button", "(", "self", ")", ":", "if", "self", ".", "window", ".", "firefox_version", ">=", "67", ":", "return", "self", ".", "root", ".", "find_element", "(", "By", ".", "CLASS_NAME", ",", "\"popup-notification-primary-button\"", ")", "ret...
Retrieve the primary button.
[ "Retrieve", "the", "primary", "button", "." ]
6575eb4c72fd024c986b254e198c8b4e6f68cddd
https://github.com/mozilla/FoxPuppet/blob/6575eb4c72fd024c986b254e198c8b4e6f68cddd/foxpuppet/windows/browser/notifications/base.py#L63-L69
train
Retrieve the primary button.
mozilla/FoxPuppet
foxpuppet/windows/browser/notifications/base.py
BaseNotification.close
def close(self): """Close the notification.""" with self.selenium.context(self.selenium.CONTEXT_CHROME): self.find_close_button().click() self.window.wait_for_notification(None)
python
def close(self): """Close the notification.""" with self.selenium.context(self.selenium.CONTEXT_CHROME): self.find_close_button().click() self.window.wait_for_notification(None)
[ "def", "close", "(", "self", ")", ":", "with", "self", ".", "selenium", ".", "context", "(", "self", ".", "selenium", ".", "CONTEXT_CHROME", ")", ":", "self", ".", "find_close_button", "(", ")", ".", "click", "(", ")", "self", ".", "window", ".", "wa...
Close the notification.
[ "Close", "the", "notification", "." ]
6575eb4c72fd024c986b254e198c8b4e6f68cddd
https://github.com/mozilla/FoxPuppet/blob/6575eb4c72fd024c986b254e198c8b4e6f68cddd/foxpuppet/windows/browser/notifications/base.py#L95-L99
train
Close the notification.
lobocv/crashreporter
crashreporter/injector.py
inject_path
def inject_path(path): """ Imports :func: from a python file at :path: and executes it with *args, **kwargs arguments. Everytime this function is called the module is reloaded so that you can alter your debug code while the application is running. The result of the function is returned, otherwise the e...
python
def inject_path(path): """ Imports :func: from a python file at :path: and executes it with *args, **kwargs arguments. Everytime this function is called the module is reloaded so that you can alter your debug code while the application is running. The result of the function is returned, otherwise the e...
[ "def", "inject_path", "(", "path", ")", ":", "try", ":", "dirname", "=", "os", ".", "path", ".", "dirname", "(", "path", ")", "if", "dirname", "not", "in", "sys", ".", "path", ":", "exists_in_sys", "=", "False", "sys", ".", "path", ".", "append", "...
Imports :func: from a python file at :path: and executes it with *args, **kwargs arguments. Everytime this function is called the module is reloaded so that you can alter your debug code while the application is running. The result of the function is returned, otherwise the exception is returned (if one is rai...
[ "Imports", ":", "func", ":", "from", "a", "python", "file", "at", ":", "path", ":", "and", "executes", "it", "with", "*", "args", "**", "kwargs", "arguments", ".", "Everytime", "this", "function", "is", "called", "the", "module", "is", "reloaded", "so", ...
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/injector.py#L11-L33
train
Imports a python file at the given path and executes it with the given arguments.
lobocv/crashreporter
crashreporter/injector.py
inject_module
def inject_module(module, *args, **kwargs): """ Imports a function from a python module :module: and executes it with *args, **kwargs arguments. Dotted referencing can be used to specify the function from the module. For example, the following code will execute func1 and func2 from module mymodule with...
python
def inject_module(module, *args, **kwargs): """ Imports a function from a python module :module: and executes it with *args, **kwargs arguments. Dotted referencing can be used to specify the function from the module. For example, the following code will execute func1 and func2 from module mymodule with...
[ "def", "inject_module", "(", "module", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "parsed", "=", "module", ".", "split", "(", "'.'", ")", "if", "len", "(", "parsed", ")", "==", "1", ":", "module_name", ",", "func_name", "=", ...
Imports a function from a python module :module: and executes it with *args, **kwargs arguments. Dotted referencing can be used to specify the function from the module. For example, the following code will execute func1 and func2 from module mymodule with no arguments inject_module('mymodule.func1') ...
[ "Imports", "a", "function", "from", "a", "python", "module", ":", "module", ":", "and", "executes", "it", "with", "*", "args", "**", "kwargs", "arguments", ".", "Dotted", "referencing", "can", "be", "used", "to", "specify", "the", "function", "from", "the"...
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/injector.py#L36-L68
train
Imports a function from a python module and executes it with the specified arguments.
samuelcolvin/grablib
grablib/common.py
log_config
def log_config(log_level: Union[str, int]) -> dict: """ Setup default config. for dictConfig. :param log_level: str name or django debugging int :return: dict suitable for ``logging.config.dictConfig`` """ if isinstance(log_level, int): # to match django log_level = {3: 'DEBUG', ...
python
def log_config(log_level: Union[str, int]) -> dict: """ Setup default config. for dictConfig. :param log_level: str name or django debugging int :return: dict suitable for ``logging.config.dictConfig`` """ if isinstance(log_level, int): # to match django log_level = {3: 'DEBUG', ...
[ "def", "log_config", "(", "log_level", ":", "Union", "[", "str", ",", "int", "]", ")", "->", "dict", ":", "if", "isinstance", "(", "log_level", ",", "int", ")", ":", "# to match django", "log_level", "=", "{", "3", ":", "'DEBUG'", ",", "2", ":", "'IN...
Setup default config. for dictConfig. :param log_level: str name or django debugging int :return: dict suitable for ``logging.config.dictConfig``
[ "Setup", "default", "config", ".", "for", "dictConfig", ".", ":", "param", "log_level", ":", "str", "name", "or", "django", "debugging", "int", ":", "return", ":", "dict", "suitable", "for", "logging", ".", "config", ".", "dictConfig" ]
2fca8a3950f29fb2a97a7bd75c0839060a91cedf
https://github.com/samuelcolvin/grablib/blob/2fca8a3950f29fb2a97a7bd75c0839060a91cedf/grablib/common.py#L34-L75
train
Setup default config. for dictConfig.
kytos/kytos-utils
kytos/utils/decorators.py
kytos_auth.authenticate
def authenticate(self): """Check the user authentication.""" endpoint = os.path.join(self.config.get('napps', 'api'), 'auth', '') username = self.config.get('auth', 'user') password = getpass("Enter the password for {}: ".format(username)) response = requests.get(endpoint, auth=(...
python
def authenticate(self): """Check the user authentication.""" endpoint = os.path.join(self.config.get('napps', 'api'), 'auth', '') username = self.config.get('auth', 'user') password = getpass("Enter the password for {}: ".format(username)) response = requests.get(endpoint, auth=(...
[ "def", "authenticate", "(", "self", ")", ":", "endpoint", "=", "os", ".", "path", ".", "join", "(", "self", ".", "config", ".", "get", "(", "'napps'", ",", "'api'", ")", ",", "'auth'", ",", "''", ")", "username", "=", "self", ".", "config", ".", ...
Check the user authentication.
[ "Check", "the", "user", "authentication", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/decorators.py#L62-L75
train
Check the user authentication.
thomasdelaet/python-velbus
velbus/messages/relay_status.py
RelayStatusMessage.populate
def populate(self, priority, address, rtr, data): """ :return: None """ assert isinstance(data, bytes) self.needs_low_priority(priority) self.needs_no_rtr(rtr) self.needs_data(data, 7) self.set_attributes(priority, address, rtr) self.channel = self...
python
def populate(self, priority, address, rtr, data): """ :return: None """ assert isinstance(data, bytes) self.needs_low_priority(priority) self.needs_no_rtr(rtr) self.needs_data(data, 7) self.set_attributes(priority, address, rtr) self.channel = self...
[ "def", "populate", "(", "self", ",", "priority", ",", "address", ",", "rtr", ",", "data", ")", ":", "assert", "isinstance", "(", "data", ",", "bytes", ")", "self", ".", "needs_low_priority", "(", "priority", ")", "self", ".", "needs_no_rtr", "(", "rtr", ...
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/relay_status.py#L50-L64
train
Populates the object with the data from the specified byte array.
thomasdelaet/python-velbus
velbus/messages/relay_status.py
RelayStatusMessage.to_json
def to_json(self): """ :return: str """ json_dict = self.to_json_basic() json_dict['channel'] = self.channel json_dict['disable_inhibit_forced'] = self.disable_inhibit_forced json_dict['status'] = self.status json_dict['led_status'] = self.led_status ...
python
def to_json(self): """ :return: str """ json_dict = self.to_json_basic() json_dict['channel'] = self.channel json_dict['disable_inhibit_forced'] = self.disable_inhibit_forced json_dict['status'] = self.status json_dict['led_status'] = self.led_status ...
[ "def", "to_json", "(", "self", ")", ":", "json_dict", "=", "self", ".", "to_json_basic", "(", ")", "json_dict", "[", "'channel'", "]", "=", "self", ".", "channel", "json_dict", "[", "'disable_inhibit_forced'", "]", "=", "self", ".", "disable_inhibit_forced", ...
:return: str
[ ":", "return", ":", "str" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/relay_status.py#L66-L76
train
Returns a JSON string representation of the current object.
thomasdelaet/python-velbus
velbus/messages/relay_status.py
RelayStatusMessage.data_to_binary
def data_to_binary(self): """ :return: bytes """ return bytes([ COMMAND_CODE, self.channels_to_byte([self.channel]), self.disable_inhibit_forced, self.status, self.led_status ]) + struct.pack('>L', self.delay_time)[-3:]
python
def data_to_binary(self): """ :return: bytes """ return bytes([ COMMAND_CODE, self.channels_to_byte([self.channel]), self.disable_inhibit_forced, self.status, self.led_status ]) + struct.pack('>L', self.delay_time)[-3:]
[ "def", "data_to_binary", "(", "self", ")", ":", "return", "bytes", "(", "[", "COMMAND_CODE", ",", "self", ".", "channels_to_byte", "(", "[", "self", ".", "channel", "]", ")", ",", "self", ".", "disable_inhibit_forced", ",", "self", ".", "status", ",", "s...
:return: bytes
[ ":", "return", ":", "bytes" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/relay_status.py#L120-L130
train
Converts the object to binary format.
lobocv/crashreporter
crashreporter/api.py
upload_report
def upload_report(server, payload, timeout=HQ_DEFAULT_TIMEOUT): """ Upload a report to the server. :param payload: Dictionary (JSON serializable) of crash data. :return: server response """ try: data = json.dumps(payload) r = requests.post(server + '/reports/upload', data=data, t...
python
def upload_report(server, payload, timeout=HQ_DEFAULT_TIMEOUT): """ Upload a report to the server. :param payload: Dictionary (JSON serializable) of crash data. :return: server response """ try: data = json.dumps(payload) r = requests.post(server + '/reports/upload', data=data, t...
[ "def", "upload_report", "(", "server", ",", "payload", ",", "timeout", "=", "HQ_DEFAULT_TIMEOUT", ")", ":", "try", ":", "data", "=", "json", ".", "dumps", "(", "payload", ")", "r", "=", "requests", ".", "post", "(", "server", "+", "'/reports/upload'", ",...
Upload a report to the server. :param payload: Dictionary (JSON serializable) of crash data. :return: server response
[ "Upload", "a", "report", "to", "the", "server", ".", ":", "param", "payload", ":", "Dictionary", "(", "JSON", "serializable", ")", "of", "crash", "data", ".", ":", "return", ":", "server", "response" ]
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/api.py#L12-L24
train
Uploads a report to the server.
lobocv/crashreporter
crashreporter/api.py
delete_report
def delete_report(server, report_number, timeout=HQ_DEFAULT_TIMEOUT): """ Delete a specific crash report from the server. :param report_number: Report Number :return: server response """ try: r = requests.post(server + "/reports/delete/%d" % report_number, timeout=timeout) except Exc...
python
def delete_report(server, report_number, timeout=HQ_DEFAULT_TIMEOUT): """ Delete a specific crash report from the server. :param report_number: Report Number :return: server response """ try: r = requests.post(server + "/reports/delete/%d" % report_number, timeout=timeout) except Exc...
[ "def", "delete_report", "(", "server", ",", "report_number", ",", "timeout", "=", "HQ_DEFAULT_TIMEOUT", ")", ":", "try", ":", "r", "=", "requests", ".", "post", "(", "server", "+", "\"/reports/delete/%d\"", "%", "report_number", ",", "timeout", "=", "timeout",...
Delete a specific crash report from the server. :param report_number: Report Number :return: server response
[ "Delete", "a", "specific", "crash", "report", "from", "the", "server", ".", ":", "param", "report_number", ":", "Report", "Number", ":", "return", ":", "server", "response" ]
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/api.py#L38-L50
train
Delete a specific crash report from the server.
mozilla/FoxPuppet
foxpuppet/windows/manager.py
WindowManager.windows
def windows(self): """Return a list of all open windows. Returns: list: List of FoxPuppet BrowserWindow objects. """ from foxpuppet.windows import BrowserWindow return [ BrowserWindow(self.selenium, handle) for handle in self.selenium.window...
python
def windows(self): """Return a list of all open windows. Returns: list: List of FoxPuppet BrowserWindow objects. """ from foxpuppet.windows import BrowserWindow return [ BrowserWindow(self.selenium, handle) for handle in self.selenium.window...
[ "def", "windows", "(", "self", ")", ":", "from", "foxpuppet", ".", "windows", "import", "BrowserWindow", "return", "[", "BrowserWindow", "(", "self", ".", "selenium", ",", "handle", ")", "for", "handle", "in", "self", ".", "selenium", ".", "window_handles", ...
Return a list of all open windows. Returns: list: List of FoxPuppet BrowserWindow objects.
[ "Return", "a", "list", "of", "all", "open", "windows", "." ]
6575eb4c72fd024c986b254e198c8b4e6f68cddd
https://github.com/mozilla/FoxPuppet/blob/6575eb4c72fd024c986b254e198c8b4e6f68cddd/foxpuppet/windows/manager.py#L26-L38
train
Return a list of all open windows.
thomasdelaet/python-velbus
velbus/connections/socket.py
SocketConnection.stop
def stop(self): """Close the socket.""" self.logger.warning("Stop executed") try: self._socket.close() except Exception: self.logger.error("Error while closing socket") raise VelbusException("Error while closing socket") time.sleep(1)
python
def stop(self): """Close the socket.""" self.logger.warning("Stop executed") try: self._socket.close() except Exception: self.logger.error("Error while closing socket") raise VelbusException("Error while closing socket") time.sleep(1)
[ "def", "stop", "(", "self", ")", ":", "self", ".", "logger", ".", "warning", "(", "\"Stop executed\"", ")", "try", ":", "self", ".", "_socket", ".", "close", "(", ")", "except", "Exception", ":", "self", ".", "logger", ".", "error", "(", "\"Error while...
Close the socket.
[ "Close", "the", "socket", "." ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/connections/socket.py#L46-L54
train
Close the socket.
thomasdelaet/python-velbus
velbus/connections/socket.py
SocketConnection.read_daemon
def read_daemon(self): """Read thread.""" while True: data = self._socket.recv(9999) self.feed_parser(data)
python
def read_daemon(self): """Read thread.""" while True: data = self._socket.recv(9999) self.feed_parser(data)
[ "def", "read_daemon", "(", "self", ")", ":", "while", "True", ":", "data", "=", "self", ".", "_socket", ".", "recv", "(", "9999", ")", "self", ".", "feed_parser", "(", "data", ")" ]
Read thread.
[ "Read", "thread", "." ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/connections/socket.py#L66-L70
train
Read thread.
KE-works/pykechain
pykechain/models/validators/validators_base.py
PropertyValidator._parse_effects
def _parse_effects(self, effects_json=None): # type: (dict) -> Any """Parse multiple effects from an effects(list) json.""" if isinstance(effects_json, list): return [ValidatorEffect.parse(effect) for effect in effects_json] elif isinstance(effects_json, dict): re...
python
def _parse_effects(self, effects_json=None): # type: (dict) -> Any """Parse multiple effects from an effects(list) json.""" if isinstance(effects_json, list): return [ValidatorEffect.parse(effect) for effect in effects_json] elif isinstance(effects_json, dict): re...
[ "def", "_parse_effects", "(", "self", ",", "effects_json", "=", "None", ")", ":", "# type: (dict) -> Any", "if", "isinstance", "(", "effects_json", ",", "list", ")", ":", "return", "[", "ValidatorEffect", ".", "parse", "(", "effect", ")", "for", "effect", "i...
Parse multiple effects from an effects(list) json.
[ "Parse", "multiple", "effects", "from", "an", "effects", "(", "list", ")", "json", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/validators/validators_base.py#L81-L90
train
Parse multiple effects from an effects ( list ) json.
KE-works/pykechain
pykechain/models/validators/validators_base.py
PropertyValidator.parse
def parse(cls, json): # type: (Dict) -> Any """Parse a json dict and return the correct subclass of :class:`PropertyValidator`. It uses the 'effect' key to determine which :class:`PropertyValidator` to instantiate. Please refer to :class:`pykechain.enums.PropertyVTypes` for the supporte...
python
def parse(cls, json): # type: (Dict) -> Any """Parse a json dict and return the correct subclass of :class:`PropertyValidator`. It uses the 'effect' key to determine which :class:`PropertyValidator` to instantiate. Please refer to :class:`pykechain.enums.PropertyVTypes` for the supporte...
[ "def", "parse", "(", "cls", ",", "json", ")", ":", "# type: (Dict) -> Any", "if", "'vtype'", "in", "json", ":", "vtype", "=", "json", ".", "get", "(", "'vtype'", ")", "if", "vtype", "not", "in", "PropertyVTypes", ".", "values", "(", ")", ":", "raise", ...
Parse a json dict and return the correct subclass of :class:`PropertyValidator`. It uses the 'effect' key to determine which :class:`PropertyValidator` to instantiate. Please refer to :class:`pykechain.enums.PropertyVTypes` for the supported effects. :param json: dictionary containing the spec...
[ "Parse", "a", "json", "dict", "and", "return", "the", "correct", "subclass", "of", ":", "class", ":", "PropertyValidator", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/validators/validators_base.py#L93-L116
train
Parse a json dict and return the correct subclass of PropertyValidator.
KE-works/pykechain
pykechain/models/validators/validators_base.py
PropertyValidator.as_json
def as_json(self): # type: () -> dict """JSON representation of the effect. :returns: a python dictionary, serializable as json of the effect :rtype: dict """ new_json = dict( vtype=self.vtype, config=self._config ) if self.on_val...
python
def as_json(self): # type: () -> dict """JSON representation of the effect. :returns: a python dictionary, serializable as json of the effect :rtype: dict """ new_json = dict( vtype=self.vtype, config=self._config ) if self.on_val...
[ "def", "as_json", "(", "self", ")", ":", "# type: () -> dict", "new_json", "=", "dict", "(", "vtype", "=", "self", ".", "vtype", ",", "config", "=", "self", ".", "_config", ")", "if", "self", ".", "on_valid", ":", "new_json", "[", "'config'", "]", "[",...
JSON representation of the effect. :returns: a python dictionary, serializable as json of the effect :rtype: dict
[ "JSON", "representation", "of", "the", "effect", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/validators/validators_base.py#L118-L136
train
Returns a python dictionary serializable as json of the effect.
KE-works/pykechain
pykechain/models/validators/validators_base.py
PropertyValidator._logic
def _logic(self, value=None): # type: (Any) -> Tuple[Union[bool, None], str] """Process the inner logic of the validator. The validation results are returned as tuple (boolean (true/false), reasontext) """ self._validation_result, self._validation_reason = None, 'No reason' ...
python
def _logic(self, value=None): # type: (Any) -> Tuple[Union[bool, None], str] """Process the inner logic of the validator. The validation results are returned as tuple (boolean (true/false), reasontext) """ self._validation_result, self._validation_reason = None, 'No reason' ...
[ "def", "_logic", "(", "self", ",", "value", "=", "None", ")", ":", "# type: (Any) -> Tuple[Union[bool, None], str]", "self", ".", "_validation_result", ",", "self", ".", "_validation_reason", "=", "None", ",", "'No reason'", "return", "self", ".", "_validation_resul...
Process the inner logic of the validator. The validation results are returned as tuple (boolean (true/false), reasontext)
[ "Process", "the", "inner", "logic", "of", "the", "validator", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/validators/validators_base.py#L194-L201
train
Process the inner logic of the validator.
KE-works/pykechain
pykechain/models/validators/validators_base.py
ValidatorEffect.parse
def parse(cls, json): # type: (dict) -> Any """Parse a json dict and return the correct subclass of :class:`ValidatorEffect`. It uses the 'effect' key to determine which :class:`ValidatorEffect` to instantiate. Please refer to :class:`enums.ValidatorEffectTypes` for the supported effect...
python
def parse(cls, json): # type: (dict) -> Any """Parse a json dict and return the correct subclass of :class:`ValidatorEffect`. It uses the 'effect' key to determine which :class:`ValidatorEffect` to instantiate. Please refer to :class:`enums.ValidatorEffectTypes` for the supported effect...
[ "def", "parse", "(", "cls", ",", "json", ")", ":", "# type: (dict) -> Any", "effect", "=", "json", ".", "get", "(", "'effect'", ")", "if", "effect", ":", "from", "pykechain", ".", "models", ".", "validators", "import", "effects", "effect_implementation_classna...
Parse a json dict and return the correct subclass of :class:`ValidatorEffect`. It uses the 'effect' key to determine which :class:`ValidatorEffect` to instantiate. Please refer to :class:`enums.ValidatorEffectTypes` for the supported effects. :param json: dictionary containing the specific key...
[ "Parse", "a", "json", "dict", "and", "return", "the", "correct", "subclass", "of", ":", "class", ":", "ValidatorEffect", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/validators/validators_base.py#L231-L251
train
Parse a json dict and return the correct subclass of a ValidatorEffect.
KE-works/pykechain
pykechain/models/validators/validators_base.py
ValidatorEffect.as_json
def as_json(self): # type: () -> dict """JSON representation of the effect. :returns: a python dictionary, serializable as json of the effect :rtype: dict """ self._json = dict( effect=self.effect, config=self._config ) return self...
python
def as_json(self): # type: () -> dict """JSON representation of the effect. :returns: a python dictionary, serializable as json of the effect :rtype: dict """ self._json = dict( effect=self.effect, config=self._config ) return self...
[ "def", "as_json", "(", "self", ")", ":", "# type: () -> dict", "self", ".", "_json", "=", "dict", "(", "effect", "=", "self", ".", "effect", ",", "config", "=", "self", ".", "_config", ")", "return", "self", ".", "_json" ]
JSON representation of the effect. :returns: a python dictionary, serializable as json of the effect :rtype: dict
[ "JSON", "representation", "of", "the", "effect", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/validators/validators_base.py#L253-L264
train
Returns a python dictionary of the effect.
thomasdelaet/python-velbus
velbus/messages/set_temperature.py
SetTemperatureMessage.data_to_binary
def data_to_binary(self): """ :return: bytes """ return bytes([ COMMAND_CODE, int(self.temp_type), int(self.temp) ])
python
def data_to_binary(self): """ :return: bytes """ return bytes([ COMMAND_CODE, int(self.temp_type), int(self.temp) ])
[ "def", "data_to_binary", "(", "self", ")", ":", "return", "bytes", "(", "[", "COMMAND_CODE", ",", "int", "(", "self", ".", "temp_type", ")", ",", "int", "(", "self", ".", "temp", ")", "]", ")" ]
:return: bytes
[ ":", "return", ":", "bytes" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/set_temperature.py#L34-L42
train
Converts the data to binary format.
thomasdelaet/python-velbus
velbus/messages/write_module_address_and_serial_number.py
WriteModuleAddressAndSerialNumberMessage.populate
def populate(self, priority, address, rtr, data): """ :return: None """ assert isinstance(data, bytes) self.needs_firmware_priority(priority) self.needs_no_rtr(rtr) self.needs_data(data, 6) self.set_attributes(priority, address, rtr) self.module_ty...
python
def populate(self, priority, address, rtr, data): """ :return: None """ assert isinstance(data, bytes) self.needs_firmware_priority(priority) self.needs_no_rtr(rtr) self.needs_data(data, 6) self.set_attributes(priority, address, rtr) self.module_ty...
[ "def", "populate", "(", "self", ",", "priority", ",", "address", ",", "rtr", ",", "data", ")", ":", "assert", "isinstance", "(", "data", ",", "bytes", ")", "self", ".", "needs_firmware_priority", "(", "priority", ")", "self", ".", "needs_no_rtr", "(", "r...
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/write_module_address_and_serial_number.py#L31-L45
train
Populates the object with the contents of the data.
thomasdelaet/python-velbus
velbus/messages/write_module_address_and_serial_number.py
WriteModuleAddressAndSerialNumberMessage.data_to_binary
def data_to_binary(self): """ :return: bytes """ return chr(COMMAND_CODE) + chr(self.module_type) + \ struct.pack('>L', self.current_serial)[2:] + \ chr(self.module_address) + \ struct.pack('>L', self.new_serial)[2:]
python
def data_to_binary(self): """ :return: bytes """ return chr(COMMAND_CODE) + chr(self.module_type) + \ struct.pack('>L', self.current_serial)[2:] + \ chr(self.module_address) + \ struct.pack('>L', self.new_serial)[2:]
[ "def", "data_to_binary", "(", "self", ")", ":", "return", "chr", "(", "COMMAND_CODE", ")", "+", "chr", "(", "self", ".", "module_type", ")", "+", "struct", ".", "pack", "(", "'>L'", ",", "self", ".", "current_serial", ")", "[", "2", ":", "]", "+", ...
:return: bytes
[ ":", "return", ":", "bytes" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/write_module_address_and_serial_number.py#L47-L54
train
Converts the data to binary format.
robert-b-clarke/nre-darwin-py
nredarwin/webservice.py
DarwinLdbSession.get_station_board
def get_station_board( self, crs, rows=17, include_departures=True, include_arrivals=False, destination_crs=None, origin_crs=None ): """ Query the darwin webservice to obtain a board for a particular station and return a StationBoard in...
python
def get_station_board( self, crs, rows=17, include_departures=True, include_arrivals=False, destination_crs=None, origin_crs=None ): """ Query the darwin webservice to obtain a board for a particular station and return a StationBoard in...
[ "def", "get_station_board", "(", "self", ",", "crs", ",", "rows", "=", "17", ",", "include_departures", "=", "True", ",", "include_arrivals", "=", "False", ",", "destination_crs", "=", "None", ",", "origin_crs", "=", "None", ")", ":", "# Determine the darwn qu...
Query the darwin webservice to obtain a board for a particular station and return a StationBoard instance Positional arguments: crs -- the three letter CRS code of a UK station Keyword arguments: rows -- the number of rows to retrieve (default 10) include_departures -- ...
[ "Query", "the", "darwin", "webservice", "to", "obtain", "a", "board", "for", "a", "particular", "station", "and", "return", "a", "StationBoard", "instance" ]
6b0b181770e085dc7f71fbd2eb3fe779f653da62
https://github.com/robert-b-clarke/nre-darwin-py/blob/6b0b181770e085dc7f71fbd2eb3fe779f653da62/nredarwin/webservice.py#L67-L121
train
This method returns a StationBoard instance for a particular station.
robert-b-clarke/nre-darwin-py
nredarwin/webservice.py
DarwinLdbSession.get_service_details
def get_service_details(self, service_id): """ Get the details of an individual service and return a ServiceDetails instance. Positional arguments: service_id: A Darwin LDB service id """ service_query = \ self._soap_client.service['LDBServiceSoap']['...
python
def get_service_details(self, service_id): """ Get the details of an individual service and return a ServiceDetails instance. Positional arguments: service_id: A Darwin LDB service id """ service_query = \ self._soap_client.service['LDBServiceSoap']['...
[ "def", "get_service_details", "(", "self", ",", "service_id", ")", ":", "service_query", "=", "self", ".", "_soap_client", ".", "service", "[", "'LDBServiceSoap'", "]", "[", "'GetServiceDetails'", "]", "try", ":", "soap_response", "=", "service_query", "(", "ser...
Get the details of an individual service and return a ServiceDetails instance. Positional arguments: service_id: A Darwin LDB service id
[ "Get", "the", "details", "of", "an", "individual", "service", "and", "return", "a", "ServiceDetails", "instance", "." ]
6b0b181770e085dc7f71fbd2eb3fe779f653da62
https://github.com/robert-b-clarke/nre-darwin-py/blob/6b0b181770e085dc7f71fbd2eb3fe779f653da62/nredarwin/webservice.py#L123-L137
train
Get the details of an individual service and return a ServiceDetails instance.
robert-b-clarke/nre-darwin-py
nredarwin/webservice.py
ServiceDetails.previous_calling_points
def previous_calling_points(self): """ A list of CallingPoint objects. This is the list of all previous calling points for the service, including all associated services if multiple services join together to form this service. """ calling_points = list() ...
python
def previous_calling_points(self): """ A list of CallingPoint objects. This is the list of all previous calling points for the service, including all associated services if multiple services join together to form this service. """ calling_points = list() ...
[ "def", "previous_calling_points", "(", "self", ")", ":", "calling_points", "=", "list", "(", ")", "for", "cpl", "in", "self", ".", "_previous_calling_point_lists", ":", "calling_points", "+=", "cpl", ".", "calling_points", "return", "calling_points" ]
A list of CallingPoint objects. This is the list of all previous calling points for the service, including all associated services if multiple services join together to form this service.
[ "A", "list", "of", "CallingPoint", "objects", "." ]
6b0b181770e085dc7f71fbd2eb3fe779f653da62
https://github.com/robert-b-clarke/nre-darwin-py/blob/6b0b181770e085dc7f71fbd2eb3fe779f653da62/nredarwin/webservice.py#L601-L612
train
A list of all previous calling points for this service.
robert-b-clarke/nre-darwin-py
nredarwin/webservice.py
ServiceDetails.subsequent_calling_points
def subsequent_calling_points(self): """ A list of CallingPoint objects. This is the list of all subsequent calling points for the service, including all associated services if the service splits into multiple services. """ calling_points = list() for cpl...
python
def subsequent_calling_points(self): """ A list of CallingPoint objects. This is the list of all subsequent calling points for the service, including all associated services if the service splits into multiple services. """ calling_points = list() for cpl...
[ "def", "subsequent_calling_points", "(", "self", ")", ":", "calling_points", "=", "list", "(", ")", "for", "cpl", "in", "self", ".", "_subsequent_calling_point_lists", ":", "calling_points", "+=", "cpl", ".", "calling_points", "return", "calling_points" ]
A list of CallingPoint objects. This is the list of all subsequent calling points for the service, including all associated services if the service splits into multiple services.
[ "A", "list", "of", "CallingPoint", "objects", "." ]
6b0b181770e085dc7f71fbd2eb3fe779f653da62
https://github.com/robert-b-clarke/nre-darwin-py/blob/6b0b181770e085dc7f71fbd2eb3fe779f653da62/nredarwin/webservice.py#L615-L626
train
A list of all subsequent CallingPoints for this service.
thomasdelaet/python-velbus
velbus/modules/vmbin.py
VMB7INModule.get_state
def get_state(self, channel): """ Ignore channel """ val = None if channel not in self._unit: return val if self._unit[channel] == 'l/h': val = ((1000 * 3600) / (self._delay[channel] * self._pulses[channel])) elif self._unit[channel] == 'm3...
python
def get_state(self, channel): """ Ignore channel """ val = None if channel not in self._unit: return val if self._unit[channel] == 'l/h': val = ((1000 * 3600) / (self._delay[channel] * self._pulses[channel])) elif self._unit[channel] == 'm3...
[ "def", "get_state", "(", "self", ",", "channel", ")", ":", "val", "=", "None", "if", "channel", "not", "in", "self", ".", "_unit", ":", "return", "val", "if", "self", ".", "_unit", "[", "channel", "]", "==", "'l/h'", ":", "val", "=", "(", "(", "1...
Ignore channel
[ "Ignore", "channel" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/modules/vmbin.py#L131-L146
train
Get the state of a specific channel.
kytos/kytos-utils
kytos/utils/openapi.py
OpenAPI.render_template
def render_template(self): """Render and save API doc in openapi.yml.""" self._parse_paths() context = dict(napp=self._napp.__dict__, paths=self._paths) self._save(context)
python
def render_template(self): """Render and save API doc in openapi.yml.""" self._parse_paths() context = dict(napp=self._napp.__dict__, paths=self._paths) self._save(context)
[ "def", "render_template", "(", "self", ")", ":", "self", ".", "_parse_paths", "(", ")", "context", "=", "dict", "(", "napp", "=", "self", ".", "_napp", ".", "__dict__", ",", "paths", "=", "self", ".", "_paths", ")", "self", ".", "_save", "(", "contex...
Render and save API doc in openapi.yml.
[ "Render", "and", "save", "API", "doc", "in", "openapi", ".", "yml", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/openapi.py#L35-L39
train
Render and save API doc in openapi. yml.
kytos/kytos-utils
kytos/utils/openapi.py
OpenAPI._parse_decorated_functions
def _parse_decorated_functions(self, code): """Return URL rule, HTTP methods and docstring.""" matches = re.finditer(r""" # @rest decorators (?P<decorators> (?:@rest\(.+?\)\n)+ # one or more @rest decorators inside ) # ...
python
def _parse_decorated_functions(self, code): """Return URL rule, HTTP methods and docstring.""" matches = re.finditer(r""" # @rest decorators (?P<decorators> (?:@rest\(.+?\)\n)+ # one or more @rest decorators inside ) # ...
[ "def", "_parse_decorated_functions", "(", "self", ",", "code", ")", ":", "matches", "=", "re", ".", "finditer", "(", "r\"\"\"\n # @rest decorators\n (?P<decorators>\n (?:@rest\\(.+?\\)\\n)+ # one or more @rest decorators inside\n ...
Return URL rule, HTTP methods and docstring.
[ "Return", "URL", "rule", "HTTP", "methods", "and", "docstring", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/openapi.py#L46-L60
train
Parse the decorated functions in the code.
kytos/kytos-utils
kytos/utils/openapi.py
OpenAPI._parse_docstring
def _parse_docstring(self, docstring): """Parse the method docstring.""" match = re.match(r""" # Following PEP 257 \s* (?P<summary>[^\n]+?) \s* # First line ( # Description and YAML are optional (\n \s*){2} ...
python
def _parse_docstring(self, docstring): """Parse the method docstring.""" match = re.match(r""" # Following PEP 257 \s* (?P<summary>[^\n]+?) \s* # First line ( # Description and YAML are optional (\n \s*){2} ...
[ "def", "_parse_docstring", "(", "self", ",", "docstring", ")", ":", "match", "=", "re", ".", "match", "(", "r\"\"\"\n # Following PEP 257\n \\s* (?P<summary>[^\\n]+?) \\s* # First line\n\n ( # Description and YAML are option...
Parse the method docstring.
[ "Parse", "the", "method", "docstring", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/openapi.py#L69-L102
train
Parse the method docstring.
kytos/kytos-utils
kytos/utils/openapi.py
OpenAPI._parse_methods
def _parse_methods(cls, list_string): """Return HTTP method list. Use json for security reasons.""" if list_string is None: return APIServer.DEFAULT_METHODS # json requires double quotes json_list = list_string.replace("'", '"') return json.loads(json_list)
python
def _parse_methods(cls, list_string): """Return HTTP method list. Use json for security reasons.""" if list_string is None: return APIServer.DEFAULT_METHODS # json requires double quotes json_list = list_string.replace("'", '"') return json.loads(json_list)
[ "def", "_parse_methods", "(", "cls", ",", "list_string", ")", ":", "if", "list_string", "is", "None", ":", "return", "APIServer", ".", "DEFAULT_METHODS", "# json requires double quotes", "json_list", "=", "list_string", ".", "replace", "(", "\"'\"", ",", "'\"'", ...
Return HTTP method list. Use json for security reasons.
[ "Return", "HTTP", "method", "list", ".", "Use", "json", "for", "security", "reasons", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/openapi.py#L127-L133
train
Return HTTP method list. Use json for security reasons.
kytos/kytos-utils
kytos/utils/openapi.py
OpenAPI._rule2path
def _rule2path(cls, rule): """Convert relative Flask rule to absolute OpenAPI path.""" typeless = re.sub(r'<\w+?:', '<', rule) # remove Flask types return typeless.replace('<', '{').replace('>', '}')
python
def _rule2path(cls, rule): """Convert relative Flask rule to absolute OpenAPI path.""" typeless = re.sub(r'<\w+?:', '<', rule) # remove Flask types return typeless.replace('<', '{').replace('>', '}')
[ "def", "_rule2path", "(", "cls", ",", "rule", ")", ":", "typeless", "=", "re", ".", "sub", "(", "r'<\\w+?:'", ",", "'<'", ",", "rule", ")", "# remove Flask types", "return", "typeless", ".", "replace", "(", "'<'", ",", "'{'", ")", ".", "replace", "(", ...
Convert relative Flask rule to absolute OpenAPI path.
[ "Convert", "relative", "Flask", "rule", "to", "absolute", "OpenAPI", "path", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/openapi.py#L142-L145
train
Convert relative Flask rule to absolute OpenAPI path.
thomasdelaet/python-velbus
velbus/__init__.py
on_app_engine
def on_app_engine(): """ :return: bool """ if 'SERVER_SOFTWARE' in os.environ: server_software = os.environ['SERVER_SOFTWARE'] if server_software.startswith('Google App Engine') or \ server_software.startswith('Development'): return True return False ...
python
def on_app_engine(): """ :return: bool """ if 'SERVER_SOFTWARE' in os.environ: server_software = os.environ['SERVER_SOFTWARE'] if server_software.startswith('Google App Engine') or \ server_software.startswith('Development'): return True return False ...
[ "def", "on_app_engine", "(", ")", ":", "if", "'SERVER_SOFTWARE'", "in", "os", ".", "environ", ":", "server_software", "=", "os", ".", "environ", "[", "'SERVER_SOFTWARE'", "]", "if", "server_software", ".", "startswith", "(", "'Google App Engine'", ")", "or", "...
:return: bool
[ ":", "return", ":", "bool" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/__init__.py#L92-L102
train
Returns True if the current environment is on App Engine.
thomasdelaet/python-velbus
velbus/__init__.py
register_module
def register_module(module_name, module_class): """ :return: None """ assert isinstance(module_name, str) assert isinstance(module_class, type) if module_name not in ModuleRegistry: ModuleRegistry[module_name] = module_class else: raise Exception("double registration in modul...
python
def register_module(module_name, module_class): """ :return: None """ assert isinstance(module_name, str) assert isinstance(module_class, type) if module_name not in ModuleRegistry: ModuleRegistry[module_name] = module_class else: raise Exception("double registration in modul...
[ "def", "register_module", "(", "module_name", ",", "module_class", ")", ":", "assert", "isinstance", "(", "module_name", ",", "str", ")", "assert", "isinstance", "(", "module_class", ",", "type", ")", "if", "module_name", "not", "in", "ModuleRegistry", ":", "M...
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/__init__.py#L112-L121
train
Registers a module with the registry.
thomasdelaet/python-velbus
velbus/__init__.py
checksum
def checksum(data): """ :return: int """ assert isinstance(data, bytes) assert len(data) >= MINIMUM_MESSAGE_SIZE - 2 assert len(data) <= MAXIMUM_MESSAGE_SIZE - 2 __checksum = 0 for data_byte in data: __checksum += data_byte __checksum = -(__checksum % 256) + 256 try: ...
python
def checksum(data): """ :return: int """ assert isinstance(data, bytes) assert len(data) >= MINIMUM_MESSAGE_SIZE - 2 assert len(data) <= MAXIMUM_MESSAGE_SIZE - 2 __checksum = 0 for data_byte in data: __checksum += data_byte __checksum = -(__checksum % 256) + 256 try: ...
[ "def", "checksum", "(", "data", ")", ":", "assert", "isinstance", "(", "data", ",", "bytes", ")", "assert", "len", "(", "data", ")", ">=", "MINIMUM_MESSAGE_SIZE", "-", "2", "assert", "len", "(", "data", ")", "<=", "MAXIMUM_MESSAGE_SIZE", "-", "2", "__che...
:return: int
[ ":", "return", ":", "int" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/__init__.py#L123-L138
train
Calculate checksum of data.
KE-works/pykechain
pykechain/models/part.py
Part.property
def property(self, name): """Retrieve the property belonging to this part based on its name or uuid. :param name: property name or property UUID to search for :type name: basestring :return: a single :class:`Property` :raises NotFoundError: if the `Property` is not part of the `...
python
def property(self, name): """Retrieve the property belonging to this part based on its name or uuid. :param name: property name or property UUID to search for :type name: basestring :return: a single :class:`Property` :raises NotFoundError: if the `Property` is not part of the `...
[ "def", "property", "(", "self", ",", "name", ")", ":", "found", "=", "None", "if", "is_uuid", "(", "name", ")", ":", "found", "=", "find", "(", "self", ".", "properties", ",", "lambda", "p", ":", "name", "==", "p", ".", "id", ")", "else", ":", ...
Retrieve the property belonging to this part based on its name or uuid. :param name: property name or property UUID to search for :type name: basestring :return: a single :class:`Property` :raises NotFoundError: if the `Property` is not part of the `Part` Example ------...
[ "Retrieve", "the", "property", "belonging", "to", "this", "part", "based", "on", "its", "name", "or", "uuid", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L69-L103
train
Retrieve the property belonging to this part based on its name or uuid.
KE-works/pykechain
pykechain/models/part.py
Part.parent
def parent(self): # type: () -> Any """Retrieve the parent of this `Part`. :return: the parent :class:`Part` of this part :raises APIError: if an Error occurs Example ------- >>> part = project.part('Frame') >>> bike = part.parent() """ ...
python
def parent(self): # type: () -> Any """Retrieve the parent of this `Part`. :return: the parent :class:`Part` of this part :raises APIError: if an Error occurs Example ------- >>> part = project.part('Frame') >>> bike = part.parent() """ ...
[ "def", "parent", "(", "self", ")", ":", "# type: () -> Any", "if", "self", ".", "parent_id", ":", "return", "self", ".", "_client", ".", "part", "(", "pk", "=", "self", ".", "parent_id", ",", "category", "=", "self", ".", "category", ")", "else", ":", ...
Retrieve the parent of this `Part`. :return: the parent :class:`Part` of this part :raises APIError: if an Error occurs Example ------- >>> part = project.part('Frame') >>> bike = part.parent()
[ "Retrieve", "the", "parent", "of", "this", "Part", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L105-L122
train
Retrieve the parent of this Part.
KE-works/pykechain
pykechain/models/part.py
Part.children
def children(self, **kwargs): """Retrieve the children of this `Part` as `Partset`. When you call the :func:`Part.children()` method without any additional filtering options for the children, the children are cached to help speed up subsequent calls to retrieve the children. The cached children...
python
def children(self, **kwargs): """Retrieve the children of this `Part` as `Partset`. When you call the :func:`Part.children()` method without any additional filtering options for the children, the children are cached to help speed up subsequent calls to retrieve the children. The cached children...
[ "def", "children", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "not", "kwargs", ":", "# no kwargs provided is the default, we aim to cache it.", "if", "not", "self", ".", "_cached_children", ":", "self", ".", "_cached_children", "=", "list", "(", "self...
Retrieve the children of this `Part` as `Partset`. When you call the :func:`Part.children()` method without any additional filtering options for the children, the children are cached to help speed up subsequent calls to retrieve the children. The cached children are returned as a list and not a...
[ "Retrieve", "the", "children", "of", "this", "Part", "as", "Partset", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L124-L163
train
Retrieve the children of this Part as Partset.
KE-works/pykechain
pykechain/models/part.py
Part.siblings
def siblings(self, **kwargs): # type: (Any) -> Any """Retrieve the siblings of this `Part` as `Partset`. Siblings are other Parts sharing the same parent of this `Part`, including the part itself. :param kwargs: Additional search arguments to search for, check :class:`pykechain.Client....
python
def siblings(self, **kwargs): # type: (Any) -> Any """Retrieve the siblings of this `Part` as `Partset`. Siblings are other Parts sharing the same parent of this `Part`, including the part itself. :param kwargs: Additional search arguments to search for, check :class:`pykechain.Client....
[ "def", "siblings", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# type: (Any) -> Any", "if", "self", ".", "parent_id", ":", "return", "self", ".", "_client", ".", "parts", "(", "parent", "=", "self", ".", "parent_id", ",", "category", "=", "self", ...
Retrieve the siblings of this `Part` as `Partset`. Siblings are other Parts sharing the same parent of this `Part`, including the part itself. :param kwargs: Additional search arguments to search for, check :class:`pykechain.Client.parts` for additional info :type kwargs...
[ "Retrieve", "the", "siblings", "of", "this", "Part", "as", "Partset", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L165-L181
train
Retrieve the siblings of this Part as Partset.
KE-works/pykechain
pykechain/models/part.py
Part.model
def model(self): """ Retrieve the model of this `Part` as `Part`. For instance, you can get the part model of a part instance. But trying to get the model of a part that has no model, like a part model, will raise a :exc:`NotFoundError`. .. versionadded:: 1.8 :return: ...
python
def model(self): """ Retrieve the model of this `Part` as `Part`. For instance, you can get the part model of a part instance. But trying to get the model of a part that has no model, like a part model, will raise a :exc:`NotFoundError`. .. versionadded:: 1.8 :return: ...
[ "def", "model", "(", "self", ")", ":", "if", "self", ".", "category", "==", "Category", ".", "INSTANCE", ":", "model_id", "=", "self", ".", "_json_data", "[", "'model'", "]", ".", "get", "(", "'id'", ")", "return", "self", ".", "_client", ".", "model...
Retrieve the model of this `Part` as `Part`. For instance, you can get the part model of a part instance. But trying to get the model of a part that has no model, like a part model, will raise a :exc:`NotFoundError`. .. versionadded:: 1.8 :return: the model of this part instance as :c...
[ "Retrieve", "the", "model", "of", "this", "Part", "as", "Part", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L183-L205
train
Retrieve the model of this Part as Part.
KE-works/pykechain
pykechain/models/part.py
Part.instances
def instances(self, **kwargs): """ Retrieve the instances of this `Part` as a `PartSet`. For instance, if you have a model part, you can get the list of instances that are created based on this moodel. If there are no instances (only possible if the multiplicity is :attr:`enums.Multipli...
python
def instances(self, **kwargs): """ Retrieve the instances of this `Part` as a `PartSet`. For instance, if you have a model part, you can get the list of instances that are created based on this moodel. If there are no instances (only possible if the multiplicity is :attr:`enums.Multipli...
[ "def", "instances", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "category", "==", "Category", ".", "MODEL", ":", "return", "self", ".", "_client", ".", "parts", "(", "model", "=", "self", ",", "category", "=", "Category", ".", ...
Retrieve the instances of this `Part` as a `PartSet`. For instance, if you have a model part, you can get the list of instances that are created based on this moodel. If there are no instances (only possible if the multiplicity is :attr:`enums.Multiplicity.ZERO_MANY`) than a :exc:`NotFoundError...
[ "Retrieve", "the", "instances", "of", "this", "Part", "as", "a", "PartSet", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L207-L234
train
Retrieve the instances of this Part as a PartSet.
KE-works/pykechain
pykechain/models/part.py
Part.instance
def instance(self): """ Retrieve the single (expected) instance of this 'Part' (of `Category.MODEL`) as a 'Part'. See :func:`Part.instances()` method for documentation. :return: :class:`Part` with category `INSTANCE` :raises NotFoundError: if the instance does not exist ...
python
def instance(self): """ Retrieve the single (expected) instance of this 'Part' (of `Category.MODEL`) as a 'Part'. See :func:`Part.instances()` method for documentation. :return: :class:`Part` with category `INSTANCE` :raises NotFoundError: if the instance does not exist ...
[ "def", "instance", "(", "self", ")", ":", "instances_list", "=", "list", "(", "self", ".", "instances", "(", ")", ")", "if", "len", "(", "instances_list", ")", "==", "1", ":", "return", "instances_list", "[", "0", "]", "elif", "len", "(", "instances_li...
Retrieve the single (expected) instance of this 'Part' (of `Category.MODEL`) as a 'Part'. See :func:`Part.instances()` method for documentation. :return: :class:`Part` with category `INSTANCE` :raises NotFoundError: if the instance does not exist :raises MultipleFoundError: if there ar...
[ "Retrieve", "the", "single", "(", "expected", ")", "instance", "of", "this", "Part", "(", "of", "Category", ".", "MODEL", ")", "as", "a", "Part", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L236-L253
train
Retrieves the single instance of this Part as a Part.
KE-works/pykechain
pykechain/models/part.py
Part.proxy_model
def proxy_model(self): """ Retrieve the proxy model of this proxied `Part` as a `Part`. Allows you to retrieve the model of a proxy. But trying to get the catalog model of a part that has no proxy, will raise an :exc:`NotFoundError`. Only models can have a proxy. :return: :clas...
python
def proxy_model(self): """ Retrieve the proxy model of this proxied `Part` as a `Part`. Allows you to retrieve the model of a proxy. But trying to get the catalog model of a part that has no proxy, will raise an :exc:`NotFoundError`. Only models can have a proxy. :return: :clas...
[ "def", "proxy_model", "(", "self", ")", ":", "if", "self", ".", "category", "!=", "Category", ".", "MODEL", ":", "raise", "IllegalArgumentError", "(", "\"Part {} is not a model, therefore it cannot have a proxy model\"", ".", "format", "(", "self", ")", ")", "if", ...
Retrieve the proxy model of this proxied `Part` as a `Part`. Allows you to retrieve the model of a proxy. But trying to get the catalog model of a part that has no proxy, will raise an :exc:`NotFoundError`. Only models can have a proxy. :return: :class:`Part` with category `MODEL` and from whi...
[ "Retrieve", "the", "proxy", "model", "of", "this", "proxied", "Part", "as", "a", "Part", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L255-L281
train
Retrieve the proxy model of this proxied Part as a Part.
KE-works/pykechain
pykechain/models/part.py
Part.add
def add(self, model, **kwargs): # type: (Part, **Any) -> Part """Add a new child instance, based on a model, to this part. This can only act on instances. It needs a model from which to create the child instance. In order to prevent the backend from updating the frontend you may add `s...
python
def add(self, model, **kwargs): # type: (Part, **Any) -> Part """Add a new child instance, based on a model, to this part. This can only act on instances. It needs a model from which to create the child instance. In order to prevent the backend from updating the frontend you may add `s...
[ "def", "add", "(", "self", ",", "model", ",", "*", "*", "kwargs", ")", ":", "# type: (Part, **Any) -> Part", "if", "self", ".", "category", "!=", "Category", ".", "INSTANCE", ":", "raise", "APIError", "(", "\"Part should be of category INSTANCE\"", ")", "return"...
Add a new child instance, based on a model, to this part. This can only act on instances. It needs a model from which to create the child instance. In order to prevent the backend from updating the frontend you may add `suppress_kevents=True` as additional keyword=value argument to this method...
[ "Add", "a", "new", "child", "instance", "based", "on", "a", "model", "to", "this", "part", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L283-L311
train
Add a new child instance based on a model to this part.
KE-works/pykechain
pykechain/models/part.py
Part.add_to
def add_to(self, parent, **kwargs): # type: (Part, **Any) -> Part """Add a new instance of this model to a part. This works if the current part is a model and an instance of this model is to be added to a part instances in the tree. In order to prevent the backend from updating...
python
def add_to(self, parent, **kwargs): # type: (Part, **Any) -> Part """Add a new instance of this model to a part. This works if the current part is a model and an instance of this model is to be added to a part instances in the tree. In order to prevent the backend from updating...
[ "def", "add_to", "(", "self", ",", "parent", ",", "*", "*", "kwargs", ")", ":", "# type: (Part, **Any) -> Part", "if", "self", ".", "category", "!=", "Category", ".", "MODEL", ":", "raise", "APIError", "(", "\"Part should be of category MODEL\"", ")", "return", ...
Add a new instance of this model to a part. This works if the current part is a model and an instance of this model is to be added to a part instances in the tree. In order to prevent the backend from updating the frontend you may add `suppress_kevents=True` as additional keyword=value...
[ "Add", "a", "new", "instance", "of", "this", "model", "to", "a", "part", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L313-L344
train
Add a new instance of this model to a part.
KE-works/pykechain
pykechain/models/part.py
Part.add_model
def add_model(self, *args, **kwargs): # type: (*Any, **Any) -> Part """Add a new child model to this model. In order to prevent the backend from updating the frontend you may add `suppress_kevents=True` as additional keyword=value argument to this method. This will improve performance o...
python
def add_model(self, *args, **kwargs): # type: (*Any, **Any) -> Part """Add a new child model to this model. In order to prevent the backend from updating the frontend you may add `suppress_kevents=True` as additional keyword=value argument to this method. This will improve performance o...
[ "def", "add_model", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# type: (*Any, **Any) -> Part", "if", "self", ".", "category", "!=", "Category", ".", "MODEL", ":", "raise", "APIError", "(", "\"Part should be of category MODEL\"", ")", "r...
Add a new child model to this model. In order to prevent the backend from updating the frontend you may add `suppress_kevents=True` as additional keyword=value argument to this method. This will improve performance of the backend against a trade-off that someone looking at the frontend won't no...
[ "Add", "a", "new", "child", "model", "to", "this", "model", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L346-L360
train
Add a new child model to this model.
KE-works/pykechain
pykechain/models/part.py
Part.add_proxy_to
def add_proxy_to(self, parent, name, multiplicity=Multiplicity.ONE_MANY, **kwargs): # type: (Any, AnyStr, Any, **Any) -> Part """Add this model as a proxy to another parent model. This will add the current model as a proxy model to another parent model. It ensure that it will copy the w...
python
def add_proxy_to(self, parent, name, multiplicity=Multiplicity.ONE_MANY, **kwargs): # type: (Any, AnyStr, Any, **Any) -> Part """Add this model as a proxy to another parent model. This will add the current model as a proxy model to another parent model. It ensure that it will copy the w...
[ "def", "add_proxy_to", "(", "self", ",", "parent", ",", "name", ",", "multiplicity", "=", "Multiplicity", ".", "ONE_MANY", ",", "*", "*", "kwargs", ")", ":", "# type: (Any, AnyStr, Any, **Any) -> Part", "return", "self", ".", "_client", ".", "create_proxy_model", ...
Add this model as a proxy to another parent model. This will add the current model as a proxy model to another parent model. It ensure that it will copy the whole subassembly to the 'parent' model. In order to prevent the backend from updating the frontend you may add `suppress_kevents=True` a...
[ "Add", "this", "model", "as", "a", "proxy", "to", "another", "parent", "model", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L362-L396
train
Add this model as a proxy to another parent model.
KE-works/pykechain
pykechain/models/part.py
Part.add_property
def add_property(self, *args, **kwargs): # type: (*Any, **Any) -> Property """Add a new property to this model. See :class:`pykechain.Client.create_property` for available parameters. :return: :class:`Property` :raises APIError: in case an Error occurs """ if se...
python
def add_property(self, *args, **kwargs): # type: (*Any, **Any) -> Property """Add a new property to this model. See :class:`pykechain.Client.create_property` for available parameters. :return: :class:`Property` :raises APIError: in case an Error occurs """ if se...
[ "def", "add_property", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# type: (*Any, **Any) -> Property", "if", "self", ".", "category", "!=", "Category", ".", "MODEL", ":", "raise", "APIError", "(", "\"Part should be of category MODEL\"", ")...
Add a new property to this model. See :class:`pykechain.Client.create_property` for available parameters. :return: :class:`Property` :raises APIError: in case an Error occurs
[ "Add", "a", "new", "property", "to", "this", "model", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L398-L410
train
Add a new property to this model.
KE-works/pykechain
pykechain/models/part.py
Part.edit
def edit(self, name=None, description=None, **kwargs): # type: (AnyStr, AnyStr, **Any) -> None """ Edit the details of a part (model or instance). For an instance you can edit the Part instance name and the part instance description. To alter the values of properties use :func:`...
python
def edit(self, name=None, description=None, **kwargs): # type: (AnyStr, AnyStr, **Any) -> None """ Edit the details of a part (model or instance). For an instance you can edit the Part instance name and the part instance description. To alter the values of properties use :func:`...
[ "def", "edit", "(", "self", ",", "name", "=", "None", ",", "description", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# type: (AnyStr, AnyStr, **Any) -> None", "update_dict", "=", "{", "'id'", ":", "self", ".", "id", "}", "if", "name", ":", "if", ...
Edit the details of a part (model or instance). For an instance you can edit the Part instance name and the part instance description. To alter the values of properties use :func:`Part.update()`. In order to prevent the backend from updating the frontend you may add `suppress_kevents=True` as ...
[ "Edit", "the", "details", "of", "a", "part", "(", "model", "or", "instance", ")", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L424-L479
train
Edit the details of a Part instance.
KE-works/pykechain
pykechain/models/part.py
Part.update
def update(self, name=None, update_dict=None, bulk=True, **kwargs): """ Edit part name and property values in one go. In order to prevent the backend from updating the frontend you may add `suppress_kevents=True` as additional keyword=value argument to this method. This will improve per...
python
def update(self, name=None, update_dict=None, bulk=True, **kwargs): """ Edit part name and property values in one go. In order to prevent the backend from updating the frontend you may add `suppress_kevents=True` as additional keyword=value argument to this method. This will improve per...
[ "def", "update", "(", "self", ",", "name", "=", "None", ",", "update_dict", "=", "None", ",", "bulk", "=", "True", ",", "*", "*", "kwargs", ")", ":", "# dict(name=name, properties=json.dumps(update_dict))) with property ids:value", "action", "=", "'bulk_update_prope...
Edit part name and property values in one go. In order to prevent the backend from updating the frontend you may add `suppress_kevents=True` as additional keyword=value argument to this method. This will improve performance of the backend against a trade-off that someone looking at the frontend...
[ "Edit", "part", "name", "and", "property", "values", "in", "one", "go", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L505-L556
train
Update the properties of a KE - chain version.
KE-works/pykechain
pykechain/models/part.py
Part.add_with_properties
def add_with_properties(self, model, name=None, update_dict=None, bulk=True, **kwargs): """ Add a part and update its properties in one go. In order to prevent the backend from updating the frontend you may add `suppress_kevents=True` as additional keyword=value argument to this method....
python
def add_with_properties(self, model, name=None, update_dict=None, bulk=True, **kwargs): """ Add a part and update its properties in one go. In order to prevent the backend from updating the frontend you may add `suppress_kevents=True` as additional keyword=value argument to this method....
[ "def", "add_with_properties", "(", "self", ",", "model", ",", "name", "=", "None", ",", "update_dict", "=", "None", ",", "bulk", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "category", "!=", "Category", ".", "INSTANCE", ":", "r...
Add a part and update its properties in one go. In order to prevent the backend from updating the frontend you may add `suppress_kevents=True` as additional keyword=value argument to this method. This will improve performance of the backend against a trade-off that someone looking at the fronte...
[ "Add", "a", "part", "and", "update", "its", "properties", "in", "one", "go", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L558-L618
train
Add a new part and update its properties in one go.
KE-works/pykechain
pykechain/models/part.py
Part.as_dict
def as_dict(self): """ Retrieve the properties of a part inside a dict in this structure: {property_name: property_value}. .. versionadded:: 1.9 :returns: the values of the properties as a `dict` :rtype: dict Example ------- >>> front_wheel = client.sco...
python
def as_dict(self): """ Retrieve the properties of a part inside a dict in this structure: {property_name: property_value}. .. versionadded:: 1.9 :returns: the values of the properties as a `dict` :rtype: dict Example ------- >>> front_wheel = client.sco...
[ "def", "as_dict", "(", "self", ")", ":", "properties_dict", "=", "dict", "(", ")", "for", "prop", "in", "self", ".", "properties", ":", "properties_dict", "[", "prop", ".", "name", "]", "=", "prop", ".", "value", "return", "properties_dict" ]
Retrieve the properties of a part inside a dict in this structure: {property_name: property_value}. .. versionadded:: 1.9 :returns: the values of the properties as a `dict` :rtype: dict Example ------- >>> front_wheel = client.scope('Bike Project').part('Front Wheel') ...
[ "Retrieve", "the", "properties", "of", "a", "part", "inside", "a", "dict", "in", "this", "structure", ":", "{", "property_name", ":", "property_value", "}", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L620-L642
train
Returns the properties of a part inside a dict in this structure.
KE-works/pykechain
pykechain/models/part.py
Part.order_properties
def order_properties(self, property_list=None): """ Order the properties of a part model using a list of property objects or property names or property id's. :param property_list: ordered list of property names (basestring) or property id's (uuid) :type property_list: list(basestring) ...
python
def order_properties(self, property_list=None): """ Order the properties of a part model using a list of property objects or property names or property id's. :param property_list: ordered list of property names (basestring) or property id's (uuid) :type property_list: list(basestring) ...
[ "def", "order_properties", "(", "self", ",", "property_list", "=", "None", ")", ":", "if", "self", ".", "category", "!=", "Category", ".", "MODEL", ":", "raise", "APIError", "(", "\"Part should be of category MODEL\"", ")", "if", "not", "isinstance", "(", "pro...
Order the properties of a part model using a list of property objects or property names or property id's. :param property_list: ordered list of property names (basestring) or property id's (uuid) :type property_list: list(basestring) :returns: the :class:`Part` with the reordered list of proper...
[ "Order", "the", "properties", "of", "a", "part", "model", "using", "a", "list", "of", "property", "objects", "or", "property", "names", "or", "property", "id", "s", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L644-L685
train
Order the properties of a part model using a list of property objects or property id s.
KE-works/pykechain
pykechain/models/part.py
Part.populate_descendants
def populate_descendants(self, batch=200): """ Retrieve the descendants of a specific part in a list of dicts and populate the :func:`Part.children()` method. Each `Part` has a :func:`Part.children()` method to retrieve the children on the go. This function prepopulates the children and...
python
def populate_descendants(self, batch=200): """ Retrieve the descendants of a specific part in a list of dicts and populate the :func:`Part.children()` method. Each `Part` has a :func:`Part.children()` method to retrieve the children on the go. This function prepopulates the children and...
[ "def", "populate_descendants", "(", "self", ",", "batch", "=", "200", ")", ":", "descendants_flat_list", "=", "list", "(", "self", ".", "_client", ".", "parts", "(", "pk", "=", "self", ".", "id", ",", "category", "=", "self", ".", "category", ",", "des...
Retrieve the descendants of a specific part in a list of dicts and populate the :func:`Part.children()` method. Each `Part` has a :func:`Part.children()` method to retrieve the children on the go. This function prepopulates the children and the children's children with its children in one call, making ...
[ "Retrieve", "the", "descendants", "of", "a", "specific", "part", "in", "a", "list", "of", "dicts", "and", "populate", "the", ":", "func", ":", "Part", ".", "children", "()", "method", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L687-L717
train
Retrieve the descendants of a specific Part in a list of dicts and populate the Part. children method.
KE-works/pykechain
pykechain/models/part.py
Part.clone
def clone(self, **kwargs): """ Clone a part. .. versionadded:: 2.3 :param kwargs: (optional) additional keyword=value arguments :type kwargs: dict :return: cloned :class:`models.Part` :raises APIError: if the `Part` could not be cloned Example -...
python
def clone(self, **kwargs): """ Clone a part. .. versionadded:: 2.3 :param kwargs: (optional) additional keyword=value arguments :type kwargs: dict :return: cloned :class:`models.Part` :raises APIError: if the `Part` could not be cloned Example -...
[ "def", "clone", "(", "self", ",", "*", "*", "kwargs", ")", ":", "parent", "=", "self", ".", "parent", "(", ")", "return", "self", ".", "_client", ".", "_create_clone", "(", "parent", ",", "self", ",", "*", "*", "kwargs", ")" ]
Clone a part. .. versionadded:: 2.3 :param kwargs: (optional) additional keyword=value arguments :type kwargs: dict :return: cloned :class:`models.Part` :raises APIError: if the `Part` could not be cloned Example ------- >>> bike = client.model('Bike') ...
[ "Clone", "a", "part", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L719-L737
train
Clone a part.
KE-works/pykechain
pykechain/models/part.py
Part.copy
def copy(self, target_parent, name=None, include_children=True, include_instances=True): """ Copy the `Part` to target parent, both of them having the same category. .. versionadded:: 2.3 :param target_parent: `Part` object under which the desired `Part` is copied :type target_...
python
def copy(self, target_parent, name=None, include_children=True, include_instances=True): """ Copy the `Part` to target parent, both of them having the same category. .. versionadded:: 2.3 :param target_parent: `Part` object under which the desired `Part` is copied :type target_...
[ "def", "copy", "(", "self", ",", "target_parent", ",", "name", "=", "None", ",", "include_children", "=", "True", ",", "include_instances", "=", "True", ")", ":", "if", "self", ".", "category", "==", "Category", ".", "MODEL", "and", "target_parent", ".", ...
Copy the `Part` to target parent, both of them having the same category. .. versionadded:: 2.3 :param target_parent: `Part` object under which the desired `Part` is copied :type target_parent: :class:`Part` :param name: how the copied top-level `Part` should be called :type nam...
[ "Copy", "the", "Part", "to", "target", "parent", "both", "of", "them", "having", "the", "same", "category", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L739-L785
train
Copy the Part to target parent.
KE-works/pykechain
pykechain/models/part.py
Part.move
def move(self, target_parent, name=None, include_children=True, include_instances=True): """ Move the `Part` to target parent, both of them the same category. .. versionadded:: 2.3 :param target_parent: `Part` object under which the desired `Part` is moved :type target_parent: ...
python
def move(self, target_parent, name=None, include_children=True, include_instances=True): """ Move the `Part` to target parent, both of them the same category. .. versionadded:: 2.3 :param target_parent: `Part` object under which the desired `Part` is moved :type target_parent: ...
[ "def", "move", "(", "self", ",", "target_parent", ",", "name", "=", "None", ",", "include_children", "=", "True", ",", "include_instances", "=", "True", ")", ":", "if", "not", "name", ":", "name", "=", "self", ".", "name", "if", "self", ".", "category"...
Move the `Part` to target parent, both of them the same category. .. versionadded:: 2.3 :param target_parent: `Part` object under which the desired `Part` is moved :type target_parent: :class:`Part` :param name: how the moved top-level `Part` should be called :type name: basest...
[ "Move", "the", "Part", "to", "target", "parent", "both", "of", "them", "the", "same", "category", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L787-L839
train
Move the Part to target parent.
thomasdelaet/python-velbus
velbus/messages/channel_name_part3.py
ChannelNamePart3Message.data_to_binary
def data_to_binary(self): """ :return: bytes """ return bytes([ COMMAND_CODE, self.channels_to_byte([self.channel]) ]) + bytes(self.name, 'utf-8')
python
def data_to_binary(self): """ :return: bytes """ return bytes([ COMMAND_CODE, self.channels_to_byte([self.channel]) ]) + bytes(self.name, 'utf-8')
[ "def", "data_to_binary", "(", "self", ")", ":", "return", "bytes", "(", "[", "COMMAND_CODE", ",", "self", ".", "channels_to_byte", "(", "[", "self", ".", "channel", "]", ")", "]", ")", "+", "bytes", "(", "self", ".", "name", ",", "'utf-8'", ")" ]
:return: bytes
[ ":", "return", ":", "bytes" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/channel_name_part3.py#L36-L43
train
Convert the data to binary format.
thomasdelaet/python-velbus
velbus/messages/channel_name_part3.py
ChannelNamePart3Message.to_json
def to_json(self): """ :return: str """ json_dict = self.to_json_basic() json_dict['channel'] = self.channel return json.dumps(json_dict)
python
def to_json(self): """ :return: str """ json_dict = self.to_json_basic() json_dict['channel'] = self.channel return json.dumps(json_dict)
[ "def", "to_json", "(", "self", ")", ":", "json_dict", "=", "self", ".", "to_json_basic", "(", ")", "json_dict", "[", "'channel'", "]", "=", "self", ".", "channel", "return", "json", ".", "dumps", "(", "json_dict", ")" ]
:return: str
[ ":", "return", ":", "str" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/channel_name_part3.py#L45-L51
train
Returns a JSON string representation of the current object.
thomasdelaet/python-velbus
velbus/messages/channel_name_part3.py
ChannelNamePart3Message2.populate
def populate(self, priority, address, rtr, data): """ :return: None """ assert isinstance(data, bytes) self.needs_low_priority(priority) self.needs_no_rtr(rtr) self.needs_data(data, 5) self.set_attributes(priority, address, rtr) self.channel = data...
python
def populate(self, priority, address, rtr, data): """ :return: None """ assert isinstance(data, bytes) self.needs_low_priority(priority) self.needs_no_rtr(rtr) self.needs_data(data, 5) self.set_attributes(priority, address, rtr) self.channel = data...
[ "def", "populate", "(", "self", ",", "priority", ",", "address", ",", "rtr", ",", "data", ")", ":", "assert", "isinstance", "(", "data", ",", "bytes", ")", "self", ".", "needs_low_priority", "(", "priority", ")", "self", ".", "needs_no_rtr", "(", "rtr", ...
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/channel_name_part3.py#L59-L69
train
Populates the object with the data from the given bytes.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/biosignalsnotebooks/old/_factory.py
_generate_footer
def _generate_footer(notebook_object, notebook_type): """ Internal function that is used for generation of the notebooks footer. ---------- Parameters ---------- notebook_object : notebook object Object of "notebook" class where the header will be created. notebook_type : str ...
python
def _generate_footer(notebook_object, notebook_type): """ Internal function that is used for generation of the notebooks footer. ---------- Parameters ---------- notebook_object : notebook object Object of "notebook" class where the header will be created. notebook_type : str ...
[ "def", "_generate_footer", "(", "notebook_object", ",", "notebook_type", ")", ":", "footer_aux", "=", "FOOTER", "if", "\"Main_Files\"", "in", "notebook_type", ":", "footer_aux", "=", "footer_aux", ".", "replace", "(", "\"../MainFiles/\"", ",", "\"\"", ")", "# ====...
Internal function that is used for generation of the notebooks footer. ---------- Parameters ---------- notebook_object : notebook object Object of "notebook" class where the header will be created. notebook_type : str Notebook type: - "Main_Files_Signal_Samples" ...
[ "Internal", "function", "that", "is", "used", "for", "generation", "of", "the", "notebooks", "footer", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/biosignalsnotebooks/old/_factory.py#L343-L383
train
Internal function that is used for generating the notebooks footer.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/biosignalsnotebooks/old/_factory.py
_generate_notebook_by_difficulty_body
def _generate_notebook_by_difficulty_body(notebook_object, dict_by_difficulty): """ Internal function that is used for generation of the page where notebooks are organized by difficulty level. ---------- Parameters ---------- notebook_object : notebook object Object of "notebook" cl...
python
def _generate_notebook_by_difficulty_body(notebook_object, dict_by_difficulty): """ Internal function that is used for generation of the page where notebooks are organized by difficulty level. ---------- Parameters ---------- notebook_object : notebook object Object of "notebook" cl...
[ "def", "_generate_notebook_by_difficulty_body", "(", "notebook_object", ",", "dict_by_difficulty", ")", ":", "difficulty_keys", "=", "list", "(", "dict_by_difficulty", ".", "keys", "(", ")", ")", "difficulty_keys", ".", "sort", "(", ")", "for", "difficulty", "in", ...
Internal function that is used for generation of the page where notebooks are organized by difficulty level. ---------- Parameters ---------- notebook_object : notebook object Object of "notebook" class where the body will be created. dict_by_difficulty : dict Global Dictionary...
[ "Internal", "function", "that", "is", "used", "for", "generation", "of", "the", "page", "where", "notebooks", "are", "organized", "by", "difficulty", "level", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/biosignalsnotebooks/old/_factory.py#L442-L481
train
Internal function that is used for generating the page where notebooks are organized by difficulty level.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/biosignalsnotebooks/old/_factory.py
_generate_dir_structure
def _generate_dir_structure(path): """ Internal function intended to generate the biosignalsnotebooks directories in order to the user can visualise and execute the Notebook created with "notebook" class in Jupyter. ---------- Parameters ---------- path : str Path where the biosigna...
python
def _generate_dir_structure(path): """ Internal function intended to generate the biosignalsnotebooks directories in order to the user can visualise and execute the Notebook created with "notebook" class in Jupyter. ---------- Parameters ---------- path : str Path where the biosigna...
[ "def", "_generate_dir_structure", "(", "path", ")", ":", "# ============================ Creation of the main directory ==================================", "current_dir", "=", "(", "path", "+", "\"\\\\opensignalsfactory_environment\"", ")", ".", "replace", "(", "\"\\\\\"", ",", ...
Internal function intended to generate the biosignalsnotebooks directories in order to the user can visualise and execute the Notebook created with "notebook" class in Jupyter. ---------- Parameters ---------- path : str Path where the biosignalsnotebooks environment (files and folders) wil...
[ "Internal", "function", "intended", "to", "generate", "the", "biosignalsnotebooks", "directories", "in", "order", "to", "the", "user", "can", "visualise", "and", "execute", "the", "Notebook", "created", "with", "notebook", "class", "in", "Jupyter", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/biosignalsnotebooks/old/_factory.py#L669-L713
train
Internal function that generates the biosignalsnotebooks directories.