601 if os.path.exists(apiname): |
601 if os.path.exists(apiname): |
602 os.remove(apiname) |
602 os.remove(apiname) |
603 for apiname in glob.glob( |
603 for apiname in glob.glob( |
604 os.path.join(apidir, progLanguage, "*.bas") |
604 os.path.join(apidir, progLanguage, "*.bas") |
605 ) + glob.glob(os.path.join(apidir, progLanguage.lower(), "*.bas")): |
605 ) + glob.glob(os.path.join(apidir, progLanguage.lower(), "*.bas")): |
606 os.remove(apiname) |
606 if os.path.exists(apiname): |
|
607 os.remove(apiname) |
607 |
608 |
608 # remove empty directories |
609 # remove empty directories |
609 with contextlib.suppress(FileNotFoundError, OSError): |
610 with contextlib.suppress(FileNotFoundError, OSError): |
610 os.rmdir(os.path.join(apidir, progLanguage)) |
611 os.rmdir(os.path.join(apidir, progLanguage)) |
611 with contextlib.suppress(FileNotFoundError, OSError): |
612 with contextlib.suppress(FileNotFoundError, OSError): |
694 # 1. cleanup desktop links |
695 # 1. cleanup desktop links |
695 regName = "Desktop" |
696 regName = "Desktop" |
696 desktopEntry = getWinregEntry(regName, regPath) |
697 desktopEntry = getWinregEntry(regName, regPath) |
697 if desktopEntry: |
698 if desktopEntry: |
698 desktopFolder = os.path.normpath(os.path.expandvars(desktopEntry)) |
699 desktopFolder = os.path.normpath(os.path.expandvars(desktopEntry)) |
699 for linkName in windowsDesktopNames(): |
700 for linkName in windowsDesktopNames(clean=True): |
700 linkPath = os.path.join(desktopFolder, linkName) |
701 linkPath = os.path.join(desktopFolder, linkName) |
701 if os.path.exists(linkPath): |
702 if os.path.exists(linkPath): |
702 try: |
703 try: |
703 os.remove(linkPath) |
704 os.remove(linkPath) |
704 except OSError: |
705 except OSError: |
2011 shortcut.WorkingDirectory = os.path.dirname(targetPath) |
2012 shortcut.WorkingDirectory = os.path.dirname(targetPath) |
2012 shortcut.IconLocation = iconPath |
2013 shortcut.IconLocation = iconPath |
2013 shortcut.save() |
2014 shortcut.save() |
2014 |
2015 |
2015 |
2016 |
2016 def windowsDesktopNames(): |
2017 def windowsDesktopNames(clean=False): |
2017 """ |
2018 """ |
2018 Function to generate the link names for the Windows Desktop. |
2019 Function to generate the link names for the Windows Desktop. |
2019 |
2020 |
|
2021 @param clean flag indicating to get the desktop names for a cleanup operation |
|
2022 @type bool |
2020 @return list of desktop link names |
2023 @return list of desktop link names |
2021 @rtype list of str |
2024 @rtype list of str |
2022 """ |
2025 """ |
2023 return [e[0] for e in windowsDesktopEntries()] |
2026 return [e[0] for e in windowsDesktopEntries(clean=clean)] |
2024 |
2027 |
2025 |
2028 |
2026 def windowsDesktopEntries(): |
2029 def windowsDesktopEntries(clean=False): |
2027 """ |
2030 """ |
2028 Function to generate data for the Windows Desktop links. |
2031 Function to generate data for the Windows Desktop links. |
2029 |
2032 |
|
2033 @param clean flag indicating to get the desktop entries for a cleanup operation |
|
2034 @type bool |
2030 @return list of tuples containing the desktop link name, |
2035 @return list of tuples containing the desktop link name, |
2031 the link target and the icon target |
2036 the link target and the icon target |
2032 @rtype list of tuples of (str, str, str) |
2037 @rtype list of tuples of (str, str, str) |
2033 """ |
2038 """ |
2034 global cfg |
2039 global cfg |
2044 "eric7 Browser (Python {0}.{1}).lnk", |
2049 "eric7 Browser (Python {0}.{1}).lnk", |
2045 os.path.join(cfg["bindir"], "eric7_browser.cmd"), |
2050 os.path.join(cfg["bindir"], "eric7_browser.cmd"), |
2046 os.path.join(cfg["ericPixDir"], "ericWeb48.ico"), |
2051 os.path.join(cfg["ericPixDir"], "ericWeb48.ico"), |
2047 ), |
2052 ), |
2048 ] |
2053 ] |
|
2054 |
|
2055 if clean: |
|
2056 # clean obsolete entries as well |
|
2057 entriesTemplates.extend([ |
|
2058 ( |
|
2059 "eric7 (Python {0}.{1}).lnk", |
|
2060 os.path.join(cfg["bindir"], "eric7_ide.cmd"), |
|
2061 os.path.join(cfg["ericPixDir"], "eric7.ico"), |
|
2062 ), |
|
2063 ]) |
2049 |
2064 |
2050 return [ |
2065 return [ |
2051 (e[0].format(majorVersion, minorVersion), e[1], e[2]) for e in entriesTemplates |
2066 (e[0].format(majorVersion, minorVersion), e[1], e[2]) for e in entriesTemplates |
2052 ] |
2067 ] |
2053 |
2068 |
2058 |
2073 |
2059 @return name of the Start Menu top entry |
2074 @return name of the Start Menu top entry |
2060 @rtype str |
2075 @rtype str |
2061 """ |
2076 """ |
2062 majorVersion, minorVersion = sys.version_info[:2] |
2077 majorVersion, minorVersion = sys.version_info[:2] |
2063 return "eric7 IDE (Python {0}.{1})".format(majorVersion, minorVersion) |
2078 return "eric7 (Python {0}.{1})".format(majorVersion, minorVersion) |
2064 |
2079 |
2065 |
2080 |
2066 def main(argv): |
2081 def main(argv): |
2067 """ |
2082 """ |
2068 The main function of the script. |
2083 The main function of the script. |