def write_optional_lo_rule(self):
        number = len(self.opt_child_lo_elem)
        if number > 1:
            obj = 'objects'
            pred = 'these'
            i = 0
            elements = '{}'.format(strFunctions.get_element_name(
                self.opt_child_lo_elem[i]))
            for i in range(1, number-1):
                elements += ', {}'.format(strFunctions.get_element_name(
                    self.opt_child_lo_elem[i]))
            elements += ' and {}'.format(strFunctions.get_element_name(
                self.opt_child_lo_elem[i+1]))
        else:
            obj = 'object'
            pred = 'this'
            elements = '{}'.format(strFunctions.get_element_name(
                self.opt_child_lo_elem[0]))

        text = 'The {0} sub{1} on {2} {3} object is optional, but if ' \
               'present, {4} container {1} must not be empty.'\
            .format(elements, obj, self.indef, self.formatted_name, pred)
        ref = '{}, {}.'\
            .format(self.pkg_ref, strFunctions.wrap_section(self.name))
        sev = 'ERROR'
        return dict({'number': self.number, 'text': text,
                     'reference': ref, 'severity': sev})
 def write_core_subobject_rule(self, lo_child=None):
     if lo_child is None:
         text = '{0} {1} object may have the optional SBML Level~3 ' \
                'Core subobjects for notes and annotations. No other ' \
                'elements from the SBML Level 3 Core namespaces are ' \
                'permitted on {2} {1}.'\
             .format(self.indef_u, self.formatted_name, self.indef)
         ref = 'SBML Level~3 Version~1 Core, Section~3.2.'
         sev = 'ERROR'
     else:
         if 'type' in lo_child:
             loname = strFunctions.get_element_name(lo_child)
             element = lo_child['element']
         else:
             # we are in a plugin so have different fields
             loname = strFunctions.cap_list_of_name(lo_child['name'])
             element = lo_child['name']
         text = 'Apart from the general notes and annotations subobjects ' \
                'permitted on all SBML objects, a {} container object ' \
                'may only contain \{} objects.'\
             .format(loname, element)
         ref = '{}, {}.'\
             .format(self.pkg_ref, strFunctions.wrap_section(self.name))
         sev = 'ERROR'
     return dict({'number': self.number, 'text': text,
                  'reference': ref, 'severity': sev})
 def parse_optional_elements(attributes):
     num = len(attributes)
     if num == 0:
         return ''
     elif num == 1:
         return 'one and only one instance of the {} element' \
             .format(strFunctions.get_element_name(attributes[0]))
     else:
         optional_statement = 'one and only one instance of each of the {}' \
             .format(strFunctions.get_element_name(attributes[0]))
         i = 1
         while i < num - 1:
             optional_statement += ', {}' \
                 .format(strFunctions.get_element_name(attributes[i]))
             i += 1
         optional_statement += ' and {} elements'\
             .format(strFunctions.get_element_name(attributes[i]))
         return optional_statement
 def write_core_attribute_rule(self, lo_child=None):
     if lo_child is None:
         text = '{0} {1} object may have the optional SBML Level~3 ' \
                'Core attributes {2} and {3}. No other attributes from the ' \
                'SBML Level 3 Core namespaces are permitted on {4} {1}.'\
             .format(self.indef_u, self.formatted_name,
                     strFunctions.wrap_token('metaid'),
                     strFunctions.wrap_token('sboTerm'), self.indef)
         ref = 'SBML Level~3 Version~1 Core, Section~3.2.'
         sev = 'ERROR'
     else:
         text = 'A {0} object may have the optional SBML Level~3 ' \
                'Core attributes {1} and {2}. No other attributes from the ' \
                'SBML Level 3 Core namespaces are permitted on a {0} object.'\
             .format(strFunctions.get_element_name(lo_child),
                     strFunctions.wrap_token('metaid'),
                     strFunctions.wrap_token('sboTerm'))
         ref = '{}, {}.'\
             .format(self.pkg_ref, strFunctions.wrap_section(self.name))
         sev = 'ERROR'
     return dict({'number': self.number, 'text': text,
                  'reference': ref, 'severity': sev})