scripts/install.py

branch
eric7-maintenance
changeset 10460
3b34efa2857c
parent 10349
df7edc29cbfb
parent 10439
21c28b0f9e41
child 10534
783d835d7fe4
--- a/scripts/install.py	Sun Dec 03 14:54:00 2023 +0100
+++ b/scripts/install.py	Mon Jan 01 11:10:45 2024 +0100
@@ -1,7 +1,7 @@
 #!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2002 - 2023 Detlev Offenbach <detlev@die-offenbachs.de>
+# Copyright (c) 2002 - 2024 Detlev Offenbach <detlev@die-offenbachs.de>
 #
 # This is the install script for eric.
 
@@ -102,7 +102,8 @@
     """
     Exit the install script.
 
-    @param rcode result code to report back (integer)
+    @param rcode result code to report back
+    @type int
     """
     global currDir
 
@@ -173,8 +174,10 @@
     """
     Copy a string to a file.
 
-    @param name the name of the file.
-    @param text the contents to copy to the file.
+    @param name name of the file
+    @type str
+    @param text contents to copy to the file
+    @type str
     """
     with open(name, "w") as f:
         f.write(text)
@@ -184,8 +187,10 @@
     """
     Modify a desktop file and write it to its destination.
 
-    @param src source file name (string)
-    @param dst destination file name (string)
+    @param src source file name
+    @type str
+    @param dst destination file name
+    @type str
     """
     global cfg, platBinDir
 
@@ -208,8 +213,10 @@
     """
     Modify an appstream file and write it to its destination.
 
-    @param src source file name (string)
-    @param dst destination file name (string)
+    @param src source file name
+    @type str
+    @param dst destination file name
+    @type str
     """
     if os.path.exists(os.path.join("eric", "src", "eric7", "UI", "Info.py")):
         # Installing from installer archive
@@ -242,13 +249,16 @@
     Create the platform specific names for the wrapper script.
 
     @param dname name of the directory to place the wrapper into
+    @type str
     @param wfile basename (without extension) of the wrapper script
-    @return the names of the wrapper scripts
+    @type str
+    @return list containing the names of the wrapper scripts
+    @rtype list of str
     """
     wnames = (
-        (dname + "\\" + wfile + ".cmd", dname + "\\" + wfile + ".bat")
+        [dname + "\\" + wfile + ".cmd", dname + "\\" + wfile + ".bat"]
         if sys.platform.startswith(("win", "cygwin"))
-        else (dname + "/" + wfile,)
+        else [dname + "/" + wfile]
     )
 
     return wnames
@@ -258,13 +268,17 @@
     """
     Create an executable wrapper for a Python script.
 
-    @param pydir the name of the directory where the Python script will
-        eventually be installed (string)
-    @param wfile the basename of the wrapper (string)
-    @param saveDir directory to save the file into (string)
-    @param isGuiScript flag indicating a wrapper script for a GUI
-        application (boolean)
-    @return the platform specific name of the wrapper (string)
+    @param pydir name of the directory where the Python script will
+        eventually be installed
+    @type str
+    @param wfile basename of the wrapper
+    @type str
+    @param saveDir directory to save the file into
+    @type str
+    @param isGuiScript flag indicating a wrapper script for a GUI application
+    @type bool
+    @return the platform specific name of the wrapper
+    @rtype str
     """
     # all kinds of Windows systems
     if sys.platform.startswith(("win", "cygwin")):
@@ -319,11 +333,16 @@
     designer template files and DTDs of a directory tree.
 
     @param src name of the source directory
+    @type str
     @param dst name of the destination directory
+    @type str
     @param filters list of filter pattern determining the files to be copied
+    @type list of str
     @param excludeDirs list of (sub)directories to exclude from copying
+    @type list of str
     @param excludePatterns list of filter pattern determining the files to
         be skipped
+    @type list of str
     """
     if excludeDirs is None:
         excludeDirs = []
@@ -384,7 +403,8 @@
     Cleanup the sources directory to get rid of leftover files
     and directories.
 
-    @param dirName name of the directory to prune (string)
+    @param dirName name of the directory to prune
+    @type str
     """
     # step 1: delete all Ui_*.py files without a corresponding
     #         *.ui file
@@ -509,7 +529,7 @@
         ]:
             with contextlib.suppress(AttributeError):
                 if os.path.exists(getConfig(name)):
-                    shutil.rmtree(getConfig(name), True)
+                    shutil.rmtree(getConfig(name), ignore_errors=True)
 
         # Cleanup translations
         for name in glob.glob(
@@ -623,8 +643,7 @@
     global doCleanDesktopLinks, forceCleanDesktopLinks
 
     regPath = (
-        "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer"
-        + "\\User Shell Folders"
+        "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders"
     )
 
     if doCleanDesktopLinks or forceCleanDesktopLinks:
@@ -660,9 +679,12 @@
     """
     Wrapper function around shutil.copy() to ensure the permissions.
 
-    @param src source file name (string)
-    @param dst destination file name or directory name (string)
-    @param perm permissions to be set (integer)
+    @param src source file name
+    @type str
+    @param dst destination file name or directory name
+    @type str
+    @param perm permissions to be set
+    @type int
     """
     shutil.copy(src, dst)
     if os.path.isdir(dst):
@@ -674,7 +696,8 @@
     """
     Actually perform the installation steps.
 
-    @return result code (integer)
+    @return result code
+    @rtype int
     """
     global distDir, doCleanup, cfg, progLanguages, sourceDir, configName
     global installApis
@@ -715,7 +738,7 @@
 
     # set install prefix, if not None
     if distDir:
-        for key in list(cfg.keys()):
+        for key in cfg:
             cfg[key] = os.path.normpath(os.path.join(distDir, cfg[key].lstrip(os.sep)))
 
     try:
@@ -1070,8 +1093,7 @@
         return
 
     regPath = (
-        "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer"
-        + "\\User Shell Folders"
+        "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders"
     )
 
     # 1. create desktop shortcuts
@@ -1171,7 +1193,7 @@
         from eric7.UI.Info import CopyrightShort, Version  # noqa: I101
     else:
         Version = "Unknown"
-        CopyrightShort = "(c) 2002 - 2023 Detlev Offenbach"
+        CopyrightShort = "(c) 2002 - 2024 Detlev Offenbach"
 
     copyToFile(
         os.path.join(directories["contents"], "Info.plist"),
@@ -1843,9 +1865,12 @@
     Local function to create the Python source file name for the compiled
     .ui file.
 
-    @param py_dir suggested name of the directory (string)
-    @param py_file suggested name for the compile source file (string)
-    @return tuple of directory name (string) and source file name (string)
+    @param py_dir suggested name of the directory
+    @type str
+    @param py_file suggested name for the compile source file
+    @type str
+    @return tuple of directory name and source file name
+    @rtype tuple of (str, str)
     """
     return py_dir, "Ui_{0}".format(py_file)
 
@@ -1930,7 +1955,8 @@
     """
     Function to prepare an Info.py file when installing from source.
 
-    @param fileName name of the Python file containing the info (string)
+    @param fileName name of the Python file containing the info
+    @type str
     """
     if not fileName:
         return
@@ -1974,7 +2000,7 @@
     @param path registry path of the variable
     @type str
     @return value of requested registry variable
-    @rtype any
+    @rtype Any
     """
     try:
         import winreg  # noqa: I101, I103
@@ -2317,7 +2343,7 @@
     try:
         if doCleanup:
             if distDir:
-                shutil.rmtree(distDir, True)
+                shutil.rmtree(distDir, ignore_errors=True)
             else:
                 cleanUp()
     except OSError as msg:

eric ide

mercurial