New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

robotkernel

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

robotkernel - pypi Package Compare versions

Comparing version
1.6a1
to
1.6a2
+105
src/robotkernel/display_ipykernel.py
# -*- coding: utf-8 -*-
from ipykernel.comm import CommManager
from ipykernel.kernelbase import Kernel
from ipykernel.zmqshell import ZMQInteractiveShell
from traitlets import Any
from traitlets import Instance
from traitlets import Type
class DisplayKernel(Kernel):
"""BaseKernel with interactive shell for display hooks."""
shell = Instance(
"IPython.core.interactiveshell.InteractiveShellABC", allow_none=True
)
shell_class = Type(ZMQInteractiveShell)
def __init__(self, **kwargs):
super().__init__(**kwargs)
# Configure IPython shell
self.shell = self.shell_class.instance(
parent=self,
profile_dir=self.profile_dir,
user_module=self.user_module,
user_ns=self.user_ns,
kernel=self,
)
self.shell.displayhook.session = self.session
self.shell.displayhook.pub_socket = self.iopub_socket
self.shell.displayhook.topic = self._topic("execute_result")
self.shell.display_pub.session = self.session
self.shell.display_pub.pub_socket = self.iopub_socket
self.comm_manager = CommManager(parent=self, kernel=self)
self.shell.configurables.append(self.comm_manager)
for type_ in ["comm_open", "comm_msg", "comm_close"]:
self.shell_handlers[type_] = getattr(self.comm_manager, type_)
user_module = Any()
def _user_module_changed(self, name, old, new):
if self.shell is not None:
self.shell.user_module = new
user_ns = Instance(dict, args=(), allow_none=True)
def _user_ns_changed(self, name, old, new):
if self.shell is not None:
self.shell.user_ns = new
self.shell.init_user_ns()
def start(self):
self.shell.exit_now = False
super().start()
def set_parent(self, ident, parent, *args, **kwargs):
"""Overridden from parent to tell the display hook and output streams about the parent message."""
super().set_parent(ident, parent, *args, **kwargs)
self.shell.set_parent(parent)
def do_shutdown(self, restart):
self.shell.exit_now = True
def send_error(self, content=None):
self.send_response(self.iopub_socket, "error", content)
def send_display_data(self, data=None, metadata=None, display_id=None):
if isinstance(data, str):
self.send_response(
self.iopub_socket, "display_data", {"data": {"text/plain": data}}
)
else:
self.send_response(
self.iopub_socket,
"display_data",
{
"data": data or {},
"metadata": metadata or {},
"transient": {"display_id": display_id},
},
)
def send_update_display_data(self, data=None, metadata=None, display_id=None):
self.send_response(
self.iopub_socket,
"update_display_data",
{
"data": data or {},
"metadata": metadata or {},
"transient": {"display_id": display_id},
},
)
def send_execute_result(self, data=None, metadata=None, display_id=None):
self.send_response(
self.iopub_socket,
"execute_result",
{
"data": data or {},
"metadata": metadata or {},
"transient": {"display_id": display_id},
"execution_count": self.execution_count,
},
)
# -*- coding: utf-8 -*-
from IPython import get_ipython
from pyolite import ipython_shell
import json
class DisplayKernel:
"""BaseKernel with interactive shell for display hooks."""
def __init__(self, *args, **kwargs):
self.shell = ipython_shell
self.shell.displayhook.publish_execution_error = None
self.execution_count = 0
def _get_parent_header(self):
ip = get_ipython()
return ip.kernel._parent_header
def _set_parent_header(self, header):
ip = get_ipython()
ip.kernel._parent_header = header
_parent_header = property(_get_parent_header, _set_parent_header)
def get_parent(self):
ip = get_ipython()
return ip.kernel.get_parent()
@property
def user_ns(self):
return self.shell.user_ns
@property
def comm_manager(self):
ip = get_ipython()
return ip.kernel.comm_manager
@property
def comm_info(self):
ip = get_ipython()
return ip.kernel.comm_info
@property
def interpreter(self):
ip = get_ipython()
return ip.kernel.interpreter
def start(self):
self.execution_count = 0
self.shell.exit_now = False
def set_parent(self, ident, parent, *args, **kwargs):
"""Overridden from parent to tell the display hook and output streams about the parent message."""
self.shell.set_parent(parent)
def do_shutdown(self, restart):
self.execution_count = 0
self.shell.exit_now = True
def send_display_data(self, data=None, metadata=None, display_id=None):
if isinstance(data, str):
self.shell.display_pub.publish(**{"data": {"text/plain": data}})
else:
self.shell.display_pub.publish(
**{
"data": data or {},
"metadata": metadata or {},
"transient": {"display_id": display_id},
},
)
def send_update_display_data(self, data=None, metadata=None, display_id=None):
self.shell.display_pub.publish(
**{
"data": data or {},
"metadata": metadata or {},
"transient": {"display_id": display_id},
"update": True,
},
)
def send_execute_result(self, data=None, metadata=None, display_id=None):
self.shell.displayhook.publish_execution_result(
self.execution_count,
data or {},
metadata or {},
display_id and {"display_id": display_id} or {},
)
def send_error(self, content=None):
self.shell.displayhook.publish_execution_error(
f"{content['ename']}",
f"{content['evalue']}",
json.dumps(content["traceback"]),
)
def inspect(self, code, cursor_pos, detail_level):
return self.do_inspect(code, cursor_pos, detail_level)
def is_complete(self, code, cursor_pos):
result = self.do_complete(code, cursor_pos)
if result["cursor_start"] != result["cursor_end"]:
result["status"] = "incomplete"
result["indent"] = " " * (
len(code[: result["cursor_end"]])
- len(code[: result["cursor_end"]].lstrip())
)
return result
def complete(self, code, cursor_pos):
return self.do_complete(code, cursor_pos)
def run(self, code):
self.execution_count += 1
return self.do_execute(code, silent=False)
+6
-0
Changelog
=========
1.6a2 (2022-03-09)
------------------
- Add pyolite support
[datakurre]
1.6.0a1 (2022-02-22)

@@ -5,0 +11,0 @@ --------------------

+7
-1
Metadata-Version: 2.1
Name: robotkernel
Version: 1.6a1
Version: 1.6a2
Summary: A Jupyter kernel for interactive acceptance-test-driven development with the Robot Framework

@@ -193,2 +193,8 @@ Home-page: https://github.com/robots-from-jupyter/robotkernel

1.6a2 (2022-03-09)
------------------
- Add pyolite support
[datakurre]
1.6.0a1 (2022-02-22)

@@ -195,0 +201,0 @@ --------------------

+1
-1
[metadata]
name = robotkernel
version = 1.6a1
version = 1.6a2
description = A Jupyter kernel for interactive acceptance-test-driven development with the Robot Framework

@@ -5,0 +5,0 @@ long_description = file: README.rst, CHANGELOG.rst

Metadata-Version: 2.1
Name: robotkernel
Version: 1.6a1
Version: 1.6a2
Summary: A Jupyter kernel for interactive acceptance-test-driven development with the Robot Framework

@@ -193,2 +193,8 @@ Home-page: https://github.com/robots-from-jupyter/robotkernel

1.6a2 (2022-03-09)
------------------
- Add pyolite support
[datakurre]
1.6.0a1 (2022-02-22)

@@ -195,0 +201,0 @@ --------------------

@@ -66,2 +66,4 @@ .gitignore

src/robotkernel/display.py
src/robotkernel/display_ipykernel.py
src/robotkernel/display_pyolite.py
src/robotkernel/exceptions.py

@@ -68,0 +70,0 @@ src/robotkernel/executors.py

# -*- coding: utf-8 -*-
from io import StringIO
from ipykernel.comm import CommManager
from ipykernel.kernelbase import Kernel
from ipykernel.zmqshell import ZMQInteractiveShell
from robotkernel.constants import THROBBER
from traitlets import Any
from traitlets import Instance
from traitlets import Type
import re
class DisplayKernel(Kernel):
"""BaseKernel with interactive shell for display hooks."""
try:
from robotkernel.display_ipykernel import DisplayKernel
except ImportError:
from robotkernel.display_pyolite import DisplayKernel
shell = Instance(
"IPython.core.interactiveshell.InteractiveShellABC", allow_none=True
)
shell_class = Type(ZMQInteractiveShell)
def __init__(self, **kwargs):
super().__init__(**kwargs)
# Configure IPython shell
self.shell = self.shell_class.instance(
parent=self,
profile_dir=self.profile_dir,
user_module=self.user_module,
user_ns=self.user_ns,
kernel=self,
)
self.shell.displayhook.session = self.session
self.shell.displayhook.pub_socket = self.iopub_socket
self.shell.displayhook.topic = self._topic("execute_result")
self.shell.display_pub.session = self.session
self.shell.display_pub.pub_socket = self.iopub_socket
self.comm_manager = CommManager(parent=self, kernel=self)
self.shell.configurables.append(self.comm_manager)
for type_ in ["comm_open", "comm_msg", "comm_close"]:
self.shell_handlers[type_] = getattr(self.comm_manager, type_)
user_module = Any()
def _user_module_changed(self, name, old, new):
if self.shell is not None:
self.shell.user_module = new
user_ns = Instance(dict, args=(), allow_none=True)
def _user_ns_changed(self, name, old, new):
if self.shell is not None:
self.shell.user_ns = new
self.shell.init_user_ns()
def start(self):
self.shell.exit_now = False
super().start()
def set_parent(self, ident, parent, *args, **kwargs):
"""Overridden from parent to tell the display hook and output streams about the parent message."""
super().set_parent(ident, parent, *args, **kwargs)
self.shell.set_parent(parent)
def do_shutdown(self, restart):
self.shell.exit_now = True
def send_error(self, content=None):
self.send_response(self.iopub_socket, "error", content)
def send_display_data(self, data=None, metadata=None, display_id=None):
if isinstance(data, str):
self.send_response(
self.iopub_socket, "display_data", {"data": {"text/plain": data}}
)
else:
self.send_response(
self.iopub_socket,
"display_data",
{
"data": data or {},
"metadata": metadata or {},
"transient": {"display_id": display_id},
},
)
def send_update_display_data(self, data=None, metadata=None, display_id=None):
self.send_response(
self.iopub_socket,
"update_display_data",
{
"data": data or {},
"metadata": metadata or {},
"transient": {"display_id": display_id},
},
)
def send_execute_result(self, data=None, metadata=None, display_id=None):
self.send_response(
self.iopub_socket,
"execute_result",
{
"data": data or {},
"metadata": metadata or {},
"transient": {"display_id": display_id},
"execution_count": self.execution_count,
},
)
class ProgressUpdater(StringIO):

@@ -112,0 +14,0 @@ """Wrapper designed to capture robot.api.logger.console and display it."""

@@ -5,3 +5,2 @@ # -*- coding: utf-8 -*-

from io import StringIO
from IPython.core.display import clear_output
from IPython.core.display import display

@@ -134,3 +133,3 @@ from PIL import Image

widget.disabled = True
clear_output(wait=True)
out.clear_output(wait=True)
try:

@@ -137,0 +136,0 @@ execute(**values)

# -*- coding: utf-8 -*-
from collections import OrderedDict
from IPython.utils.tokenutil import line_at_cursor
from robotkernel import __version__

@@ -43,2 +42,8 @@ from robotkernel.completion_finders import complete_libraries

try:
from IPython.utils.tokenutil import line_at_cursor
except (ImportError, RecursionError):
from pyolite.kernel import line_at_cursor
if HAS_NBIMPORTER:

@@ -49,3 +54,3 @@ import nbimporter # noqa

# noinspection PyAbstractClass,DuplicatedCode
class RobotKernel(DisplayKernel):
class RobotKernel(DisplayKernel): # noqa: R0901 Too many ancestors
implementation = "IRobot"

@@ -52,0 +57,0 @@ implementation_version = __version__