Utilities: removed some obsolete functions.

Fri, 04 Dec 2020 18:29:31 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 04 Dec 2020 18:29:31 +0100
changeset 7849
70e464748aaa
parent 7848
97e9b5cc51dc
child 7850
e64b178499da
child 7852
24d47bf35c2b

Utilities: removed some obsolete functions.

eric6/APIs/Python3/eric6.api file | annotate | diff | comparison | revisions
eric6/Debugger/DebugUI.py file | annotate | diff | comparison | revisions
eric6/Documentation/Help/source.qch file | annotate | diff | comparison | revisions
eric6/Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
eric6/Documentation/Source/eric6.Utilities.__init__.html file | annotate | diff | comparison | revisions
eric6/E5Gui/E5SingleApplication.py file | annotate | diff | comparison | revisions
eric6/Graphics/ImportsDiagramBuilder.py file | annotate | diff | comparison | revisions
eric6/Graphics/PackageDiagramBuilder.py file | annotate | diff | comparison | revisions
eric6/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py file | annotate | diff | comparison | revisions
eric6/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py file | annotate | diff | comparison | revisions
eric6/UI/EmailDialog.py file | annotate | diff | comparison | revisions
eric6/Utilities/__init__.py file | annotate | diff | comparison | revisions
eric6/ViewManager/ViewManager.py file | annotate | diff | comparison | revisions
eric6/eric6.py file | annotate | diff | comparison | revisions
--- a/eric6/APIs/Python3/eric6.api	Wed Dec 02 19:09:38 2020 +0100
+++ b/eric6/APIs/Python3/eric6.api	Fri Dec 04 18:29:31 2020 +0100
@@ -9403,7 +9403,6 @@
 eric6.Utilities.joinext?4(prefix, ext)
 eric6.Utilities.linesep?4()
 eric6.Utilities.normabsjoinpath?4(a, *p)
-eric6.Utilities.normabspath?4(path)
 eric6.Utilities.normcaseabspath?4(path)
 eric6.Utilities.normcasepath?4(path)
 eric6.Utilities.normjoinpath?4(a, *p)
@@ -9415,9 +9414,7 @@
 eric6.Utilities.readEncodedFileWithEncoding?4(filename, encoding)
 eric6.Utilities.readEncodedFileWithHash?4(filename)
 eric6.Utilities.readStringFromStream?4(stream)
-eric6.Utilities.relativePath?4(path, start)
 eric6.Utilities.relativeUniversalPath?4(path, start)
-eric6.Utilities.relpath?4(path, start=os.path.curdir)
 eric6.Utilities.rxIndex?4(rx, txt)
 eric6.Utilities.samefilepath?4(f1, f2)
 eric6.Utilities.samepath?4(f1, f2)
--- a/eric6/Debugger/DebugUI.py	Wed Dec 02 19:09:38 2020 +0100
+++ b/eric6/Debugger/DebugUI.py	Fri Dec 04 18:29:31 2020 +0100
@@ -1046,7 +1046,7 @@
                         self.ui, Program,
                         self.tr('<p><b>{0}</b> has terminated with an exit'
                                 ' status of {1}.</p>{2}')
-                            .format(Utilities.normabspath(self.ui.currentProg),
+                            .format(os.path.abspath(self.ui.currentProg),
                                     status, info))
             else:
                 if message:
@@ -1077,7 +1077,7 @@
                         self.appendStdout.emit(self.tr(
                             '"{0}" has terminated with an exit status of'
                             ' {1}.\n{2}\n').format(
-                            Utilities.normabspath(self.ui.currentProg), status,
+                            os.path.abspath(self.ui.currentProg), status,
                             info))
 
     def __clientSyntaxError(self, message, filename, lineNo, characterNo):
Binary file eric6/Documentation/Help/source.qch has changed
--- a/eric6/Documentation/Help/source.qhp	Wed Dec 02 19:09:38 2020 +0100
+++ b/eric6/Documentation/Help/source.qhp	Fri Dec 04 18:29:31 2020 +0100
@@ -17714,7 +17714,6 @@
       <keyword name="namespacePathJoin" id="namespacePathJoin" ref="eric6.Plugins.CheckerPlugins.CodeStyleChecker.Security.SecurityUtils.html#namespacePathJoin" />
       <keyword name="namespacePathSplit" id="namespacePathSplit" ref="eric6.Plugins.CheckerPlugins.CodeStyleChecker.Security.SecurityUtils.html#namespacePathSplit" />
       <keyword name="normabsjoinpath" id="normabsjoinpath" ref="eric6.Utilities.__init__.html#normabsjoinpath" />
-      <keyword name="normabspath" id="normabspath" ref="eric6.Utilities.__init__.html#normabspath" />
       <keyword name="normalizeCode" id="normalizeCode" ref="eric6.Plugins.CheckerPlugins.SyntaxChecker.SyntaxCheck.html#normalizeCode" />
       <keyword name="normalizeCode" id="normalizeCode" ref="eric6.Plugins.CheckerPlugins.SyntaxChecker.jsCheckSyntax.html#normalizeCode" />
       <keyword name="normalizeCode" id="normalizeCode" ref="eric6.Plugins.CheckerPlugins.SyntaxChecker.jsonCheckSyntax.html#normalizeCode" />
@@ -17811,9 +17810,7 @@
       <keyword name="registerView" id="registerView" ref="eric6.WebBrowser.WebInspector.html#registerView" />
       <keyword name="register_check" id="register_check" ref="eric6.Plugins.CheckerPlugins.CodeStyleChecker.pycodestyle.html#register_check" />
       <keyword name="rehashPassword" id="rehashPassword" ref="eric6.Utilities.crypto.py3PBKDF2.html#rehashPassword" />
-      <keyword name="relativePath" id="relativePath" ref="eric6.Utilities.__init__.html#relativePath" />
       <keyword name="relativeUniversalPath" id="relativeUniversalPath" ref="eric6.Utilities.__init__.html#relativeUniversalPath" />
-      <keyword name="relpath" id="relpath" ref="eric6.Utilities.__init__.html#relpath" />
       <keyword name="removeConfigurationData" id="removeConfigurationData" ref="uninstall.html#removeConfigurationData" />
       <keyword name="removeDataDirectory" id="removeDataDirectory" ref="uninstall.html#removeDataDirectory" />
       <keyword name="removeMarkers" id="removeMarkers" ref="eric6.UI.CompareDialog.html#removeMarkers" />
--- a/eric6/Documentation/Source/eric6.Utilities.__init__.html	Wed Dec 02 19:09:38 2020 +0100
+++ b/eric6/Documentation/Source/eric6.Utilities.__init__.html	Fri Dec 04 18:29:31 2020 +0100
@@ -264,10 +264,6 @@
 <td>Function returning a normalized, absolute path of the joined parts passed into it.</td>
 </tr>
 <tr>
-<td><a href="#normabspath">normabspath</a></td>
-<td>Function returning a normalized, absolute path.</td>
-</tr>
-<tr>
 <td><a href="#normcaseabspath">normcaseabspath</a></td>
 <td>Function returning an absolute path, that is normalized with respect to its case and references.</td>
 </tr>
@@ -312,18 +308,10 @@
 <td>Module function to read a string from the given stream.</td>
 </tr>
 <tr>
-<td><a href="#relativePath">relativePath</a></td>
-<td>Function to convert a file path to a path relative to a start path.</td>
-</tr>
-<tr>
 <td><a href="#relativeUniversalPath">relativeUniversalPath</a></td>
 <td>Function to convert a file path to a path relative to a start path with universal separators.</td>
 </tr>
 <tr>
-<td><a href="#relpath">relpath</a></td>
-<td>Return a relative version of a path.</td>
-</tr>
-<tr>
 <td><a href="#rxIndex">rxIndex</a></td>
 <td>Function to get the index (start position) of a regular expression match within some text.</td>
 </tr>
@@ -1918,29 +1906,6 @@
 <div align="right"><a href="#top">Up</a></div>
 <hr />
 <hr />
-<a NAME="normabspath" ID="normabspath"></a>
-<h2>normabspath</h2>
-<b>normabspath</b>(<i>path</i>)
-
-<p>
-    Function returning a normalized, absolute path.
-</p>
-<dl>
-
-<dt><i>path</i></dt>
-<dd>
-file path (string)
-</dd>
-</dl>
-<dl>
-<dt>Returns:</dt>
-<dd>
-absolute, normalized path (string)
-</dd>
-</dl>
-<div align="right"><a href="#top">Up</a></div>
-<hr />
-<hr />
 <a NAME="normcaseabspath" ID="normcaseabspath"></a>
 <h2>normcaseabspath</h2>
 <b>normcaseabspath</b>(<i>path</i>)
@@ -2004,7 +1969,7 @@
 </dd>
 <dt><i>p</i></dt>
 <dd>
-variable number of path parts to be joind (string)
+variable number of path parts to be joined (string)
 </dd>
 </dl>
 <dl>
@@ -2227,34 +2192,6 @@
 <div align="right"><a href="#top">Up</a></div>
 <hr />
 <hr />
-<a NAME="relativePath" ID="relativePath"></a>
-<h2>relativePath</h2>
-<b>relativePath</b>(<i>path, start</i>)
-
-<p>
-    Function to convert a file path to a path relative to a start path.
-</p>
-<dl>
-
-<dt><i>path</i></dt>
-<dd>
-file or directory name to convert (string)
-</dd>
-<dt><i>start</i></dt>
-<dd>
-start path (string)
-</dd>
-</dl>
-<dl>
-<dt>Returns:</dt>
-<dd>
-relative path or unchanged path, if path does not start with
-        the start path (string)
-</dd>
-</dl>
-<div align="right"><a href="#top">Up</a></div>
-<hr />
-<hr />
 <a NAME="relativeUniversalPath" ID="relativeUniversalPath"></a>
 <h2>relativeUniversalPath</h2>
 <b>relativeUniversalPath</b>(<i>path, start</i>)
@@ -2284,40 +2221,6 @@
 <div align="right"><a href="#top">Up</a></div>
 <hr />
 <hr />
-<a NAME="relpath" ID="relpath"></a>
-<h2>relpath</h2>
-<b>relpath</b>(<i>path, start=os.path.curdir</i>)
-
-<p>
-    Return a relative version of a path.
-</p>
-<dl>
-
-<dt><i>path</i></dt>
-<dd>
-path to make relative (string)
-</dd>
-<dt><i>start</i></dt>
-<dd>
-path to make relative from (string)
-</dd>
-</dl>
-<dl>
-<dt>Returns:</dt>
-<dd>
-relative path (string)
-</dd>
-</dl>
-<dl>
-
-<dt>Raises <b>ValueError</b>:</dt>
-<dd>
-raised to indicate an invalid path
-</dd>
-</dl>
-<div align="right"><a href="#top">Up</a></div>
-<hr />
-<hr />
 <a NAME="rxIndex" ID="rxIndex"></a>
 <h2>rxIndex</h2>
 <b>rxIndex</b>(<i>rx, txt</i>)
--- a/eric6/E5Gui/E5SingleApplication.py	Wed Dec 02 19:09:38 2020 +0100
+++ b/eric6/E5Gui/E5SingleApplication.py	Fri Dec 04 18:29:31 2020 +0100
@@ -162,7 +162,7 @@
         
         @param fname name of file to be opened (string)
         """
-        self.sendCommand(SAOpenFile, [Utilities.normabspath(fname)])
+        self.sendCommand(SAOpenFile, [os.path.abspath(fname)])
         
     def __openProject(self, pfname):
         """
@@ -170,7 +170,7 @@
         
         @param pfname name of the projectfile to be opened (string)
         """
-        self.sendCommand(SAOpenProject, [Utilities.normabspath(pfname)])
+        self.sendCommand(SAOpenProject, [os.path.abspath(pfname)])
         
     def __openMultiProject(self, pfname):
         """
@@ -178,7 +178,7 @@
         
         @param pfname name of the projectfile to be opened (string)
         """
-        self.sendCommand(SAOpenMultiProject, [Utilities.normabspath(pfname)])
+        self.sendCommand(SAOpenMultiProject, [os.path.abspath(pfname)])
         
     def __sendArguments(self, argsStr):
         """
--- a/eric6/Graphics/ImportsDiagramBuilder.py	Wed Dec 02 19:09:38 2020 +0100
+++ b/eric6/Graphics/ImportsDiagramBuilder.py	Fri Dec 04 18:29:31 2020 +0100
@@ -44,7 +44,7 @@
         self.setObjectName("ImportsDiagram")
         
         self.showExternalImports = showExternalImports
-        self.packagePath = Utilities.normabspath(package)
+        self.packagePath = os.path.abspath(package)
     
     def initialize(self):
         """
--- a/eric6/Graphics/PackageDiagramBuilder.py	Wed Dec 02 19:09:38 2020 +0100
+++ b/eric6/Graphics/PackageDiagramBuilder.py	Fri Dec 04 18:29:31 2020 +0100
@@ -39,7 +39,7 @@
         super(PackageDiagramBuilder, self).__init__(dialog, view, project)
         self.setObjectName("PackageDiagram")
         
-        self.package = Utilities.normabspath(package)
+        self.package = os.path.abspath(package)
         self.noAttrs = noAttrs
     
     def initialize(self):
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py	Wed Dec 02 19:09:38 2020 +0100
+++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py	Fri Dec 04 18:29:31 2020 +0100
@@ -1206,7 +1206,7 @@
             return
         
         if item.parent():
-            fn = Utilities.normabspath(item.data(0, self.filenameRole))
+            fn = os.path.abspath(item.data(0, self.filenameRole))
             lineno = item.data(0, self.lineRole)
             position = item.data(0, self.positionRole)
             message = item.data(0, self.messageRole)
@@ -1246,7 +1246,7 @@
             selectedIndexes = list(range(self.resultList.topLevelItemCount()))
         for index in selectedIndexes:
             itm = self.resultList.topLevelItem(index)
-            fn = Utilities.normabspath(itm.data(0, self.filenameRole))
+            fn = os.path.abspath(itm.data(0, self.filenameRole))
             vm.openSourceFile(fn, 1)
             editor = vm.getOpenEditor(fn)
             editor.clearStyleWarnings()
@@ -1264,7 +1264,7 @@
         for index in range(self.resultList.topLevelItemCount()):
             itm = self.resultList.topLevelItem(index)
             errorFiles.append(
-                Utilities.normabspath(itm.data(0, self.filenameRole)))
+                os.path.abspath(itm.data(0, self.filenameRole)))
         for file in openFiles:
             if file not in errorFiles:
                 editor = vm.getOpenEditor(file)
--- a/eric6/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py	Wed Dec 02 19:09:38 2020 +0100
+++ b/eric6/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py	Fri Dec 04 18:29:31 2020 +0100
@@ -463,7 +463,7 @@
         vm = e5App().getObject("ViewManager")
         
         if itm.parent():
-            fn = Utilities.normabspath(itm.data(0, self.filenameRole))
+            fn = os.path.abspath(itm.data(0, self.filenameRole))
             lineno = itm.data(0, self.lineRole)
             index = itm.data(0, self.indexRole)
             error = itm.data(0, self.errorRole)
@@ -476,7 +476,7 @@
             else:
                 editor.toggleSyntaxError(lineno, index, True, error, show=True)
         else:
-            fn = Utilities.normabspath(itm.data(0, self.filenameRole))
+            fn = os.path.abspath(itm.data(0, self.filenameRole))
             vm.openSourceFile(fn)
             editor = vm.getOpenEditor(fn)
             for index in range(itm.childCount()):
@@ -508,7 +508,7 @@
             selectedIndexes = list(range(self.resultList.topLevelItemCount()))
         for index in selectedIndexes:
             itm = self.resultList.topLevelItem(index)
-            fn = Utilities.normabspath(itm.data(0, self.filenameRole))
+            fn = os.path.abspath(itm.data(0, self.filenameRole))
             vm.openSourceFile(fn, 1)
             editor = vm.getOpenEditor(fn)
             editor.clearSyntaxError()
@@ -531,7 +531,7 @@
         for index in range(self.resultList.topLevelItemCount()):
             itm = self.resultList.topLevelItem(index)
             errorFiles.append(
-                Utilities.normabspath(itm.data(0, self.filenameRole)))
+                os.path.abspath(itm.data(0, self.filenameRole)))
         for file in openFiles:
             if file not in errorFiles:
                 editor = vm.getOpenEditor(file)
--- a/eric6/UI/EmailDialog.py	Wed Dec 02 19:09:38 2020 +0100
+++ b/eric6/UI/EmailDialog.py	Fri Dec 04 18:29:31 2020 +0100
@@ -10,7 +10,6 @@
 import os
 import mimetypes
 import smtplib
-import socket
 
 from PyQt5.QtCore import Qt, pyqtSlot
 from PyQt5.QtGui import QTextOption
--- a/eric6/Utilities/__init__.py	Wed Dec 02 19:09:38 2020 +0100
+++ b/eric6/Utilities/__init__.py	Fri Dec 04 18:29:31 2020 +0100
@@ -755,7 +755,6 @@
     return QDir.fromNativeSeparators(path)
 
 
-# TODO: check which path functions are already covered by Python 3
 def normcasepath(path):
     """
     Function returning a path, that is normalized with respect to its case
@@ -767,16 +766,6 @@
     return os.path.normcase(os.path.normpath(path))
 
 
-def normabspath(path):
-    """
-    Function returning a normalized, absolute path.
-    
-    @param path file path (string)
-    @return absolute, normalized path (string)
-    """
-    return os.path.abspath(path)
-
-
 def normcaseabspath(path):
     """
     Function returning an absolute path, that is normalized with respect to
@@ -793,7 +782,7 @@
     Function returning a normalized path of the joined parts passed into it.
     
     @param a first path to be joined (string)
-    @param p variable number of path parts to be joind (string)
+    @param p variable number of path parts to be joined (string)
     @return normalized path (string)
     """
     return os.path.normpath(os.path.join(a, *p))
@@ -811,30 +800,6 @@
     return os.path.abspath(os.path.join(a, *p))
 
 
-def relpath(path, start=os.path.curdir):
-    """
-    Return a relative version of a path.
-    
-    @param path path to make relative (string)
-    @param start path to make relative from (string)
-    @return relative path (string)
-    @exception ValueError raised to indicate an invalid path
-    """
-    if not path:
-        raise ValueError("no path specified")
-
-    start_list = os.path.abspath(start).split(os.path.sep)
-    path_list = os.path.abspath(path).split(os.path.sep)
-
-    # Work out how much of the filepath is shared by start and path.
-    i = len(os.path.commonprefix([start_list, path_list]))
-
-    rel_list = [os.path.pardir] * (len(start_list) - i) + path_list[i:]
-    if not rel_list:
-        return os.path.curdir
-    return os.path.join(*rel_list)
-
-
 def isinpath(file):
     """
     Function to check for an executable file.
@@ -875,8 +840,8 @@
     if start:
         if path == start:
             return True
-        elif normcasepath(toNativeSeparators(path)).startswith(
-                normcasepath(toNativeSeparators(start + "/"))):
+        elif normcasepath(path).startswith(
+                normcasepath(start + "/")):
             return True
         else:
             return False
@@ -884,27 +849,6 @@
         return False
 
 
-def relativePath(path, start):
-    """
-    Function to convert a file path to a path relative to a start path.
-    
-    @param path file or directory name to convert (string)
-    @param start start path (string)
-    @return relative path or unchanged path, if path does not start with
-        the start path (string)
-    """
-    if startswithPath(path, start):
-        if path == start:
-            return ""
-        else:
-            if start.endswith(("/", "\\")):
-                return path[len(start):]
-            else:
-                return path[len(start) + 1:]
-    else:
-        return path
-
-
 def relativeUniversalPath(path, start):
     """
     Function to convert a file path to a path relative to a start path
@@ -915,7 +859,7 @@
     @return relative path or unchanged path, if path does not start with
         the start path with universal separators (string)
     """
-    return fromNativeSeparators(relativePath(path, start))
+    return fromNativeSeparators(os.path.relpath(path, start))
 
 
 def absolutePath(path, start):
@@ -928,7 +872,7 @@
     @return absolute path (string)
     """
     if not os.path.isabs(path):
-        path = os.path.join(start, path)
+        path = os.path.normpath(os.path.join(start, path))
     return path
 
 
@@ -942,7 +886,7 @@
     @return absolute path with native separators (string)
     """
     if not os.path.isabs(path):
-        path = toNativeSeparators(os.path.join(start, path))
+        path = toNativeSeparators(os.path.normpath(os.path.join(start, path)))
     return path
 
 
--- a/eric6/ViewManager/ViewManager.py	Wed Dec 02 19:09:38 2020 +0100
+++ b/eric6/ViewManager/ViewManager.py	Fri Dec 04 18:29:31 2020 +0100
@@ -4495,7 +4495,7 @@
         
         @param prog name of file to be opened (string)
         """
-        prog = Utilities.normabspath(prog)
+        prog = os.path.abspath(prog)
         # Open up the new files.
         self.openSourceFile(prog)
 
--- a/eric6/eric6.py	Wed Dec 02 19:09:38 2020 +0100
+++ b/eric6/eric6.py	Fri Dec 04 18:29:31 2020 +0100
@@ -369,13 +369,12 @@
             disabledPlugins.append(pluginName)
     for arg in sys.argv:
         if arg.startswith("--plugin=") and sys.argv.index(arg) < ddindex:
-            import Utilities
             # extract the plugin development option
             pluginFile = arg.replace("--plugin=", "").replace('"', "")
             sys.argv.remove(arg)
             ddindex -= 1
             pluginFile = os.path.expanduser(pluginFile)
-            pluginFile = Utilities.normabspath(pluginFile)
+            pluginFile = os.path.abspath(pluginFile)
             break
     
     # is there a set of filenames or options on the command line,

eric ide

mercurial