src/eric7/Utilities/__init__.py

branch
eric7
changeset 9507
1f39839655ea
parent 9482
a2bc06a54d9d
child 9531
155b2646799a
--- a/src/eric7/Utilities/__init__.py	Fri Nov 11 17:14:21 2022 +0100
+++ b/src/eric7/Utilities/__init__.py	Fri Nov 11 17:49:06 2022 +0100
@@ -65,10 +65,6 @@
     setConfigDir,
 )
 
-# TODO: move 'normalizeCode' here
-from eric7.Plugins.CheckerPlugins.SyntaxChecker.SyntaxCheck import (  # __IGNORE_WARNING__
-    normalizeCode,
-)
 from eric7.UI.Info import Program, Version
 
 
@@ -538,6 +534,21 @@
     return data.decode("utf-8")
 
 
+def normalizeCode(codestring):
+    """
+    Function to normalize the given code.
+
+    @param codestring code to be normalized (string)
+    @return normalized code (string)
+    """
+    codestring = codestring.replace("\r\n", "\n").replace("\r", "\n")
+
+    if codestring and codestring[-1] != "\n":
+        codestring += "\n"
+
+    return codestring
+
+
 _escape = re.compile("[&<>\"'\u0080-\uffff]")
 
 _escape_map = {

eric ide

mercurial