def write_macro_for_listof(self, sbml_class): 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']) self.write_line('\\newcommand{0}\\{1}{2}{0}\\defRef{0}{1}{2}' '{0}{3}{2}{2}' .format(self.start_b, lo_name, self.end_b, strFunctions.make_class(lo_name))) # hack for render if sbml_class['name'] == 'GradientBase': self.write_line('\\newcommand{0}\\{4}{2}{0}\\defRef{0}{1}{2}' '{0}{3}{2}{2}' .format(self.start_b, lo_name, self.end_b, strFunctions.make_class(lo_name), 'ListOfGradientBases')) elif sbml_class['name'] == 'RenderPoint': self.write_line('\\newcommand{0}\\{4}{2}{0}\\defRef{0}{1}{2}' '{0}{3}{2}{2}' .format(self.start_b, lo_name, self.end_b, strFunctions.make_class(lo_name), 'ListOfRenderPoints'))
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 get_class(self, name): for i in range(0, len(self.sbml_classes)): this_class = self.sbml_classes[i] if this_class['name'] == name: return this_class elif this_class['hasListOf'] is True: if strFunctions.cap_list_of_name(this_class['name']) == name: return this_class return None
def write_child_element(self, attrib, name): if attrib['type'] == 'element': if self.derives_from_other_ns(attrib['element']): child_name = '\\class{' + attrib['element'] + '}' else: child_name = '\\' + attrib['element'] elif attrib['type'] == 'lo_element': child_name = '\\' + strFunctions.cap_list_of_name(attrib['name']) elif attrib['type'] == 'inline_lo_element': child_name = '\\' + strFunctions.cap_list_of_name(attrib['name']) else: return # hack for render if child_name == '\\RelAbsVector': return self.write_line('{} \{} contains {} {} element.' .format(strFunctions.get_indefinite(name). capitalize(), name, 'at most one' if attrib['reqd'] is True else 'exactly one', child_name))
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{}{}-class{}' .format(self.start_b, lo_name.lower(), self.end_b)) self.skip_line() self.write_to_do('explain {}'.format(lo_name)) self.write_line('The \\{0} object derives from the \\class{1}ListOf{2}' ' and inherits the core attributes and subobjects ' 'from the \\class{1}SBase{2} class. It contains ' 'one or more objects of type \\{3}.' .format(lo_name, self.start_b, self.end_b, classname)) self.skip_line() written = False for i in range(0, len(sbml_class['lo_attribs'])): if not written: self.write_line('In addition the \\{} 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']))