You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
690 B
23 lines
690 B
import json |
|
|
|
from django.core.management.base import BaseCommand, CommandError |
|
|
|
from finance.exports import ExportError, write_export |
|
|
|
|
|
class Command(BaseCommand): |
|
help = "Create a versioned portable financial export." |
|
|
|
def add_arguments(self, parser): |
|
parser.add_argument("--output", dest="name") |
|
|
|
def handle(self, *args, **options): |
|
try: |
|
result = write_export(options["name"]) |
|
except ExportError as exc: |
|
raise CommandError(exc.code) from None |
|
self.stdout.write(json.dumps({ |
|
"name": result.name, |
|
"version": result.version, |
|
"rows": result.row_counts, |
|
}, separators=(",", ":")))
|
|
|