moglo_sie_odpiac.py
976 Bytes
#-*- coding:utf-8 -*-
from django.core.management.base import BaseCommand
from dictionary.models import Entry, Lemma, Lemma_Status
class Command(BaseCommand):
def handle(self, **options):
to_check()
def to_check():
all = 0
semantic_statuses = [s.id for s in Lemma_Status.objects.filter(status__startswith='(S)')]
all_entries = {e.id: len(e.rel_entries.all()) for e in Entry.objects.all()}
potential_errors = [id for id in all_entries.keys() if all_entries[id] > 1]
for id in potential_errors:
in_semantics = []
e = Entry.objects.get(id=id)
if e.actual_lemma().status.id in semantic_statuses:
for re in e.rel_entries.all():
if len(re.lemmas.all()) > 0:
if re.actual_lemma().status.id in semantic_statuses:
in_semantics.append(re.name)
if len(in_semantics) > 1:
print ' '.join(in_semantics)
all += 1
# print all