def _getTableRows(self, fileManData, fileNo, fieldsList): rows = [] for ien in getKeys(fileManData.dataEntries, float): row = [""] * len(fieldsList) row[0] = ien dataEntry = fileManData.dataEntries[ien] name = dataEntry.name if isFilePointerType(dataEntry): link, name = convertFilePointerToHtml(name) if "datetime.datetime" in str(type(name)): name = str(name) if name is None: name = str(name) dataHtmlLink = "<a href=\"%s/%s/%s\">%s</a>" % ( FILES_URL, fileNo.replace( ".", "_"), getDataEntryHtmlFileName(ien, fileNo), name) for fldId in dataEntry.fields: dataField = dataEntry.fields[fldId] # Use index of field name to place data correctly in row if fldId == '.01': row[fieldsList.index(dataField.name)] = dataHtmlLink else: row[fieldsList.index( dataField.name)] = self._dataFieldToHtml( dataField, False, dataField.name, writeLabels=False) rows.append(row) return rows
def getFileManFilePointerLink(dataEntry, value, **kargs): if value: fields = value.split('^') if len(fields) == 3: # fileNo, ien, name refFile = getDataEntryHtmlFileName(fields[1], fields[0]) value = '<a href="%s/%s/%s">%s</a>' % (VIV_URL, fields[0].replace(".","_"),refFile, fields[-1]) elif len(fields) == 2: value = 'File: %s, IEN: %s' % (fields[0], fields[1]) else: logger.error("Unknown File Pointer Value %s" % value) return value
def getFileManFilePointerLink(dataEntry, value, **kargs): if value: fields = value.split('^') if len(fields) == 3: # fileNo, ien, name refFile = getDataEntryHtmlFileName(fields[1], fields[0]) value = '<a href="%s/%s/%s">%s</a>' % (VIV_URL, fields[0].replace( ".", "_"), refFile, fields[-1]) elif len(fields) == 2: value = 'File: %s, IEN: %s' % (fields[0], fields[1]) else: logger.error("Unknown File Pointer Value %s" % value) return value
def convertFilePointerToHtml(inputValue): value = inputValue name = inputValue fields = inputValue.split('^') if len(fields) == 3: # fileNo, ien, name refFile = getDataEntryHtmlFileName(fields[1], fields[0]) value = '<a href="%s/%s/%s">%s</a>' % (VIV_URL, fields[0].replace(".","_"), refFile, fields[-1]) name = fields[-1] elif len(fields) == 2: value = 'File: %s, IEN: %s' % (fields[0], fields[1]) name = value else: logger.error("Unknown File Pointer Value '%s'" % inputValue) return value, name
def convertFilePointerToHtml(inputValue): value = inputValue name = inputValue fields = inputValue.split('^') if len(fields) == 3: # fileNo, ien, name refFile = getDataEntryHtmlFileName(fields[1], fields[0]) value = '<a href="%s/%s/%s">%s</a>' % (FILES_URL, fields[0].replace(".", "_"), refFile, fields[-1]) name = fields[-1] elif len(fields) == 2: value = 'File: %s, IEN: %s' % (fields[0], fields[1]) name = value else: logger.error("Unknown File Pointer Value '%s'" % inputValue) return value, name
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 _getTableRows(self, fileManData, fileNo, fieldsList): rows = [] for ien in getKeys(fileManData.dataEntries.keys(), float): row = [""] * len(fieldsList) row[0] = ien dataEntry = fileManData.dataEntries[ien] name = dataEntry.name if isFilePointerType(dataEntry): link, name = convertFilePointerToHtml(name) dataHtmlLink = "<a href=\"%s/%s/%s\">%s</a>" % (VIV_URL, fileNo.replace(".","_"), getDataEntryHtmlFileName(ien, fileNo), str(name).replace("\xa0", "")) for field in dataEntry.fields: # Use index of field name to place data correctly in row row[fieldsList.index(dataEntry.fields[field].name)] = dataEntry.fields[field].value if field == '.01': row[fieldsList.index(dataEntry.fields[field].name)] = dataHtmlLink rows.append(row) return rows
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 = "%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 _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 _getTableRows(self, fileManData, fileNo, fieldsList): rows = [] for ien in getKeys(fileManData.dataEntries.keys(), float): row = [""] * len(fieldsList) row[0] = ien dataEntry = fileManData.dataEntries[ien] name = dataEntry.name if isFilePointerType(dataEntry): link, name = convertFilePointerToHtml(name) dataHtmlLink = "<a href=\"%s/%s/%s\">%s</a>" % ( VIV_URL, fileNo.replace( ".", "_"), getDataEntryHtmlFileName( ien, fileNo), str(name).replace("\xa0", "")) for field in dataEntry.fields: # Use index of field name to place data correctly in row row[fieldsList.index(dataEntry.fields[field].name )] = dataEntry.fields[field].value if field == '.01': row[fieldsList.index( dataEntry.fields[field].name)] = dataHtmlLink rows.append(row) return rows
def getFileHtmlLink(dataEntry, value, **kargs): htmlFile = getDataEntryHtmlFileName(dataEntry.ien, dataEntry.fileNo) return "<a href=\"%s/%s/%s\">%s</a>" % ( FILES_URL, dataEntry.fileNo.replace(".", "_"), htmlFile, value)
def getFileHtmlLink(dataEntry, value, **kargs): htmlFile = getDataEntryHtmlFileName(dataEntry.ien, dataEntry.fileNo) return "<a href=\"%s/%s/%s\">%s</a>" % (VIV_URL, dataEntry.fileNo.replace(".","_"),htmlFile, value)