コード例 #1
0
ファイル: FileManDataToHtml.py プロジェクト: venkatAnne/VistA
 def _generateDataTableHtml(self, fileManData, fileNo):
   outDir = self.outDir
   isLargeFile = len(fileManData.dataEntries) > 4500
   tName = normalizePackageName(fileManData.name)
   outDir = os.path.join(self.outDir, fileNo.replace(".","_"))
   if not os.path.exists(outDir):
     os.mkdir(outDir)
   with open("%s/%s.html" % (outDir, fileNo), 'w') as output:
     output.write("<html>\n")
     if isLargeFile:
       ajexSrc = "%s_array.txt" % fileNo
       outputLargeDataListTableHeader(output, ajexSrc, tName)
     else:
       outputDataListTableHeader(output, tName)
     output.write("<body id=\"dt_example\">")
     output.write("""<div id="container" style="width:80%">""")
     output.write("<h1>File %s(%s) Data List</h1>" % (tName, fileNo))
     writeTableListInfo(output, tName)
     if not isLargeFile:
       output.write("<tbody>\n")
       for ien in getKeys(fileManData.dataEntries.keys(), float):
         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)
         dataHtmlLink = "<a href=\"../%s/%s\">%s</a>" % (fileNo.replace(".","_"),getDataEntryHtmlFile(dataEntry, ien, fileNo),
                                                   name)
         tableRow = [dataHtmlLink, dataEntry.ien]
         output.write("<tr>\n")
         """ table body """
         for item in tableRow:
           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")
   if isLargeFile:
     logging.info("Ajex source file: %s" % ajexSrc)
     """ Write out the data file in JSON format """
     outJson = {"aaData": []}
     with open(os.path.join(outDir, ajexSrc), 'w') as output:
       outArray =  outJson["aaData"]
       for ien in getKeys(fileManData.dataEntries.keys(), float):
         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)
         dataHtmlLink = "<a href=\"../%s/%s\">%s</a>" % (fileNo.replace(".","_"),getDataEntryHtmlFile(dataEntry, ien, fileNo),
                                                   name)
         outArray.append([dataHtmlLink, ien])
       json.dump(outJson, output)
コード例 #2
0
ファイル: FileManDataToHtml.py プロジェクト: OSEHRA/VistA
 def _generateDataTableHtml(self, fileManData, fileNo):
     outDir = self.outDir
     isLargeFile = len(fileManData.dataEntries) > 4500
     tName = normalizePackageName(fileManData.name)
     with open("%s/%s.html" % (outDir, fileNo), "w") as output:
         output.write("<html>\n")
         if isLargeFile:
             ajexSrc = "%s_array.txt" % fileNo
             outputLargeDataListTableHeader(output, ajexSrc, tName)
         else:
             outputDataListTableHeader(output, tName)
         output.write('<body id="dt_example">')
         output.write("""<div id="container" style="width:80%">""")
         output.write("<h1>File %s(%s) Data List</h1>" % (tName, fileNo))
         writeTableListInfo(output, tName)
         if not isLargeFile:
             output.write("<tbody>\n")
             for ien in getKeys(fileManData.dataEntries.keys(), float):
                 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)
                 dataHtmlLink = '<a href="%s">%s</a>' % (getDataEntryHtmlFile(dataEntry, ien, fileNo), name)
                 tableRow = [dataHtmlLink, dataEntry.ien]
                 output.write("<tr>\n")
                 """ table body """
                 for item in tableRow:
                     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")
     if isLargeFile:
         logging.info("Ajex source file: %s" % ajexSrc)
         """ Write out the data file in JSON format """
         outJson = {"aaData": []}
         with open(os.path.join(outDir, ajexSrc), "w") as output:
             outArray = outJson["aaData"]
             for ien in getKeys(fileManData.dataEntries.keys(), float):
                 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)
                 dataHtmlLink = '<a href="%s">%s</a>' % (getDataEntryHtmlFile(dataEntry, ien, fileNo), name)
                 outArray.append([dataHtmlLink, ien])
             json.dump(outJson, output)
コード例 #3
0
ファイル: ICRJsonToHtml.py プロジェクト: JennyP7/VistA
    def _generateICRIndividualPagePDF(self, icrJson, date):
        ien = icrJson['NUMBER']
        if 'CUSTODIAL PACKAGE' in icrJson:
            packageName = icrJson['CUSTODIAL PACKAGE']
            pdfOutDir = os.path.join(self._pdfOutDir,
                                     normalizePackageName(packageName))
            if not os.path.exists(pdfOutDir):
                os.mkdir(pdfOutDir)
        else:
            # TODO: PDF will not be included in a package bundle and will not be
            #       accessible from the Dox pages
            pdfOutDir = self._pdfOutDir
        pdfFile = os.path.join(pdfOutDir, 'ICR-' + ien + '.pdf')

        # Setup the pdf document
        buf = io.BytesIO()
        self.doc = SimpleDocTemplate(
            buf,
            rightMargin=inch / 2,
            leftMargin=inch / 2,
            topMargin=inch / 2,
            bottomMargin=inch / 2,
            pagesize=letter,
        )
        pdf = []
        # Title
        pdf.append(
            Paragraph("%s %s (%s)" % (icrJson['NAME'], 'ICR', ien),
                      styles['Heading1']))

        # Table
        self._icrDataEntryToPDF(pdf, icrJson)

        try:
            self.doc.build(pdf)
            with open(pdfFile, 'w') as fd:
                fd.write(buf.getvalue())
        except:
            self.failures.append(pdfFile)
コード例 #4
0
ファイル: FileManDataToHtml.py プロジェクト: MedBlox/VistA
 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")
     if pkgName == "All":
       tName = "%s %s List" % (normalizePackageName(pkgName), listName)
     else:
       tName = normalizePackageName(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:
       outputCustomDataTableHeaderRows(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 and id[0] != "Description":
             # Don't write out descriptions as lists
             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")