def _generateICRIndividualPage(self, icrJson, date): ien = icrJson['NUMBER'] outIcrFile = os.path.join(self._outDir, 'ICR-' + ien + '.html') tName = safeElementId("%s-%s" % ('ICR', ien)) with open(outIcrFile, 'w') as output: output.write("<html>") outputDataRecordTableHeader(output, tName) output.write("<body id=\"dt_example\">") output.write("""<div id="container" style="width:80%">""") output.write("<h1>%s %s (%s)</h1>\n" % (icrJson['NAME'], 'ICR', ien)) outputFileEntryTableList(output, tName) # table body self._icrDataEntryToHtml(output, icrJson) output.write("</tbody>\n") output.write("</table>\n") if date is not None: # TODO: Add to PDF? link = "https://foia-vista.osehra.org/VistA_Integration_Agreement/" output.write( "<a href=\"%s\">Generated from %s IA Listing Descriptions</a>" % (link, date)) output.write("</div>\n") output.write("</div>\n") output.write("</body></html>")
def _generateICRIndividualPage(icrJson, date, outDir, crossRef): ien = icrJson['NUMBER'] outIcrFile = os.path.join(outDir, 'ICR-' + ien + '.html') tName = safeElementId("%s-%s" % ('ICR', ien)) with open(outIcrFile, 'w') as output: output.write("""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">""") output.write ("<html>") output.write(""" <script src="https://code.jquery.com/ui/1.11.0/jquery-ui.min.js"></script> <link rel="stylesheet" href="https://code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css" /> """) outputDataRecordTableHeader(output, tName) output.write("""<script type="text/javascript" src="../dox/PDF_Script.js"></script>""") output.write("<div class=\"qindex\">\n") output.write("<a onclick=\"writeICRPDF()\" \ class=\"qindex\" href=\"#Print\">Print Page as PDF</a>") output.write("</div>") output.write("<body id=\"dt_example\">") output.write("""<div id="container" style="width:80%">""") output.write ("<title id=\"pageTitle\">%s %s (%s)</title>\n" % (icrJson['NAME'], 'ICR', ien)) output.write ("<h1>%s %s (%s)</h1>\n" % (icrJson['NAME'], 'ICR', ien)) outputFileEntryTableList(output, tName) # table body _icrDataEntryToHtml(output, icrJson, crossRef) output.write("</tbody>\n") output.write("</table>\n") if date is not None: # TODO: Add to PDF? link = "https://foia-vista.osehra.org/VistA_Integration_Agreement/" output.write("<a href=\"%s\">Generated from %s IA Listing Descriptions</a>" % (link, date)) output.write("</div>\n") output.write("</div>\n") output.write ("</body></html>")
def _generateIndividualRequirementsPage(self,reqJSON): ien = reqJSON['busNeedId'] outReqFile = os.path.join(self._outDir, 'BFFReq-' + str(ien) + '.html') tName = safeElementId("%s-%s" % ('BFFReq', ien)) with open(outReqFile, 'w') as output: output.write ("<html>") outputDataRecordTableHeader(output, tName) output.write("<body id=\"dt_example\">") output.write("""<div id="container" style="width:80%">""") output.write ("<h1>%s (%s) %s (%s)</h1>\n" % (reqJSON['name'], ien, 'Req', ien)) outputFileEntryTableList(output, tName) """ table body """ reqSummary = self._convertReqEntryToSummaryInfo(reqJSON) for idx,item in enumerate(fieldList): output.write("<tr>\n") # List of objects should be displayed as a UL object output.write("<td>%s</td>"% item) if type(reqSummary[idx]) is list: output.write("<td><ul>") for entry in reqSummary[idx]: output.write("<li>%s</li>\n" % entry) output.write("</ul></td>") # Otherwise, write it out as is else: output.write("<td>%s</td>\n" % reqSummary[idx]) output.write("</tr>\n") output.write("</tbody>\n") output.write("</table>\n") output.write("</div>\n") output.write("</div>\n") output.write ("</body></html>")
def _convertFileManDataToHtml(self, fileManData): for ien in getKeys(fileManData.dataEntries.keys(), float): outDir = self.outDir tName = safeElementId("%s-%s" % (fileManData.fileNo, ien)) dataEntry = fileManData.dataEntries[ien] if not dataEntry.name: logging.warn("no name for %s" % dataEntry) continue name = dataEntry.name if dataEntry.fileNo: outDir = os.path.join(self.outDir, dataEntry.fileNo.replace(".", "_")) if not os.path.exists(outDir): os.mkdir(outDir) if isFilePointerType(dataEntry): link, name = convertFilePointerToHtml(dataEntry.name) outHtmlFileName = getDataEntryHtmlFile(dataEntry, ien, fileManData.fileNo) with open("%s/%s" % (outDir, outHtmlFileName), 'w') as output: output.write("<html>") outputDataRecordTableHeader(output, tName) output.write("<body id=\"dt_example\">") output.write("""<div id="container" style="width:80%">""") output.write("<h1>%s (%s) %s (%s)</h1>\n" % (name, ien, fileManData.name, fileManData.fileNo)) outputFileEntryTableList(output, tName) """ table body """ output.write("<tbody>\n") self._fileManDataEntryToHtml(output, dataEntry, True) output.write("</tbody>\n") output.write("</table>\n") output.write("</div>\n") output.write("</div>\n") output.write("</body></html>")
def _convertFileManDataToHtml(self, fileManData): outDir = self.outDir for ien in getKeys(fileManData.dataEntries.keys(), float): tName = safeElementId("%s-%s" % (fileManData.fileNo, ien)) dataEntry = fileManData.dataEntries[ien] if not dataEntry.name: logging.warn("no name for %s" % dataEntry) continue name = dataEntry.name if isFilePointerType(dataEntry): link, name = convertFilePointerToHtml(dataEntry.name) outHtmlFileName = getDataEntryHtmlFile(dataEntry, ien, fileManData.fileNo) with open("%s/%s" % (outDir, outHtmlFileName), "w") as output: output.write("<html>") outputDataRecordTableHeader(output, tName) output.write('<body id="dt_example">') output.write("""<div id="container" style="width:80%">""") output.write( "<h1>%s (%s) %s (%s)</h1>\n" % (name, ien, fileManData.name, fileManData.fileNo) ) outputFileEntryTableList(output, tName) """ table body """ output.write("<tbody>\n") self._fileManDataEntryToHtml(output, dataEntry, True) output.write("</tbody>\n") output.write("</table>\n") output.write("</div>\n") output.write("</div>\n") output.write("</body></html>")
def _generateIndividualRequirementsPage(self, reqJSON): ien = reqJSON['busNeedId'] outReqFile = os.path.join(self._outDir, 'BFFReq-' + str(ien) + '.html') tName = safeElementId("%s-%s" % ('BFFReq', ien)) with open(outReqFile, 'w') as output: output.write("<html>") outputDataRecordTableHeader(output, tName) output.write("<body id=\"dt_example\">") output.write("""<div id="container" style="width:80%">""") output.write("<h1>%s (%s) %s (%s)</h1>\n" % (reqJSON['name'], ien, 'Req', ien)) outputFileEntryTableList(output, tName) """ table body """ reqSummary = self._convertReqEntryToSummaryInfo(reqJSON) for idx, item in enumerate(fieldList): output.write("<tr>\n") # List of objects should be displayed as a UL object output.write("<td>%s</td>" % item) if isinstance(reqSummary[idx], list): output.write("<td><ul>") for entry in reqSummary[idx]: output.write("<li>%s</li>\n" % entry) output.write("</ul></td>") # Otherwise, write it out as is else: output.write("<td>%s</td>\n" % reqSummary[idx]) output.write("</tr>\n") output.write("</tbody>\n") output.write("</table>\n") output.write("</div>\n") output.write("</div>\n") output.write("</body></html>")
def _generateDataListByPackage(self, dataEntryLst, pkgName, list_fields, listName, columnNames, searchColumnNames, fileNo, custom_header=None): outDir = os.path.join(self.outDir, fileNo.replace(".","_")) with open("%s/%s-%s.html" % (outDir, pkgName, listName), 'w+') as output: output.write("<html>\n") tName = safeElementId("%s-%s" % (listName, pkgName)) outputDataListTableHeader(output, tName, columnNames, searchColumnNames) output.write("<body id=\"dt_example\">") output.write("""<div id="container" style="width:80%">""") if pkgName == "All": pkgLinkName = pkgName output.write("<h1>%s %s List</h1>" % (pkgLinkName, listName)) else: output.write("<h2 align=\"right\"><a href=\"./All-%s.html\">" "All %s</a></h2>" % (listName, listName)) pkgLinkName = getPackageHRefLink(pkgName) output.write("<h1>Package: %s %s List</h1>" % (pkgLinkName, listName)) if not custom_header: outputDataTableHeader(output, columnNames, tName) outputDataTableFooter(output, columnNames, tName) else: outputCustomDataTableHeader(output, custom_header, tName) outputDataTableFooter(output, columnNames, tName) """ table body """ output.write("<tbody>\n") for dataEntry in dataEntryLst: tableRow = [""]*len(list_fields) allFields = dataEntry.fields output.write("<tr>\n") for idx, id in enumerate(list_fields): # If value has / in it, we take the first value as usual # but assume the information is a "multiple" field and # attempt to find the second bit of information within it idVal,multval = id[1].split('/') if (len(id[1].split('/')) > 1) else (id[1],None) if idVal in allFields: value = allFields[idVal].value if multval: # and (multval in value.dataEntries["1"].fields) value = self.findSubValue(dataEntry, value,multval,id); if type(value) is list: tmpValue="<ul>" for entry in value: if id[-1]: tmpValue += "<li>"+id[-1](dataEntry, entry,sourceField=id[1], targetField=id[-2], glbData=self.dataMap, crossRef=self.crossRef)+"</li>" else: tmpValue += "<li>"+ entry +"</li>" value = tmpValue+"</ul>" else: if id[-1]: value = id[-1](dataEntry, value,sourceField=id[1], targetField=id[-2], glbData=self.dataMap, crossRef=self.crossRef) tableRow[idx] = value for item in tableRow: #output.write("<td class=\"ellipsis\">%s</td>\n" % item) output.write("<td>%s</td>\n" % item) output.write("</tr>\n") output.write("</tbody>\n") output.write("</table>\n") output.write("</div>\n") output.write("</div>\n") output.write ("</body></html>\n")
def _generateICRSummaryPageImpl(self, inputJson, listName, pkgName, isForAll=False): outDir = self._outDir pkgHtmlName = pkgName outFilename = "%s/%s-%s.html" % (outDir, pkgName, listName) if not isForAll: if pkgName in pkgMap: pkgName = pkgMap[pkgName] pkgHtmlName = pkgName + '-ICR.html' outFilename = "%s/%s" % (outDir, pkgHtmlName) with open(outFilename, 'w+') as output: output.write("<html>\n") tName = safeElementId("%s-%s" % (listName, pkgName)) useAjax = useAjaxDataTable(len(inputJson)) columnNames = [x[0] for x in summary_list_fields] searchColumns = ['IA #', 'Name', 'Custodial Package', 'Date Created', 'File #', 'Remote Procedure', 'Routine', 'Date Activated'] if useAjax: ajaxSrc = '%s_array.txt' % pkgName outputLargeDataListTableHeader(output, ajaxSrc, tName, columnNames, searchColumns) else: outputDataListTableHeader(output, tName, columnNames, searchColumns) output.write("<body id=\"dt_example\">") output.write("""<div id="container" style="width:80%">""") if isForAll: output.write("<h1>%s %s</h1>" % (pkgName, listName)) else: output.write("<h2 align=\"right\"><a href=\"./All-%s.html\">" "All %s</a></h2>" % (listName, listName)) output.write("<h1>Package: %s %s</h1>" % (pkgName, listName)) # pkgLinkName = getPackageHRefLink(pkgName) outputDataTableHeader(output, columnNames, tName) outputDataTableFooter(output, columnNames, tName) """ table body """ output.write("<tbody>\n") if not useAjax: """ Now convert the ICR Data to Table data """ for icrSummary in inputJson: output.write("<tr>\n") for item in icrSummary: #output.write("<td class=\"ellipsis\">%s</td>\n" % item) output.write("<td>%s</td>\n" % item) output.write("</tr>\n") else: logging.info("Ajax source file: %s" % ajaxSrc) """ Write out the data file in JSON format """ outJson = {"aaData": []} with open(os.path.join(outDir, ajaxSrc), 'w') as ajaxOut: outArray = outJson["aaData"] for icrSummary in inputJson: outArray.append(icrSummary) json.dump(outJson, ajaxOut) output.write("</tbody>\n") output.write("</table>\n") output.write("</div>\n") output.write("</div>\n") output.write ("</body></html>\n")
def _generateICRIndividualPage(self, icrJson): ien = icrJson['NUMBER'] outIcrFile = os.path.join(self._outDir, 'ICR-' + ien + '.html') tName = safeElementId("%s-%s" % ('ICR', ien)) with open(outIcrFile, 'w') as output: output.write("<html>") outputDataRecordTableHeader(output, tName) output.write("<body id=\"dt_example\">") output.write("""<div id="container" style="width:80%">""") output.write("<h1>%s (%s) %s (%s)</h1>\n" % (icrJson['NAME'], ien, 'ICR', ien)) outputFileEntryTableList(output, tName) """ table body """ self._icrDataEntryToHtml(output, icrJson) output.write("</tbody>\n") output.write("</table>\n") output.write("</div>\n") output.write("</div>\n") output.write("</body></html>")
def _convertFileManDataToHtml(self, fileManData): fileManDataFileNo = fileManData.fileNo pathSafeFileManDataFileNo = fileManDataFileNo.replace(".", "_") for ien in getKeys(fileManData.dataEntries, float): dataEntry = fileManData.dataEntries[ien] name = dataEntry.name if not name: continue outDir = self.outDir fileNo = dataEntry.fileNo if fileNo: outDir = os.path.join(self.outDir, fileNo.replace(".", "_")) tName = safeElementId("%s-%s" % (pathSafeFileManDataFileNo, ien)) if isFilePointerType(dataEntry): link, name = convertFilePointerToHtml(name) outHtmlFileName = getDataEntryHtmlFileName(ien, fileManDataFileNo) with open(os.path.join(outDir, outHtmlFileName), 'w') as output: output.write("<html>") outputDataRecordTableHeader(output, tName) output.write("<body id=\"dt_example\">") output.write( "<a class=\"brand\" href=\"%s\" style=\"height:50px; padding: 0px;\"> \ <img src=\"https://osehra.org/sites/default/files/vivian.png\" width=\"137\" height=\"50\"/></a>" % VIV_URL) output.write("""<div id="container" style="width:80%">""") output.write("<h1>%s (%s) %s (%s)</h1>\n" % (name, ien, fileManData.name, fileManDataFileNo)) if fileNo in ['19', '101']: # Todo: Check if the object exists in options/menus first. output.write( "<a style='font-size: 15px;' href='%s/vista_menus.php#%s?name=%s'>View in ViViaN Menu</a>" % (VIV_URL, fileNo, urllib.parse.quote_plus(name))) outputFileEntryTableList(output, tName) # table body output.write("<tbody>\n") output.write( self._fileManDataEntryToHtml(dataEntry, True, None)) output.write("</tbody>\n") output.write("</table>\n") output.write("</div>\n") output.write("</div>\n") output.write("</body></html>")
def _generateICRIndividualPage(self, icrJson): ien = icrJson['NUMBER'] outIcrFile = os.path.join(self._outDir, 'ICR-' + ien + '.html') tName = safeElementId("%s-%s" % ('ICR', ien)) with open(outIcrFile, 'w') as output: output.write ("<html>") outputDataRecordTableHeader(output, tName) output.write("<body id=\"dt_example\">") output.write("""<div id="container" style="width:80%">""") output.write ("<h1>%s (%s) %s (%s)</h1>\n" % (icrJson['NAME'], ien, 'ICR', ien)) outputFileEntryTableList(output, tName) """ table body """ self._icrDataEntryToHtml(output, icrJson) output.write("</tbody>\n") output.write("</table>\n") output.write("</div>\n") output.write("</div>\n") output.write ("</body></html>")
def _generateICRIndividualPage(self, icrJson, date): ien = icrJson['NUMBER'] outIcrFile = os.path.join(self._outDir, 'ICR-' + ien + '.html') tName = safeElementId("%s-%s" % ('ICR', ien)) with open(outIcrFile, 'w') as output: output.write ("<html>") outputDataRecordTableHeader(output, tName) output.write("<body id=\"dt_example\">") output.write("""<div id="container" style="width:80%">""") output.write ("<h1>%s %s (%s)</h1>\n" % (icrJson['NAME'], 'ICR', ien)) outputFileEntryTableList(output, tName) # table body self._icrDataEntryToHtml(output, icrJson) output.write("</tbody>\n") output.write("</table>\n") if date is not None: # TODO: Add to PDF? link = "https://foia-vista.osehra.org/VistA_Integration_Agreement/" output.write("<a href=\"%s\">Generated from %s IA Listing Descriptions</a>" % (link, date)) output.write("</div>\n") output.write("</div>\n") output.write ("</body></html>")
def _convertFileManDataToHtml(self, fileManData): fileManDataFileNo = fileManData.fileNo pathSafeFileManDataFileNo = fileManDataFileNo.replace(".", "_") for ien in getKeys(fileManData.dataEntries.keys(), float): dataEntry = fileManData.dataEntries[ien] name = dataEntry.name if not name: logger.warn("no name for %s" % dataEntry) continue outDir = self.outDir fileNo = dataEntry.fileNo if fileNo: outDir = os.path.join(self.outDir, fileNo.replace(".", "_")) tName = safeElementId("%s-%s" % (pathSafeFileManDataFileNo, ien)) if isFilePointerType(dataEntry): link, name = convertFilePointerToHtml(name) outHtmlFileName = getDataEntryHtmlFileName(ien, fileManDataFileNo) with open(os.path.join(outDir, outHtmlFileName), 'w') as output: output.write("<html>") outputDataRecordTableHeader(output, tName) output.write("<body id=\"dt_example\">") output.write("""<div id="container" style="width:80%">""") output.write("<h1>%s (%s) %s (%s)</h1>\n" % (name, ien, fileManData.name, fileManDataFileNo)) if fileNo in ['19', '101']: # Todo: Check if the object exists in options/menus first. output.write( "<a style='font-size: 15px;' href='%s/../vista_menus.php#%s?name=%s'>View in ViViaN Menu</a>" % (VIV_URL, fileNo, urllib.quote_plus(name))) outputFileEntryTableList(output, tName) """ table body """ output.write("<tbody>\n") self._fileManDataEntryToHtml(output, dataEntry, True) output.write("</tbody>\n") output.write("</table>\n") output.write("</div>\n") output.write("</div>\n") output.write("</body></html>")
def _generatePkgDepSummaryPage(self, inputJson, date): outDep = {} for icrItem in inputJson: curIaNum = icrItem['IA #'] # ignore the non-active icrs if 'STATUS' not in icrItem or icrItem['STATUS'] != 'Active': continue if 'CUSTODIAL PACKAGE' in icrItem: curPkg = icrItem['CUSTODIAL PACKAGE'] outDep.setdefault(curPkg,{}) if 'SUBSCRIBING PACKAGE' in icrItem: for subPkg in icrItem['SUBSCRIBING PACKAGE']: if 'SUBSCRIBING PACKAGE' in subPkg: subPkgName = subPkg['SUBSCRIBING PACKAGE'] if isinstance(subPkgName,list): for subPkgNameEntry in subPkgName: subDep = outDep.setdefault(subPkgNameEntry, {}).setdefault('dependencies',{}) subDep.setdefault(curPkg, []).append(curIaNum) curDep = outDep.setdefault(curPkg, {}).setdefault('dependents', {}) curDep.setdefault(subPkgNameEntry, []).append(curIaNum) else: subDep = outDep.setdefault(subPkgName, {}).setdefault('dependencies',{}) subDep.setdefault(curPkg, []).append(curIaNum) curDep = outDep.setdefault(curPkg, {}).setdefault('dependents', {}) curDep.setdefault(subPkgName, []).append(curIaNum) """ Convert outDep to html page """ outDir = self._outDir outFilename = "%s/ICR-PackageDep.html" % outDir with open(outFilename, 'w+') as output: output.write("<html>\n") tName = safeElementId("%s-%s" % ('ICR', 'PackageDep')) outputDataListTableHeader(output, tName) output.write("<body id=\"dt_example\">") output.write("""<div id="container" style="width:80%">""") outputDataTableHeader(output, ['Package Name', 'Dependencies Information'], tName) """ table body """ output.write("<tbody>\n") """ Now convert the ICR Data to Table data """ for pkgName in sorted(outDep.iterkeys()): output.write("<tr>\n") output.write("<td>%s</td>\n" % getPackageHRefLink(pkgName, {'CUSTODIAL PACKAGE': pkgName}, crossRef=self._crossRef)) """ Convert the dependencies and dependent information """ output.write("<td>\n") output.write ("<ol>\n") for pkgDepType in sorted(outDep[pkgName].iterkeys()): output.write ("<li>\n") output.write ("<dt>%s:</dt>\n" % pkgDepType.upper()) depPkgInfo = outDep[pkgName][pkgDepType] for depPkgName in sorted(depPkgInfo.iterkeys()): outputInfo = getPackageHRefLink(depPkgName, {'CUSTODIAl PACKAGE': depPkgName}, crossRef=self._crossRef) outputInfo += ':   Total # of ICRs %s : [' % len(depPkgInfo[depPkgName]) for icrNo in depPkgInfo[depPkgName]: outputInfo += getICRIndividualHtmlFileLinkByIen(icrNo, {'NUMBER': icrNo}, crossRef=self._crossRef) + '  ' outputInfo += ']' output.write ("<dt>%s:</dt>\n" % outputInfo) output.write ("</li>\n") output.write ("</ol>\n") output.write("</td>\n") output.write ("</tr>\n") output.write("</tbody>\n") output.write("</table>\n") if date is not None: link = "http://foia-vista.osehra.org/VistA_Integration_Agreement/" output.write("<a href=\"%s\">Generated from %s IA Listing Descriptions</a>" % (link, date)) output.write("</div>\n") output.write("</div>\n") output.write ("</body></html>\n")
def _generateDataListByPackage( self, dataEntryLst, pkgName, list_fields, listName, columnNames, searchColumnNames, custom_header=None ): outDir = self.outDir with open("%s/%s-%s.html" % (outDir, pkgName, listName), "w+") as output: output.write("<html>\n") tName = safeElementId("%s-%s" % (listName, pkgName)) outputDataListTableHeader(output, tName, columnNames, searchColumnNames) output.write('<body id="dt_example">') output.write("""<div id="container" style="width:80%">""") if pkgName == "All": pkgLinkName = pkgName output.write("<h1>%s %s List</h1>" % (pkgLinkName, listName)) else: output.write('<h2 align="right"><a href="./All-%s.html">' "All %s</a></h2>" % (listName, listName)) pkgLinkName = getPackageHRefLink(pkgName) output.write("<h1>Package: %s %s List</h1>" % (pkgLinkName, listName)) if not custom_header: outputDataTableHeader(output, columnNames, tName) outputDataTableFooter(output, columnNames, tName) else: outputCustomDataTableHeader(output, custom_header, tName) outputDataTableFooter(output, columnNames, tName) """ table body """ output.write("<tbody>\n") for dataEntry in dataEntryLst: tableRow = [""] * len(list_fields) allFields = dataEntry.fields output.write("<tr>\n") for idx, id in enumerate(list_fields): # If value has / in it, we take the first value as usual # but assume the information is a "multiple" field and # attempt to find the second bit of information within it idVal, multval = id[1].split("/") if (len(id[1].split("/")) > 1) else (id[1], None) if idVal in allFields: value = allFields[idVal].value if multval: # and (multval in value.dataEntries["1"].fields) value = self.findSubValue(dataEntry, value, multval, id) if type(value) is list: tmpValue = "<ul>" for entry in value: if id[-1]: tmpValue += ( "<li>" + id[-1]( dataEntry, entry, sourceField=id[1], targetField=id[-2], glbData=self.dataMap, crossRef=self.crossRef, ) + "</li>" ) else: tmpValue += "<li>" + entry + "</li>" value = tmpValue + "</ul>" else: if id[-1]: value = id[-1]( dataEntry, value, sourceField=id[1], targetField=id[-2], glbData=self.dataMap, crossRef=self.crossRef, ) tableRow[idx] = value for item in tableRow: # output.write("<td class=\"ellipsis\">%s</td>\n" % item) output.write("<td>%s</td>\n" % item) output.write("</tr>\n") output.write("</tbody>\n") output.write("</table>\n") output.write("</div>\n") output.write("</div>\n") output.write("</body></html>\n")
def _generatePkgDepSummaryPage(self, inputJson, date): outDep = {} for icrItem in inputJson: curIaNum = icrItem['IA #'] # ignore the non-active icrs if 'STATUS' not in icrItem or icrItem['STATUS'] != 'Active': continue if 'CUSTODIAL PACKAGE' in icrItem: curPkg = icrItem['CUSTODIAL PACKAGE'] outDep.setdefault(curPkg,{}) if 'SUBSCRIBING PACKAGE' in icrItem: for subPkg in icrItem['SUBSCRIBING PACKAGE']: if 'SUBSCRIBING PACKAGE' in subPkg: subPkgName = subPkg['SUBSCRIBING PACKAGE'] if isinstance(subPkgName,list): for subPkgNameEntry in subPkgName: subDep = outDep.setdefault(subPkgNameEntry, {}).setdefault('dependencies',{}) subDep.setdefault(curPkg, []).append(curIaNum) curDep = outDep.setdefault(curPkg, {}).setdefault('dependents', {}) curDep.setdefault(subPkgNameEntry, []).append(curIaNum) else: subDep = outDep.setdefault(subPkgName, {}).setdefault('dependencies',{}) subDep.setdefault(curPkg, []).append(curIaNum) curDep = outDep.setdefault(curPkg, {}).setdefault('dependents', {}) curDep.setdefault(subPkgName, []).append(curIaNum) """ Convert outDep to html page """ outFilename = "%s/ICR-PackageDep.html" % self._outDir with open(outFilename, 'w+') as output: output.write("<html>\n") tName = safeElementId("%s-%s" % ('ICR', 'PackageDep')) outputDataListTableHeader(output, tName) output.write("<body id=\"dt_example\">") output.write("""<div id="container" style="width:80%">""") outputDataTableHeader(output, ['Package Name', 'Dependencies Information'], tName) """ table body """ output.write("<tbody>\n") """ Now convert the ICR Data to Table data """ for pkgName in sorted(outDep.iterkeys()): output.write("<tr>\n") output.write("<td>%s</td>\n" % getPackageHRefLink(pkgName, {'CUSTODIAL PACKAGE': pkgName}, crossRef=self._crossRef)) """ Convert the dependencies and dependent information """ output.write("<td>\n") output.write ("<ol>\n") for pkgDepType in sorted(outDep[pkgName].iterkeys()): output.write ("<li>\n") output.write ("<dt>%s:</dt>\n" % pkgDepType.upper()) depPkgInfo = outDep[pkgName][pkgDepType] for depPkgName in sorted(depPkgInfo.iterkeys()): outputInfo = getPackageHRefLink(depPkgName, {'CUSTODIAl PACKAGE': depPkgName}, crossRef=self._crossRef) outputInfo += ':   Total # of ICRs %s : [' % len(depPkgInfo[depPkgName]) for icrNo in depPkgInfo[depPkgName]: outputInfo += getICRIndividualHtmlFileLinkByIen(icrNo, {'NUMBER': icrNo}, crossRef=self._crossRef) + '  ' outputInfo += ']' output.write ("<dt>%s:</dt>\n" % outputInfo) output.write ("</li>\n") output.write ("</ol>\n") output.write("</td>\n") output.write ("</tr>\n") output.write("</tbody>\n") output.write("</table>\n") if date is not None: link = "https://foia-vista.osehra.org/VistA_Integration_Agreement/" output.write("<a href=\"%s\">Generated from %s IA Listing Descriptions</a>" % (link, date)) output.write("</div>\n") output.write("</div>\n") output.write ("</body></html>\n")
def test_safeElementId(): for input in ("01", "1.0", "99999.4"): print safeElementId(input)