Changed the JSON based file writers to ensure a "\n" at the end to make them please version control systems (see issue 528). eric7

Sun, 31 Dec 2023 20:27:52 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 31 Dec 2023 20:27:52 +0100
branch
eric7
changeset 10459
5c5ed40d533d
parent 10458
2074b8393649
child 10460
3b34efa2857c
child 10462
c8503ea3bd22

Changed the JSON based file writers to ensure a "\n" at the end to make them please version control systems (see issue 528).

src/eric7/MultiProject/MultiProjectFile.py file | annotate | diff | comparison | revisions
src/eric7/Preferences/HighlightingStylesFile.py file | annotate | diff | comparison | revisions
src/eric7/Preferences/ShortcutsFile.py file | annotate | diff | comparison | revisions
src/eric7/Preferences/ThemeManager.py file | annotate | diff | comparison | revisions
src/eric7/Project/DebuggerPropertiesFile.py file | annotate | diff | comparison | revisions
src/eric7/Project/ProjectFile.py file | annotate | diff | comparison | revisions
src/eric7/Project/UserProjectFile.py file | annotate | diff | comparison | revisions
src/eric7/Sessions/SessionFile.py file | annotate | diff | comparison | revisions
src/eric7/Tasks/TasksFile.py file | annotate | diff | comparison | revisions
src/eric7/Templates/TemplatesFile.py file | annotate | diff | comparison | revisions
src/eric7/VCS/VersionControl.py file | annotate | diff | comparison | revisions
--- a/src/eric7/MultiProject/MultiProjectFile.py	Sun Dec 31 18:01:05 2023 +0100
+++ b/src/eric7/MultiProject/MultiProjectFile.py	Sun Dec 31 20:27:52 2023 +0100
@@ -67,7 +67,7 @@
         ]
 
         try:
-            jsonString = json.dumps(multiProjectDict, indent=2)
+            jsonString = json.dumps(multiProjectDict, indent=2) + "\n"
             with open(filename, "w") as f:
                 f.write(jsonString)
         except (OSError, TypeError) as err:
--- a/src/eric7/Preferences/HighlightingStylesFile.py	Sun Dec 31 18:01:05 2023 +0100
+++ b/src/eric7/Preferences/HighlightingStylesFile.py	Sun Dec 31 20:27:52 2023 +0100
@@ -82,7 +82,7 @@
             stylesDict["lexers"].append(lexerDict)
 
         try:
-            jsonString = json.dumps(stylesDict, indent=2)
+            jsonString = json.dumps(stylesDict, indent=2) + "\n"
             with open(filename, "w") as f:
                 f.write(jsonString)
         except (OSError, TypeError) as err:
--- a/src/eric7/Preferences/ShortcutsFile.py	Sun Dec 31 18:01:05 2023 +0100
+++ b/src/eric7/Preferences/ShortcutsFile.py	Sun Dec 31 20:27:52 2023 +0100
@@ -155,7 +155,7 @@
         }
 
         try:
-            jsonString = json.dumps(shortcutsDict, indent=2)
+            jsonString = json.dumps(shortcutsDict, indent=2) + "\n"
             with open(filename, "w") as f:
                 f.write(jsonString)
         except (OSError, TypeError) as err:
--- a/src/eric7/Preferences/ThemeManager.py	Sun Dec 31 18:01:05 2023 +0100
+++ b/src/eric7/Preferences/ThemeManager.py	Sun Dec 31 20:27:52 2023 +0100
@@ -199,7 +199,7 @@
                 }
 
                 try:
-                    jsonString = json.dumps(themeDict, indent=2)
+                    jsonString = json.dumps(themeDict, indent=2) + "\n"
                     with open(filename, "w") as f:
                         f.write(jsonString)
                 except (OSError, TypeError) as err:
--- a/src/eric7/Project/DebuggerPropertiesFile.py	Sun Dec 31 18:01:05 2023 +0100
+++ b/src/eric7/Project/DebuggerPropertiesFile.py	Sun Dec 31 20:27:52 2023 +0100
@@ -65,7 +65,7 @@
         debuggerPropertiesDict["debug_properties"] = self.__project.debugProperties
 
         try:
-            jsonString = json.dumps(debuggerPropertiesDict, indent=2)
+            jsonString = json.dumps(debuggerPropertiesDict, indent=2) + "\n"
             with open(filename, "w") as f:
                 f.write(jsonString)
         except (OSError, TypeError) as err:
--- a/src/eric7/Project/ProjectFile.py	Sun Dec 31 18:01:05 2023 +0100
+++ b/src/eric7/Project/ProjectFile.py	Sun Dec 31 20:27:52 2023 +0100
@@ -90,7 +90,7 @@
                 )
 
         try:
-            jsonString = json.dumps(projectDict, indent=2, sort_keys=True)
+            jsonString = json.dumps(projectDict, indent=2, sort_keys=True) + "\n"
             with open(filename, "w", newline="") as f:
                 f.write(jsonString)
         except (OSError, TypeError) as err:
--- a/src/eric7/Project/UserProjectFile.py	Sun Dec 31 18:01:05 2023 +0100
+++ b/src/eric7/Project/UserProjectFile.py	Sun Dec 31 20:27:52 2023 +0100
@@ -61,7 +61,7 @@
         userProjectDict["user_data"] = self.__project.pudata
 
         try:
-            jsonString = json.dumps(userProjectDict, indent=2)
+            jsonString = json.dumps(userProjectDict, indent=2) + "\n"
             with open(filename, "w") as f:
                 f.write(jsonString)
         except (OSError, TypeError) as err:
--- a/src/eric7/Sessions/SessionFile.py	Sun Dec 31 18:01:05 2023 +0100
+++ b/src/eric7/Sessions/SessionFile.py	Sun Dec 31 20:27:52 2023 +0100
@@ -222,7 +222,7 @@
         sessionDict["ProjectBrowserStates"] = browsersList
 
         try:
-            jsonString = json.dumps(sessionDict, indent=2)
+            jsonString = json.dumps(sessionDict, indent=2) + "\n"
             with open(filename, "w") as f:
                 f.write(jsonString)
         except (OSError, TypeError) as err:
--- a/src/eric7/Tasks/TasksFile.py	Sun Dec 31 18:01:05 2023 +0100
+++ b/src/eric7/Tasks/TasksFile.py	Sun Dec 31 20:27:52 2023 +0100
@@ -84,7 +84,7 @@
             ]
 
         try:
-            jsonString = json.dumps(tasksDict, indent=2)
+            jsonString = json.dumps(tasksDict, indent=2) + "\n"
             with open(filename, "w") as f:
                 f.write(jsonString)
         except (OSError, TypeError) as err:
--- a/src/eric7/Templates/TemplatesFile.py	Sun Dec 31 18:01:05 2023 +0100
+++ b/src/eric7/Templates/TemplatesFile.py	Sun Dec 31 20:27:52 2023 +0100
@@ -76,7 +76,7 @@
         templatesDict["template_groups"] = templateGroups
 
         try:
-            jsonString = json.dumps(templatesDict, indent=2)
+            jsonString = json.dumps(templatesDict, indent=2) + "\n"
             with open(filename, "w") as f:
                 f.write(jsonString)
         except (OSError, TypeError) as err:
--- a/src/eric7/VCS/VersionControl.py	Sun Dec 31 18:01:05 2023 +0100
+++ b/src/eric7/VCS/VersionControl.py	Sun Dec 31 20:27:52 2023 +0100
@@ -297,7 +297,7 @@
                 del messages[noMessages:]
 
                 with contextlib.suppress(TypeError, OSError):
-                    jsonString = json.dumps(messages, indent=2)
+                    jsonString = json.dumps(messages, indent=2) + "\n"
                     with open(
                         os.path.join(projectMgmtDir, VersionControl.commitHistoryData),
                         "w",
@@ -331,7 +331,7 @@
             )
             if lockFile.lock():
                 with contextlib.suppress(TypeError, OSError):
-                    jsonString = json.dumps([], indent=2)
+                    jsonString = json.dumps([], indent=2) + "\n"
                     with open(
                         os.path.join(projectMgmtDir, VersionControl.commitHistoryData),
                         "w",

eric ide

mercurial