diff options
Diffstat (limited to 'chimere/management/commands/v3_to_v2_routes.py')
| -rw-r--r-- | chimere/management/commands/v3_to_v2_routes.py | 26 | 
1 files changed, 26 insertions, 0 deletions
diff --git a/chimere/management/commands/v3_to_v2_routes.py b/chimere/management/commands/v3_to_v2_routes.py new file mode 100644 index 0000000..d373e25 --- /dev/null +++ b/chimere/management/commands/v3_to_v2_routes.py @@ -0,0 +1,26 @@ +from io import StringIO +import json + +from django.core.management import call_command +from django.core.management.base import BaseCommand + + +class Command(BaseCommand): +    help = "Route dump for v2" + +    def handle(self, *args, **options): +        out = StringIO() +        call_command('dumpdata', 'chimere.Route', indent=4, stdout=out) +        vals = out.getvalue() +        routes = json.loads(vals) +        new_routes = [] +        for route in routes: +            data = route.copy() +            data['fields'].pop('weight') +            data['fields'].pop('normalised_weight') +            data['fields'].pop('color') +            new_routes.append(data) +        res = json.dumps(new_routes) +        self.stdout.write(res) + +  | 
