Пример #1
0
    def create_language(self, name, code):
        """Creates a new language called `name`, with ISO code `code`.

        :param name: name of the new language
        :type name: unicode string
        :param code: ISO code of the new language
        :type code: string
        :rtype: `Language`

        """
        try:
            Language.objects.get_by_admin_name(name)
            # QAZ: Raise a more specific exception.
            raise EATSException('A language named "%s" already exists' % name)
        except Language.DoesNotExist:
            pass
        try:
            Language.objects.get_by_code(code)
            # QAZ: Raise a more specific exception.
            raise EATSException('A language coded "%s" already exists' % code)
        except Language.DoesNotExist:
            pass
        language = self.create_topic(proxy=Language)
        language.add_type(self.language_type)
        language.create_name(name, name_type=self.admin_name_type)
        language.create_name(code, name_type=self.language_code_type)
        return language
Пример #2
0
    def create_script(self, name, code, separator):
        """Creates a new script called `name`, with ISO code `code`.

        :param name: name of the new script
        :type name: unicode string
        :param code: ISO code of the new script
        :type code: string
        :param separator: separator to be used between name parts
        :type separator: unicode string
        :rtype: `Script`

        """
        try:
            Script.objects.get_by_admin_name(name)
            # QAZ: Raise a more specific exception with error message.
            raise EATSException('A script named "%s" already exists' % name)
        except Script.DoesNotExist:
            pass
        try:
            Script.objects.get_by_code(code)
            # QAZ: Raise a more specific exception with error message.
            raise Exception('A script coded "%s" already exists' % code)
        except Script.DoesNotExist:
            pass
        script = self.create_topic(proxy=Script)
        script.add_type(self.script_type)
        script.create_name(name, name_type=self.admin_name_type)
        script.create_name(code, name_type=self.script_code_type)
        script.separator = separator
        return script
Пример #3
0
    def create_entity_relationship_type(self, name, reverse_name):
        """Creates a new entity relationship type.

        :param name: forward name of the new entity relationship type
        :type name: unicode string
        :param reverse_name: reverse name of the new entity relationship type
        :type reverse_name: unicode string
        :rtype: `EntityRelationshipType`

        """
        try:
            EntityRelationshipType.objects.get_by_admin_name(
                name, reverse_name)
            # QAZ: Raise a more specific exception.
            raise EATSException(
                'An entity relationship type named "%s" already exists' % name)
        except EntityRelationshipType.DoesNotExist:
            pass
        entity_relationship_type = self.create_topic(
            proxy=EntityRelationshipType)
        entity_relationship_type.add_type(self.entity_relationship_type_type)
        entity_relationship_type.create_name(
            name, name_type=self.relationship_name_type)
        entity_relationship_type.create_name(
            reverse_name, name_type=self.reverse_relationship_name_type)
        return entity_relationship_type
Пример #4
0
    def create_name_type(self, name):
        """Creates a new name type called `name`.

        :param name: name of the new name type
        :type name: unicode string
        :rtype: `NameType`

        """
        try:
            NameType.objects.get_by_admin_name(name)
            # QAZ: Raise a more specific exception.
            raise EATSException('A name type named "%s" already exists' % name)
        except NameType.DoesNotExist:
            pass
        name_type = self.create_topic(proxy=NameType)
        name_type.add_type(self.name_type_type)
        name_type.create_name(name, name_type=self.admin_name_type)
        return name_type
Пример #5
0
    def create_calendar(self, name):
        """Creates a new calendar called `name`.

        :param name: name of the new calendar
        :type name: unicode string
        :rtype: `Calendar`

        """
        try:
            Calendar.objects.get_by_admin_name(name)
            # QAZ: Raise a more specific exception.
            raise EATSException('A calendar named "%s" already exists' % name)
        except Calendar.DoesNotExist:
            pass
        calendar = self.create_topic(proxy=Calendar)
        calendar.add_type(self.calendar_type)
        calendar.create_name(name, name_type=self.admin_name_type)
        return calendar
Пример #6
0
    def create_authority(self, name):
        """Creates a new authority called `name`.

        :param name: name of the new authority
        :type name: unicode string
        :rtype: `Authority`

        """
        try:
            Authority.objects.get_by_admin_name(name)
            # Raise a more specific exception.
            raise EATSException('An authority named "%s" already exists' %
                                name)
        except Authority.DoesNotExist:
            authority = self.create_topic(proxy=Authority)
            authority.add_type(self.authority_type)
            authority.create_name(name, name_type=self.admin_name_type)
            return authority
Пример #7
0
    def create_date_period(self, name):
        """Creates a new date period called `name`.

        :param name: name of the new date period
        :type name: unicode string
        :rtype: `DatePeriod`

        """
        try:
            DatePeriod.objects.get_by_admin_name(name)
            # QAZ: Raise a more specific exception.
            raise EATSException('A date period named "%s" already exists' %
                                name)
        except DatePeriod.DoesNotExist:
            pass
        date_period = self.create_topic(proxy=DatePeriod)
        date_period.add_type(self.date_period_type)
        date_period.create_name(name, name_type=self.admin_name_type)
        return date_period