No need for hardcoding line endings for windows. Python handles this by default
This commit is contained in:
@@ -51,13 +51,9 @@ class ConcatFile(TextFile):
|
|||||||
|
|
||||||
theResult = self.theConv.theText
|
theResult = self.theConv.theText
|
||||||
|
|
||||||
if self.winEnding:
|
|
||||||
self.theConv.windowsEndings()
|
|
||||||
|
|
||||||
if theResult is not None and self.outFile is not None:
|
if theResult is not None and self.outFile is not None:
|
||||||
self.outFile.write(theResult.rstrip())
|
self.outFile.write(theResult.rstrip())
|
||||||
self.outFile.write(self.endLine)
|
self.outFile.write("\n\n")
|
||||||
self.outFile.write(self.endLine)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -67,7 +63,7 @@ class ConcatFile(TextFile):
|
|||||||
|
|
||||||
def _doOpenFile(self, filePath):
|
def _doOpenFile(self, filePath):
|
||||||
try:
|
try:
|
||||||
self.outFile = open(filePath,mode="w+")
|
self.outFile = open(filePath,mode="wt+")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.makeAlert(["Failed to open file.",str(e)], nwAlert.ERROR)
|
self.makeAlert(["Failed to open file.",str(e)], nwAlert.ERROR)
|
||||||
return False
|
return False
|
||||||
|
|||||||
+11
-11
@@ -34,15 +34,15 @@ class HtmlFile(TextFile):
|
|||||||
|
|
||||||
def _doOpenFile(self, filePath):
|
def _doOpenFile(self, filePath):
|
||||||
try:
|
try:
|
||||||
self.outFile = open(filePath,mode="w+")
|
self.outFile = open(filePath,mode="wt+")
|
||||||
self.outFile.write("<!DOCTYPE html>"+self.endLine)
|
self.outFile.write("<!DOCTYPE html>\n")
|
||||||
self.outFile.write("<html>"+self.endLine)
|
self.outFile.write("<html>\n")
|
||||||
self.outFile.write("<head>"+self.endLine)
|
self.outFile.write("<head>\n")
|
||||||
self.outFile.write("<style>"+self.endLine)
|
self.outFile.write("<style>\n")
|
||||||
self.outFile.write(" pre {background-color: #ffff99;}"+self.endLine)
|
self.outFile.write(" pre {background-color: #ffff99;}\n")
|
||||||
self.outFile.write("</style>"+self.endLine)
|
self.outFile.write("</style>\n")
|
||||||
self.outFile.write("</head>"+self.endLine)
|
self.outFile.write("</head>\n")
|
||||||
self.outFile.write("<body>"+self.endLine)
|
self.outFile.write("<body>\n")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.makeAlert(["Failed to open file.",str(e)], nwAlert.ERROR)
|
self.makeAlert(["Failed to open file.",str(e)], nwAlert.ERROR)
|
||||||
return False
|
return False
|
||||||
@@ -50,8 +50,8 @@ class HtmlFile(TextFile):
|
|||||||
|
|
||||||
def _doCloseFile(self):
|
def _doCloseFile(self):
|
||||||
if self.outFile is not None:
|
if self.outFile is not None:
|
||||||
self.outFile.write("</body>"+self.endLine)
|
self.outFile.write("</body>\n")
|
||||||
self.outFile.write("</html>"+self.endLine)
|
self.outFile.write("</html>\n")
|
||||||
self.outFile.close()
|
self.outFile.close()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ class LaTeXFile(TextFile):
|
|||||||
def _doOpenFile(self, filePath):
|
def _doOpenFile(self, filePath):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.outFile = open(filePath,mode="w+")
|
self.outFile = open(filePath,mode="wt+")
|
||||||
self.outFile.write(r"\documentclass[12pt]{report}"+self.endLine)
|
self.outFile.write(r"\documentclass[12pt]{report}\n")
|
||||||
self.outFile.write(r"\usepackage[utf8]{inputenc}"+self.endLine)
|
self.outFile.write(r"\usepackage[utf8]{inputenc}\n")
|
||||||
self.outFile.write(r"\begin{document}"+self.endLine)
|
self.outFile.write(r"\begin{document}\n")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.makeAlert(["Failed to open file.",str(e)], nwAlert.ERROR)
|
self.makeAlert(["Failed to open file.",str(e)], nwAlert.ERROR)
|
||||||
return False
|
return False
|
||||||
@@ -48,7 +48,7 @@ class LaTeXFile(TextFile):
|
|||||||
def _doCloseFile(self):
|
def _doCloseFile(self):
|
||||||
|
|
||||||
if self.outFile is not None:
|
if self.outFile is not None:
|
||||||
self.outFile.write(r"\end{document}"+self.endLine)
|
self.outFile.write(r"\end{document}\n")
|
||||||
self.outFile.close()
|
self.outFile.close()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class MarkdownFile(TextFile):
|
|||||||
|
|
||||||
def _doOpenFile(self, filePath):
|
def _doOpenFile(self, filePath):
|
||||||
try:
|
try:
|
||||||
self.outFile = open(filePath,mode="w+")
|
self.outFile = open(filePath,mode="wt+")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.makeAlert(["Failed to open file.",str(e)], nwAlert.ERROR)
|
self.makeAlert(["Failed to open file.",str(e)], nwAlert.ERROR)
|
||||||
return False
|
return False
|
||||||
|
|||||||
+2
-12
@@ -34,7 +34,6 @@ class TextFile():
|
|||||||
self.theText = ""
|
self.theText = ""
|
||||||
self.expNovel = True
|
self.expNovel = True
|
||||||
self.expNotes = False
|
self.expNotes = False
|
||||||
self.winEnding = self.mainConf.osWindows
|
|
||||||
|
|
||||||
self.theConv = ToText(self.theProject, self.theParent)
|
self.theConv = ToText(self.theProject, self.theParent)
|
||||||
self.makeAlert = self.theParent.makeAlert
|
self.makeAlert = self.theParent.makeAlert
|
||||||
@@ -43,11 +42,6 @@ class TextFile():
|
|||||||
self.setMeta(False)
|
self.setMeta(False)
|
||||||
self.setWordWrap(80)
|
self.setWordWrap(80)
|
||||||
|
|
||||||
if self.winEnding:
|
|
||||||
self.endLine = "\r\n"
|
|
||||||
else:
|
|
||||||
self.endLine = "\n"
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
@@ -145,9 +139,6 @@ class TextFile():
|
|||||||
self.theConv.doHeaders()
|
self.theConv.doHeaders()
|
||||||
self.theConv.doConvert()
|
self.theConv.doConvert()
|
||||||
|
|
||||||
if self.winEnding:
|
|
||||||
self.theConv.windowsEndings()
|
|
||||||
|
|
||||||
if self.theConv.theResult is not None and self.outFile is not None:
|
if self.theConv.theResult is not None and self.outFile is not None:
|
||||||
self.outFile.write(self.theConv.theResult)
|
self.outFile.write(self.theConv.theResult)
|
||||||
|
|
||||||
@@ -162,9 +153,8 @@ class TextFile():
|
|||||||
that uses a different file format that requires a different approach.
|
that uses a different file format that requires a different approach.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.outFile = open(filePath,mode="w+")
|
self.outFile = open(filePath,mode="wt+")
|
||||||
self.outFile.write(self.endLine)
|
self.outFile.write("\n\n")
|
||||||
self.outFile.write(self.endLine)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.makeAlert(["Failed to open file.",str(e)], nwAlert.ERROR)
|
self.makeAlert(["Failed to open file.",str(e)], nwAlert.ERROR)
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -276,10 +276,6 @@ class Tokenizer():
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def windowsEndings(self):
|
|
||||||
self.theResult = self.theResult.replace("\n","\r\n")
|
|
||||||
return
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Internal Functions
|
# Internal Functions
|
||||||
##
|
##
|
||||||
|
|||||||
Reference in New Issue
Block a user