create_TEI_walenty.py 891 Bytes
#-*- coding:utf-8 -*-

import datetime
import os

from django.core.management.base import BaseCommand

from dictionary.models import Lemma, Frame_Opinion_Value, \
                              get_checked_statuses
from dictionary.teixml import createteixml
from settings import WALENTY_PATH

class Command(BaseCommand):
    args = 'none'
    
    def handle(self, *args, **options):
        now = datetime.datetime.now().strftime('%Y%m%d')
        filename_base = '%s_%s.xml' % ('walenty', now)
        outpath = os.path.join(WALENTY_PATH, filename_base)
        checked_statuses = get_checked_statuses()
        lemmas = Lemma.objects.filter(old=False).order_by('entry_obj__name')
        checked_lemmas = lemmas.filter(status__in=checked_statuses)
        frame_opinion_values = Frame_Opinion_Value.objects.all()
        createteixml(outpath, checked_lemmas, frame_opinion_values)