Skip to content

Commit

Permalink
WIP: css grid support (#111)
Browse files Browse the repository at this point in the history
* initial css grid support

* use ordereddict to get widgets to appear in order

* some docs and error if sidebar is False when adding to it

* fix test calls

* fix pylint errors

* fix centering of progress indicator

* better name for progress and remove comment

* document centering solution

* finish the add function span logic

* pylint stuff

* filter templates examples and docs from checkdocs

* adhere to pydocstyle

* finish DropDown to Dropdown

* update

* add pydocstyle to test reqs

* bump webpack

* move checkdocs step

* missed some "DropDown"s

* fix copy paste error
  • Loading branch information
jwkvam committed Apr 13, 2017
1 parent ab1b4d9 commit 68b9529
Show file tree
Hide file tree
Showing 26 changed files with 606 additions and 393 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ install:
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION
- source activate test-environment
- pip install -r requirements.txt
- make checkdocs

script:
- make test
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ lint:
eslint:
eslint bowtie/src/*.js{,x}

checkdocs:
pydocstyle --count --match-dir='(?!examples|doc|.*templates)[^\.].*'

coverage:
py.test --cov=./ --cov-report html --ignore=doc

Expand Down
6 changes: 2 additions & 4 deletions bowtie/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""
Interactive dashboard toolkit
"""
"""Interactive dashboard toolkit."""

__version__ = '0.2.6'
__version__ = '0.3.0-dev'

from bowtie._layout import Layout
from bowtie._command import command
31 changes: 10 additions & 21 deletions bowtie/_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,30 @@


class WrongNumberOfArguments(TypeError):
"""The "build" function accepts an incorrect number of arguments.
"""
"""The "build" function accepts an incorrect number of arguments."""

pass


def command(func):
"""
Decorates a function for building a Bowtie
application and turns it into a command line interface.
"""Command line interface decorator.
Decorate a function for building a Bowtie
application and turn it into a command line interface.
"""

@click.group(options_metavar='[-p <path>] [--help]')
@click.option('--path', '-p', default='build', type=str,
help='Path to build the app.')
@click.pass_context
def cmd(ctx, path):
"""
Bowtie CLI to help build and run your app.
"""
"""Bowtie CLI to help build and run your app."""
ctx.obj = path

# pylint: disable=unused-variable
@cmd.command(add_help_option=False)
@click.pass_context
def build(ctx):
"""
Writes the app, downloads the packages, and bundles it with Webpack.
"""
"""Write the app, downloads the packages, and bundles it with Webpack."""
nargs = numargs(func)
if nargs == 0:
func()
Expand All @@ -62,9 +57,7 @@ def build(ctx):
@click.argument('extra', nargs=-1, type=click.UNPROCESSED)
@click.pass_context
def serve(ctx, extra):
"""
Serves the Bowtie app locally.
"""
"""Serve the Bowtie app."""
line = ('./{}/src/server.py'.format(ctx.obj),) + extra
call(line)

Expand All @@ -73,9 +66,7 @@ def serve(ctx, extra):
@click.argument('extra', nargs=-1, type=click.UNPROCESSED)
@click.pass_context
def dev(ctx, extra):
"""
Recompiles the app for development.
"""
"""Recompile the app for development."""
line = ('webpack', '-d') + extra
call(line, cwd=ctx.obj)

Expand All @@ -84,9 +75,7 @@ def dev(ctx, extra):
@click.argument('extra', nargs=-1, type=click.UNPROCESSED)
@click.pass_context
def prod(ctx, extra):
"""
Recompiles the app for production.
"""
"""Recompile the app for production."""
line = ('webpack', '--define', 'process.env.NODE_ENV="production"', '--progress') + extra
call(line, cwd=ctx.obj)

Expand Down
11 changes: 4 additions & 7 deletions bowtie/_compat.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
"""
python 2/3 compatability
"""
"""Python 2/3 compatability."""

import inspect
import sys
Expand All @@ -14,22 +12,21 @@
makedirs_lib = makedirs
# pylint: disable=function-redefined,missing-docstring
def makedirs(name, mode=0o777, exist_ok=False):
"""Create directories recursively."""
try:
makedirs_lib(name, mode=mode)
except OSError:
if not exist_ok:
raise

def numargs(func):
"""Gets number of arguments in python 3.
"""
"""Get number of arguments in Python 3."""
return len(inspect.signature(func).parameters)

if IS_PY2:
# pylint: disable=function-redefined
def numargs(func):
"""Gets number of arguments in python 2.
"""
"""Get number of arguments in Python 2."""
count = 0
# pylint: disable=deprecated-method
for args in inspect.getargspec(func)[:2]:
Expand Down
60 changes: 20 additions & 40 deletions bowtie/_component.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
"""
Bowtie Component classes, all visual and control components inherit these
"""Bowtie abstract component classes.
All visual and control components inherit these.
"""

# need this for get commands on python2
Expand All @@ -23,8 +24,7 @@


def varname(variable):
"""Returns the name of the given variable.
"""
"""Return the name of the given variable."""
frame = inspect.stack()[2][0]
for name, var in frame.f_locals.items():
if variable is var:
Expand All @@ -35,9 +35,7 @@ def varname(variable):


def json_conversion(obj):
"""
Encode additional objects to JSON.
"""
"""Encode additional objects to JSON."""
try:
# numpy isn't an explicit dependency of bowtie
# so we can't assume it's available
Expand All @@ -62,16 +60,12 @@ def json_conversion(obj):


def jdumps(data):
"""
Encoding Python object to JSON string with additional encoders.
"""
"""Encode Python object to JSON with additional encoders."""
return json.dumps(data, default=json_conversion)


def encoders(obj):
"""
Convert objects to msgpack encodable ones.
"""
"""Convert Python object to msgpack encodable ones."""
try:
# numpy isn't an explicit dependency of bowtie
# so we can't assume it's available
Expand All @@ -98,24 +92,17 @@ def encoders(obj):


def pack(x):
"""
Encode ``x`` into msgpack with additional encoders.
"""
"""Encode ``x`` into msgpack with additional encoders."""
return bytes(msgpack.packb(x, default=encoders))


def unpack(x):
"""
Decode ``x`` from msgpack into a string.
"""
"""Decode ``x`` from msgpack into Python object."""
return msgpack.unpackb(bytes(x['data']), encoding='utf8')


def make_event(event):
"""
Creates an event from a method signature.
"""

"""Create an event from a method signature."""
# pylint: disable=missing-docstring
@property
@wraps(event)
Expand All @@ -136,17 +123,12 @@ def actualevent(self):


def is_event(attribute):
"""
Test if a method is an event.
"""
"""Test if a method is an event."""
return attribute.startswith('on_')


def make_command(command):
"""
Creates an command from a method signature.
"""

"""Create an command from a method signature."""
# pylint: disable=missing-docstring
@wraps(command)
def actualcommand(self, *args, **kwds):
Expand All @@ -165,17 +147,12 @@ def actualcommand(self, *args, **kwds):


def is_command(attribute):
"""
Test if a method is an command.
"""
"""Test if a method is an command."""
return attribute.startswith('do_')


def make_getter(getter):
"""
Creates an command from a method signature.
"""

"""Create an command from a method signature."""
# pylint: disable=missing-docstring
def get(self, timeout=10):
name = getter.__name__
Expand All @@ -197,8 +174,8 @@ def get(self, timeout=10):


def is_getter(attribute):
"""
Test if a method is a getter.
"""Test if a method is a getter.
It can be `get` or `get_*`.
"""
return attribute.startswith('get')
Expand All @@ -220,10 +197,12 @@ def __new__(mcs, name, parents, dct):

# pylint: disable=too-few-public-methods
class Component(with_metaclass(_Maker, object)):
"""
"""Abstract class for all components.
All visual and control classes subclass this so their events
and commands get transformed by the metaclass.
"""

_NEXT_UUID = 0

@classmethod
Expand All @@ -232,6 +211,7 @@ def _next_uuid(cls):
return cls._NEXT_UUID

def __init__(self):
"""Give the component a unique ID."""
# wanted to put "self" instead of "Component"
# was surprised that didn't work
self._uuid = Component._next_uuid()
Expand Down

0 comments on commit 68b9529

Please sign in to comment.