fix a couple of python warnings (#3526)

This commit is contained in:
Mathieu Pellerin 2016-09-23 12:36:05 +07:00 committed by Matthias Kuhn
parent 9900036989
commit eefeef573d
3 changed files with 7 additions and 5 deletions

View File

@ -35,6 +35,7 @@ import configparser
from gettext import gettext, ngettext
import logging
import os
import codecs
import webbrowser
from xml.dom.minidom import parseString
import xml.etree.ElementTree as etree
@ -61,7 +62,8 @@ class StaticContext(object):
"""init"""
self.ppath = os.path.dirname(os.path.abspath(__file__))
self.metadata = configparser.ConfigParser()
self.metadata.readfp(open(os.path.join(self.ppath, 'metadata.txt')))
with codecs.open(os.path.join(self.ppath, 'metadata.txt'), "r", "utf8") as f:
self.metadata.read_file(f)
def get_ui_class(ui_file):

View File

@ -580,7 +580,8 @@ class Plugins(QObject):
global errorDetails
cp = configparser.ConfigParser()
try:
cp.read_file(codecs.open(metadataFile, "r", "utf8"))
with codecs.open(metadataFile, "r", "utf8") as f:
cp.read_file(f)
return cp.get('general', fct)
except Exception as e:
if not errorDetails:

View File

@ -254,9 +254,8 @@ def findPlugins(path):
cp = configparser.ConfigParser()
try:
f = codecs.open(metadataFile, "r", "utf8")
cp.read_file(f)
f.close()
with codecs.open(metadataFile, "r", "utf8") as f:
cp.read_file(f)
except:
cp = None