This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2020-09-05 23:07:06 +00:00
|
|
|
"""Apply flow from commandline"""
|
|
|
|
from django.core.management.base import BaseCommand, no_translations
|
|
|
|
|
|
|
|
from passbook.flows.transfer.importer import FlowImporter
|
|
|
|
|
|
|
|
|
2020-09-16 19:54:35 +00:00
|
|
|
class Command(BaseCommand): # pragma: no cover
|
2020-09-05 23:07:06 +00:00
|
|
|
"""Apply flow from commandline"""
|
|
|
|
|
|
|
|
@no_translations
|
|
|
|
def handle(self, *args, **options):
|
|
|
|
"""Apply all flows in order, abort when one fails to import"""
|
|
|
|
for flow_path in options.get("flows", []):
|
|
|
|
with open(flow_path, "r") as flow_file:
|
|
|
|
importer = FlowImporter(flow_file.read())
|
|
|
|
valid = importer.validate()
|
|
|
|
if not valid:
|
|
|
|
raise ValueError("Flow invalid")
|
|
|
|
importer.apply()
|
|
|
|
|
|
|
|
def add_arguments(self, parser):
|
|
|
|
parser.add_argument("flows", nargs="+", type=str)
|