Skip to content

Commit

Permalink
init commit, echo kernel works
Browse files Browse the repository at this point in the history
  • Loading branch information
laixintao committed Sep 11, 2018
0 parents commit daaaa93
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 0 deletions.
112 changes: 112 additions & 0 deletions .gitignore
@@ -0,0 +1,112 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json
*.ipynb
31 changes: 31 additions & 0 deletions dot_kernel/__init__.py
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-

from ipykernel.kernelbase import Kernel


class EchoKernel(Kernel):
implementation = "Echo"
implementation_version = "1.0"
language = "no-op"
language_version = "0.1"
language_info = {
"name": "Any text",
"mimetype": "text/plain",
"file_extension": ".txt",
}
banner = "Echo kernel - as useful as a parrot"

def do_execute(
self, code, silent, store_history=True, user_expressions=None, allow_stdin=False
):
if not silent:
stream_content = {"name": "stdout", "text": code}
self.send_response(self.iopub_socket, "stream", stream_content)

return {
"status": "ok",
# The base class increments the execution count
"execution_count": self.execution_count,
"payload": [],
"user_expressions": {},
}
4 changes: 4 additions & 0 deletions dot_kernel/__main__.py
@@ -0,0 +1,4 @@
from . import EchoKernel
from ipykernel.kernelapp import IPKernelApp

IPKernelApp.launch_instance(kernel_class=EchoKernel)
4 changes: 4 additions & 0 deletions dot_kernel_spec/kernel.json
@@ -0,0 +1,4 @@
{
"argv": ["python", "-m", "dot_kernel", "-f", "{connection_file}"],
"display_name": "dot"
}
14 changes: 14 additions & 0 deletions setup.py
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-

from setuptools import setup

setup(
name="dot_kernel",
version="1.0.0",
url="https://github.com/mypackage.git",
author="Author Name",
author_email="author@gmail.com",
description="Description of my package",
packages=["dot_kernel"],
install_requires=[],
)

0 comments on commit daaaa93

Please sign in to comment.