Example #1
0
 def build():
     """Write the app, downloads the packages, and bundles it with Webpack."""
     nargs = numargs(func)
     if nargs == 0:
         app = func()
     else:
         raise WrongNumberOfArguments(
             'Decorated function "{}" should have no arguments, it has {}.'.
             format(func.__name__, nargs))
     _build(app)
Example #2
0
 def build(ctx):
     """Write the app, downloads the packages, and bundles it with Webpack."""
     nargs = numargs(func)
     if nargs == 0:
         func()
     elif nargs == 1:
         func(ctx.obj)
     else:
         raise WrongNumberOfArguments(
             'Function "{}" should have 0 or 1 argument, it has {}.'.format(
                 func.__name__, nargs))
Example #3
0
def test_numargs():
    """Numargs testing."""

    # pylint: disable=missing-docstring
    def onearg(x):
        return x

    def zeroarg():
        pass

    def varargs(*y):
        return y

    def onevarargs(x, *y):
        return x, y

    assert numargs(onearg) == 1
    assert numargs(onevarargs) == 2
    assert numargs(zeroarg) == 0
    assert numargs(varargs) == 1
Example #4
0
 def run(extra):
     """Build the app and serve it."""
     nargs = numargs(func)
     if nargs == 0:
         app = func()
     else:
         raise WrongNumberOfArguments(
             'Decorated function "{}" should have no arguments, it has {}.'.
             format(func.__name__, nargs))
     # pylint:disable=protected-access
     _build(app)
     filepath = './{}/src/server.py'.format(_DIRECTORY)
     line = (filepath, ) + extra
     call(line)