Skip to content

Commit

Permalink
window: Use configparser to parse export extension files
Browse files Browse the repository at this point in the history
  • Loading branch information
mitya57 committed Dec 31, 2024
1 parent 8eda3a5 commit 53a54ae
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions ReText/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import configparser
import os
import sys
import warnings
Expand Down Expand Up @@ -906,17 +907,10 @@ def updateExtensionsVisibility(self):
action[0].setEnabled(enabled)

def readExtension(self, fileName):
extFile = QFile(fileName)
extFile.open(QIODevice.OpenModeFlag.ReadOnly)
extension = {}
stream = QTextStream(extFile)
while not stream.atEnd():
line = stream.readLine()
if '=' in line:
index = line.index('=')
extension[line[:index].rstrip()] = line[index+1:].lstrip()
extFile.close()
return extension
parser = configparser.ConfigParser(interpolation=None)
parser.optionxform = str
parser.read(fileName)
return dict(parser.items('Desktop Entry'))

def openFile(self):
supportedExtensions = ['.txt']
Expand Down

0 comments on commit 53a54ae

Please sign in to comment.