src/eric7/Project/ProjectFile.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9278
36448ca469c2
diff -r e9e7eca7efee -r bf71ee032bb4 src/eric7/Project/ProjectFile.py
--- a/src/eric7/Project/ProjectFile.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/Project/ProjectFile.py	Wed Jul 13 14:55:47 2022 +0200
@@ -28,10 +28,11 @@
     """
     Class representing the project JSON file.
     """
+
     def __init__(self, project: Project, parent: QObject = None):
         """
         Constructor
-        
+
         @param project reference to the project object
         @type Project
         @param parent reference to the parent object (defaults to None)
@@ -39,11 +40,11 @@
         """
         super().__init__(parent)
         self.__project = project
-    
+
     def writeFile(self, filename: str) -> bool:
         """
         Public method to write the project data to a project JSON file.
-        
+
         @param filename name of the project file
         @type str
         @return flag indicating a successful write
@@ -52,38 +53,50 @@
         projectDict = {}
         projectDict["header"] = {
             "comment": "eric project file for project {0}".format(
-                self.__project.getProjectName()),
+                self.__project.getProjectName()
+            ),
             "copyright": "Copyright (C) {0} {1}, {2}".format(
-                time.strftime('%Y'),
+                time.strftime("%Y"),
                 self.__project.pdata["AUTHOR"],
-                self.__project.pdata["EMAIL"])
+                self.__project.pdata["EMAIL"],
+            ),
         }
-        
+
         if Preferences.getProject("TimestampFile"):
-            projectDict["header"]["saved"] = (
-                time.strftime('%Y-%m-%d, %H:%M:%S')
-            )
-        
+            projectDict["header"]["saved"] = time.strftime("%Y-%m-%d, %H:%M:%S")
+
         projectDict["project"] = copy.deepcopy(self.__project.pdata)
-        
+
         # modify paths to contain universal separators
         for key in (
-            "SOURCES", "FORMS", "TRANSLATIONS", "TRANSLATIONEXCEPTIONS",
-            "RESOURCES", "INTERFACES", "PROTOCOLS", "OTHERS"
+            "SOURCES",
+            "FORMS",
+            "TRANSLATIONS",
+            "TRANSLATIONEXCEPTIONS",
+            "RESOURCES",
+            "INTERFACES",
+            "PROTOCOLS",
+            "OTHERS",
         ):
             with contextlib.suppress(KeyError):
-                projectDict["project"][key] = sorted([
-                    Utilities.fromNativeSeparators(f)
-                    for f in projectDict["project"][key]
-                ])
+                projectDict["project"][key] = sorted(
+                    [
+                        Utilities.fromNativeSeparators(f)
+                        for f in projectDict["project"][key]
+                    ]
+                )
         for key in (
-            "SPELLWORDS", "SPELLEXCLUDES", "TRANSLATIONPATTERN",
-            "TRANSLATIONSBINPATH", "MAINSCRIPT"
+            "SPELLWORDS",
+            "SPELLEXCLUDES",
+            "TRANSLATIONPATTERN",
+            "TRANSLATIONSBINPATH",
+            "MAINSCRIPT",
         ):
             with contextlib.suppress(KeyError):
                 projectDict["project"][key] = Utilities.fromNativeSeparators(
-                    projectDict["project"][key])
-        
+                    projectDict["project"][key]
+                )
+
         try:
             jsonString = json.dumps(projectDict, indent=2, sort_keys=True)
             with open(filename, "w", newline="") as f:
@@ -96,16 +109,16 @@
                     self.tr(
                         "<p>The project file <b>{0}</b> could not be "
                         "written.</p><p>Reason: {1}</p>"
-                    ).format(filename, str(err))
+                    ).format(filename, str(err)),
                 )
                 return False
-        
+
         return True
-    
+
     def readFile(self, filename: str) -> bool:
         """
         Public method to read the project data from a project JSON file.
-        
+
         @param filename name of the project file
         @type str
         @return flag indicating a successful read
@@ -122,28 +135,37 @@
                 self.tr(
                     "<p>The project file <b>{0}</b> could not be "
                     "read.</p><p>Reason: {1}</p>"
-                ).format(filename, str(err))
+                ).format(filename, str(err)),
             )
             return False
-        
+
         # modify paths to contain native separators
         for key in (
-            "SOURCES", "FORMS", "TRANSLATIONS", "TRANSLATIONEXCEPTIONS",
-            "RESOURCES", "INTERFACES", "PROTOCOLS", "OTHERS"
+            "SOURCES",
+            "FORMS",
+            "TRANSLATIONS",
+            "TRANSLATIONEXCEPTIONS",
+            "RESOURCES",
+            "INTERFACES",
+            "PROTOCOLS",
+            "OTHERS",
         ):
             with contextlib.suppress(KeyError):
                 projectDict["project"][key] = [
-                    Utilities.toNativeSeparators(f)
-                    for f in projectDict["project"][key]
+                    Utilities.toNativeSeparators(f) for f in projectDict["project"][key]
                 ]
         for key in (
-            "SPELLWORDS", "SPELLEXCLUDES", "TRANSLATIONPATTERN",
-            "TRANSLATIONSBINPATH", "MAINSCRIPT"
+            "SPELLWORDS",
+            "SPELLEXCLUDES",
+            "TRANSLATIONPATTERN",
+            "TRANSLATIONSBINPATH",
+            "MAINSCRIPT",
         ):
             with contextlib.suppress(KeyError):
                 projectDict["project"][key] = Utilities.toNativeSeparators(
-                    projectDict["project"][key])
-        
+                    projectDict["project"][key]
+                )
+
         self.__project.pdata = projectDict["project"]
-        
+
         return True

eric ide

mercurial