make the MAP_IDBDE an attribut of Import Command
This commit is contained in:
parent
64dd635039
commit
19d76876de
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
|
@ -15,6 +17,10 @@ class ImportCommand(BaseCommand):
|
||||||
Generic command for import of NK15 database
|
Generic command for import of NK15 database
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(args, kwargs)
|
||||||
|
self.MAP_IDBDE = dict()
|
||||||
|
|
||||||
def print_success(self, to_print):
|
def print_success(self, to_print):
|
||||||
return self.stdout.write(self.style.SUCCESS(to_print))
|
return self.stdout.write(self.style.SUCCESS(to_print))
|
||||||
|
|
||||||
|
@ -36,6 +42,14 @@ class ImportCommand(BaseCommand):
|
||||||
parser.add_argument('-c', '--chunk', type=int, default=100, help="chunk size for bulk_create")
|
parser.add_argument('-c', '--chunk', type=int, default=100, help="chunk size for bulk_create")
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
def save_map(self, filename):
|
||||||
|
with open(filename, 'w') as fp:
|
||||||
|
json.dump(self.MAP_IDBDE, fp, sort_keys=True, indent=2)
|
||||||
|
|
||||||
|
def load_map(self, filename):
|
||||||
|
with open(filename, 'w') as fp:
|
||||||
|
self.MAP_IDBDE = json.load(fp)
|
||||||
|
|
||||||
|
|
||||||
class BulkCreateManager(object):
|
class BulkCreateManager(object):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue