--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/eric7/CodeFormatting/IsortUtilities.py Mon Oct 31 15:29:18 2022 +0100 @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2022 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing some utility functions for the isort import statement formatting +tool. +""" + +import contextlib +import os +import sys + +import isort + +from PyQt6.QtCore import QCoreApplication, pyqtSlot + +from eric7.EricWidgets import EricMessageBox + + +@pyqtSlot() +def aboutIsort(): + """ + Slot to show an 'About isort' dialog. + """ + EricMessageBox.information( + None, + QCoreApplication.translate("IsortUtilities", "About isort"), + QCoreApplication.translate( + "IsortUtilities", + """<p><b>isort Version {0}</b></p>""" + """<p><i>isort</i> is a Python utility / library to sort imports""" + """ alphabetically, and automatically separated into sections and by""" + """ type.</p>""", + ).format(isort.__version__), + ) + + +@contextlib.contextmanager +def suppressStderr(): + """ + Function to suppress output to stderr. + """ + stderr = sys.stderr + with open(os.devnull, "w") as devnull: + sys.stderr = devnull + yield + sys.stderr = stderr