コード例 #1
0
 def write_element_not_ns_rule(self):
     text = 'Wherever they appear in an SBML document, elements and ' \
            'attributes from the {0} must use the ' \
            '\\uri{1}http://www.sbml.org/sbml/level{2}/version{3}' \
            '/{4}/version{5}{6} namespace, declaring so either explicitly ' \
            'or implicitly.'\
         .format(self.full_pkg_command, self.start_b, self.level,
                 self.version, self.package, self.pkg_version, self.end_b)
     ref = '{0} {1}.'\
         .format(self.pkg_ref,
                 strFunctions.wrap_section('xml-namespace', False))
     sev = 'ERROR'
     lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
     short = 'Element not in {0} namespace'.format(self.up_package)
     lib_ref = 'L3V1 {0} V1 Section 3.1'.format(self.up_package)
     tc = '{0}ElementNotInNs'.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
     })
コード例 #2
0
 def write_ns_rule(self):
     text = 'To conform to the {0} specification for SBML Level~{1} ' \
            'Version~{2}, an SBML document must declare ' \
            '\\uri{3}http://www.sbml.org/sbml/' \
            'level{1}/version{2}/{4}/version{5}{6} as the XMLNamespace ' \
            'to use for elements of this package.'\
         .format(self.full_pkg_command, self.level, self.version,
                 self.start_b, self.package, self.pkg_version, self.end_b)
     ref = '{0} {1}.'\
         .format(self.pkg_ref,
                 strFunctions.wrap_section('xml-namespace', False))
     sev = 'ERROR'
     lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
     short = 'The {0} namespace is not correctly ' \
             'declared.'.format(self.up_package)
     lib_ref = 'L3V1 {0} V1 Section 3.1'.format(self.up_package)
     tc = '{0}NSUndeclared'.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
     })
コード例 #3
0
 def write_package_object_rule(self):
     if len(self.reqd_elem) == 0 and len(self.opt_elem) == 0:
         return
     reqd = self.parse_required_elements(self.reqd_elem)
     opt = self.parse_optional_elements(self.opt_elem)
     no_other_statement = 'No other elements from the SBML Level 3 {0} ' \
                          'namespaces are permitted on {1} {2} object. '\
         .format(self.fullname, self.indef, self.formatted_name)
     if len(opt) == 0 and len(reqd) > 0:
         text = '{0} {1} object must contain {2}. {3}'\
             .format(self.indef_u, self.formatted_name,
                     reqd, no_other_statement)
     elif len(reqd) == 0 and len(opt) > 0:
         text = '{0} {1} object may contain {2}. {3}'\
             .format(self.indef_u, self.formatted_name,
                     opt, no_other_statement)
     else:
         text = '{0} {1} object must contain {2}, and may contain {3}. {4}'\
             .format(self.indef_u, self.formatted_name,
                     reqd, opt, no_other_statement)
     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)
     short = 'Elements allowed on <{0}>.'.format(self.lower_name)
     lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package)
     tc = '{0}{1}AllowedElements'.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,
                  'plugin': False, 'object': self.name,
                  'reqd': self.reqd_elem, 'opt': self.opt_elem})
コード例 #4
0
 def write_package_attribute_rule(self):
     if len(self.reqd_att) == 0 and len(self.opt_att) == 0:
         return
     reqd = self.parse_required(self, self.reqd_att)
     opt = self.parse_optional(self, self.opt_att)
     no_other_statement = 'No other attributes from the SBML Level~3 {0} ' \
                          'namespaces are permitted on {1} {2} object. '\
         .format(self.fullname, self.indef, self.formatted_name)
     if len(opt) == 0 and len(reqd) > 0:
         text = '{0} {1} object must have {2}. {3}'\
             .format(self.indef_u, self.formatted_name,
                     reqd, no_other_statement)
     elif len(reqd) == 0 and len(opt) > 0:
         text = '{0} {1} object may have {2}. {3}'\
             .format(self.indef_u, self.formatted_name,
                     opt, no_other_statement)
     else:
         text = '{0} {1} object must have {2}, and may have {3}. {4}'\
             .format(self.indef_u, self.formatted_name,
                     reqd, opt, no_other_statement)
     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'
     lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
     short = 'Attributes allowed on <{0}>.'.format(self.lower_name)
     lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package)
     tc = '{0}{1}AllowedAttributes'.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,
                  'plugin': True, 'object': self.name, 'lo': False,
                  'reqd': self.reqd_att, 'opt': self.opt_att})
コード例 #5
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})
コード例 #6
0
    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})
コード例 #7
0
 def write_empty_list_rule(self):
     text = 'No empty lists'
     ref = '{0} {1}.'\
         .format(self.pkg_ref,
                 strFunctions.wrap_section('primitive-types', False))
     sev = 'ERROR'
     lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
     short = 'No empty listOf'.format(self.up_package)
     lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package)
     tc = '{0}EmptyListElement'.format(global_variables.prefix)
     return dict({'number': self.number, 'text': text,
                  'reference': ref, 'severity': sev, 'typecode': tc,
                  'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref})
コード例 #8
0
 def write_allowed_attributes_rule(self):
     text = 'Allowed attributes'
     ref = '{0} {1}.'\
         .format(self.pkg_ref,
                 strFunctions.wrap_section('primitive-types', False))
     sev = 'ERROR'
     lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
     short = 'Allowed attributes'.format(self.up_package)
     lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package)
     tc = 'AllowedAttributes'.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})
コード例 #9
0
 def write_valid_ns_rule(self):
     text = 'Invalid namespace declared.'
     ref = '{0} {1}.'\
         .format(self.pkg_ref,
                 strFunctions.wrap_section('primitive-types', False))
     sev = 'ERROR'
     lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
     short = 'Invalid namespace'.format(self.up_package)
     lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package)
     tc = 'InvalidNamespaceOn{0}'.format(global_variables.prefix)
     return dict({'number': self.number, 'text': text,
                  'reference': ref, 'severity': sev, 'typecode': tc,
                  'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref})
コード例 #10
0
 def write_valid_ns_rule(self):
     text = 'Invalid namespace declared.'
     ref = '{0} {1}.'\
         .format(self.pkg_ref,
                 strFunctions.wrap_section('primitive-types', False))
     sev = 'ERROR'
     lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
     short = 'Invalid namespace'.format(self.up_package)
     lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package)
     tc = 'InvalidNamespaceOn{0}'.format(global_variables.prefix)
     return dict({'number': self.number, 'text': text,
                  'reference': ref, 'severity': sev, 'typecode': tc,
                  'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref})
コード例 #11
0
 def write_empty_list_rule(self):
     text = 'No empty lists'
     ref = '{0} {1}.'\
         .format(self.pkg_ref,
                 strFunctions.wrap_section('primitive-types', False))
     sev = 'ERROR'
     lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
     short = 'No empty listOf'.format(self.up_package)
     lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package)
     tc = '{0}EmptyListElement'.format(global_variables.prefix)
     return dict({'number': self.number, 'text': text,
                  'reference': ref, 'severity': sev, 'typecode': tc,
                  'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref})
コード例 #12
0
 def write_allowed_attributes_rule(self):
     text = 'Allowed attributes'
     ref = '{0} {1}.'\
         .format(self.pkg_ref,
                 strFunctions.wrap_section('primitive-types', False))
     sev = 'ERROR'
     lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
     short = 'Allowed attributes'.format(self.up_package)
     lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package)
     tc = 'AllowedAttributes'.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})
コード例 #13
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
     })
コード例 #14
0
 def write_reqd_value_rule(self):
     text = 'The value of attribute {0} on the \\class{1}SBML{2} object ' \
            'must be set to \\val{1}{3}{2}.' \
         .format(strFunctions.wrap_token('required', self.package),
                 self.start_b, self.end_b, self.reqd_status)
     ref = '{0} {1}.'\
         .format(self.pkg_ref,
                 strFunctions.wrap_section('xml-namespace', False))
     sev = 'ERROR'
     lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
     short = 'The {0}:required attribute must be \'{1}\'' \
             ''.format(self.package, self.reqd_status)
     lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package)
     tc = '{0}AttributeRequiredMustHaveValue'.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})
コード例 #15
0
 def write_reqd_value_rule(self):
     text = 'The value of attribute {0} on the \\class{1}SBML{2} object ' \
            'must be set to \\val{1}{3}{2}.' \
         .format(strFunctions.wrap_token('required', self.package),
                 self.start_b, self.end_b, self.reqd_status)
     ref = '{0} {1}.'\
         .format(self.pkg_ref,
                 strFunctions.wrap_section('xml-namespace', False))
     sev = 'ERROR'
     lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
     short = 'The {0}:required attribute must be \'{1}\'' \
             ''.format(self.package, self.reqd_status)
     lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package)
     tc = '{0}AttributeRequiredMustHaveValue'.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})
コード例 #16
0
 def write_element_not_ns_rule(self):
     text = 'Wherever they appear in an SBML document, elements and ' \
            'attributes from the {0} must use the ' \
            '\\uri{1}http://www.sbml.org/sbml/level{2}/version{3}' \
            '/{4}/version{5}{6} namespace, declaring so either explicitly ' \
            'or implicitly.'\
         .format(self.full_pkg_command, self.start_b, self.level,
                 self.version, self.package, self.pkg_version, self.end_b)
     ref = '{0} {1}.'\
         .format(self.pkg_ref,
                 strFunctions.wrap_section('xml-namespace', False))
     sev = 'ERROR'
     lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
     short = 'Element not in {0} namespace'.format(self.up_package)
     lib_ref = 'L3V1 {0} V1 Section 3.1'.format(self.up_package)
     tc = '{0}ElementNotInNs'.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})
コード例 #17
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})
コード例 #18
0
 def write_ns_rule(self):
     text = 'To conform to the {0} specification for SBML Level~{1} ' \
            'Version~{2}, an SBML document must declare ' \
            '\\uri{3}http://www.sbml.org/sbml/' \
            'level{1}/version{2}/{4}/version{5}{6} as the XMLNamespace ' \
            'to use for elements of this package.'\
         .format(self.full_pkg_command, self.level, self.version,
                 self.start_b, self.package, self.pkg_version, self.end_b)
     ref = '{0} {1}.'\
         .format(self.pkg_ref,
                 strFunctions.wrap_section('xml-namespace', False))
     sev = 'ERROR'
     lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
     short = 'The {0} namespace is not correctly ' \
             'declared.'.format(self.up_package)
     lib_ref = 'L3V1 {0} V1 Section 3.1'.format(self.up_package)
     tc = '{0}NSUndeclared'.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})
コード例 #19
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})
コード例 #20
0
ファイル: TexBodySyntaxFile.py プロジェクト: hovo1990/deviser
    def write_file(self):
        BaseTexFile.BaseTexFile.write_file(self)

        self.write_line('\\section{Package syntax and semantics}')
        self.skip_line()
        self.write_line('In this section, we define the syntax and '
                        'semantics of the {0} for '
                        '\\sbmlthreecore. We expound on the various data '
                        'types and constructs defined in this package, '
                        'then in {1}, we provide complete '
                        'examples of using the constructs in example '
                        'SBML models.'.format(self.full_pkg_command,
                                              strFunctions.wrap_section(
                                                  'examples', False)))
        self.skip_line()

        self.write_namespace_section()
        self.write_primitive_data_types()
        for i in range(0, len(self.plugins)):
            self.write_body_for_extended_class(self.plugins[i])
        for i in range(0, len(self.sbml_classes)):
            # hack for render
            if self.sbml_classes[i]['name'] != 'RelAbsVector':
                self.write_body_for_class(self.sbml_classes[i])
コード例 #21
0
    def write_file(self):
        BaseTexFile.BaseTexFile.write_file(self)

        self.write_line('\\section{Package syntax and semantics}')
        self.skip_line()
        self.write_line('In this section, we define the syntax and '
                        'semantics of the {0} for '
                        '\\sbmlthreecore. We expound on the various data '
                        'types and constructs defined in this package, '
                        'then in {1}, we provide complete '
                        'examples of using the constructs in example '
                        'SBML models.'.format(self.full_pkg_command,
                                              strFunctions.wrap_section(
                                                  'examples', False)))
        self.skip_line()

        self.write_namespace_section()
        self.write_primitive_data_types()
        for i in range(0, len(self.plugins)):
            self.write_body_for_extended_class(self.plugins[i])
        for i in range(0, len(self.sbml_classes)):
            # hack for render
            if self.sbml_classes[i]['name'] != 'RelAbsVector':
                self.write_body_for_class(self.sbml_classes[i])
コード例 #22
0
    def write_lochild_attribute_rule(self, child, lo_info):
        child_class = query.get_class(child['element'], child['root'])
        if not child_class or len(child_class['lo_attribs']) == 0:
            return
        # if these are all elements we dont need this
        num = len(child_class['lo_attribs'])
        count = 0
        for attrib in child_class['lo_attribs']:
            if self.is_element(attrib['type']):
                count += 1
        if count == num:
            return
        attributes = []
        if len(child_class['lo_class_name']) == 0:
            child_class['lo_class_name'] = strFunctions.list_of_name(child_class['name'])
        formatted_name = '\\' + child_class['lo_class_name']
        name = child_class['name']
        child_reqd = []
        child_opt = []
        for attrib in child_class['lo_attribs']:
            attributes.append(attrib)
            if attrib['reqd']:
                child_reqd.append(attrib)
            else:
                child_opt.append(attrib)
        lo_info.append(dict({'formatted_name': formatted_name,
                             'name': child_class['lo_class_name'],
                             'attributes': attributes}))

        reqd = self.parse_required(self, child_reqd)
        opt = self.parse_optional(self, child_opt)
        no_other_statement = 'No other attributes from the SBML Level 3 {0} ' \
                             'namespaces are permitted on {1} {2} object. '\
            .format(self.fullname, self.indef, formatted_name)
        if len(opt) == 0 and len(reqd) > 0:
            text = '{0} {1} object must have {2}. {3}'\
                .format(self.indef_u, formatted_name,
                        reqd, no_other_statement)
        elif len(reqd) == 0 and len(opt) > 0:
            text = '{0} {1} object may have {2}. {3}'\
                .format(self.indef_u, formatted_name,
                        opt, no_other_statement)
        else:
            text = '{0} {1} object must have {2}, and may have {3}. {4}'\
                .format(self.indef_u, formatted_name,
                        reqd, opt, no_other_statement)
        ref = '{0}, {1}.'\
            .format(self.pkg_ref,
                    strFunctions.wrap_section(child_class['lo_class_name']))
        sev = 'ERROR'
        lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
        short = 'Attributes allowed on <{0}>.'.format(strFunctions.lower_first(child_class['lo_class_name']))
        lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package)
        tc = '{0}{1}LO{2}AllowedAttributes'.format(self.up_package, self.name,
                                                   strFunctions.plural(name))
        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': True,
                     'reqd': child_reqd, 'opt': child_opt,
                     'lo_object': lo_info[0]['name']})
コード例 #23
0
    def write_attribute_type_rule(self, attribute, lo=None):
        if lo:
            formatted_name = lo['formatted_name']
            refname = lo['name']
            abbrev = strFunctions.abbrev_lo_name(refname)
        else:
            formatted_name = self.formatted_name
            refname = self.name
            abbrev = self.name
        att_type = attribute['type']
        att_name = strFunctions.upper_first(attribute['name'])
        name = strFunctions.wrap_token(attribute['texname'], self.package)
        rule_type = 'String'
        if att_type == 'SId':
            return
        elif att_type == 'SIdRef':
            [ref_name, ref_type] = \
                strFunctions.get_sid_refs(attribute['element'])
            # hack for render
            if ref_name == 'StartHead' or ref_name == 'EndHead':
                ref_name = 'LineEnding'
            text = 'The value of the attribute {0} of {1} {2} object must be ' \
                   'the identifier of an existing \{3} object defined in the ' \
                   'enclosing \Model object.'\
                .format(name, self.indef, formatted_name, ref_name)
            rule_type = ref_type
        elif att_type == 'string' or att_type == 'IDREF':
            text = 'The attribute {0} on {1} {2} must have a value of data ' \
                   'type {3}.'\
                .format(name, self.indef, formatted_name,
                        strFunctions.wrap_token('string'))
        elif att_type == 'int' or att_type == 'uint':
            text = 'The attribute {0} on {1} {2} must have a value of data ' \
                   'type {3}.'\
                .format(name, self.indef, formatted_name,
                        strFunctions.wrap_token('integer'))
            rule_type = 'Integer' if att_type == 'int' else 'UnInteger'
        elif att_type == 'double':
            text = 'The attribute {0} on {1} {2} must have a value of data ' \
                   'type {3}.'\
                .format(name, self.indef, formatted_name,
                        strFunctions.wrap_token('double'))
            rule_type = 'Double'
        elif att_type == 'boolean' or att_type == 'bool':
            text = 'The attribute {0} on {1} {2} must have a value of data ' \
                   'type {3}.'\
                .format(name, self.indef, formatted_name,
                        strFunctions.wrap_token('boolean'))
            rule_type = 'Boolean'
        elif att_type == 'UnitSId' or att_type == 'UnitSIdRef':
            text = 'The value of the attribute {0} on {1} {2} must have a ' \
                   'taken from the following: the identifier of a ' \
                   '\\UnitDefinition object in the enclosing \Model, or one ' \
                   'of the base units in SBML.'.format(name,
                                                       self.indef,
                                                       formatted_name)
            rule_type = 'Unit'
        elif att_type == 'enum':
            enum_name = strFunctions.texify(attribute['element'])
            enums = attribute['parent']['root']['enums']
            enum_values = self.parse_enum_values(attribute['element'], enums)
            text = 'The value of the attribute {0} of {1} {2} object must ' \
                   'conform to the syntax of SBML data type {3} and ' \
                   'may only take on the allowed values of {3} defined ' \
                   'in SBML; that is, the value must be one of the ' \
                   'following: {4}.'.format(name, self.indef,
                                            formatted_name,
                                            strFunctions.wrap_enum(enum_name),
                                            enum_values)
            rule_type = '{0}Enum'.format(attribute['element'])
        elif att_type == 'array':
            text = 'The value of the attribute {0} of {1} {2} object must ' \
                   'be an array of values of type {3}.'\
                .format(name, self.indef, formatted_name,
                        strFunctions.wrap_token(attribute['element']))
        elif att_type == 'element' and attribute['element'] == 'RelAbsVector':
            text = 'The value of the attribute {0} of {1} {2} object must ' \
                   'conform to the syntax of SBML data type \\RelAbsVector ' \
                   'i.e. a string encoding optionally an absolute number ' \
                   'followed by an optional relative number followed ' \
                   'by a \\% sign. Adding spaces between the ' \
                   'coordinates is encouraged, but not required.'\
                .format(name, self.indef, formatted_name)
        else:
            text = 'FIXME: Encountered an unknown attribute type {0} in ' \
                   'ValidationRulesForClass'\
                .format(att_type)
#            global_variables.code_returned = \
#                global_variables.return_codes['unknown type used']

        ref = '{0}, {1}.'\
            .format(self.pkg_ref, strFunctions.wrap_section(refname))
        sev = 'ERROR'
        lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
        short = '{0} attribute must be {1}.'.format(att_name, rule_type)
        lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package)
        tc = '{0}{1}{2}MustBe{3}'.format(self.up_package, abbrev, att_name,
                                         rule_type)
        return dict({'number': self.number, 'text': text,
                     'reference': ref, 'severity': sev, 'typecode': tc,
                     'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref,
                     'object': refname, 'attrib': att_name,
                     'attrib_type': att_type})
コード例 #24
0
    def write_attribute_type_rule(self, attribute, lo=None):
        if lo:
            formatted_name = lo['formatted_name']
            refname = lo['name']
            abbrev = strFunctions.abbrev_lo_name(refname)
        else:
            formatted_name = self.formatted_name
            refname = self.name
            abbrev = self.name
        att_type = attribute['type']
        att_name = strFunctions.upper_first(attribute['name'])
        name = strFunctions.wrap_token(attribute['texname'], self.package)
        rule_type = 'String'
        if att_type == 'SId':
            return
        elif att_type == 'SIdRef':
            [ref_name, ref_type] = \
                strFunctions.get_sid_refs(attribute['element'])
            # hack for render
            if ref_name == 'StartHead' or ref_name == 'EndHead':
                ref_name = 'LineEnding'
            if ref_name == 'SBase':
                text = 'The value of the attribute {0} of {1} {2} object must be ' \
                       'the identifier of an existing object derived from the \SBase class and defined in the ' \
                       'enclosing \Model object.'\
                    .format(name, self.indef, self.formatted_name, ref_name)
            else:
                text = 'The value of the attribute {0} of {1} {2} object must be ' \
                       'the identifier of an existing \{3} object defined in the ' \
                       'enclosing \Model object.'\
                .format(name, self.indef, self.formatted_name, ref_name)
            rule_type = ref_type
        elif att_type == 'string':
            text = 'The attribute {0} on {1} {2} must have a value of data ' \
                   'type {3}.'\
                .format(name, self.indef, self.formatted_name,
                        strFunctions.wrap_token('string'))
        elif att_type == 'ID':
            text = 'The attribute {0} on {1} {2} must have a value of XML data ' \
                   'type {3}.'\
                .format(name, self.indef, self.formatted_name,
                        strFunctions.wrap_token('ID'))
        elif att_type == 'IDREF':
            text = 'The value of the attribute {0} of {1} {2} object must be ' \
                   'the \'metaid\' of an existing \SBase object defined in the ' \
                   'enclosing \Model object.'\
                .format(name, self.indef, formatted_name)
            rule_type = 'SBase'
        elif att_type == 'int' or att_type == 'uint':
            text = 'The attribute {0} on {1} {2} must have a value of data ' \
                   'type {3}{4}'\
                .format(name, self.indef, self.formatted_name,
                        strFunctions.wrap_token('integer'),
                        '.' if att_type == 'int' else ', and must be non negative.')
            rule_type = 'Integer' if att_type == 'int' else 'NonNegativeInteger'
        elif att_type == 'double':
            text = 'The attribute {0} on {1} {2} must have a value of data ' \
                   'type {3}.'\
                .format(name, self.indef, self.formatted_name,
                        strFunctions.wrap_token('double'))
            rule_type = 'Double'
        elif att_type == 'bool' or att_type == 'boolean':
            text = 'The attribute {0} on {1} {2} must have a value of data ' \
                   'type {3}.'\
                .format(name, self.indef, self.formatted_name,
                        strFunctions.wrap_token('boolean'))
            rule_type = 'Boolean'
        elif att_type == 'UnitSId' or att_type == 'UnitSIdRef':
            text = 'The value of the attribute {0} on {1} {2} must have a ' \
                   'taken from the following: the identifier of a ' \
                   '\\UnitDefinition object in the enclosing \Model, or one ' \
                   'of the base units in SBML.'.format(name,
                                                       self.indef,
                                                       formatted_name)
            rule_type = 'UnitSId'
        elif att_type == 'enum':
            enum_name = attribute['element']
            enums = attribute['parent']['root']['enums']
            enum_values = self.parse_enum_values(enum_name, enums)
            text = 'The value of the attribute {0} of {1} {2} object must ' \
                   'conform to the syntax of SBML data type {3} and ' \
                   'may only take on the allowed values of {3} defined ' \
                   'in SBML; that is, the value must be one of the ' \
                   'following {4}.'.format(name, self.indef,
                                           self.formatted_name,
                                           strFunctions.wrap_enum(enum_name),
                                           enum_values)
            rule_type = '{0}Enum'.format(attribute['element'])
        elif att_type == 'array':
            array_type = strFunctions.lower_first(attribute['element'])
            text = 'The value of the attribute {0} of {1} {2} object must ' \
                   'be an array of values of type {3}.'\
                .format(name, self.indef, self.formatted_name,
                        strFunctions.wrap_token(array_type))
        else:
            text = 'FIX ME: Encountered an unknown attribute type {0} in ' \
                   'ValidationRulesForClass:write_attribute_type_rule'\
                .format(att_type)

        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'
        lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib)
        short = '{0} attribute must be {1}.'.format(att_name, rule_type)
        lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package)
        tc = '{0}{1}{2}MustBe{3}'.format(self.up_package, self.name, att_name,
                                         rule_type)
        return dict({'number': self.number, 'text': text,
                     'reference': ref, 'severity': sev, 'typecode': tc,
                     'plugin': True, 'object': self.name, 'lo': False,
                     'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref,
                     'attrib': attribute['name'], 'attrib_type': att_type})
コード例 #25
0
    def write_attribute_type_rule(self, attribute):
        att_type = attribute['type']
        att_name = strFunctions.upper_first(attribute['name'])
        name = strFunctions.wrap_token(attribute['name'], self.package)
        rule_type = 'String'
        if att_type == 'SId':
            return
        elif att_type == 'SIdRef':
            ref_name = strFunctions.upper_first(attribute['name'])
            # hack for render
            if ref_name == 'StartHead' or ref_name == 'EndHead':
                ref_name = 'LineEnding'
            text = 'The value of the attribute {0} of {1} {2} object must be ' \
                   'the identifier of an existing \{3} object defined in the ' \
                   'enclosing \Model object.'\
                .format(name, self.indef, self.formatted_name, ref_name)
            rule_type = ref_name
        elif att_type == 'string':
            text = 'The attribute {0} on {1} {2} must have a value of data ' \
                   'type {3}.'\
                .format(name, self.indef, self.formatted_name,
                        strFunctions.wrap_token('string'))
        elif att_type == 'int' or att_type == 'uint':
            text = 'The attribute {0} on {1} {2} must have a value of data ' \
                   'type {3}.'\
                .format(name, self.indef, self.formatted_name,
                        strFunctions.wrap_token('integer'))
            rule_type = 'Integer' if att_type == 'int' else 'UnInteger'
        elif att_type == 'double':
            text = 'The attribute {0} on {1} {2} must have a value of data ' \
                   'type {3}.'\
                .format(name, self.indef, self.formatted_name,
                        strFunctions.wrap_token('double'))
            rule_type = 'Double'
        elif att_type == 'bool' or att_type == 'boolean':
            text = 'The attribute {0} on {1} {2} must have a value of data ' \
                   'type {3}.'\
                .format(name, self.indef, self.formatted_name,
                        strFunctions.wrap_token('boolean'))
            rule_type = 'Boolean'
        elif att_type == 'enum':
            enum_name = attribute['element']
            enums = attribute['parent']['root']['enums']
            enum_values = self.parse_enum_values(enum_name, enums)
            text = 'The value of the attribute {0} of {1} {2} object must ' \
                   'conform to the syntax of SBML data type {3} and ' \
                   'may only take on the allowed values of {3} defined ' \
                   'in SBML; that is, the value must be one of the ' \
                   'following {4}.'.format(name, self.indef,
                                           self.formatted_name,
                                           strFunctions.wrap_enum(enum_name),
                                           enum_values)
            rule_type = '{0}Enum'.format(attribute['element'])
        elif att_type == 'array':
            text = 'The value of the attribute {0} of {1} {2} object must ' \
                   'be an array of values of type {3}.'\
                .format(name, self.indef, self.formatted_name,
                        strFunctions.wrap_token(attribute['element']))
        else:
            text = 'FIX ME: Encountered an unknown attribute type {0} in ' \
                   'ValidationRulesForClass:write_attribute_type_rule'\
                .format(att_type)

        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)
        short = 'Attribute {0} values allowed on <{1}>.' \
                ''.format(attribute['name'], self.lower_name)
        lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package)
        tc = '{0}{1}{2}MustBe{3}'.format(self.up_package, self.name, att_name,
                                         rule_type)
        return dict({'number': self.number, 'text': text,
                     'reference': ref, 'severity': sev, 'typecode': tc,
                     'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref})