Django command minor enhancements.

This commit is contained in:
Romain Dorgueil
2019-04-19 14:56:04 +02:00
parent 7462b6e33b
commit e5110b14b1
5 changed files with 12 additions and 7 deletions

6
.isort.cfg Normal file
View File

@ -0,0 +1,6 @@
[settings]
line_length=120
indent=' '
multi_line_output=5
known_first_party=bonobo
known_third_party=mondrian,whistle

View File

@ -195,4 +195,3 @@ def open_examples_fs(*pathsegments):
api.register_group(get_argument_parser, parse_args)

View File

@ -23,5 +23,6 @@ class partial(functools.partial):
@property
def __name__(self):
return get_name(self.func)
def using(self, *service_names):
return use(*service_names)(self)

View File

@ -61,11 +61,10 @@ class ETLCommand(BaseCommand):
for i, graph in enumerate(graph_coll):
if not isinstance(graph, bonobo.Graph):
raise ValueError("Expected a Graph instance, got {!r}.".format(graph))
print(term.lightwhite("{}. {}".format(i + 1, graph.name)))
print(term.lightwhite("{}. {}".format(i + 1, graph.name or repr(graph).strip("<>"))))
result = bonobo.run(graph, services=services, strategy=strategy)
results.append(result)
print(term.lightblack(" ... return value: " + str(result)))
print()
return results
@ -76,6 +75,6 @@ class ETLCommand(BaseCommand):
self.stderr = OutputWrapper(ConsoleOutputPlugin._stderr, ending=CLEAR_EOL + "\n")
self.stderr.style_func = lambda x: Fore.LIGHTRED_EX + Back.RED + "!" + Style.RESET_ALL + " " + x
self.run(*args, **options)
results = self.run(*args, **options)
self.stdout, self.stderr = _stdout_backup, _stderr_backup

View File

@ -18,9 +18,9 @@ class ApiHelper:
assert (
len(parameters) > 0 and parameters[0] == "graph"
), 'First parameter of a graph api function must be "graph".'
assert required_parameters.intersection(parameters) == required_parameters, (
"Graph api functions must define the following parameters: " + ", ".join(sorted(required_parameters))
)
assert (
required_parameters.intersection(parameters) == required_parameters
), "Graph api functions must define the following parameters: " + ", ".join(sorted(required_parameters))
self.__all__.append(get_name(x))
return x