import_roles.py
1.29 KB
#! /usr/bin/python
# -*- coding: utf-8 -*-
from django.core.management.base import BaseCommand
from settings import PROJECT_PATH
from semantics.models import SemanticRole
ROLE_NAMES = [('Initiator', '91,106,217', None), ('Stimulus', '62,173,226', None), ('Theme', '90,179,69', None), ('Experiencer', '149,195,86', None), ('Factor', '82,150,87', None), ('Instrument', '199,221,60', None), ('Recipient', '203,77,141', None), ('Result', '231,155,159', None), ('Cause', '127,199,195', None), ('Condition', '219,235,234', None), ('Attribute', '220,53,47', None), ('Manner', '191,48,44', None), ('Measure', '238,72,154', None), ('Location', '187,129,45', None), ('Path', '224,121,44', None), ('Time', '242,236,54', None), ('Duration', '233,192,6', None), ('Purpose', '171,85,186', None), ('Source', None, 'left'), ('Foreground', None, 'top'), ('Background', None, 'bottom'), ('Goal', None, 'right')]
#==========================================================#
class Command(BaseCommand):
args = 'none'
help = ''
def handle(self, **options):
import_roles()
def import_roles():
roles = []
for role_name, color, gradient in ROLE_NAMES:
r = SemanticRole(role=role_name, color=color, gradient=gradient)
roles.append(r)
SemanticRole.objects.bulk_create(roles)