def write_reqd_lo_rule(self):
        number = len(self.reqd_child_lo_elem)
        unusual_min = False
        no_min = 0
        # check whether have unusual minimums
        for i in range(0, number):
            if 'min_lo_children' in self.reqd_child_lo_elem[i]:
                min_no = self.reqd_child_lo_elem[i]['min_lo_children']
                if min_no == 0:
                    unusual_min = True
                    no_min += 1
                elif min_no > 1:
                    unusual_min = True
        if no_min == number:
            return None
        if number > 1:
            obj = 'objects'
            i = 0
            elements = '{0}'.format(strFunctions.get_element_name(
                self.reqd_child_lo_elem[i]))
            for i in range(1, number-1):
                elements += ', {0}'.format(strFunctions.get_element_name(
                    self.reqd_child_lo_elem[i]))
            elements += ' and {0}'.format(strFunctions.get_element_name(
                self.reqd_child_lo_elem[i+1]))
        else:
            obj = 'object'
            elements = '{0}'.format(strFunctions.get_element_name(
                self.reqd_child_lo_elem[0]))

        text = 'The {0} sub{1} on {2} {3} object must not be empty.'\
            .format(elements, obj, self.indef, self.formatted_name)
        if unusual_min:
            for i in range(0, number):
                num = strFunctions.replace_digits(str(
                    self.reqd_child_lo_elem[i]['min_lo_children'])).lower()
                name = strFunctions.get_element_name(self.reqd_child_lo_elem[i])
                text += 'The {0} must contain at least {1} instances of the ' \
                        '\{2} object.' \
                        ''.format(name, num,
                                  self.reqd_child_lo_elem[i]['name'])
        ref = '{0}, {1}.'\
            .format(self.pkg_ref, strFunctions.wrap_section(self.name))
        sev = 'ERROR'
        lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
        lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package)
        if unusual_min:
            short = 'No children in ListOf elements allowed on <{0}>.' \
                    ''.format(self.lower_name)
            tc = '{0}{1}LOReqdElementChildren'.format(self.up_package,
                                                      self.name)
        else:
            short = 'No Empty ListOf elements allowed on <{0}>.' \
                    ''.format(self.lower_name)
            tc = '{0}{1}EmptyReqdLOElements'.format(self.up_package, self.name)
        return dict({'number': self.number, 'text': text,
                     'reference': ref, 'severity': sev, 'typecode': tc,
                     'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref})
Пример #2
0
 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'
         lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
         tc = '{0}{1}AllowedCoreAttributes'.format(self.up_package,
                                                   self.name)
         short = 'Core attributes allowed on <{0}>.'.format(self.lower_name)
         lo = False
     else:
         loname = strFunctions.get_element_name(lo_child,
                                                leave_pkg_prefix=False)
         temp = strFunctions.remove_prefix(lo_child['element'])
         lo_name = loname[7:]  #strFunctions.plural(temp)
         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, False),
                     strFunctions.wrap_token('metaid'),
                     strFunctions.wrap_token('sboTerm'))
         sec_name = 'listof' + lo_name.lower()
         ref = '{0}, {1}.'\
             .format(self.pkg_ref, strFunctions.wrap_section(sec_name))
         sev = 'ERROR'
         lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
         tc = '{0}{1}LO{2}AllowedCoreAttributes'.format(
             self.up_package, self.name, lo_name)
         lo = True
         short = 'Core attributes allowed on <listOf{0}>.'.format(lo_name)
     lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package)
     return dict({
         'number': self.number,
         'text': text,
         'reference': ref,
         'severity': sev,
         'typecode': tc,
         'lib_sev': lib_sev,
         'short': short,
         'lib_ref': lib_ref,
         'plugin': False,
         'object': self.name,
         'lo': lo,
         'reqd': self.reqd_elem,
         'opt': self.opt_elem
     })
Пример #3
0
 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'
         tc = '{0}{1}AllowedCoreAttributes'.format(self.up_package,
                                                   self.name)
         lo = False
     else:
         lo_name = strFunctions.plural(lo_child['name'])
         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 = '{0}, {1}.'\
             .format(self.pkg_ref, strFunctions.wrap_section(self.name))
         sev = 'ERROR'
         tc = '{0}{1}LO{2}AllowedCoreAttributes'.format(self.up_package,
                                                        self.name, lo_name)
         lo = True
     lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
     short = 'Core attributes allowed on <{0}>.'.format(self.lower_name)
     lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package)
     return dict({'number': self.number, 'text': text,
                  'reference': ref, 'severity': sev, 'typecode': tc,
                  'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref,
                  'plugin': True, 'object': self.name, 'lo': lo,
                  'reqd': self.reqd_elem, 'opt': self.opt_elem})
 def parse_optional_elements(attributes):
     num = len(attributes)
     if num == 0:
         return ''
     elif num == 1:
         return 'one and only one instance of the {0} element' \
             .format(strFunctions.get_element_name(attributes[0], False))
     else:
         optional_statement = 'one and only one instance of each of the {0}' \
             .format(strFunctions.get_element_name(attributes[0], False))
         i = 1
         while i < num - 1:
             optional_statement += ', {0}' \
                 .format(strFunctions.get_element_name(attributes[i], False))
             i += 1
         optional_statement += ' and {0} elements'\
             .format(strFunctions.get_element_name(attributes[i], False))
         return optional_statement
Пример #5
0
 def parse_required_elements(attributes):
     num = len(attributes)
     if num == 0:
         return ''
     elif num == 1:
         return 'one and only one instance of the {0} element'\
             .format(strFunctions.get_element_name(attributes[0]))
     else:
         required_statement = 'one and only one instance of each of the {0}'\
             .format(strFunctions.get_element_name(attributes[0]))
         i = 1
         while i < num - 1:
             required_statement += ', {0}'\
                 .format(strFunctions.get_element_name(attributes[i]))
             i += 1
         required_statement += ' and \{0} elements'\
             .format(strFunctions.get_element_name(attributes[i]))
         return required_statement
Пример #6
0
 def parse_required_elements(attributes):
     num = len(attributes)
     if num == 0:
         return ''
     elif num == 1:
         return 'one and only one instance of the {0} element'\
             .format(strFunctions.get_element_name(attributes[0]))
     else:
         required_statement = 'one and only one instance of each of the {0}'\
             .format(strFunctions.get_element_name(attributes[0]))
         i = 1
         while i < num - 1:
             required_statement += ', {0}'\
                 .format(strFunctions.get_element_name(attributes[i]))
             i += 1
         required_statement += ' and \{0} elements'\
             .format(strFunctions.get_element_name(attributes[i]))
         return required_statement
Пример #7
0
 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'
         lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
         tc = '{0}{1}AllowedCoreElements'.format(self.up_package, self.name)
         short = 'Core elements allowed on <{0}>.'.format(self.lower_name)
         lo = False
     else:
         loname = strFunctions.get_element_name(lo_child,
                                                leave_pkg_prefix=False)
         temp = strFunctions.remove_prefix(lo_child['element'])
         lo_name = loname[7:]  #strFunctions.plural(temp)
         text = 'Apart from the general notes and annotations subobjects ' \
                'permitted on all SBML objects, a {0} container object ' \
                'may only contain \{1} objects.'\
             .format(loname, temp)
         sec_name = 'listof' + lo_name.lower()
         ref = '{0}, {1}.'\
             .format(self.pkg_ref, strFunctions.wrap_section(sec_name))
         sev = 'ERROR'
         lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
         tc = '{0}{1}LO{2}AllowedCoreElements'.format(
             self.up_package, self.name, lo_name)
         lo = True
         short = 'Core elements allowed on <listOf{0}>.'.format(lo_name)
     lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package)
     return dict({
         'number': self.number,
         'text': text,
         'reference': ref,
         'severity': sev,
         'typecode': tc,
         'lib_sev': lib_sev,
         'short': short,
         'lib_ref': lib_ref,
         'plugin': False,
         'object': self.name,
         'lo': lo,
         'reqd': self.reqd_elem,
         'opt': self.opt_elem
     })
Пример #8
0
 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'
         tc = '{0}{1}AllowedCoreElements'.format(self.up_package, self.name)
         lo = False
     else:
         if 'type' in lo_child:
             loname = strFunctions.get_element_name(lo_child)
             element = lo_child['element']
             lo_name = strFunctions.plural(element)
         else:
             # we are in a plugin so have different fields
             loname = strFunctions.cap_list_of_name(lo_child['name'])
             element = lo_child['name']
             lo_name = strFunctions.plural(element)
         text = 'Apart from the general notes and annotations subobjects ' \
                'permitted on all SBML objects, a \{0} container object ' \
                'may only contain \{1} objects.'\
             .format(loname, element)
         add_extended = True
         if self.package == 'render':
             add_extended = False
         ref = '{0}, {1}.'\
             .format(self.pkg_ref, strFunctions.wrap_section(self.name, True, add_extended))
         sev = 'ERROR'
         tc = '{0}{1}LO{2}AllowedCoreElements'.format(self.up_package, self.name,
                                                  lo_name)
         lo = True
     lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
     short = 'Core elements allowed on <{0}>.'.format(self.lower_name)
     lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package)
     return dict({'number': self.number, 'text': text,
                  'reference': ref, 'severity': sev, 'typecode': tc,
                  'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref,
                  'plugin': True, 'object': self.name, 'lo': lo,
                  'reqd': self.reqd_elem, 'opt': self.opt_elem})
Пример #9
0
 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'
         tc = '{0}{1}AllowedCoreElements'.format(self.up_package, self.name)
         lo = False
     else:
         if 'type' in lo_child:
             loname = strFunctions.get_element_name(lo_child)
             element = lo_child['element']
             lo_name = strFunctions.plural(element)
         else:
             # we are in a plugin so have different fields
             loname = strFunctions.cap_list_of_name(lo_child['name'])
             element = lo_child['name']
             lo_name = strFunctions.plural(element)
         text = 'Apart from the general notes and annotations subobjects ' \
                'permitted on all SBML objects, a \{0} container object ' \
                'may only contain \{1} objects.'\
             .format(loname, element)
         ref = '{0}, {1}.'\
             .format(self.pkg_ref, strFunctions.wrap_section(self.name))
         sev = 'ERROR'
         tc = '{0}{1}LO{2}AllowedCoreElements'.format(self.up_package, self.name,
                                                  lo_name)
         lo = True
     lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
     short = 'Core elements allowed on <{0}>.'.format(self.lower_name)
     lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package)
     return dict({'number': self.number, 'text': text,
                  'reference': ref, 'severity': sev, 'typecode': tc,
                  'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref,
                  'plugin': True, 'object': self.name, 'lo': lo,
                  'reqd': self.reqd_elem, 'opt': self.opt_elem})