Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linting #64

Merged
merged 2 commits into from
Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
adding flake8 linter, fixing lint errors
  • Loading branch information
timkpaine authored and maartenbreddels committed Jan 30, 2019
commit 716b8d564c7e23c22043d7f15329a621e770ef77
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ before_install:
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda info -a
- conda create -q -n test-environment -c conda-forge python=$PYTHON_VERSION jupyter_server pytest==3.10.1 pytest-cov nodejs
- conda create -q -n test-environment -c conda-forge python=$PYTHON_VERSION jupyter_server pytest==3.10.1 pytest-cov nodejs flake8
- source activate test-environment
install:
- pip install ".[test]"
before_script:
- flake8 voila
script:
- py.test tests/
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ universal = 1

[metadata]
license_file = LICENSE

[flake8]
max-line-length=200
1 change: 1 addition & 0 deletions voila/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# The full license is in the file LICENSE, distributed with this software. #
#############################################################################


def _jupyter_nbextension_paths():
return [dict(
section="notebook",
Expand Down
10 changes: 3 additions & 7 deletions voila/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
#############################################################################

from zmq.eventloop import ioloop

ioloop.install()

import os
import shutil
import tempfile
import json
import logging
import gettext

Expand Down Expand Up @@ -41,6 +37,7 @@
from ._version import __version__
from .static_file_handler import MultiStaticFileHandler

ioloop.install()
_kernel_id_regex = r"(?P<kernel_id>\w+-\w+-\w+-\w+-\w+)"


Expand Down Expand Up @@ -72,9 +69,7 @@ class Voila(Application):
config=True,
help='Will autoreload to server and the page when a template, js file or Python code changes'
)
root_dir = Unicode(config=True,
help="The directory to use for notebooks."
)
root_dir = Unicode(config=True, help="The directory to use for notebooks.")
static_root = Unicode(
STATIC_ROOT,
config=True,
Expand Down Expand Up @@ -255,4 +250,5 @@ def listen(self):
finally:
shutil.rmtree(self.connection_dir)


main = Voila.launch_instance
3 changes: 1 addition & 2 deletions voila/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from jupyter_server.base.handlers import JupyterHandler

import nbformat
import nbformat # noqa: F401
from nbconvert.preprocessors.execute import executenb
from nbconvert import HTMLExporter

Expand Down Expand Up @@ -87,4 +87,3 @@ def filter_empty_code_cells(cell):
# Compose reply
self.set_header('Content-Type', 'text/html')
self.write(html)

8 changes: 5 additions & 3 deletions voila/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
#############################################################################

import os
import json
from jupyter_core.paths import jupyter_path

ROOT = os.path.dirname(__file__)
STATIC_ROOT = os.path.join(ROOT, 'static')


def collect_template_paths(
nbconvert_template_paths,
static_paths,
Expand Down Expand Up @@ -41,19 +43,19 @@ def collect_template_paths(
conf.get('base_template', 'default'))

extra_nbconvert_path = os.path.join(dirname, 'nbconvert_templates')
#if not os.path.exists(extra_nbconvert_path):
# if not os.path.exists(extra_nbconvert_path):
# log.warning('template named %s found at path %r, but %s does not exist', template_name,
# dirname, extra_nbconvert_path)
nbconvert_template_paths.insert(0, extra_nbconvert_path)

extra_static_path = os.path.join(dirname, 'static')
#if not os.path.exists(extra_static_path):
# if not os.path.exists(extra_static_path):
# log.warning('template named %s found at path %r, but %s does not exist', template_name,
# dirname, extra_static_path)
static_paths.insert(0, extra_static_path)

extra_template_path = os.path.join(dirname, 'templates')
#if not os.path.exists(extra_template_path):
# if not os.path.exists(extra_template_path):
# log.warning('template named %s found at path %r, but %s does not exist', template_name,
# dirname, extra_template_path)
template_paths.insert(0, extra_template_path)
Expand Down
2 changes: 0 additions & 2 deletions voila/server_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

from jinja2 import Environment, FileSystemLoader

from jupyter_core.paths import jupyter_path

from jupyter_server.utils import url_path_join
from jupyter_server.base.handlers import path_regex
from jupyter_server.base.handlers import FileFindHandler
Expand Down
2 changes: 1 addition & 1 deletion voila/static_file_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class MultiStaticFileHandler(tornado.web.StaticFileHandler):
"""A static file handler that 'merges' a list of directories

If initialized like this::

application = web.Application([
Expand Down
17 changes: 8 additions & 9 deletions voila/treehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def generate_breadcrumbs(self, path):
for i in range(len(parts)):
if parts[i]:
link = url_path_join(self.base_url, 'voila/tree',
url_escape(url_path_join(*parts[:i + 1])),
)
url_escape(url_path_join(*parts[:i + 1])),
)
breadcrumbs.append((link, parts[i]))
return breadcrumbs

Expand All @@ -49,13 +49,12 @@ def get(self, path=''):
page_title = self.generate_page_title(path)
contents = cm.get(path)
self.write(self.render_template('tree.html',
page_title=page_title,
notebook_path=path,
breadcrumbs=breadcrumbs,
contents=contents,
terminals_available=False,
server_root=self.settings['server_root_dir'],
))
page_title=page_title,
notebook_path=path,
breadcrumbs=breadcrumbs,
contents=contents,
terminals_available=False,
server_root=self.settings['server_root_dir']))
elif cm.file_exists(path):
# it's not a directory, we have redirecting to do
model = cm.get(path, content=False)
Expand Down