misc: migrate to mondrian 0.8, humanize cli commands
This commit is contained in:
@ -46,7 +46,7 @@ python.add_requirements(
|
|||||||
'fs ~=2.0',
|
'fs ~=2.0',
|
||||||
'graphviz >=0.8,<0.9',
|
'graphviz >=0.8,<0.9',
|
||||||
'jinja2 ~=2.9',
|
'jinja2 ~=2.9',
|
||||||
'mondrian ~=0.7',
|
'mondrian ~=0.8',
|
||||||
'packaging ~=17.0',
|
'packaging ~=17.0',
|
||||||
'psutil ~=5.4',
|
'psutil ~=5.4',
|
||||||
'python-slugify ~=1.2.0',
|
'python-slugify ~=1.2.0',
|
||||||
|
|||||||
@ -7,6 +7,7 @@ from contextlib import contextmanager
|
|||||||
import bonobo.util.environ
|
import bonobo.util.environ
|
||||||
from bonobo.util import get_name
|
from bonobo.util import get_name
|
||||||
from bonobo.util.environ import get_argument_parser, parse_args
|
from bonobo.util.environ import get_argument_parser, parse_args
|
||||||
|
from mondrian import humanizer
|
||||||
|
|
||||||
|
|
||||||
class BaseCommand:
|
class BaseCommand:
|
||||||
@ -60,7 +61,8 @@ class BaseGraphCommand(BaseCommand):
|
|||||||
return options
|
return options
|
||||||
|
|
||||||
def handle(self, file, mod, **options):
|
def handle(self, file, mod, **options):
|
||||||
options = self.parse_options(**options)
|
with humanizer.humanize():
|
||||||
|
options = self.parse_options(**options)
|
||||||
with self.read(file, mod, **options) as (graph, graph_execution_options, options):
|
with self.read(file, mod, **options) as (graph, graph_execution_options, options):
|
||||||
return self.do_handle(graph, **graph_execution_options, **options)
|
return self.do_handle(graph, **graph_execution_options, **options)
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import bonobo
|
|||||||
from bonobo.commands import BaseCommand
|
from bonobo.commands import BaseCommand
|
||||||
from bonobo.registry import READER, WRITER, default_registry
|
from bonobo.registry import READER, WRITER, default_registry
|
||||||
from bonobo.util.resolvers import _resolve_options, _resolve_transformations
|
from bonobo.util.resolvers import _resolve_options, _resolve_transformations
|
||||||
|
from mondrian import humanizer
|
||||||
|
|
||||||
|
|
||||||
class ConvertCommand(BaseCommand):
|
class ConvertCommand(BaseCommand):
|
||||||
@ -48,6 +49,7 @@ class ConvertCommand(BaseCommand):
|
|||||||
help="Add a named option to the writer factory.",
|
help="Add a named option to the writer factory.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@humanizer.humanize()
|
||||||
def handle(
|
def handle(
|
||||||
self,
|
self,
|
||||||
input_filename,
|
input_filename,
|
||||||
@ -60,6 +62,8 @@ class ConvertCommand(BaseCommand):
|
|||||||
limit=None,
|
limit=None,
|
||||||
transformation=None,
|
transformation=None,
|
||||||
):
|
):
|
||||||
|
graph = bonobo.Graph()
|
||||||
|
|
||||||
reader_factory = default_registry.get_reader_factory_for(input_filename, format=reader)
|
reader_factory = default_registry.get_reader_factory_for(input_filename, format=reader)
|
||||||
reader_kwargs = _resolve_options((option or []) + (reader_option or []))
|
reader_kwargs = _resolve_options((option or []) + (reader_option or []))
|
||||||
|
|
||||||
@ -78,7 +82,6 @@ class ConvertCommand(BaseCommand):
|
|||||||
|
|
||||||
transformations += _resolve_transformations(transformation)
|
transformations += _resolve_transformations(transformation)
|
||||||
|
|
||||||
graph = bonobo.Graph()
|
|
||||||
graph.add_chain(
|
graph.add_chain(
|
||||||
reader_factory(input_filename, **reader_kwargs),
|
reader_factory(input_filename, **reader_kwargs),
|
||||||
*transformations,
|
*transformations,
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import os
|
|||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
|
||||||
from bonobo.commands import BaseCommand
|
from bonobo.commands import BaseCommand
|
||||||
|
from mondrian import humanizer
|
||||||
|
|
||||||
|
|
||||||
class InitCommand(BaseCommand):
|
class InitCommand(BaseCommand):
|
||||||
@ -30,7 +31,11 @@ class InitCommand(BaseCommand):
|
|||||||
with open(filename, "w+") as f:
|
with open(filename, "w+") as f:
|
||||||
f.write(template.render(name=name))
|
f.write(template.render(name=name))
|
||||||
|
|
||||||
self.logger.info("Generated {} using template {!r}.".format(filename, template_name))
|
print(
|
||||||
|
humanizer.Success(
|
||||||
|
"Generated {} using template {!r}.".format(filename, template_name)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def create_package(self, *, filename):
|
def create_package(self, *, filename):
|
||||||
_, ext = os.path.splitext(filename)
|
_, ext = os.path.splitext(filename)
|
||||||
@ -52,18 +57,23 @@ class InitCommand(BaseCommand):
|
|||||||
self.logger.info('Generated "{}" package with medikit.'.format(package_name))
|
self.logger.info('Generated "{}" package with medikit.'.format(package_name))
|
||||||
self.create_file_from_template(template="default", filename=os.path.join(filename, package_name, "__main__.py"))
|
self.create_file_from_template(template="default", filename=os.path.join(filename, package_name, "__main__.py"))
|
||||||
|
|
||||||
print('Your "{}" package has been created.'.format(package_name))
|
print(
|
||||||
print()
|
humanizer.Success(
|
||||||
print("Install it...")
|
'Package "{}" has been created.'.format(package_name),
|
||||||
print()
|
'',
|
||||||
print(" pip install --editable {}".format(filename))
|
"Install it...",
|
||||||
print()
|
'',
|
||||||
print("Then maybe run the example...")
|
" $ `pip install --editable {}`".format(filename),
|
||||||
print()
|
'',
|
||||||
print(" python -m {}".format(package_name))
|
"Then maybe run the example...",
|
||||||
print()
|
'',
|
||||||
print("Enjoy!")
|
" $ `python -m {}`".format(package_name),
|
||||||
|
'',
|
||||||
|
"Enjoy!"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
@humanizer.humanize()
|
||||||
def handle(self, *, template, filename, package=False, force=False):
|
def handle(self, *, template, filename, package=False, force=False):
|
||||||
if os.path.exists(filename) and not force:
|
if os.path.exists(filename) and not force:
|
||||||
raise FileExistsError("Target filename already exists, use --force to override.")
|
raise FileExistsError("Target filename already exists, use --force to override.")
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
from bonobo.commands import BaseCommand
|
from bonobo.commands import BaseCommand
|
||||||
|
from mondrian import humanizer
|
||||||
|
|
||||||
|
|
||||||
def get_versions(*, all=False, quiet=None):
|
def get_versions(*, all=False, quiet=None):
|
||||||
@ -21,6 +22,7 @@ def get_versions(*, all=False, quiet=None):
|
|||||||
|
|
||||||
|
|
||||||
class VersionCommand(BaseCommand):
|
class VersionCommand(BaseCommand):
|
||||||
|
@humanizer.humanize()
|
||||||
def handle(self, *, all=False, quiet=False):
|
def handle(self, *, all=False, quiet=False):
|
||||||
for line in get_versions(all=all, quiet=quiet):
|
for line in get_versions(all=all, quiet=quiet):
|
||||||
print(line)
|
print(line)
|
||||||
|
|||||||
57
setup.py
57
setup.py
@ -2,11 +2,10 @@
|
|||||||
# All changes will be overriden.
|
# All changes will be overriden.
|
||||||
# Edit Projectfile and run “make update” (or “medikit update”) to regenerate.
|
# Edit Projectfile and run “make update” (or “medikit update”) to regenerate.
|
||||||
|
|
||||||
|
from setuptools import setup, find_packages
|
||||||
from codecs import open
|
from codecs import open
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
from setuptools import find_packages, setup
|
|
||||||
|
|
||||||
here = path.abspath(path.dirname(__file__))
|
here = path.abspath(path.dirname(__file__))
|
||||||
|
|
||||||
# Py3 compatibility hacks, borrowed from IPython.
|
# Py3 compatibility hacks, borrowed from IPython.
|
||||||
@ -45,17 +44,14 @@ else:
|
|||||||
setup(
|
setup(
|
||||||
author='Romain Dorgueil',
|
author='Romain Dorgueil',
|
||||||
author_email='romain@dorgueil.net',
|
author_email='romain@dorgueil.net',
|
||||||
data_files=[
|
data_files=[('share/jupyter/nbextensions/bonobo-jupyter', [
|
||||||
(
|
'bonobo/contrib/jupyter/static/extension.js',
|
||||||
'share/jupyter/nbextensions/bonobo-jupyter',
|
'bonobo/contrib/jupyter/static/index.js',
|
||||||
[
|
'bonobo/contrib/jupyter/static/index.js.map'
|
||||||
'bonobo/contrib/jupyter/static/extension.js',
|
])],
|
||||||
'bonobo/contrib/jupyter/static/index.js',
|
description=(
|
||||||
'bonobo/contrib/jupyter/static/index.js.map',
|
'Bonobo, a simple, modern and atomic extract-transform-load toolkit for '
|
||||||
],
|
'python 3.5+.'),
|
||||||
)
|
|
||||||
],
|
|
||||||
description=('Bonobo, a simple, modern and atomic extract-transform-load toolkit for ' 'python 3.5+.'),
|
|
||||||
license='Apache License, Version 2.0',
|
license='Apache License, Version 2.0',
|
||||||
name='bonobo',
|
name='bonobo',
|
||||||
python_requires='>=3.5',
|
python_requires='>=3.5',
|
||||||
@ -65,31 +61,21 @@ setup(
|
|||||||
packages=find_packages(exclude=['ez_setup', 'example', 'test']),
|
packages=find_packages(exclude=['ez_setup', 'example', 'test']),
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'cached-property (~= 1.4)',
|
'cached-property (~= 1.4)', 'fs (~= 2.0)', 'graphviz (>= 0.8, < 0.9)',
|
||||||
'fs (~= 2.0)',
|
'jinja2 (~= 2.9)', 'mondrian (~= 0.8)', 'packaging (~= 17.0)',
|
||||||
'graphviz (>= 0.8, < 0.9)',
|
'psutil (~= 5.4)', 'python-slugify (~= 1.2.0)', 'requests (~= 2.0)',
|
||||||
'jinja2 (~= 2.9)',
|
'stevedore (~= 1.27)', 'whistle (~= 1.0)'
|
||||||
'mondrian (~= 0.7)',
|
|
||||||
'packaging (~= 17.0)',
|
|
||||||
'psutil (~= 5.4)',
|
|
||||||
'python-slugify (~= 1.2.0)',
|
|
||||||
'requests (~= 2.0)',
|
|
||||||
'stevedore (~= 1.27)',
|
|
||||||
'whistle (~= 1.0)',
|
|
||||||
],
|
],
|
||||||
extras_require={
|
extras_require={
|
||||||
'dev': [
|
'dev': [
|
||||||
'cookiecutter (>= 1.5, < 1.6)',
|
'cookiecutter (>= 1.5, < 1.6)', 'coverage (~= 4.4)',
|
||||||
'coverage (~= 4.4)',
|
'pytest (~= 3.4)', 'pytest-cov (~= 2.5)',
|
||||||
'pytest (~= 3.4)',
|
'pytest-timeout (>= 1, < 2)', 'sphinx (~= 1.7)',
|
||||||
'pytest-cov (~= 2.5)',
|
'sphinx-sitemap (>= 0.2, < 0.3)'
|
||||||
'pytest-timeout (>= 1, < 2)',
|
|
||||||
'sphinx (~= 1.7)',
|
|
||||||
'sphinx-sitemap (>= 0.2, < 0.3)',
|
|
||||||
],
|
],
|
||||||
'docker': ['bonobo-docker (~= 0.6.0a1)'],
|
'docker': ['bonobo-docker (~= 0.6.0a1)'],
|
||||||
'jupyter': ['ipywidgets (~= 6.0)', 'jupyter (~= 1.0)'],
|
'jupyter': ['ipywidgets (~= 6.0)', 'jupyter (~= 1.0)'],
|
||||||
'sqlalchemy': ['bonobo-sqlalchemy (~= 0.6.0a1)'],
|
'sqlalchemy': ['bonobo-sqlalchemy (~= 0.6.0a1)']
|
||||||
},
|
},
|
||||||
entry_points={
|
entry_points={
|
||||||
'bonobo.commands': [
|
'bonobo.commands': [
|
||||||
@ -99,10 +85,11 @@ setup(
|
|||||||
'init = bonobo.commands.init:InitCommand',
|
'init = bonobo.commands.init:InitCommand',
|
||||||
'inspect = bonobo.commands.inspect:InspectCommand',
|
'inspect = bonobo.commands.inspect:InspectCommand',
|
||||||
'run = bonobo.commands.run:RunCommand',
|
'run = bonobo.commands.run:RunCommand',
|
||||||
'version = bonobo.commands.version:VersionCommand',
|
'version = bonobo.commands.version:VersionCommand'
|
||||||
],
|
],
|
||||||
'console_scripts': ['bonobo = bonobo.commands:entrypoint'],
|
'console_scripts': ['bonobo = bonobo.commands:entrypoint']
|
||||||
},
|
},
|
||||||
url='https://www.bonobo-project.org/',
|
url='https://www.bonobo-project.org/',
|
||||||
download_url='https://github.com/python-bonobo/bonobo/tarball/{version}'.format(version=version),
|
download_url='https://github.com/python-bonobo/bonobo/tarball/{version}'.
|
||||||
|
format(version=version),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user