コード例 #1
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})
コード例 #2
0
    def write_body_for_lo_class(self, sbml_class, nested=False):
        lo_name = 'default'
        if sbml_class['hasListOf']:
            if 'lo_elementName' in sbml_class \
                    and sbml_class['lo_elementName'] != '':
                lo_name = strFunctions.upper_first(
                    sbml_class['lo_elementName'])
            else:
                lo_name = strFunctions.cap_list_of_name(sbml_class['name'])

        # do not write if already written
        if lo_name in self.classes_written:
            return
        self.classes_written.append(lo_name)

        if 'texname' in sbml_class:
            classname = sbml_class['texname']
        else:
            classname = sbml_class['name']

        self.write_comment_line('---------------------------------------------'
                                '------------')
        self.write_line('\subsection{0}The \class{0}{1}{2} class{2}'
                        .format(self.start_b, lo_name, self.end_b))
        self.write_line('\label{0}{1}-class{2}'
                        .format(self.start_b, lo_name.lower(), self.end_b))
        self.skip_line()
        self.write_to_do('explain {0}'.format(lo_name))

        if 'min_lo_children' not in sbml_class:
            number = 'one'
        elif sbml_class['min_lo_children'] == 1:
            number = 'one'
        else:
            number = strFunctions.replace_digits(str(
                sbml_class['min_lo_children'])).lower()

        self.write_line('The \\{0} object derives from the \\class{1}SBase{2}'
                        ' and inherits the core attributes and subobjects '
                        'from that class.  It contains '
                        '{4} or more objects of type \\{3}.'
                        .format(lo_name, self.start_b, self.end_b, classname,
                                number))
        self.skip_line()

        written = False
        for i in range(0, len(sbml_class['lo_attribs'])):
            if not written:
                self.write_line('In addition the  \\{0} object has the '
                                'following attributes.'
                                .format(lo_name))
                self.skip_line()
                written = True
            att = sbml_class['lo_attribs'][i]
            self.write_attibute_paragraph(att, lo_name)

        if not nested:
            self.write_body_for_class(self.get_class(sbml_class['name']))
コード例 #3
0
ファイル: TexBodySyntaxFile.py プロジェクト: hovo1990/deviser
    def write_body_for_lo_class(self, sbml_class, nested=False):
        lo_name = 'default'
        if sbml_class['hasListOf']:
            if 'lo_elementName' in sbml_class \
                    and sbml_class['lo_elementName'] != '':
                lo_name = strFunctions.upper_first(
                    sbml_class['lo_elementName'])
            else:
                lo_name = strFunctions.cap_list_of_name(sbml_class['name'])

        # do not write if already written
        if lo_name in self.classes_written:
            return
        self.classes_written.append(lo_name)

        if 'texname' in sbml_class:
            classname = sbml_class['texname']
        else:
            classname = sbml_class['name']

        self.write_comment_line('---------------------------------------------'
                                '------------')
        self.write_line('\subsection{0}The \class{0}{1}{2} class{2}'
                        .format(self.start_b, lo_name, self.end_b))
        self.write_line('\label{0}{1}-class{2}'
                        .format(self.start_b, lo_name.lower(), self.end_b))
        self.skip_line()
        self.write_to_do('explain {0}'.format(lo_name))

        if 'min_lo_children' not in sbml_class:
            number = 'one'
        elif sbml_class['min_lo_children'] == 1:
            number = 'one'
        else:
            number = strFunctions.replace_digits(str(
                sbml_class['min_lo_children'])).lower()

        self.write_line('The \\{0} object derives from the \\class{1}SBase{2}'
                        ' and inherits the core attributes and subobjects '
                        'from that class.  It contains '
                        '{4} or more objects of type \\{3}.'
                        .format(lo_name, self.start_b, self.end_b, classname,
                                number))
        self.skip_line()

        written = False
        for i in range(0, len(sbml_class['lo_attribs'])):
            if not written:
                self.write_line('In addition the  \\{0} object has the '
                                'following attributes.'
                                .format(lo_name))
                self.skip_line()
                written = True
            att = sbml_class['lo_attribs'][i]
            self.write_attibute_paragraph(att, lo_name)

        if not nested:
            self.write_body_for_class(self.get_class(sbml_class['name']))
コード例 #4
0
 def parse_attributes(self, attributes):
     for i in range(0, len(attributes)):
         texname = strFunctions.replace_digits(attributes[i]['name'])
         attributes[i]['texname'] = texname
         if attributes[i]['type'] == 'element':
             if attributes[i]['reqd'] is True:
                 self.reqd_elem.append(attributes[i])
             else:
                 self.opt_elem.append(attributes[i])
         elif attributes[i]['type'] == 'lo_element' \
                 or attributes[i]['type'] == 'inline_lo_element':
             if attributes[i]['reqd'] is True:
                 self.reqd_child_lo_elem.append(attributes[i])
                 self.reqd_elem.append(attributes[i])
             else:
                 self.opt_elem.append(attributes[i])
                 self.opt_child_lo_elem.append(attributes[i])
         else:
             if attributes[i]['reqd'] is True:
                 self.reqd_att.append(attributes[i])
             else:
                 self.opt_att.append(attributes[i])
コード例 #5
0
 def parse_attributes(self, attributes):
     for i in range(0, len(attributes)):
         texname = strFunctions.replace_digits(attributes[i]['name'])
         attributes[i]['texname'] = texname
         if attributes[i]['type'] == 'element':
             if attributes[i]['reqd'] is True:
                 self.reqd_elem.append(attributes[i])
             else:
                 self.opt_elem.append(attributes[i])
         elif attributes[i]['type'] == 'lo_element' \
                 or attributes[i]['type'] == 'inline_lo_element':
             if attributes[i]['reqd'] is True:
                 self.reqd_child_lo_elem.append(attributes[i])
                 self.reqd_elem.append(attributes[i])
             else:
                 self.opt_elem.append(attributes[i])
                 self.opt_child_lo_elem.append(attributes[i])
         else:
             if attributes[i]['reqd'] is True:
                 self.reqd_att.append(attributes[i])
             else:
                 self.opt_att.append(attributes[i])