get_realizations.py
1 KB
#-*- coding:utf-8 -*-
import codecs
from django.core.management.base import BaseCommand
from django.utils.encoding import smart_str
from dictionary.models import Argument
class Command(BaseCommand):
args = 'none'
help = """
Get list of argument realizations and write it to the real.txt file in
data dir.
"""
def handle(self, **options):
get_realizations()
def get_realizations():
"""
Get list of argument realizations and write it to the real.txt file in
data dir.
"""
real_path = 'data/real.txt'
real_file = codecs.open(real_path, 'wt', 'utf-8')
for arg in Argument.objects.order_by('type').all():
if arg.realizations.count() > 0:
print smart_str(arg.text_rep)
real_file.write(arg.text_rep + u'-->\n')
for real in arg.realizations.order_by('type'):
real_file.write(' ' + real.text_rep + '\n')
real_file.close()