def _writeGlobalReferenceToPDF(self, section, pdf): for globalReference in section: globalReferenceSection = [] name = globalReference["GLOBAL REFERENCE"] globalReferenceSection.append( Paragraph("%s : %s" % ("globalReference", name), styles['Heading3'])) if 'GLOBAL DESCRIPTION' in globalReference: # TODO: Each line should be its own Paragraph description = globalReference["GLOBAL DESCRIPTION"] globalReferenceSection.append( self._convertIndividualFieldValuePDF( 'GLOBAL DESCRIPTION', " ".join(description), True)) globalReferenceSection.append(Spacer(1, 20)) if 'FIELD NUMBER' in globalReference: fieldNumber = globalReference["FIELD NUMBER"] table = [] fieldList = SUBFILE_FIELDS['FIELD NUMBER'] if 'FIELD NUMBER' in fieldList: # TODO: How does this happen? fieldList.remove('FIELD NUMBER') header = ["FIELD #"] + SUBFILE_FIELDS['FIELD NUMBER'] header = [x if x != "LOCATION" else "LOC." for x in header] table.append(generatePDFTableHeader(header)) for f in fieldNumber: if type(f) is dict: row = [] row.append( self._convertIndividualFieldValuePDF( 'FIELD NUMBER', f['FIELD NUMBER'], False)) for field in SUBFILE_FIELDS['FIELD NUMBER']: if field in f: row.append( self._convertIndividualFieldValuePDF( field, f[field], False, False)) else: row.append(Paragraph("", styles['Normal'])) table.append(row) columns = 12 columnWidth = self.doc.width / columns t = Table(table, colWidths=[ columnWidth, columnWidth * 2, columnWidth * 2, columnWidth * 6, columnWidth ]) t.setStyle( TableStyle([ ('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black), ('BOX', (0, 0), (-1, -1), 0.25, colors.black), ])) globalReferenceSection.append(t) pdf.append(KeepTogether(globalReferenceSection))
def _writeGlobalReferenceToPDF(self, section, pdf): for globalReference in section: globalReferenceSection = [] name = globalReference["GLOBAL REFERENCE"] globalReferenceSection.append(Paragraph("%s : %s" % ("globalReference", name), styles['Heading3'])) if 'GLOBAL DESCRIPTION' in globalReference: # TODO: Each line should be its own Paragraph description = globalReference["GLOBAL DESCRIPTION"] globalReferenceSection.append(self._convertIndividualFieldValuePDF('GLOBAL DESCRIPTION', " ".join(description), True)) globalReferenceSection.append(Spacer(1, 20)) if 'FIELD NUMBER' in globalReference: fieldNumber = globalReference["FIELD NUMBER"] table = [] fieldList = SUBFILE_FIELDS['FIELD NUMBER'] if 'FIELD NUMBER' in fieldList: # TODO: How does this happen? fieldList.remove('FIELD NUMBER') header = ["FIELD #"] + SUBFILE_FIELDS['FIELD NUMBER'] header = [x if x != "LOCATION" else "LOC." for x in header] table.append(generatePDFTableHeader(header)) for f in fieldNumber: if type(f) is dict: row =[] row.append(self._convertIndividualFieldValuePDF('FIELD NUMBER', f['FIELD NUMBER'], False)) for field in SUBFILE_FIELDS['FIELD NUMBER']: if field in f: row.append(self._convertIndividualFieldValuePDF(field, f[field], False, False)) else: row.append(Paragraph("", styles['Normal'])) table.append(row) columns = 12 columnWidth = self.doc.width/columns t = Table(table, colWidths=[columnWidth, columnWidth*2, columnWidth*2, columnWidth*6, columnWidth]) t.setStyle(TableStyle([('INNERGRID', (0,0), (-1,-1), 0.25, colors.black), ('BOX', (0,0), (-1,-1), 0.25, colors.black), ])) globalReferenceSection.append(t) pdf.append(KeepTogether(globalReferenceSection))
def _writeComponentEntryPointToPDF(section, pdf, doc): for component in section: componentSection = [] name = component["COMPONENT/ENTRY POINT"] componentSection.append(Paragraph("%s : %s" % ("COMPONENT/ENTRY POINT", name), STYLES['Heading3'])) if 'COMPONENT DESCRIPTION' in component: # TODO: Each line should be its own Paragraph description = component["COMPONENT DESCRIPTION"] if type(description) is list: description = " ".join(description) componentSection.append(_convertIndividualFieldValuePDF('COMPONENT DESCRIPTION', description, True)) componentSection.append(Spacer(1, 20)) if 'VARIABLES' in component: variables = component["VARIABLES"] table = [] table.append(generatePDFTableHeader(["VARIABLES", "TYPE", "VARIABLES DESCRIPTION"])) for variable in variables: if type(variable) is dict: row =[] _variables = variable['VARIABLES'] if type(_variables) is list: _variables = _variables[0] if "-" in _variables: # TODO: This is a workaround for an error in original # file, see ICR-639. This does not create an error # when creating the html file, but the formating is # incorrect. variable['VARIABLES'] = _variables.split("-")[0] variable['VARIABLES DESCRIPTION'] = _variables.split("-")[1] else: # TODO: ICR-5317 VARIABLES are not # parsed correctly. Skip them for now. variable['VARIABLES'] = "" row.append(_convertIndividualFieldValuePDF('VARIABLES', variable['VARIABLES'], False)) if 'TYPE' in variable: if type(variable['TYPE']) is list: # TODO: ICR-6551 VARIABLES are not # parsed correctly. Skip them for now. variable['TYPE'] = "" row.append(_convertIndividualFieldValuePDF('TYPE', variable['TYPE'], False, False)) else: row.append(Paragraph("", STYLES['Normal'])) if 'VARIABLES DESCRIPTION' in variable: description = variable['VARIABLES DESCRIPTION'] if type(description) is list: description = " ".join(description) if len(description) > 1000: # TODO: Skipping long descriptions for now # See ICR-2916, ICR-3486, etc. description = "" row.append(_convertIndividualFieldValuePDF('VARIABLES DESCRIPTION', description, False, False)) else: row.append(Paragraph("", STYLES['Normal'])) table.append(row) else: # TODO: Parsing error! See ICR-28 pass columns = 10 columnWidth = doc.width/columns t = Table(table, colWidths=[columnWidth*2, columnWidth, columnWidth*7]) t.setStyle(TableStyle([('INNERGRID', (0,0), (-1,-1), 0.25, colors.black), ('BOX', (0,0), (-1,-1), 0.25, colors.black), ])) componentSection.append(t) pdf.append(KeepTogether(componentSection))
def _writeComponentEntryPointToPDF(self, section, pdf): for component in section: componentSection = [] name = component["COMPONENT/ENTRY POINT"] componentSection.append(Paragraph("%s : %s" % ("COMPONENT/ENTRY POINT", name), styles['Heading3'])) if 'COMPONENT DESCRIPTION' in component: # TODO: Each line should be its own Paragraph description = component["COMPONENT DESCRIPTION"] if type(description) is list: description = " ".join(description) componentSection.append(self._convertIndividualFieldValuePDF('COMPONENT DESCRIPTION', description, True)) componentSection.append(Spacer(1, 20)) if 'VARIABLES' in component: variables = component["VARIABLES"] table = [] table.append(generatePDFTableHeader(["VARIABLES", "TYPE", "VARIABLES DESCRIPTION"])) for variable in variables: if type(variable) is dict: row =[] _variables = variable['VARIABLES'] if type(_variables) is list: _variables = _variables[0] if "-" in _variables: # TODO: This is a workaround for an error in original # file, see ICR-639. This does not create an error # when creating the html file, but the formating is # incorrect. variable['VARIABLES'] = _variables.split("-")[0] variable['VARIABLES DESCRIPTION'] = _variables.split("-")[1] else: # TODO: ICR-5317 VARIABLES are not # parsed correctly. Skip them for now. variable['VARIABLES'] = "" row.append(self._convertIndividualFieldValuePDF('VARIABLES', variable['VARIABLES'], False)) if 'TYPE' in variable: if type(variable['TYPE']) is list: # TODO: ICR-6551 VARIABLES are not # parsed correctly. Skip them for now. variable['TYPE'] = "" row.append(self._convertIndividualFieldValuePDF('TYPE', variable['TYPE'], False, False)) else: row.append(Paragraph("", styles['Normal'])) if 'VARIABLES DESCRIPTION' in variable: description = variable['VARIABLES DESCRIPTION'] if type(description) is list: description = " ".join(description) if len(description) > 1000: # TODO: Skipping long descriptions for now # See ICR-2916, ICR-3486, etc. description = "" row.append(self._convertIndividualFieldValuePDF('VARIABLES DESCRIPTION', description, False, False)) else: row.append(Paragraph("", styles['Normal'])) table.append(row) else: # TODO: Parsing error! See ICR-28 pass columns = 10 columnWidth = self.doc.width/columns t = Table(table, colWidths=[columnWidth*2, columnWidth, columnWidth*7]) t.setStyle(TableStyle([('INNERGRID', (0,0), (-1,-1), 0.25, colors.black), ('BOX', (0,0), (-1,-1), 0.25, colors.black), ])) componentSection.append(t) pdf.append(KeepTogether(componentSection))