コード例 #1
0
 def parse_optional(self, attributes):
     num = len(attributes)
     if num == 0:
         return ''
     elif num == 1:
         return 'the optional attribute {}' \
             .format(strFunctions.wrap_token(attributes[0]['texname'],
                                             self.package))
     else:
         optional_statement = 'the optional attributes {}' \
             .format(strFunctions.wrap_token(attributes[0]['texname'],
                                             self.package))
         i = 1
         while i < num - 1:
             optional_statement += ', {}' \
                 .format(strFunctions.wrap_token(attributes[i]['texname'],
                                                 self.package))
             i += 1
         optional_statement += ' and {}' \
             .format(strFunctions.wrap_token(attributes[i]['texname'],
                                             self.package))
         return optional_statement
コード例 #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'
     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})
コード例 #3
0
 def parse_required(self, attributes):
     num = len(attributes)
     if num == 0:
         return ''
     elif num == 1:
         return 'the required attribute {}'\
             .format(strFunctions.wrap_token(attributes[0]['name'],
                                             self.package))
     else:
         required_statement = 'the required attributes {}'\
             .format(strFunctions.wrap_token(attributes[0]['name'],
                                             self.package))
         i = 1
         while i < num - 1:
             required_statement += ', {}'\
                 .format(strFunctions.wrap_token(attributes[i]['name'],
                                                 self.package))
             i += 1
         required_statement += ' and {}'\
             .format(strFunctions.wrap_token(attributes[i]['name'],
                                             self.package))
         return required_statement
コード例 #4
0
 def write_attibute_paragraph(self, attrib, name):
     att_name = attrib['texname']
     if attrib['type'] == 'lo_element' \
             or attrib['type'] == 'inline_lo_element':
         return
     elif attrib['type'] == 'element' \
             and attrib['element'] != 'RelAbsVector':
         return
     else:
         self.write_line('\paragraph{0}The \\fixttspace\\token{0}{1}{2} '
                         'attribute{2}'.format(self.start_b, att_name,
                                               self.end_b))
         self.skip_line()
         self.write_line('{} \{} has {} attribute {} {}.'
                         .format(strFunctions.get_indefinite(name).
                                 capitalize(),
                                 name,
                                 'a required' if attrib['reqd'] is True
                                 else 'an optional',
                                 strFunctions.wrap_token(att_name),
                                 strFunctions.wrap_type(attrib['type'],
                                                        attrib['element'],
                                                        True)))
     self.skip_line()
コード例 #5
0
    def write_attribute_type_rule(self, attribute):
        att_type = attribute['type']
        name = strFunctions.wrap_token(attribute['texname'], self.package)
        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 {} of {} {} object must be ' \
                   'the identifier of an existing \{} object defined in the ' \
                   'enclosing \Model object.'\
                .format(name, self.indef, self.formatted_name, ref_name)
        elif att_type == 'string':
            text = 'The attribute {} on {} {} must have a value of data ' \
                   'type {}.'\
                .format(name, self.indef, self.formatted_name,
                        strFunctions.wrap_token('string'))
        elif att_type == 'int' or att_type == 'uint':
            text = 'The attribute {} on {} {} must have a value of data ' \
                   'type {}.'\
                .format(name, self.indef, self.formatted_name,
                        strFunctions.wrap_token('integer'))
        elif att_type == 'double':
            text = 'The attribute {} on {} {} must have a value of data ' \
                   'type {}.'\
                .format(name, self.indef, self.formatted_name,
                        strFunctions.wrap_token('double'))
        elif att_type == 'boolean' or att_type == 'bool':
            text = 'The attribute {} on {} {} must have a value of data ' \
                   'type {}.'\
                .format(name, self.indef, self.formatted_name,
                        strFunctions.wrap_token('boolean'))
        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,
                                           self.formatted_name,
                                           strFunctions.wrap_enum(enum_name),
                                           enum_values)
        elif att_type == 'array':
            text = 'The value of the attribute {} of {} {} object must ' \
                   'be an array of values of type {}.'\
                .format(name, self.indef, self.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, self.formatted_name)
        else:
            text = 'FIX ME: Encountered an unknown attribute type {} in ' \
                   'ValidationRulesForClass:write_attribute_type_rule'\
                .format(att_type)

        ref = '{}, {}.'\
            .format(self.pkg_ref, strFunctions.wrap_section(self.name))
        sev = 'ERROR'
        return dict({'number': self.number, 'text': text,
                     'reference': ref, 'severity': sev})