Umlaute werden nach HTML Tags formatiert
Verfasst: Mittwoch 28. Februar 2018, 13:48
Hallo zusammen,
ich bin der neue hier und habe direkt ein großes vielleicht aber auch ein kleines Anliegen.
Mit Python bin ich noch nicht sehr geübt und bekam von einem Kollegen ein Projekt geerbt.
Es wird eine SQL Datei genommen und diese wird mit Parametern via Python angereichert.
Nachdem Fileopen und filewrite werden die Umlaute in zb ä umgewandelt was aber nicht gewollt ist.
Das SQL File liegt als UTF8 vor.
Den Teil
[/code] habe ich auch bereits auf
from HTMLParser import HTMLParser # HTMLParser
geändert ohne Erfolg.
Vielleicht hat ja von euch einer eine Idee.
ich bin der neue hier und habe direkt ein großes vielleicht aber auch ein kleines Anliegen.
Mit Python bin ich noch nicht sehr geübt und bekam von einem Kollegen ein Projekt geerbt.
Es wird eine SQL Datei genommen und diese wird mit Parametern via Python angereichert.
Nachdem Fileopen und filewrite werden die Umlaute in zb ä umgewandelt was aber nicht gewollt ist.
Das SQL File liegt als UTF8 vor.
Code: Alles auswählen
# Add Spool Output to content
# Add an additional message that the original files were altered
newContent = ""
newContent += "------------------------------------------------------------\n"
newContent += "-- This file is altered! Should be deployed with SQL-Plus --\n"
newContent += "------------------------------------------------------------\n"
newContent += "\n"
newContent += "SPOOL " + fName[:fName.index(".")] + ".spool\n"
newContent += "ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL = 1;\n"
newContent += "SET SQLBLANKLINES ON\n"
newContent = unicode(newContent)
# The Application file containing pages/images/etc.
if fName.find("f"+appID) != -1:
consolePrint(loglevel, "Application-File found!")
newContent += "\n"
if appInst.find("APEX") != -1:
consolePrint(loglevel, "Application File!")
newContent += "DELETE WWV_FLOW_WORKSHEET_CONDITIONS where flow_id = '" + appID +"';\n"
# Append Application data
newContent += "\n"
newContent += "------------------------------------------------------------\n"
newContent += "-- Contents of Application-File --\n"
newContent += "------------------------------------------------------------\n"
newContent += "\n"
newContent += fData.decode('utf-8')
# Replace all Exit-Statements
newContent = newContent.replace("exit sql.sqlcode", "EXIT 0")
newContent = newContent.replace("EXIT SQL.SQLCODE", "EXIT 0")
validFile = True
elif fName.find("DBO_"+appID) != -1:
consolePrint(loglevel, "Database-File found!")
newContent += generateDB(appInst, wsName, fData)
# newContent += fData.decode('utf-8')
validFile = True
# Write content to file
if validFile==True:
f = open(fName, 'wb')
f.write(newContent.encode('ascii', 'xmlcharrefreplace'))
f.close()
Code: Alles auswählen
# Write content to file
if validFile==True:
f = open(fName, 'wb')
f.write(newContent.encode('ascii', 'xmlcharrefreplace'))
f.close()
from HTMLParser import HTMLParser # HTMLParser
Code: Alles auswählen
parser = HTMLParser()
f.write(parser.unescape(newContent).encode('utf-8')) geändert ohne Erfolg
Vielleicht hat ja von euch einer eine Idee.