eric6/Project/Project.py

changeset 8235
78e6d29eb773
parent 8228
772103b14c18
child 8237
acc1490f822e
diff -r fcb6b4b96274 -r 78e6d29eb773 eric6/Project/Project.py
--- a/eric6/Project/Project.py	Tue Apr 13 18:02:59 2021 +0200
+++ b/eric6/Project/Project.py	Tue Apr 13 19:59:17 2021 +0200
@@ -1565,12 +1565,9 @@
         """
         dirty = False
         
-        if os.path.isabs(fn):
-            # make it relative to the project root, if it starts with that path
-            newfn = self.getRelativePath(fn)
-        else:
-            # assume relative paths are relative to the project root
-            newfn = fn
+        # make it relative to the project root, if it starts with that path
+        # assume relative paths are relative to the project root
+        newfn = self.getRelativePath(fn) if os.path.isabs(fn) else fn
         newdir = os.path.dirname(newfn)
         
         if isSourceFile:
@@ -2218,10 +2215,7 @@
             if entry.startswith(dn):
                 self.pdata["OTHERS"].remove(entry)
                 dirty = True
-        if not dn.endswith(os.sep):
-            dn2 = dn + os.sep
-        else:
-            dn2 = dn
+        dn2 = dn if dn.endswith(os.sep) else dn + os.sep
         for key in ["SOURCES", "FORMS", "INTERFACES", "PROTOCOLS", "RESOURCES",
                     "TRANSLATIONS", ]:
             for entry in self.pdata[key][:]:
@@ -4561,10 +4555,7 @@
         self.recentMenu.clear()
         
         for idx, rp in enumerate(self.recent, start=1):
-            if idx < 10:
-                formatStr = '&{0:d}. {1}'
-            else:
-                formatStr = '{0:d}. {1}'
+            formatStr = '&{0:d}. {1}' if idx < 10 else '{0:d}. {1}'
             act = self.recentMenu.addAction(
                 formatStr.format(
                     idx,
@@ -4686,10 +4677,7 @@
                 # set fn to project relative name
                 # then reset ns to fully qualified name for insertion,
                 # possibly.
-                if directory == "":
-                    fn = ns
-                else:
-                    fn = os.path.join(directory, ns)
+                fn = os.path.join(directory, ns) if directory else ns
                 ns = os.path.abspath(os.path.join(curpath, ns))
                 
                 # do not bother with dirs here...
@@ -5327,10 +5315,7 @@
         
         # write the file
         try:
-            if self.pdata["EOL"] == 0:
-                newline = None
-            else:
-                newline = self.getEolString()
+            newline = None if self.pdata["EOL"] == 0 else self.getEolString()
             with open(pkglist, "w", encoding="utf-8",
                       newline=newline) as pkglistFile:
                 pkglistFile.write("\n".join(header) + "\n")

eric ide

mercurial