export_variant.py 764 Bytes
# -*- coding: utf-8 -*-
from django.core.management import BaseCommand
from common.util import uniprint
from dictionary.models import TableTemplate, Cell


class Command(BaseCommand):
    args = '<variant name> <input file name>'
    help = 'Imports variant from text file'

    def handle(self, variant, **options):
        export_variant(variant)

def export_variant(variant):
    for c in Cell.objects.filter(table_template__variant__id=variant):
        tt = c.table_template
        ic = tt.inflection_characteristic
        pt = tt.pattern_type
        data = (variant, ic.part_of_speech.symbol, pt.symbol, ic.symbol,
            '', '', '', '', c.base_form_label.symbol,
            c.tag, c.prefix, c.suffix, str(c.index))
        uniprint('\t'.join(data))