Пример #1
0
    def _generatePackageDependencyGraph(self, package):
        # merge the routine and package list
        depPackages, depPackageMerged = mergeAndSortDependencyListByPackage(package, self._isDependency)
        packageName = package.getName()
        totalPackage = len(depPackageMerged)
        if (totalPackage == 0) or (totalPackage > MAX_DEPENDENCY_LIST_SIZE):
            logger.info("Nothing to do exiting... Package: %s Total: %d " %
                         (packageName, totalPackage))
            return
        dirName = os.path.join(self._outDir, packageName)
        if self._isDependency:
            packageSuffix = "_dependency"
        else:
            packageSuffix = "_dependent"
        normalizedName = normalizePackageName(packageName)
        dotFilename = os.path.join(dirName, "%s%s.dot" % (normalizedName, packageSuffix))
        with open(dotFilename, 'w') as output:
            output.write("digraph %s%s {\n" % (normalizedName, packageSuffix))
            output.write("\tnode [shape=box fontsize=14];\n") # set the node shape to be box
            output.write("\tnodesep=0.35;\n") # set the node sep to be 0.35
            output.write("\transsep=0.55;\n") # set the rank sep to be 0.75
            output.write("\tedge [fontsize=12];\n") # set the edge label and size props
            output.write("\t%s [style=filled fillcolor=orange label=\"%s\"];\n" % (normalizedName,
                                                                                   packageName))
            for depPackage in depPackages:
                depPackageName = depPackage.getName()
                normalizedDepPackName = normalizePackageName(depPackageName)
                output.write("\t%s [label=\"%s\" URL=\"%s\"];\n" % (normalizedDepPackName,
                                                                    depPackageName,
                                                                    getPackageHtmlFileName(depPackageName)))
                depMetricsList = depPackageMerged[depPackage]
                edgeWeight = sum(depMetricsList[0:7:2])
                edgeLinkURL = getPackageDependencyHtmlFileName(normalizedName, normalizedDepPackName)
                if self._isDependency:
                    edgeStartNode = normalizedName
                    edgeEndNode = normalizedDepPackName
                    edgeLinkArch = packageName
                    toolTipStartPackage = packageName
                    toolTipEndPackage = depPackageName
                else:
                    edgeStartNode = normalizedDepPackName
                    edgeEndNode = normalizedName
                    edgeLinkArch = depPackageName
                    toolTipStartPackage = depPackageName
                    toolTipEndPackage = packageName
                (edgeLabel, edgeToolTip, edgeStyle) = getPackageGraphEdgePropsByMetrics(depMetricsList,
                                                                                        toolTipStartPackage,
                                                                                        toolTipEndPackage)
                output.write("\t%s->%s [label=\"%s\" weight=%d URL=\"%s#%s\" style=\"%s\" labeltooltip=\"%s\" edgetooltip=\"%s\"];\n" %
                                (edgeStartNode, edgeEndNode, edgeLabel,
                                 edgeWeight, edgeLinkURL, edgeLinkArch,
                                 edgeStyle, edgeToolTip, edgeToolTip))
            output.write("}\n")

        pngFilename = os.path.join(dirName, "%s%s.png" % (normalizedName, packageSuffix))
        cmapxFilename = os.path.join(dirName, "%s%s.cmapx" % (normalizedName, packageSuffix))
        self._generateImagesFromDotFile(pngFilename, cmapxFilename, dotFilename)
Пример #2
0
 def _generateDataTableHtml(self, fileManData, fileNo, outDir):
     isLargeFile = len(fileManData.dataEntries) > 4500
     tName = normalizePackageName(fileManData.name)
     # Note: We are not normalizing fileNo here
     with open(os.path.join(outDir, "%s.html" % 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")
             rows = self._getTableRows(fileManData, fileNo)
             for tableRow in rows:
                 output.write("<tr>\n")
                 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:
         logger.info("Writing Ajax file: %s" % ajexSrc)
         """ Write out the data file in JSON format """
         outJson = {"aaData": self._getTableRows(fileManData, fileNo)}
         with open(os.path.join(outDir, ajexSrc), 'w') as output:
             json.dump(outJson, output)
Пример #3
0
 def _generateDataTableHtml(self, fileManData, fileNo, outDir):
     tName = normalizePackageName(fileManData.name)
     fieldNamesList = self.schemaParser._allSchema[fileNo].getFieldNames()
     # Note: We are not normalizing fileNo here
     with open(os.path.join(outDir, "%s.html" % fileNo), 'w') as output:
         output.write("<html>\n")
         # All files are now "large files" and need the ajexSrc file
         ajexSrc = "%s_array.txt" % fileNo
         outputLargeDataListTableHeader(output,
                                        ajexSrc,
                                        tName,
                                        columns=fieldNamesList,
                                        searchColumnNames=fieldNamesList,
                                        hideColumnNames=[""])
         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))
         outputDataTableHeader(output, fieldNamesList, tName)
         output.write("<tbody>\n")
         # Don't add rows to import from Ajex
         output.write("</tbody>\n")
         output.write("</table>\n")
         output.write("</div>\n")
         output.write("</div>\n")
         output.write("</body></html>\n")
     # Write out the data file in JSON format
     outJson = {
         "aaData": self._getTableRows(fileManData, fileNo, fieldNamesList)
     }
     with open(os.path.join(outDir, ajexSrc), 'w') as output:
         # Ensure that the OSEHRA Encoder is used to write out data.
         json.dump(outJson, output, ensure_ascii=False, cls=OSEHRAEncoder)
Пример #4
0
 def _generateDataTableHtml(self, fileManData, fileNo, outDir):
   isLargeFile = len(fileManData.dataEntries) > 4500
   tName = normalizePackageName(fileManData.name)
   fieldNamesList =  self.schemaParser._allSchema[fileNo].getFieldNames()
   # Note: We are not normalizing fileNo here
   with open(os.path.join(outDir, "%s.html" % fileNo), 'w') as output:
     output.write("<html>\n")
     # All files are now "large files" and need the ajexSrc file
     ajexSrc = "%s_array.txt" % fileNo
     outputLargeDataListTableHeader(output, ajexSrc, tName, columns=fieldNamesList, searchColumnNames=fieldNamesList, hideColumnNames=[""] )
     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))
     outputDataTableHeader(output, fieldNamesList, tName)
     output.write("<tbody>\n")
     # Don't add rows to import from Ajex
     output.write("</tbody>\n")
     output.write("</table>\n")
     output.write("</div>\n")
     output.write("</div>\n")
     output.write ("</body></html>\n")
   """ Write out the data file in JSON format """
   outJson = {"aaData": self._getTableRows(fileManData, fileNo, fieldNamesList)}
   with open(os.path.join(outDir, ajexSrc), 'w') as output:
     # Ensure that the OSEHRA Encoder is used to write out data.
     json.dump(outJson, output,ensure_ascii=False, cls=OSEHRAEncoder)
Пример #5
0
    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)
Пример #6
0
def _generateICRIndividualPagePDF(icrJson, date, pdfOutDir):
    ien = icrJson['NUMBER']
    if 'CUSTODIAL PACKAGE' in icrJson:
        packageName = icrJson['CUSTODIAL PACKAGE']
        pdfOutDir = os.path.join(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
        logger.warn("Could not find package for: ICR %s" % ien)
    pdfFile = os.path.join(pdfOutDir, 'ICR-' + ien + '.pdf')

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

    # Table
    _icrDataEntryToPDF(pdf, icrJson, doc)

    try:
        doc.build(pdf)
        with open(pdfFile, 'w') as fd:
            fd.write(buf.getvalue())
    except:
        global FAILURES
        FAILURES.append(pdfFile)
Пример #7
0
def _generateICRIndividualPagePDF(icrJson, date, pdfOutDir):
    ien = icrJson['NUMBER']
    if 'CUSTODIAL PACKAGE' in icrJson:
        packageName = icrJson['CUSTODIAL PACKAGE']
        pdfOutDir = os.path.join(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
        logger.warn("Could not find package for: ICR %s" % ien)
    pdfFile = os.path.join(pdfOutDir, 'ICR-' + ien + '.pdf')

    # Setup the pdf document
    buf = io.BytesIO()
    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
    _icrDataEntryToPDF(pdf, icrJson, doc)

    try:
        doc.build(pdf)
        with open(pdfFile, 'w') as fd:
            fd.write(buf.getvalue())
    except:
        global FAILURES
        FAILURES.append(pdfFile)
Пример #8
0
 def _generateDataListByPackage(self,
                                dataEntryLst,
                                pkgName,
                                list_fields,
                                listName,
                                columnNames,
                                searchColumnNames,
                                fileNoOutDir,
                                custom_header=None):
     filename = os.path.join(fileNoOutDir,
                             "%s-%s.html" % (pkgName, listName))
     with open(filename, '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(
             "<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%">""")
         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 isinstance(value, 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>%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")
Пример #9
0
    def _generateServerMenu(self, allMenuList, allOptionList, serverMenuList):
        """
    Generates a virtual menu based upon content in serverMenuList
    All "SERVER" type options are sorted based upon value 12 or "Package"

    :param allMenuList: all available menus as dictionary
    :param allOptionList: all available options as dictionary
    :param serverMenuList: array of options that have "SERVER" type
    :return: None
    """
        # Add virtual menu for all "Server" type OPTIONS to be a child of
        menuArray = {}
        fileDataArray = {}
        menuArray['0'] = FileManDataEntry(19, "9999990")
        menuArray['0'].addField(
            FileManDataField('1', 4, 'MENU TEXT', 'Unknown'))
        menuArray['0'].addField(FileManDataField('4', 2, 'TYPE', 'menu'))
        menuArray['0'].type = 'menu'
        menuArray['0'].name = "19^9999990"
        fileDataArray['0'] = FileManFileData("9999990", 'TMP' + "1")

        serverMenuEntry = FileManDataEntry(19, "9999999")
        serverMenuEntry.name = "ZZSERVERMENU"
        serverMenuEntry.addField(FileManDataField('3.6', 0, 'CREATOR',
                                                  '200^1'))
        serverMenuEntry.addField(
            FileManDataField('1.1', 1, 'UPPERCASE MENU TEXT',
                             'SERVER VIRTUAL MENU'))
        serverMenuEntry.addField(FileManDataField('4', 2, 'TYPE', 'menu'))
        serverMenuEntry.addField(
            FileManDataField('1', 4, 'MENU TEXT', 'Server Virtual Menu'))
        serverMenuEntry.addField(
            FileManDataField('.01', 3, 'NAME', 'ZZSERVERMENU'))
        for menu in serverMenuList:
            if '12' in menu.fields:
                menuIEN = menu.fields['12'].value.split('^')[1]
                packageName = normalizePackageName(
                    self.dataMap.outFileManData['9.4'].dataEntries[menuIEN].
                    name)
                if menuIEN not in menuArray:
                    menuArray[menuIEN] = FileManDataEntry(
                        19, "999999" + menuIEN)
                    menuArray[menuIEN].addField(
                        FileManDataField('1', 4, 'MENU TEXT', packageName))
                    menuArray[menuIEN].addField(
                        FileManDataField('4', 2, 'TYPE', 'menu'))
                    menuArray[menuIEN].type = 'menu'
                    menuArray[menuIEN].name = "19^999999" + str(menuIEN)
                    fileDataArray[menuIEN] = FileManFileData(
                        "999999" + str(menuIEN), 'TMP' + "2")
            else:
                menuIEN = '0'
            tmp = FileManDataEntry(19, menu.ien)
            tmp.name = "19^" + menu.ien
            fileDataArray[menuIEN].addFileManDataEntry(
                len(fileDataArray[menuIEN].dataEntries), tmp)
            menuArray[menuIEN].addField(
                FileManDataField('10', 5, 'MENU', fileDataArray[menuIEN]))

        index = 1
        test = FileManFileData("9999999", 'Server Virtual Menu')
        for menu in menuArray:
            allOptionList.append(menuArray[menu])
            allMenuList.append(menuArray[menu])
            test.addFileManDataEntry(index, menuArray[menu])
            index += 1
        serverMenuEntry.addField(FileManDataField('10', 5, 'MENU', test))
        allMenuList.append(serverMenuEntry)
Пример #10
0
 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(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("Ajax 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(
                             ien, fileNo), str(name).replace("\xa0", ""))
                 outArray.append([dataHtmlLink, ien])
             json.dump(outJson, output)
Пример #11
0
 def _generateDataListByPackage(self, dataEntryLst, pkgName, list_fields,
                                listName, columnNames, searchColumnNames,
                                fileNoOutDir, custom_header=None):
   filename = os.path.join(fileNoOutDir, "%s-%s.html" % (pkgName, listName))
   with open(filename, '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")
Пример #12
0
    def _generatePackageDependencyGraph(self, package):
        # merge the routine and package list
        depPackages, depPackageMerged = mergeAndSortDependencyListByPackage(
            package, self._isDependency)
        packageName = package.getName()
        totalPackage = len(depPackageMerged)
        if (totalPackage == 0) or (totalPackage > MAX_DEPENDENCY_LIST_SIZE):
            logger.info("Nothing to do exiting... Package: %s Total: %d " %
                        (packageName, totalPackage))
            return
        dirName = os.path.join(self._outDir, packageName)
        if self._isDependency:
            packageSuffix = "_dependency"
        else:
            packageSuffix = "_dependent"
        normalizedName = normalizePackageName(packageName)
        dotFilename = os.path.join(
            dirName, "%s%s.dot" % (normalizedName, packageSuffix))
        with open(dotFilename, 'w') as output:
            output.write("digraph %s%s {\n" % (normalizedName, packageSuffix))
            output.write("\tnode [shape=box fontsize=14];\n"
                         )  # set the node shape to be box
            output.write("\tnodesep=0.35;\n")  # set the node sep to be 0.35
            output.write("\transsep=0.55;\n")  # set the rank sep to be 0.75
            output.write(
                "\tedge [fontsize=12];\n")  # set the edge label and size props
            output.write(
                "\t%s [style=filled fillcolor=orange label=\"%s\"];\n" %
                (normalizedName, packageName))
            for depPackage in depPackages:
                depPackageName = depPackage.getName()
                normalizedDepPackName = normalizePackageName(depPackageName)
                output.write("\t%s [label=\"%s\" URL=\"%s\"];\n" %
                             (normalizedDepPackName, depPackageName,
                              getPackageHtmlFileName(depPackageName)))
                depMetricsList = depPackageMerged[depPackage]
                edgeWeight = sum(depMetricsList[0:7:2])
                edgeLinkURL = getPackageDependencyHtmlFileName(
                    normalizedName, normalizedDepPackName)
                if self._isDependency:
                    edgeStartNode = normalizedName
                    edgeEndNode = normalizedDepPackName
                    edgeLinkArch = packageName
                    toolTipStartPackage = packageName
                    toolTipEndPackage = depPackageName
                else:
                    edgeStartNode = normalizedDepPackName
                    edgeEndNode = normalizedName
                    edgeLinkArch = depPackageName
                    toolTipStartPackage = depPackageName
                    toolTipEndPackage = packageName
                (edgeLabel, edgeToolTip,
                 edgeStyle) = getPackageGraphEdgePropsByMetrics(
                     depMetricsList, toolTipStartPackage, toolTipEndPackage)
                output.write(
                    "\t%s->%s [label=\"%s\" weight=%d URL=\"%s#%s\" style=\"%s\" labeltooltip=\"%s\" edgetooltip=\"%s\"];\n"
                    % (edgeStartNode, edgeEndNode, edgeLabel, edgeWeight,
                       edgeLinkURL, edgeLinkArch, edgeStyle, edgeToolTip,
                       edgeToolTip))
            output.write("}\n")

        pngFilename = os.path.join(
            dirName, "%s%s.png" % (normalizedName, packageSuffix))
        cmapxFilename = os.path.join(
            dirName, "%s%s.cmapx" % (normalizedName, packageSuffix))
        self._generateImagesFromDotFile(pngFilename, cmapxFilename,
                                        dotFilename)
Пример #13
0
 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(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("Ajax 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(ien, fileNo),
                                                         str(name).replace("\xa0", ""))
         outArray.append([dataHtmlLink, ien])
       json.dump(outJson, output)